Update frontend cypress tests

This commit is contained in:
Ramon Wenger 2021-03-25 20:49:36 +01:00
parent ef5c1c6279
commit a8d3635d7b
5 changed files with 141 additions and 130 deletions

View File

@ -1,14 +1,15 @@
import {mockUpdateOnboardingProgress} from '../../support/helpers'; import {mockUpdateOnboardingProgress} from '../../support/helpers';
const schema = require('../../fixtures/schema.json');
const me = require('../../fixtures/me.join-class.json'); const me = require('../../fixtures/me.join-class.json');
describe('Onboarding', () => { describe('Onboarding', () => {
beforeEach(() => { beforeEach(() => {
cy.server(); cy.server();
cy.task('getSchema').then(schema => {
cy.mockGraphql({ cy.mockGraphql({
schema: schema, schema,
});
}); });
}); });

View File

@ -1,21 +1,11 @@
const schema = require('../../fixtures/schema.json');
const me = require('../../fixtures/me.new-student.json');
describe('Project Entry', () => { const operations = {
beforeEach(() => {
cy.viewport('macbook-15');
cy.fakeLogin('rahel.cueni', 'test');
cy.server();
cy.mockGraphql({
schema: schema,
operations: {
MeQuery: { MeQuery: {
me: { me: {
id: 'VXNlck5vZGU6NQ==', id: 'VXNlck5vZGU6NQ==',
onboardingVisited: true, onboardingVisited: true,
permissions: [] permissions: [],
} },
}, },
ProjectsQuery: { ProjectsQuery: {
projects: { projects: {
@ -33,15 +23,15 @@ describe('Project Entry', () => {
'lastName': 'Cueni', 'lastName': 'Cueni',
'id': 'VXNlck5vZGU6NQ==', 'id': 'VXNlck5vZGU6NQ==',
'avatarUrl': '', 'avatarUrl': '',
'__typename': 'UserNode' '__typename': 'UserNode',
}, },
'entriesCount': 2, 'entriesCount': 2,
'__typename': 'ProjectNode' '__typename': 'ProjectNode',
}, },
'__typename': 'ProjectNodeEdge' '__typename': 'ProjectNodeEdge',
}], }],
'__typename': 'ProjectNodeConnection' '__typename': 'ProjectNodeConnection',
} },
}, },
ProjectQuery: { ProjectQuery: {
'project': { 'project': {
@ -57,7 +47,7 @@ describe('Project Entry', () => {
'lastName': 'Cueni', 'lastName': 'Cueni',
'id': 'VXNlck5vZGU6NQ==', 'id': 'VXNlck5vZGU6NQ==',
'avatarUrl': '', 'avatarUrl': '',
'__typename': 'UserNode' '__typename': 'UserNode',
}, },
'entriesCount': 1, 'entriesCount': 1,
'__typename': 'ProjectNode', '__typename': 'ProjectNode',
@ -70,37 +60,49 @@ describe('Project Entry', () => {
'nextSteps': 'Go for the head', 'nextSteps': 'Go for the head',
'documentUrl': '', 'documentUrl': '',
'__typename': 'ProjectEntryNode', '__typename': 'ProjectEntryNode',
'created': '2020-01-20T15:20:31.262510+00:00' 'created': '2020-01-20T15:20:31.262510+00:00',
}, },
'__typename': 'ProjectEntryNodeEdge' '__typename': 'ProjectEntryNodeEdge',
}], }],
'__typename': 'ProjectEntryNodeConnection' '__typename': 'ProjectEntryNodeConnection',
} },
} },
}, },
AddProjectEntry: variables => ({ AddProjectEntry: variables => ({
addProjectEntry: { addProjectEntry: {
projectEntry: Object.assign({}, variables.input.projectEntry, { projectEntry: Object.assign({}, variables.input.projectEntry, {
created: '2020-01-20T15:26:58.722773+00:00' created: '2020-01-20T15:26:58.722773+00:00',
}), }),
errors: null, errors: null,
__typename: 'AddProjectEntryPayload' __typename: 'AddProjectEntryPayload',
} },
}), }),
UpdateProjectEntry: variables => ({ UpdateProjectEntry: variables => ({
updateProjectEntry: { updateProjectEntry: {
projectEntry: variables.input.projectEntry, projectEntry: variables.input.projectEntry,
errors: null, errors: null,
__typename: 'UpdateProjectEntryPayload' __typename: 'UpdateProjectEntryPayload',
} },
}), }),
DeleteProjectEntry: { DeleteProjectEntry: {
deleteProjectEntry: { deleteProjectEntry: {
success: true, success: true,
__typename: 'DeleteProjectEntryPayload' __typename: 'DeleteProjectEntryPayload',
} },
} },
} };
describe('Project Entry', () => {
beforeEach(() => {
cy.viewport('macbook-15');
cy.fakeLogin('rahel.cueni', 'test');
cy.server();
cy.task('getSchema').then(schema => {
cy.mockGraphql({
schema,
operations,
});
}); });
}); });

View File

@ -1,4 +1,3 @@
const schema = require('../../fixtures/schema.json');
const me = require('../../fixtures/me.join-class.json'); const me = require('../../fixtures/me.join-class.json');
const selectedClass = require('../../fixtures/selected-school-class.json'); const selectedClass = require('../../fixtures/selected-school-class.json');
@ -6,8 +5,10 @@ describe('Class Management', () => {
beforeEach(() => { beforeEach(() => {
cy.server(); cy.server();
cy.task('getSchema').then(schema => {
cy.mockGraphql({ cy.mockGraphql({
schema: schema, schema,
});
}); });
cy.viewport('macbook-15'); cy.viewport('macbook-15');
@ -104,7 +105,7 @@ describe('Class Management', () => {
}); });
cy.visit('/me/my-class'); cy.visit('/me/my-class');
cy.get('[data-cy=school-class-member]').should('have.length', 2); cy.get('[data-cy=group-list-member]').should('have.length', 2);
cy.get('[data-cy=remove-from-class]').should('have.length', 0); cy.get('[data-cy=remove-from-class]').should('have.length', 0);
cy.get('[data-cy=add-to-class]').should('have.length', 0); cy.get('[data-cy=add-to-class]').should('have.length', 0);
}); });
@ -187,8 +188,10 @@ describe('Teacher Class Management', () => {
beforeEach(() => { beforeEach(() => {
cy.server(); cy.server();
cy.task('getSchema').then(schema => {
cy.mockGraphql({ cy.mockGraphql({
schema: schema, schema,
});
}); });
cy.viewport('macbook-15'); cy.viewport('macbook-15');
@ -232,7 +235,7 @@ describe('Teacher Class Management', () => {
cy.get('[data-cy=edit-group-name-link]').click(); cy.get('[data-cy=edit-group-name-link]').click();
cy.get('[data-cy=edit-name-input] input').type('{selectall}{backspace}').type(className); cy.get('[data-cy=edit-name-input] input').type('{selectall}{backspace}').type(className);
cy.get('[data-cy=modal-save-button]').click(); cy.get('[data-cy=modal-save-button]').click();
cy.get('[data-cy=school-class-name]').should('contain', className); cy.get('[data-cy=group-list-name]').should('contain', className);
}); });
// // fixme: cache misbehaves with mequery, but only for test // // fixme: cache misbehaves with mequery, but only for test

View File

@ -1,33 +1,37 @@
import {mockUpdateLastModule} from '../../support/helpers'; import {mockUpdateLastModule} from '../../support/helpers';
const schema = require('../../fixtures/schema.json');
const assignments = require('../../fixtures/assignments.json'); const assignments = require('../../fixtures/assignments.json');
const module = require('../../fixtures/module.json'); const module = require('../../fixtures/module.json');
const spellCheck = require('../../fixtures/spell-check.json'); const spellCheck = require('../../fixtures/spell-check.json');
describe('Spellcheck', () => { const operations = {
before(() => {
cy.server();
cy.mockGraphql({
schema: schema,
operations: {
MeQuery: { MeQuery: {
me: { me: {
permissions: [], permissions: [],
onboardingVisited: true onboardingVisited: true,
} },
}, },
AssignmentsQuery: { AssignmentsQuery: {
assignments assignments,
}, },
ModulesQuery: { ModulesQuery: {
module module,
}, },
SpellCheck: { SpellCheck: {
spellCheck spellCheck,
}, },
...mockUpdateLastModule() ...mockUpdateLastModule(),
} };
describe('Spellcheck', () => {
before(() => {
cy.server();
cy.task('getSchema').then(schema => {
cy.mockGraphql({
schema,
operations,
});
}); });
}); });

View File

@ -1,12 +1,13 @@
const schema = require('../../fixtures/schema.json');
const module = require('../../fixtures/module.json'); const module = require('../../fixtures/module.json');
describe('Survey', () => { describe('Survey', () => {
beforeEach(() => { beforeEach(() => {
cy.server(); cy.server();
cy.task('getSchema').then(schema => {
cy.mockGraphql({ cy.mockGraphql({
schema: schema, schema,
});
}); });
cy.viewport('macbook-15'); cy.viewport('macbook-15');