Update some cypress tests
This commit is contained in:
parent
23a3c3ca6e
commit
8bf76a606e
|
|
@ -1,58 +1,64 @@
|
|||
|
||||
import {getModules, getMe} from '../../support/helpers';
|
||||
import mocks from '../../fixtures/mocks';
|
||||
|
||||
const operations = {
|
||||
MeQuery() {
|
||||
return getMe({
|
||||
schoolClasses: ['FLID2018a', 'Andere Klasse'],
|
||||
teacher: true,
|
||||
});
|
||||
},
|
||||
ModulesQuery: getModules,
|
||||
UpdateSettings: {
|
||||
updateSettings: {
|
||||
success: true,
|
||||
},
|
||||
},
|
||||
MySchoolClassQuery: {
|
||||
me: {},
|
||||
},
|
||||
UpdateLastModule: {
|
||||
updateLastModule: {
|
||||
success: true,
|
||||
},
|
||||
},
|
||||
SyncModuleVisibility: {
|
||||
syncModuleVisibility: {
|
||||
success: true,
|
||||
},
|
||||
},
|
||||
};
|
||||
import {getModules, getMinimalMe} from '../../support/helpers';
|
||||
|
||||
describe('Apply module visibility', () => {
|
||||
const schoolClasses = [
|
||||
{
|
||||
name: 'FLID2018a',
|
||||
id: btoa('SchoolClassNode:1')
|
||||
},
|
||||
{
|
||||
name: 'Andere Klasse',
|
||||
id: btoa('SchoolClassNode:2')
|
||||
},
|
||||
];
|
||||
|
||||
const {me: minimalMe} = getMinimalMe({});
|
||||
const me = {
|
||||
...minimalMe,
|
||||
schoolClasses: {
|
||||
edges: schoolClasses.map(scn => ({node: scn}))
|
||||
}
|
||||
};
|
||||
// name: '[\'FLID2018a\', \'Andere Klasse\']'
|
||||
const operations = {
|
||||
MeQuery: {
|
||||
me
|
||||
},
|
||||
ModulesQuery: getModules,
|
||||
UpdateSettings: {
|
||||
updateSettings: {
|
||||
success: true,
|
||||
},
|
||||
},
|
||||
MySchoolClassQuery: {
|
||||
me,
|
||||
},
|
||||
UpdateLastModule: {
|
||||
updateLastModule: {
|
||||
success: true,
|
||||
},
|
||||
},
|
||||
SyncModuleVisibility: {
|
||||
syncModuleVisibility: {
|
||||
success: true,
|
||||
},
|
||||
},
|
||||
ModuleDetailsQuery: {
|
||||
module: {
|
||||
id: 'some-module-id'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
cy.server();
|
||||
cy.task('getSchema').then(schema => {
|
||||
cy.mockGraphql({
|
||||
schema,
|
||||
// endpoint: '/api/graphql'
|
||||
mocks,
|
||||
operations,
|
||||
});
|
||||
});
|
||||
cy.setup();
|
||||
});
|
||||
|
||||
it('clicks through the UI', () => {
|
||||
// Cypress.config({
|
||||
// baseUrl: 'http://localhost:8080',
|
||||
// });
|
||||
cy.viewport('macbook-15');
|
||||
cy.mockGraphqlOps({
|
||||
operations
|
||||
});
|
||||
|
||||
// login as teacher
|
||||
cy.fakeLogin('ross.geller', 'test');
|
||||
// cy.apolloLogin('ross.geller', 'test');
|
||||
// cy.wait('@gqlBetaLogin');
|
||||
// go to module
|
||||
cy.visit('/module/lohn-und-budget');
|
||||
cy.selectClass('Andere Klasse');
|
||||
|
|
|
|||
|
|
@ -15,23 +15,6 @@ const topics = [
|
|||
|
||||
let recentModules = [];
|
||||
|
||||
const me = () => {
|
||||
console.log('getting me');
|
||||
return {
|
||||
lastModule: {
|
||||
slug: 'lohn-und-budget',
|
||||
id: 'last-module-id',
|
||||
},
|
||||
lastTopic: {
|
||||
id: 'VG9waWNOb2RlOjU=',
|
||||
slug: 'geld-und-kauf',
|
||||
},
|
||||
recentModules: {
|
||||
edges: recentModules,
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
const getId = (id) => btoa(`ModuleNode:${id}`);
|
||||
|
||||
const modules = {
|
||||
|
|
@ -80,54 +63,19 @@ const moduleNodes = Object.values(modules).map(module => ({
|
|||
}));
|
||||
console.log(moduleNodes);
|
||||
|
||||
const getTopic = () => ({
|
||||
topic: {
|
||||
title: 'Geld und Kauf',
|
||||
id: 'VG9waWNOb2RlOjU=',
|
||||
teaser: 'Topic 2',
|
||||
modules: {
|
||||
edges: moduleNodes,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const getOperations = () => ({
|
||||
MeQuery: {
|
||||
me: me(),
|
||||
},
|
||||
AssignmentsQuery: {
|
||||
assignments: [],
|
||||
},
|
||||
ModuleDetailsQuery: variables => ({module: getModuleBySlug(variables.slug)}),
|
||||
TopicsQuery: {
|
||||
topics: {
|
||||
edges: topics.map(topic => ({node: topic})),
|
||||
},
|
||||
},
|
||||
Topic: getTopic(),
|
||||
UpdateLastTopic: () => {
|
||||
const Topic = getTopic();
|
||||
const topic = Topic.topic;
|
||||
return {
|
||||
updateLastTopic: {
|
||||
topic,
|
||||
const getTopic = () => {
|
||||
console.info('calling getTopic');
|
||||
return {
|
||||
topic: {
|
||||
title: 'Geld und Kauf',
|
||||
id: 'VG9waWNOb2RlOjU=',
|
||||
teaser: 'Topic 2',
|
||||
modules: {
|
||||
edges: moduleNodes,
|
||||
},
|
||||
};
|
||||
},
|
||||
NewsTeasers: {
|
||||
newsTeasers: {
|
||||
edges: [],
|
||||
},
|
||||
},
|
||||
UpdateLastModule: ({input: {id}}) => {
|
||||
const lastModule = modules[id];
|
||||
return {
|
||||
updateLastModule: {
|
||||
lastModule,
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
const checkHome = (n, skipHome) => {
|
||||
cy.log(`Checking if home has ${n} teasers`);
|
||||
|
|
@ -147,13 +95,70 @@ const goToModule = (topicTitle, moduleMetaTitle) => {
|
|||
};
|
||||
|
||||
describe('Current Module', () => {
|
||||
const me = {
|
||||
lastModule: {
|
||||
slug: 'lohn-und-budget',
|
||||
id: 'last-module-id',
|
||||
},
|
||||
lastTopic: {
|
||||
id: 'VG9waWNOb2RlOjU=',
|
||||
slug: 'geld-und-kauf',
|
||||
},
|
||||
recentModules: {
|
||||
edges: recentModules,
|
||||
},
|
||||
};
|
||||
|
||||
const operations = {
|
||||
MeQuery: {
|
||||
me,
|
||||
},
|
||||
AssignmentsQuery: {
|
||||
assignments: [],
|
||||
},
|
||||
ModuleDetailsQuery: variables => {
|
||||
console.log('calling ModuleDetailsQuery', getModuleBySlug(variables.slug));
|
||||
return {
|
||||
module: getModuleBySlug(variables.slug)
|
||||
};
|
||||
},
|
||||
TopicsQuery: {
|
||||
topics: {
|
||||
edges: topics.map(topic => ({node: topic})),
|
||||
},
|
||||
},
|
||||
Topic: getTopic(),
|
||||
UpdateLastTopic: () => {
|
||||
const Topic = getTopic();
|
||||
const topic = Topic.topic;
|
||||
return {
|
||||
updateLastTopic: {
|
||||
topic,
|
||||
},
|
||||
};
|
||||
},
|
||||
NewsTeasers: {
|
||||
newsTeasers: {
|
||||
edges: [],
|
||||
},
|
||||
},
|
||||
UpdateLastModule: ({input: {id}}) => {
|
||||
const lastModule = modules[id];
|
||||
return {
|
||||
updateLastModule: {
|
||||
lastModule,
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
before(() => {
|
||||
cy.setup();
|
||||
});
|
||||
|
||||
it.skip('is set correctly', () => {
|
||||
cy.mockGraphqlOps({
|
||||
operations: getOperations(),
|
||||
operations,
|
||||
});
|
||||
|
||||
cy.visit('/');
|
||||
|
|
|
|||
|
|
@ -1,77 +1,64 @@
|
|||
import module from '../../fixtures/module.minimal';
|
||||
import mocks from '../../fixtures/mocks';
|
||||
import {getMinimalMe} from '../../support/helpers';
|
||||
|
||||
const operations = isTeacher => ({
|
||||
operations: {
|
||||
MeQuery: getMinimalMe({isTeacher}),
|
||||
ModuleDetailsQuery: {
|
||||
module,
|
||||
},
|
||||
CreateSnapshot: {
|
||||
createSnapshot: {
|
||||
snapshot: {
|
||||
id: '',
|
||||
title: '',
|
||||
created: '',
|
||||
creator: '',
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
},
|
||||
ModuleSnapshotsQuery: {
|
||||
module: {
|
||||
...module,
|
||||
snapshots: [
|
||||
{
|
||||
id: 'snapshot-id',
|
||||
title: 'title',
|
||||
created: '2020-01-01',
|
||||
mine: true,
|
||||
shared: false,
|
||||
creator: 'me',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
SnapshotDetail: {
|
||||
snapshot: {
|
||||
chapters: [],
|
||||
module: {}
|
||||
}
|
||||
},
|
||||
ApplySnapshot: {
|
||||
applySnapshot: {
|
||||
success: true
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
describe('Snapshot', () => {
|
||||
const operations = isTeacher => ({
|
||||
operations: {
|
||||
MeQuery: getMinimalMe({isTeacher}),
|
||||
ModuleDetailsQuery: {
|
||||
module,
|
||||
},
|
||||
CreateSnapshot: {
|
||||
createSnapshot: {
|
||||
snapshot: {
|
||||
id: '',
|
||||
title: '',
|
||||
created: '',
|
||||
creator: '',
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
},
|
||||
ModuleSnapshotsQuery: {
|
||||
module: {
|
||||
...module,
|
||||
snapshots: [
|
||||
{
|
||||
id: 'snapshot-id',
|
||||
title: 'title',
|
||||
created: '2020-01-01',
|
||||
mine: true,
|
||||
shared: false,
|
||||
creator: 'me',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
SnapshotDetail: {
|
||||
snapshot: {
|
||||
chapters: [],
|
||||
module: {}
|
||||
}
|
||||
},
|
||||
ApplySnapshot: {
|
||||
applySnapshot: {
|
||||
success: true
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
cy.server();
|
||||
|
||||
cy.task('getSchema').then(schema => {
|
||||
cy.mockGraphql({
|
||||
schema,
|
||||
mocks,
|
||||
});
|
||||
});
|
||||
|
||||
cy.viewport('macbook-15');
|
||||
cy.setup();
|
||||
});
|
||||
|
||||
it('Menu is visible for teacher', () => {
|
||||
cy.fakeLogin('ross.geller', 'test');
|
||||
|
||||
cy.mockGraphqlOps(operations(true));
|
||||
cy.visit('module/miteinander-reden/');
|
||||
cy.getByDataCy('snapshot-menu').should('be.visible');
|
||||
});
|
||||
|
||||
it('Menu is not visible for student', () => {
|
||||
cy.fakeLogin('rachel.green', 'test');
|
||||
cy.mockGraphqlOps(operations(false));
|
||||
cy.visit('module/miteinander-reden/');
|
||||
|
||||
|
|
@ -80,8 +67,6 @@ describe('Snapshot', () => {
|
|||
});
|
||||
|
||||
it('Creates Snapshot', () => {
|
||||
cy.fakeLogin('ross.geller', 'test');
|
||||
|
||||
cy.mockGraphqlOps(operations(true));
|
||||
cy.visit('module/miteinander-reden/');
|
||||
cy.getByDataCy('module-snapshots-button').click();
|
||||
|
|
@ -93,8 +78,6 @@ describe('Snapshot', () => {
|
|||
});
|
||||
|
||||
it('Applies Snapshot', () => {
|
||||
cy.fakeLogin('ross.geller', 'test');
|
||||
|
||||
cy.mockGraphqlOps(operations(true));
|
||||
cy.visit('module/miteinander-reden/snapshots');
|
||||
cy.getByDataCy('snapshot-link').click();
|
||||
|
|
|
|||
|
|
@ -1,13 +1,9 @@
|
|||
<template>
|
||||
<div v-if="module.id">
|
||||
<module
|
||||
:module="module"
|
||||
v-if="module.id"
|
||||
@editNote="editNote"
|
||||
@addNote="addNote"
|
||||
@bookmark="bookmark"/>
|
||||
</div>
|
||||
|
||||
<module
|
||||
:module="module"
|
||||
@editNote="editNote"
|
||||
@addNote="addNote"
|
||||
@bookmark="bookmark"/>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
|
@ -37,6 +33,16 @@
|
|||
};
|
||||
},
|
||||
|
||||
created() {
|
||||
this.$log.debug('**** module.vue created ****');
|
||||
this.$log.debug(`||| module id ${this.module.id} |||`);
|
||||
this.updateLastVisitedModule(this.module.id);
|
||||
},
|
||||
mounted() {
|
||||
this.$log.debug('**** module.vue mounted ****');
|
||||
this.$log.debug(`||| module id ${this.module.id} |||`);
|
||||
},
|
||||
|
||||
apollo: {
|
||||
module() {
|
||||
return {
|
||||
|
|
@ -47,9 +53,10 @@
|
|||
update(data) {
|
||||
return this.$getRidOfEdges(data).module || {};
|
||||
},
|
||||
result({data: {module: {id}}}) {
|
||||
this.updateLastVisitedModule(id);
|
||||
},
|
||||
// result({data: {module: {id}}}) {
|
||||
// // this.$log.debug(`=== updating result for module ${id} ===`);
|
||||
// // this.updateLastVisitedModule(id);
|
||||
// },
|
||||
fetchPolicy: 'cache-first',
|
||||
};
|
||||
},
|
||||
|
|
@ -60,10 +67,15 @@
|
|||
|
||||
methods: {
|
||||
updateLastVisitedModule(moduleId) {
|
||||
this.$log.debug(`updating last visited module for module ${moduleId}`);
|
||||
if (!moduleId) {
|
||||
this.$log.warn('no module id');
|
||||
return;
|
||||
}
|
||||
if (this.me.lastModule.id === moduleId) {
|
||||
this.$log.debug('same module already set as last module');
|
||||
return;
|
||||
}
|
||||
this.$apollo.mutate({
|
||||
mutation: UPDATE_LAST_MODULE_MUTATION,
|
||||
variables: {
|
||||
|
|
|
|||
Loading…
Reference in New Issue