Add new test scenario and fix it
This commit is contained in:
parent
240fcf0795
commit
10cc8ca3ba
|
|
@ -86,13 +86,13 @@
|
||||||
},
|
},
|
||||||
"bookmark": null,
|
"bookmark": null,
|
||||||
"__typename": "ModuleNode"
|
"__typename": "ModuleNode"
|
||||||
}
|
},
|
||||||
|
"__typename": "ModuleNodeEdge"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"__typename": "ModuleNodeEdge"
|
"__typename": "ModuleNodeConnection"
|
||||||
},
|
},
|
||||||
"__typename": "ModuleNodeConnection"
|
"__typename": "TopicNode"
|
||||||
},
|
}
|
||||||
"__typename": "TopicNode"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,28 @@ const schema = require('../fixtures/schema.json');
|
||||||
const assignments = require('../fixtures/assignments.json');
|
const assignments = require('../fixtures/assignments.json');
|
||||||
const mePayload = require('../fixtures/me.join-class.json');
|
const mePayload = require('../fixtures/me.join-class.json');
|
||||||
const topics = require('../fixtures/topics.json');
|
const topics = require('../fixtures/topics.json');
|
||||||
const topic = require('../fixtures/geld-und-kauf.json');
|
const baseTopic = require('../fixtures/geld-und-kauf.json');
|
||||||
|
|
||||||
const moduleTeasers = require('../fixtures/module-teasers.json');
|
const moduleTeasers = require('../fixtures/module-teasers.json');
|
||||||
const fullModules = require('../fixtures/full-modules.json');
|
const fullModules = require('../fixtures/full-modules.json');
|
||||||
|
|
||||||
|
const topic = {
|
||||||
|
topic: {
|
||||||
|
...baseTopic.topic,
|
||||||
|
modules: {
|
||||||
|
'__typename': 'ModuleNodeConnection',
|
||||||
|
edges: [
|
||||||
|
...Object.values(moduleTeasers).map(module => {
|
||||||
|
return {
|
||||||
|
node: module,
|
||||||
|
__typename: 'ModuleNodeEdge'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Cypress.Commands.add('checkHome', (n, skipHome) => {
|
Cypress.Commands.add('checkHome', (n, skipHome) => {
|
||||||
if (!skipHome) {
|
if (!skipHome) {
|
||||||
cy.get('[data-cy="home-link"]').click();
|
cy.get('[data-cy="home-link"]').click();
|
||||||
|
|
@ -18,6 +35,7 @@ Cypress.Commands.add('checkHome', (n, skipHome) => {
|
||||||
Cypress.Commands.add('goToModule', (topicTitle, moduleMetaTitle) => {
|
Cypress.Commands.add('goToModule', (topicTitle, moduleMetaTitle) => {
|
||||||
cy.get('[data-cy=open-sidebar-link]').click();
|
cy.get('[data-cy=open-sidebar-link]').click();
|
||||||
cy.contains(topicTitle).click();
|
cy.contains(topicTitle).click();
|
||||||
|
cy.get('[data-cy=topic-title]').should('exist').should('contain', topicTitle);
|
||||||
cy.contains(moduleMetaTitle).click();
|
cy.contains(moduleMetaTitle).click();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -72,9 +90,6 @@ describe('Current Module', () => {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
UpdateLastModule: variables => {
|
UpdateLastModule: variables => {
|
||||||
console.log(variables);
|
|
||||||
console.log(moduleTeasers);
|
|
||||||
console.log(moduleTeasers[variables.input.id]);
|
|
||||||
return {
|
return {
|
||||||
updateLastModule: {
|
updateLastModule: {
|
||||||
lastModule: moduleTeasers[variables.input.id],
|
lastModule: moduleTeasers[variables.input.id],
|
||||||
|
|
@ -96,18 +111,18 @@ describe('Current Module', () => {
|
||||||
cy.checkHome(0, true);
|
cy.checkHome(0, true);
|
||||||
cy.get('[data-cy=no-modules-yet]').should('exist').should('contain', 'Sie haben sich noch kein Modul angeschaut. Legen Sie jetzt los!');
|
cy.get('[data-cy=no-modules-yet]').should('exist').should('contain', 'Sie haben sich noch kein Modul angeschaut. Legen Sie jetzt los!');
|
||||||
|
|
||||||
cy.goToModule('1. Geld und Kauf', 'Modul 2');
|
cy.goToModule('Geld und Kauf', 'Modul 2');
|
||||||
cy.get('[data-cy=module-title]').should('contain', 'Geld');
|
cy.get('[data-cy=module-title]').should('contain', 'Geld');
|
||||||
cy.checkHome(1);
|
cy.checkHome(1);
|
||||||
cy.get('[data-cy=start-module-teaser]').first().should('contain', 'Geld');
|
cy.get('[data-cy=start-module-teaser]').first().should('contain', 'Geld');
|
||||||
|
|
||||||
cy.goToModule('1. Geld und Kauf', 'Modul 1');
|
cy.goToModule('Geld und Kauf', 'Modul 1');
|
||||||
cy.get('[data-cy=module-title]').should('contain', 'Lohn und Budget');
|
cy.get('[data-cy=module-title]').should('contain', 'Lohn und Budget');
|
||||||
cy.checkHome(2);
|
cy.checkHome(2);
|
||||||
cy.get('[data-cy=start-module-teaser]').first().should('contain', 'Lohn und Budget');
|
cy.get('[data-cy=start-module-teaser]').first().should('contain', 'Lohn und Budget');
|
||||||
cy.get('[data-cy=start-module-teaser]').eq(1).should('contain', 'Geld');
|
cy.get('[data-cy=start-module-teaser]').eq(1).should('contain', 'Geld');
|
||||||
|
|
||||||
cy.goToModule('1. Geld und Kauf', 'Modul 4');
|
cy.goToModule('Geld und Kauf', 'Modul 4');
|
||||||
cy.get('[data-cy=module-title]').should('contain', 'Lerntipps');
|
cy.get('[data-cy=module-title]').should('contain', 'Lerntipps');
|
||||||
cy.checkHome(3);
|
cy.checkHome(3);
|
||||||
cy.get('[data-cy=start-module-teaser]').first().should('contain', 'Lerntipps');
|
cy.get('[data-cy=start-module-teaser]').first().should('contain', 'Lerntipps');
|
||||||
|
|
@ -115,18 +130,25 @@ describe('Current Module', () => {
|
||||||
cy.get('[data-cy=start-module-teaser]').eq(2).should('contain', 'Geld');
|
cy.get('[data-cy=start-module-teaser]').eq(2).should('contain', 'Geld');
|
||||||
|
|
||||||
// module list is full, should switch only the order around
|
// module list is full, should switch only the order around
|
||||||
cy.goToModule('1. Geld und Kauf', 'Modul 2');
|
cy.goToModule('Geld und Kauf', 'Modul 2');
|
||||||
cy.get('[data-cy=module-title]').should('contain', 'Geld');
|
cy.get('[data-cy=module-title]').should('contain', 'Geld');
|
||||||
cy.checkHome(3);
|
cy.checkHome(3);
|
||||||
cy.get('[data-cy=start-module-teaser]').first().should('contain', 'Geld');
|
cy.get('[data-cy=start-module-teaser]').first().should('contain', 'Geld');
|
||||||
cy.get('[data-cy=start-module-teaser]').eq(1).should('contain', 'Lerntipps');
|
cy.get('[data-cy=start-module-teaser]').eq(1).should('contain', 'Lerntipps');
|
||||||
cy.get('[data-cy=start-module-teaser]').eq(2).should('contain', 'Lohn und Budget');
|
cy.get('[data-cy=start-module-teaser]').eq(2).should('contain', 'Lohn und Budget');
|
||||||
|
|
||||||
cy.get('[data-cy=start-module-teaser]').last().click();
|
cy.goToModule('Geld und Kauf', 'Modul 5');
|
||||||
cy.get('[data-cy=module-title]').should('contain', 'Lohn und Budget');
|
cy.get('[data-cy=module-title]').should('contain', 'Random');
|
||||||
cy.checkHome(3);
|
cy.checkHome(3);
|
||||||
cy.get('[data-cy=start-module-teaser]').first().should('contain', 'Lohn und Budget');
|
cy.get('[data-cy=start-module-teaser]').first().should('contain', 'Random');
|
||||||
cy.get('[data-cy=start-module-teaser]').eq(1).should('contain', 'Geld');
|
cy.get('[data-cy=start-module-teaser]').eq(1).should('contain', 'Geld');
|
||||||
cy.get('[data-cy=start-module-teaser]').eq(2).should('contain', 'Lerntipps');
|
cy.get('[data-cy=start-module-teaser]').eq(2).should('contain', 'Lerntipps');
|
||||||
|
|
||||||
|
cy.get('[data-cy=start-module-teaser]').last().click();
|
||||||
|
cy.get('[data-cy=module-title]').should('contain', 'Lerntipps');
|
||||||
|
cy.checkHome(3);
|
||||||
|
cy.get('[data-cy=start-module-teaser]').first().should('contain', 'Lerntipps');
|
||||||
|
cy.get('[data-cy=start-module-teaser]').eq(1).should('contain', 'Random');
|
||||||
|
cy.get('[data-cy=start-module-teaser]').eq(2).should('contain', 'Geld');
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -116,15 +116,20 @@
|
||||||
if (data) {
|
if (data) {
|
||||||
data.me.lastModule = lastModule;
|
data.me.lastModule = lastModule;
|
||||||
let recentModules = data.me.recentModules.edges;
|
let recentModules = data.me.recentModules.edges;
|
||||||
|
let newRecentModules;
|
||||||
let index = recentModules.findIndex(element => element.node.id === lastModule.id);
|
let index = recentModules.findIndex(element => element.node.id === lastModule.id);
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
recentModules = [...recentModules.slice(0, index), ...recentModules.slice(index + 1)]
|
newRecentModules = [...recentModules.slice(0, index), ...recentModules.slice(index + 1)]
|
||||||
|
} else if (recentModules.length >= 3) {
|
||||||
|
newRecentModules = recentModules.slice(0, recentModules.length - 1);
|
||||||
|
} else {
|
||||||
|
newRecentModules = recentModules;
|
||||||
}
|
}
|
||||||
recentModules.unshift({
|
newRecentModules.unshift({
|
||||||
__typename: 'ModuleNodeEdge',
|
__typename: 'ModuleNodeEdge',
|
||||||
node: lastModule
|
node: lastModule
|
||||||
});
|
});
|
||||||
data.me.recentModules.edges = recentModules;
|
data.me.recentModules.edges = newRecentModules;
|
||||||
store.writeQuery({query: ME_QUERY, data});
|
store.writeQuery({query: ME_QUERY, data});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,9 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="topic__content">
|
<div class="topic__content">
|
||||||
<h1 class="topic__title">{{ topic.title }}</h1>
|
<h1
|
||||||
|
data-cy="topic-title"
|
||||||
|
class="topic__title">{{ topic.title }}</h1>
|
||||||
<p class="topic__teaser">
|
<p class="topic__teaser">
|
||||||
{{ topic.teaser }}
|
{{ topic.teaser }}
|
||||||
</p>
|
</p>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue