Add frontent test for room with read only school class selected
This commit is contained in:
parent
d071afbd67
commit
0804d1e324
|
|
@ -2,6 +2,13 @@ import { GraphQLError } from 'graphql';
|
|||
|
||||
const schema = require('../../../fixtures/schema.json');
|
||||
|
||||
const redeemCoupon = coupon => {
|
||||
if (coupon !== '') {
|
||||
cy.get('[data-cy="coupon-input"]').type(coupon);
|
||||
}
|
||||
cy.get('[data-cy="coupon-button"]').click();
|
||||
};
|
||||
|
||||
describe('Email Verifcation', () => {
|
||||
beforeEach(() => {
|
||||
cy.server();
|
||||
|
|
@ -22,7 +29,7 @@ describe('Email Verifcation', () => {
|
|||
cy.apolloLogin('rahel.cueni', 'test');
|
||||
|
||||
cy.visit('/license-activation');
|
||||
cy.redeemCoupon('12345asfd');
|
||||
redeemCoupon('12345asfd');
|
||||
cy.assertStartPage();
|
||||
});
|
||||
|
||||
|
|
@ -31,7 +38,7 @@ describe('Email Verifcation', () => {
|
|||
cy.apolloLogin('rahel.cueni', 'test');
|
||||
|
||||
cy.visit('/license-activation');
|
||||
cy.redeemCoupon('');
|
||||
redeemCoupon('');
|
||||
cy.get('[data-cy="coupon-local-errors"]').contains('Coupon ist ein Pflichtfeld.');
|
||||
});
|
||||
|
||||
|
|
@ -46,7 +53,7 @@ describe('Email Verifcation', () => {
|
|||
cy.apolloLogin('rahel.cueni', 'test');
|
||||
|
||||
cy.visit('/license-activation');
|
||||
cy.redeemCoupon('12345asfd');
|
||||
redeemCoupon('12345asfd');
|
||||
cy.get('[data-cy="coupon-remote-errors"]').contains('Der angegebene Coupon-Code ist ungültig.');
|
||||
});
|
||||
|
||||
|
|
@ -61,7 +68,7 @@ describe('Email Verifcation', () => {
|
|||
cy.apolloLogin('rahel.cueni', 'test');
|
||||
|
||||
cy.visit('/license-activation');
|
||||
cy.redeemCoupon('12345asfd');
|
||||
redeemCoupon('12345asfd');
|
||||
cy.get('[data-cy="coupon-remote-errors"]').contains('Es ist ein Fehler aufgetreten. Bitte versuchen Sie es nochmals oder kontaktieren Sie den Administrator.');
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import mocks from '../../../fixtures/mocks';
|
|||
|
||||
const SELECTED_CLASS_ID = 'selectedClassId';
|
||||
|
||||
const getOperations = ({readOnly}) => ({
|
||||
const getOperations = ({readOnly, classReadOnly}) => ({
|
||||
MeQuery: {
|
||||
me: {
|
||||
onboardingVisited: true,
|
||||
|
|
@ -10,6 +10,7 @@ const getOperations = ({readOnly}) => ({
|
|||
isTeacher: true,
|
||||
selectedClass: {
|
||||
id: SELECTED_CLASS_ID,
|
||||
readOnly: classReadOnly,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -27,6 +28,7 @@ const getOperations = ({readOnly}) => ({
|
|||
schoolClass: {
|
||||
id: SELECTED_CLASS_ID,
|
||||
name: 'bla',
|
||||
readOnly: classReadOnly,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -35,17 +37,19 @@ const getOperations = ({readOnly}) => ({
|
|||
},
|
||||
});
|
||||
|
||||
Cypress.Commands.add('checkRoomReadOnly', (readOnly) => {
|
||||
const checkRoomReadOnly = ({editable, readOnly, classReadOnly = false}) => {
|
||||
const operations = getOperations({readOnly, classReadOnly});
|
||||
|
||||
cy.mockGraphqlOps({
|
||||
operations: getOperations({readOnly}),
|
||||
operations,
|
||||
});
|
||||
|
||||
const exist = readOnly ? 'not.exist' : 'exist';
|
||||
const exist = editable ? 'exist' : 'not.exist';
|
||||
cy.visit('rooms');
|
||||
cy.log('visit');
|
||||
cy.get('.room-widget').should('exist');
|
||||
cy.getByDataCy('add-room').should(exist);
|
||||
});
|
||||
};
|
||||
|
||||
describe('Room Team Management - Read only', () => {
|
||||
beforeEach(() => {
|
||||
|
|
@ -61,10 +65,14 @@ describe('Room Team Management - Read only', () => {
|
|||
});
|
||||
|
||||
it('can edit room', () => {
|
||||
cy.checkRoomReadOnly(false);
|
||||
checkRoomReadOnly({editable: true, readOnly: false});
|
||||
});
|
||||
|
||||
it('can not edit room', () => {
|
||||
cy.checkRoomReadOnly(true);
|
||||
checkRoomReadOnly({editable: false, readOnly: true});
|
||||
});
|
||||
|
||||
it('can not edit room of inactive class', () => {
|
||||
checkRoomReadOnly({editable: false, readOnly: false, classReadOnly: true});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ const getOperations = ({readOnly}) => ({
|
|||
},
|
||||
});
|
||||
|
||||
Cypress.Commands.add('checkSchoolClassTeamReadOnly', (readOnly) => {
|
||||
const checkSchoolClassTeamReadOnly = (readOnly) => {
|
||||
cy.mockGraphqlOps({
|
||||
operations: getOperations({readOnly}),
|
||||
});
|
||||
|
|
@ -47,7 +47,7 @@ Cypress.Commands.add('checkSchoolClassTeamReadOnly', (readOnly) => {
|
|||
cy.getByDataCy('current-class-name').should('exist');
|
||||
cy.getByDataCy('create-class-link').should(exist);
|
||||
cy.getByDataCy('my-team-link').should(exist);
|
||||
});
|
||||
};
|
||||
|
||||
describe('School Class and Team Management - Read only', () => {
|
||||
beforeEach(() => {
|
||||
|
|
@ -62,10 +62,10 @@ describe('School Class and Team Management - Read only', () => {
|
|||
});
|
||||
|
||||
it('can see menu items', () => {
|
||||
cy.checkSchoolClassTeamReadOnly(false);
|
||||
checkSchoolClassTeamReadOnly(false);
|
||||
});
|
||||
|
||||
it('can not see menu items', () => {
|
||||
cy.checkSchoolClassTeamReadOnly(true);
|
||||
checkSchoolClassTeamReadOnly(true);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -118,51 +118,6 @@ Cypress.Commands.add('enterPassword', (password) => {
|
|||
cy.get('[data-cy="login-button"]').click();
|
||||
});
|
||||
|
||||
Cypress.Commands.add('register', (prefix, firstname, lastname, street, city, postcode, password, passwordConfirmation, acceptTerms) => {
|
||||
let selection = prefix === 1 ? 'Herr' : 'Frau';
|
||||
|
||||
cy.get('[data-cy="prefix-selection"]').select(selection);
|
||||
|
||||
if (firstname !== '') {
|
||||
cy.get('[data-cy="firstname-input"]').type(firstname);
|
||||
}
|
||||
if (lastname !== '') {
|
||||
cy.get('[data-cy="lastname-input"]').type(lastname);
|
||||
}
|
||||
|
||||
if (street !== '') {
|
||||
cy.get('[data-cy="street-input"]').type(street);
|
||||
}
|
||||
|
||||
if (city !== '') {
|
||||
cy.get('[data-cy="city-input"]').type(city);
|
||||
}
|
||||
|
||||
if (postcode !== '') {
|
||||
cy.get('[data-cy="postcode-input"]').type(postcode);
|
||||
}
|
||||
|
||||
if (password !== '') {
|
||||
cy.get('[data-cy="password-input"]').type(password);
|
||||
}
|
||||
|
||||
if (acceptTerms) {
|
||||
cy.get('[data-cy="acceptedTerms-input"] > input').first().check({force: true}).then(() => {
|
||||
cy.get('[data-cy="acceptedTerms-input"] > input:checkbox').should('be.checked');
|
||||
});
|
||||
}
|
||||
|
||||
cy.get('[data-cy="passwordConfirmation-input"]').type(passwordConfirmation);
|
||||
cy.get('[data-cy="register-button"]').click();
|
||||
});
|
||||
|
||||
Cypress.Commands.add('redeemCoupon', coupon => {
|
||||
if (coupon !== '') {
|
||||
cy.get('[data-cy="coupon-input"]').type(coupon);
|
||||
}
|
||||
cy.get('[data-cy="coupon-button"]').click();
|
||||
});
|
||||
|
||||
Cypress.Commands.add('assertStartPage', (onboarding) => {
|
||||
if (onboarding) {
|
||||
cy.get('[data-cy=onboarding-page]').should('exist');
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
// todo: clean up this file
|
||||
|
||||
const getSchoolClassNode = (id, schoolClassName) => ({
|
||||
'id': btoa(`SchoolClassNode:${id}`),
|
||||
'name': schoolClassName,
|
||||
|
|
@ -52,43 +54,6 @@ export const getMe = ({schoolClasses, teacher}) => {
|
|||
};
|
||||
};
|
||||
|
||||
export const getAssignments = () => {
|
||||
return {
|
||||
'assignments': {
|
||||
'edges': [
|
||||
{
|
||||
'node': {
|
||||
'id': 'QXNzaWdubWVudE5vZGU6MQ==',
|
||||
'title': 'Ein Auftragstitel',
|
||||
'assignment': 'Ein Auftrag',
|
||||
'solution': null,
|
||||
'submission': {
|
||||
'id': 'U3R1ZGVudFN1Ym1pc3Npb25Ob2RlOjE=',
|
||||
'text': 'Hir ist ein Feler gewesen',
|
||||
'final': false,
|
||||
'document': '',
|
||||
'submissionFeedback': {
|
||||
'id': 'U3VibWlzc2lvbkZlZWRiYWNrTm9kZTox',
|
||||
'text': '\ud83d\ude42\ud83d\ude10\ud83e\udd2c\ud83d\udc4d\ud83e\udd22\ud83e\udd22\ud83e\udd22\ud83e\udd22\ud83d\ude2e\ud83e\udd17',
|
||||
'teacher': {
|
||||
'firstName': 'Nico',
|
||||
'lastName': 'Zickgraf',
|
||||
'__typename': 'UserNode',
|
||||
},
|
||||
'__typename': 'SubmissionFeedbackNode',
|
||||
},
|
||||
'__typename': 'StudentSubmissionNode',
|
||||
},
|
||||
'__typename': 'AssignmentNode',
|
||||
},
|
||||
'__typename': 'AssignmentNodeEdge',
|
||||
},
|
||||
],
|
||||
'__typename': 'AssignmentNodeConnection',
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export const getModules = () => {
|
||||
return {
|
||||
'lohn-und-budget': {
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ fragment UserParts on PrivateUserNode {
|
|||
}
|
||||
selectedClass {
|
||||
id
|
||||
readOnly
|
||||
}
|
||||
recentModules(orderBy: "-visited") {
|
||||
edges {
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@
|
|||
return this.me.selectedClass.id;
|
||||
},
|
||||
canAddRoom() {
|
||||
return this.me.isTeacher && !this.me.readOnly;
|
||||
return this.me.isTeacher && !this.me.readOnly && !this.me.selectedClass.readOnly;
|
||||
}
|
||||
},
|
||||
|
||||
|
|
@ -70,7 +70,7 @@
|
|||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
@import "@/styles/_mixins.scss";
|
||||
@import "~styles/helpers";
|
||||
|
||||
.rooms-page {
|
||||
display: flex;
|
||||
|
|
|
|||
Loading…
Reference in New Issue