Update some cypress tests
This commit is contained in:
parent
23a3c3ca6e
commit
8bf76a606e
|
|
@ -1,13 +1,28 @@
|
||||||
|
import {getModules, getMinimalMe} from '../../support/helpers';
|
||||||
|
|
||||||
import {getModules, getMe} from '../../support/helpers';
|
describe('Apply module visibility', () => {
|
||||||
import mocks from '../../fixtures/mocks';
|
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 = {
|
const operations = {
|
||||||
MeQuery() {
|
MeQuery: {
|
||||||
return getMe({
|
me
|
||||||
schoolClasses: ['FLID2018a', 'Andere Klasse'],
|
|
||||||
teacher: true,
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
ModulesQuery: getModules,
|
ModulesQuery: getModules,
|
||||||
UpdateSettings: {
|
UpdateSettings: {
|
||||||
|
|
@ -16,7 +31,7 @@ const operations = {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
MySchoolClassQuery: {
|
MySchoolClassQuery: {
|
||||||
me: {},
|
me,
|
||||||
},
|
},
|
||||||
UpdateLastModule: {
|
UpdateLastModule: {
|
||||||
updateLastModule: {
|
updateLastModule: {
|
||||||
|
|
@ -28,31 +43,22 @@ const operations = {
|
||||||
success: true,
|
success: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
ModuleDetailsQuery: {
|
||||||
|
module: {
|
||||||
|
id: 'some-module-id'
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
describe('Apply module visibility', () => {
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
cy.server();
|
cy.setup();
|
||||||
cy.task('getSchema').then(schema => {
|
|
||||||
cy.mockGraphql({
|
|
||||||
schema,
|
|
||||||
// endpoint: '/api/graphql'
|
|
||||||
mocks,
|
|
||||||
operations,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('clicks through the UI', () => {
|
it('clicks through the UI', () => {
|
||||||
// Cypress.config({
|
cy.mockGraphqlOps({
|
||||||
// baseUrl: 'http://localhost:8080',
|
operations
|
||||||
// });
|
});
|
||||||
cy.viewport('macbook-15');
|
|
||||||
|
|
||||||
// login as teacher
|
|
||||||
cy.fakeLogin('ross.geller', 'test');
|
|
||||||
// cy.apolloLogin('ross.geller', 'test');
|
|
||||||
// cy.wait('@gqlBetaLogin');
|
|
||||||
// go to module
|
// go to module
|
||||||
cy.visit('/module/lohn-und-budget');
|
cy.visit('/module/lohn-und-budget');
|
||||||
cy.selectClass('Andere Klasse');
|
cy.selectClass('Andere Klasse');
|
||||||
|
|
|
||||||
|
|
@ -15,23 +15,6 @@ const topics = [
|
||||||
|
|
||||||
let recentModules = [];
|
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 getId = (id) => btoa(`ModuleNode:${id}`);
|
||||||
|
|
||||||
const modules = {
|
const modules = {
|
||||||
|
|
@ -80,7 +63,9 @@ const moduleNodes = Object.values(modules).map(module => ({
|
||||||
}));
|
}));
|
||||||
console.log(moduleNodes);
|
console.log(moduleNodes);
|
||||||
|
|
||||||
const getTopic = () => ({
|
const getTopic = () => {
|
||||||
|
console.info('calling getTopic');
|
||||||
|
return {
|
||||||
topic: {
|
topic: {
|
||||||
title: 'Geld und Kauf',
|
title: 'Geld und Kauf',
|
||||||
id: 'VG9waWNOb2RlOjU=',
|
id: 'VG9waWNOb2RlOjU=',
|
||||||
|
|
@ -88,17 +73,55 @@ const getTopic = () => ({
|
||||||
modules: {
|
modules: {
|
||||||
edges: moduleNodes,
|
edges: moduleNodes,
|
||||||
},
|
},
|
||||||
},
|
}
|
||||||
});
|
};
|
||||||
|
};
|
||||||
|
|
||||||
const getOperations = () => ({
|
const checkHome = (n, skipHome) => {
|
||||||
|
cy.log(`Checking if home has ${n} teasers`);
|
||||||
|
if (!skipHome) {
|
||||||
|
cy.get('[data-cy="home-link"]').click();
|
||||||
|
}
|
||||||
|
cy.get('[data-cy=start-modules-list]').should('exist');
|
||||||
|
cy.get('[data-cy=start-module-teaser]').should('have.length', n);
|
||||||
|
};
|
||||||
|
|
||||||
|
const goToModule = (topicTitle, moduleMetaTitle) => {
|
||||||
|
cy.log(`Going to module ${moduleMetaTitle} in topic ${topicTitle}`);
|
||||||
|
cy.get('[data-cy=open-sidebar-link]').click();
|
||||||
|
cy.contains(topicTitle).click();
|
||||||
|
cy.get('[data-cy=topic-title]').should('exist').should('contain', topicTitle);
|
||||||
|
cy.contains(moduleMetaTitle).click();
|
||||||
|
};
|
||||||
|
|
||||||
|
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: {
|
MeQuery: {
|
||||||
me: me(),
|
me,
|
||||||
},
|
},
|
||||||
AssignmentsQuery: {
|
AssignmentsQuery: {
|
||||||
assignments: [],
|
assignments: [],
|
||||||
},
|
},
|
||||||
ModuleDetailsQuery: variables => ({module: getModuleBySlug(variables.slug)}),
|
ModuleDetailsQuery: variables => {
|
||||||
|
console.log('calling ModuleDetailsQuery', getModuleBySlug(variables.slug));
|
||||||
|
return {
|
||||||
|
module: getModuleBySlug(variables.slug)
|
||||||
|
};
|
||||||
|
},
|
||||||
TopicsQuery: {
|
TopicsQuery: {
|
||||||
topics: {
|
topics: {
|
||||||
edges: topics.map(topic => ({node: topic})),
|
edges: topics.map(topic => ({node: topic})),
|
||||||
|
|
@ -127,33 +150,15 @@ const getOperations = () => ({
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
|
||||||
|
|
||||||
const checkHome = (n, skipHome) => {
|
|
||||||
cy.log(`Checking if home has ${n} teasers`);
|
|
||||||
if (!skipHome) {
|
|
||||||
cy.get('[data-cy="home-link"]').click();
|
|
||||||
}
|
|
||||||
cy.get('[data-cy=start-modules-list]').should('exist');
|
|
||||||
cy.get('[data-cy=start-module-teaser]').should('have.length', n);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const goToModule = (topicTitle, moduleMetaTitle) => {
|
|
||||||
cy.log(`Going to module ${moduleMetaTitle} in topic ${topicTitle}`);
|
|
||||||
cy.get('[data-cy=open-sidebar-link]').click();
|
|
||||||
cy.contains(topicTitle).click();
|
|
||||||
cy.get('[data-cy=topic-title]').should('exist').should('contain', topicTitle);
|
|
||||||
cy.contains(moduleMetaTitle).click();
|
|
||||||
};
|
|
||||||
|
|
||||||
describe('Current Module', () => {
|
|
||||||
before(() => {
|
before(() => {
|
||||||
cy.setup();
|
cy.setup();
|
||||||
});
|
});
|
||||||
|
|
||||||
it.skip('is set correctly', () => {
|
it.skip('is set correctly', () => {
|
||||||
cy.mockGraphqlOps({
|
cy.mockGraphqlOps({
|
||||||
operations: getOperations(),
|
operations,
|
||||||
});
|
});
|
||||||
|
|
||||||
cy.visit('/');
|
cy.visit('/');
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import module from '../../fixtures/module.minimal';
|
import module from '../../fixtures/module.minimal';
|
||||||
import mocks from '../../fixtures/mocks';
|
|
||||||
import {getMinimalMe} from '../../support/helpers';
|
import {getMinimalMe} from '../../support/helpers';
|
||||||
|
|
||||||
|
describe('Snapshot', () => {
|
||||||
const operations = isTeacher => ({
|
const operations = isTeacher => ({
|
||||||
operations: {
|
operations: {
|
||||||
MeQuery: getMinimalMe({isTeacher}),
|
MeQuery: getMinimalMe({isTeacher}),
|
||||||
|
|
@ -48,30 +48,17 @@ const operations = isTeacher => ({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Snapshot', () => {
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
cy.server();
|
cy.setup();
|
||||||
|
|
||||||
cy.task('getSchema').then(schema => {
|
|
||||||
cy.mockGraphql({
|
|
||||||
schema,
|
|
||||||
mocks,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
cy.viewport('macbook-15');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Menu is visible for teacher', () => {
|
it('Menu is visible for teacher', () => {
|
||||||
cy.fakeLogin('ross.geller', 'test');
|
|
||||||
|
|
||||||
cy.mockGraphqlOps(operations(true));
|
cy.mockGraphqlOps(operations(true));
|
||||||
cy.visit('module/miteinander-reden/');
|
cy.visit('module/miteinander-reden/');
|
||||||
cy.getByDataCy('snapshot-menu').should('be.visible');
|
cy.getByDataCy('snapshot-menu').should('be.visible');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Menu is not visible for student', () => {
|
it('Menu is not visible for student', () => {
|
||||||
cy.fakeLogin('rachel.green', 'test');
|
|
||||||
cy.mockGraphqlOps(operations(false));
|
cy.mockGraphqlOps(operations(false));
|
||||||
cy.visit('module/miteinander-reden/');
|
cy.visit('module/miteinander-reden/');
|
||||||
|
|
||||||
|
|
@ -80,8 +67,6 @@ describe('Snapshot', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Creates Snapshot', () => {
|
it('Creates Snapshot', () => {
|
||||||
cy.fakeLogin('ross.geller', 'test');
|
|
||||||
|
|
||||||
cy.mockGraphqlOps(operations(true));
|
cy.mockGraphqlOps(operations(true));
|
||||||
cy.visit('module/miteinander-reden/');
|
cy.visit('module/miteinander-reden/');
|
||||||
cy.getByDataCy('module-snapshots-button').click();
|
cy.getByDataCy('module-snapshots-button').click();
|
||||||
|
|
@ -93,8 +78,6 @@ describe('Snapshot', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Applies Snapshot', () => {
|
it('Applies Snapshot', () => {
|
||||||
cy.fakeLogin('ross.geller', 'test');
|
|
||||||
|
|
||||||
cy.mockGraphqlOps(operations(true));
|
cy.mockGraphqlOps(operations(true));
|
||||||
cy.visit('module/miteinander-reden/snapshots');
|
cy.visit('module/miteinander-reden/snapshots');
|
||||||
cy.getByDataCy('snapshot-link').click();
|
cy.getByDataCy('snapshot-link').click();
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,9 @@
|
||||||
<template>
|
<template>
|
||||||
<div v-if="module.id">
|
|
||||||
<module
|
<module
|
||||||
:module="module"
|
:module="module"
|
||||||
v-if="module.id"
|
|
||||||
@editNote="editNote"
|
@editNote="editNote"
|
||||||
@addNote="addNote"
|
@addNote="addNote"
|
||||||
@bookmark="bookmark"/>
|
@bookmark="bookmark"/>
|
||||||
</div>
|
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<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: {
|
apollo: {
|
||||||
module() {
|
module() {
|
||||||
return {
|
return {
|
||||||
|
|
@ -47,9 +53,10 @@
|
||||||
update(data) {
|
update(data) {
|
||||||
return this.$getRidOfEdges(data).module || {};
|
return this.$getRidOfEdges(data).module || {};
|
||||||
},
|
},
|
||||||
result({data: {module: {id}}}) {
|
// result({data: {module: {id}}}) {
|
||||||
this.updateLastVisitedModule(id);
|
// // this.$log.debug(`=== updating result for module ${id} ===`);
|
||||||
},
|
// // this.updateLastVisitedModule(id);
|
||||||
|
// },
|
||||||
fetchPolicy: 'cache-first',
|
fetchPolicy: 'cache-first',
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
@ -60,10 +67,15 @@
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
updateLastVisitedModule(moduleId) {
|
updateLastVisitedModule(moduleId) {
|
||||||
|
this.$log.debug(`updating last visited module for module ${moduleId}`);
|
||||||
if (!moduleId) {
|
if (!moduleId) {
|
||||||
this.$log.warn('no module id');
|
this.$log.warn('no module id');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (this.me.lastModule.id === moduleId) {
|
||||||
|
this.$log.debug('same module already set as last module');
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.$apollo.mutate({
|
this.$apollo.mutate({
|
||||||
mutation: UPDATE_LAST_MODULE_MUTATION,
|
mutation: UPDATE_LAST_MODULE_MUTATION,
|
||||||
variables: {
|
variables: {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue