Refactor cypress tests

This commit is contained in:
Ramon Wenger 2021-08-05 17:35:23 +02:00
parent e7d25535a9
commit 0e1764f51c
13 changed files with 17 additions and 51 deletions

View File

@ -4,7 +4,6 @@ const minimalMe = {
lastName: '',
avatarUrl: '',
email: '',
onboardingVisited: true,
schoolClasses: {},
id: '',
readOnly: false,

View File

@ -41,7 +41,8 @@ export default {
solution: 'Assignment Solution',
}),
PrivateUserNode: () => ({
readOnly: false
readOnly: false,
onboardingVisited: true
}),
SchoolClassNode: () => ({
readOnly: false

View File

@ -5,31 +5,24 @@ const operations = {
title: 'Ein Auftragstitel',
solution: '<p>Eine Lösung</p>',
assignment: 'Ein Auftrag',
submissions: []
}
submissions: [],
},
},
MeQuery: {
me: {
onboardingVisited: true
},
me: {},
},
};
describe('Assignments', () => {
before(() => {
cy.task('getSchema').then(schema => {
cy.mockGraphql({
schema,
mocks: {},
operations,
});
beforeEach(() => {
cy.setup();
cy.mockGraphqlOps({
operations,
});
});
it('it does not display HTML tags', () => {
cy.server();
cy.viewport('macbook-15');
cy.fakeLogin('ross.geller', 'test');
cy.visit('/module/lohn-und-budget/submissions/QXNzaWdubWVudE5vZGU6MQ==');
cy.getByDataCy('assignment-solution').should('have.text', 'Eine Lösung');
});

View File

@ -25,7 +25,6 @@ const operations = {
},
MeQuery: {
me: {
onboardingVisited: true
}
},
AddProject: variables => ({

View File

@ -3,7 +3,6 @@ const operations = {
MeQuery: {
me: {
id: 'VXNlck5vZGU6NQ==',
onboardingVisited: true,
permissions: [],
},
},

View File

@ -1,11 +1,8 @@
import mocks from '../../../fixtures/mocks';
const myText = 'Mein Feedback';
const getOperations = ({readOnly, classReadOnly = false}) => ({
MeQuery: {
me: {
onboardingVisited: true,
readOnly,
selectedClass: {
id: 'selectedClassId',
@ -37,14 +34,7 @@ const getOperations = ({readOnly, classReadOnly = false}) => ({
describe('Assignment feedback read-only - Teacher', () => {
beforeEach(() => {
cy.fakeLogin('nico.teacher', 'test');
cy.server();
cy.task('getSchema').then(schema => {
cy.mockGraphql({
schema,
mocks,
});
});
cy.setup();
});
it('can not edit', () => {
@ -53,10 +43,6 @@ describe('Assignment feedback read-only - Teacher', () => {
});
cy.visit('submission/submission-id');
// cy.get('.submission-form__textarea--readonly').as('textarea');
//
// cy.get('@textarea').invoke('val').should('contain', myText);
// cy.get('@textarea').should('have.attr', 'readonly');
cy.isSubmissionReadOnly(myText);
cy.getByDataCy('final-submission-reopen').should('not.exist');

View File

@ -36,7 +36,6 @@ const myText = 'submission text';
const getOperations = ({final, readOnly, classReadOnly = false}) => ({
MeQuery: {
me: {
onboardingVisited: true,
readOnly,
selectedClass: {
id: 'selectedClassId',

View File

@ -5,7 +5,6 @@ const SELECTED_CLASS_ID = 'selectedClassId';
const getOperations = ({readOnly, classReadOnly}) => ({
MeQuery: {
me: {
onboardingVisited: true,
readOnly,
isTeacher: true,
selectedClass: {

View File

@ -5,7 +5,6 @@ const SELECTED_CLASS_ID = 'selectedClassId';
const getOperations = ({readOnly, classReadOnly}) => ({
MeQuery: {
me: {
onboardingVisited: true,
readOnly,
isTeacher: true,
selectedClass: {

View File

@ -5,7 +5,6 @@ const selectedClassName = 'My Class';
const getOperations = ({readOnly}) => ({
MeQuery: {
me: {
onboardingVisited: true,
readOnly,
isTeacher: true,
},

View File

@ -7,8 +7,7 @@ const operations = {
MeQuery: {
me: {
permissions: [],
onboardingVisited: true,
readOnly: false
readOnly: false,
},
},
AssignmentQuery: {
@ -131,19 +130,15 @@ const operations = {
};
describe('Spellcheck', () => {
before(() => {
cy.server();
cy.task('getSchema').then(schema => {
cy.mockGraphql({
schema,
operations,
});
beforeEach(() => {
cy.setup();
cy.mockGraphqlOps({
operations,
});
});
// todo: unskip me
it.skip('should highlight three errors', () => {
cy.fakeLogin('rachel.green', 'test');
it('should highlight three errors', () => {
cy.visit('/module/lohn-und-budget/');
cy.getByDataCy('spellcheck-correction').should('have.length', 0);

View File

@ -13,7 +13,6 @@ describe('Survey', () => {
MeQuery: {
me: {
permissions: [],
onboardingVisited: true
}
},
ModuleQuery: variables => ({module}),

View File

@ -3,7 +3,6 @@
export const getMinimalMe = ({readOnly = false, classReadOnly = false, isTeacher = true}) => ({
me: {
id: 'meId',
onboardingVisited: true,
readOnly,
isTeacher,
selectedClass: {