Change redirect for new student, also add new test
This commit is contained in:
parent
e869cc8829
commit
1c71c24ea0
|
|
@ -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": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -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');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -151,8 +151,8 @@ router.beforeEach(async (to, from, next) => {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (to.name !== 'noClass' && loginRequired(to) && await redirectStudentsWithoutClass()) {
|
if (to.name !== 'join-class' && loginRequired(to) && await redirectStudentsWithoutClass()) {
|
||||||
next({name: 'noClass'})
|
next({name: 'join-class'})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue