Change redirect for new student, also add new test

This commit is contained in:
Ramon Wenger 2020-02-26 12:48:30 +01:00
parent e869cc8829
commit 1c71c24ea0
3 changed files with 59 additions and 2 deletions

View File

@ -0,0 +1,19 @@
{
"me": {
"id": "VXNlck5vZGU6NQ==",
"pk": 5,
"username": "hansli",
"email": "hansli@skillbox.example",
"firstName": "Hansli",
"lastName": "Alleini",
"avatarUrl": "",
"lastModule": null,
"selectedClass": null,
"schoolClasses": {
"edges": [],
"__typename": "SchoolClassNodeConnection"
},
"__typename": "UserNode",
"permissions": []
}
}

View File

@ -0,0 +1,38 @@
const schema = require('../fixtures/schema.json');
const me = require('../fixtures/me.new-student.json');
describe('New student', () => {
it('shows "Enter Code" page and adds the user to a class', () => {
cy.server();
cy.mockGraphql({
schema: schema,
});
cy.apolloLogin('hansli', 'test');
cy.mockGraphqlOps({
operations: {
MeQuery: me,
JoinClass: {
joinClass: {
success: true,
schoolClass: {
id: "U2Nob29sQ2xhc3NOb2RlOjI=",
name: "KF1A",
__typename: "SchoolClassNode"
}
}
}
}
});
cy.visit('/');
cy.get('[data-cy=join-class-title]').should('contain', 'Zugangscode');
cy.get('[data-cy=input-class-code]').type('XXXX');
cy.get('[data-cy=join-class]').click();
cy.get('[data-cy=class-list-title]').should('contain', 'Klassenliste');
});
});

View File

@ -151,8 +151,8 @@ router.beforeEach(async (to, from, next) => {
return
}
if (to.name !== 'noClass' && loginRequired(to) && await redirectStudentsWithoutClass()) {
next({name: 'noClass'})
if (to.name !== 'join-class' && loginRequired(to) && await redirectStudentsWithoutClass()) {
next({name: 'join-class'})
return
}