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';
|
||||
import mocks from '../../fixtures/mocks';
|
||||
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() {
|
||||
return getMe({
|
||||
schoolClasses: ['FLID2018a', 'Andere Klasse'],
|
||||
teacher: true,
|
||||
});
|
||||
MeQuery: {
|
||||
me
|
||||
},
|
||||
ModulesQuery: getModules,
|
||||
UpdateSettings: {
|
||||
|
|
@ -16,7 +31,7 @@ const operations = {
|
|||
},
|
||||
},
|
||||
MySchoolClassQuery: {
|
||||
me: {},
|
||||
me,
|
||||
},
|
||||
UpdateLastModule: {
|
||||
updateLastModule: {
|
||||
|
|
@ -28,31 +43,22 @@ const operations = {
|
|||
success: true,
|
||||
},
|
||||
},
|
||||
ModuleDetailsQuery: {
|
||||
module: {
|
||||
id: 'some-module-id'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
describe('Apply module visibility', () => {
|
||||
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,7 +63,9 @@ const moduleNodes = Object.values(modules).map(module => ({
|
|||
}));
|
||||
console.log(moduleNodes);
|
||||
|
||||
const getTopic = () => ({
|
||||
const getTopic = () => {
|
||||
console.info('calling getTopic');
|
||||
return {
|
||||
topic: {
|
||||
title: 'Geld und Kauf',
|
||||
id: 'VG9waWNOb2RlOjU=',
|
||||
|
|
@ -88,17 +73,55 @@ const getTopic = () => ({
|
|||
modules: {
|
||||
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: {
|
||||
me: me(),
|
||||
me,
|
||||
},
|
||||
AssignmentsQuery: {
|
||||
assignments: [],
|
||||
},
|
||||
ModuleDetailsQuery: variables => ({module: getModuleBySlug(variables.slug)}),
|
||||
ModuleDetailsQuery: variables => {
|
||||
console.log('calling ModuleDetailsQuery', getModuleBySlug(variables.slug));
|
||||
return {
|
||||
module: getModuleBySlug(variables.slug)
|
||||
};
|
||||
},
|
||||
TopicsQuery: {
|
||||
topics: {
|
||||
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(() => {
|
||||
cy.setup();
|
||||
});
|
||||
|
||||
it.skip('is set correctly', () => {
|
||||
cy.mockGraphqlOps({
|
||||
operations: getOperations(),
|
||||
operations,
|
||||
});
|
||||
|
||||
cy.visit('/');
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import module from '../../fixtures/module.minimal';
|
||||
import mocks from '../../fixtures/mocks';
|
||||
import {getMinimalMe} from '../../support/helpers';
|
||||
|
||||
describe('Snapshot', () => {
|
||||
const operations = isTeacher => ({
|
||||
operations: {
|
||||
MeQuery: getMinimalMe({isTeacher}),
|
||||
|
|
@ -48,30 +48,17 @@ const operations = isTeacher => ({
|
|||
},
|
||||
});
|
||||
|
||||
describe('Snapshot', () => {
|
||||
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>
|
||||
|
||||
</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