Update cypress test
This commit is contained in:
parent
1a928a824a
commit
e490b58e96
|
|
@ -21,16 +21,7 @@ const selectedClass = {
|
|||
|
||||
describe('Class Management', () => {
|
||||
beforeEach(() => {
|
||||
cy.server();
|
||||
|
||||
cy.task('getSchema').then(schema => {
|
||||
cy.mockGraphql({
|
||||
schema,
|
||||
});
|
||||
});
|
||||
|
||||
cy.viewport('macbook-15');
|
||||
cy.fakeLogin('rachel.green', 'test');
|
||||
cy.setup();
|
||||
});
|
||||
|
||||
// fixme: cache misbehaves with mequery, but only for test
|
||||
|
|
@ -114,43 +105,30 @@ describe('Class Management', () => {
|
|||
// //
|
||||
// });
|
||||
|
||||
it('should not be able to leave class', () => {
|
||||
cy.mockGraphqlOps({
|
||||
operations: {
|
||||
MeQuery: me,
|
||||
MySchoolClassQuery: selectedClass,
|
||||
},
|
||||
});
|
||||
|
||||
cy.visit('/me/my-class');
|
||||
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=add-to-class]').should('have.length', 0);
|
||||
});
|
||||
|
||||
it('should leave and re-join class', () => {
|
||||
const {me: teacher} = getMinimalMe({});
|
||||
const teacherSelectedClass = {
|
||||
me: {
|
||||
...selectedClass.me,
|
||||
isTeacher: true,
|
||||
},
|
||||
};
|
||||
cy.mockGraphqlOps({
|
||||
operations: {
|
||||
MeQuery: teacher,
|
||||
MeQuery: {
|
||||
me: teacher
|
||||
},
|
||||
AddRemoveMember: {
|
||||
addRemoveMember: {
|
||||
success: true,
|
||||
},
|
||||
},
|
||||
MySchoolClassQuery: teacherSelectedClass,
|
||||
MySchoolClassQuery: {
|
||||
me: {
|
||||
...teacher,
|
||||
selectedClass
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
cy.visit('/me/my-class');
|
||||
cy.get('[data-cy=active-class-members-list]').within(() => {
|
||||
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=inactive-class-members-list]').should('not.exist');
|
||||
|
||||
|
|
@ -159,16 +137,16 @@ describe('Class Management', () => {
|
|||
cy.get('[data-cy=modal-save-button]').click();
|
||||
|
||||
cy.get('[data-cy=active-class-members-list]').within(() => {
|
||||
cy.get('[data-cy=school-class-member]').should('have.length', 1);
|
||||
cy.get('[data-cy=group-list-member]').should('have.length', 1);
|
||||
});
|
||||
cy.get('[data-cy=inactive-class-members-list]').within(() => {
|
||||
cy.get('[data-cy=school-class-member]').should('have.length', 1);
|
||||
cy.get('[data-cy=group-list-member]').should('have.length', 1);
|
||||
});
|
||||
|
||||
cy.get('[data-cy=add-to-class]').first().click();
|
||||
|
||||
cy.get('[data-cy=active-class-members-list]').within(() => {
|
||||
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=inactive-class-members-list]').should('not.exist');
|
||||
});
|
||||
|
|
@ -197,26 +175,16 @@ describe('Class Management', () => {
|
|||
|
||||
describe('Teacher Class Management', () => {
|
||||
beforeEach(() => {
|
||||
cy.server();
|
||||
|
||||
cy.task('getSchema').then(schema => {
|
||||
cy.mockGraphql({
|
||||
schema,
|
||||
});
|
||||
});
|
||||
|
||||
cy.viewport('macbook-15');
|
||||
cy.fakeLogin('ross.geller', 'test');
|
||||
cy.setup();
|
||||
});
|
||||
|
||||
it('changes class name', () => {
|
||||
let className = 'Gotta have class';
|
||||
|
||||
const {me: teacher} = getMinimalMe({});
|
||||
|
||||
let localMe = {
|
||||
me: {
|
||||
...me.me,
|
||||
isTeacher: true,
|
||||
},
|
||||
me: teacher
|
||||
};
|
||||
|
||||
cy.mockGraphqlOps({
|
||||
|
|
@ -224,8 +192,8 @@ describe('Teacher Class Management', () => {
|
|||
MeQuery: localMe,
|
||||
MySchoolClassQuery: {
|
||||
me: {
|
||||
...selectedClass.me,
|
||||
isTeacher: true,
|
||||
...teacher,
|
||||
selectedClass,
|
||||
},
|
||||
},
|
||||
UpdateSchoolClass: {
|
||||
|
|
|
|||
Loading…
Reference in New Issue