Uncomment old tests, add new test

This commit is contained in:
Ramon Wenger 2021-08-11 18:26:04 +02:00
parent e490b58e96
commit f384844380
1 changed files with 154 additions and 160 deletions

View File

@ -1,6 +1,9 @@
const me = require('../../fixtures/me.join-class.json'); const me = require('../../fixtures/me.join-class.json');
const {getMinimalMe} = require('../../support/helpers'); const {getMinimalMe} = require('../../support/helpers');
const MeQuery = getMinimalMe({});
const {me: teacher} = MeQuery;
const members = [ const members = [
{ {
id: 'VXNlck5vZGU6Mw==', id: 'VXNlck5vZGU6Mw==',
@ -24,94 +27,82 @@ describe('Class Management', () => {
cy.setup(); cy.setup();
}); });
// fixme: cache misbehaves with mequery, but only for test it('should join class', () => {
// it('should join class', () => { const name = 'KF1A';
// const name = 'KF1A'; const id = 'U2Nob29sQ2xhc3NOb2RlOjI=';
// const id = 'U2Nob29sQ2xhc3NOb2RlOjI=';
// const __typename = 'SchoolClassNode';
//
// let localMe = {
// ...me
// };
//
// cy.mockGraphqlOps({
// operations: {
// MeQuery: localMe,
// // JoinClass() {
// // // fixme: is this necessary? the cache somehow does not seem to do anything for the MeQuery
// // let schoolClass = {
// // id,
// // name,
// // // __typename
// // };
// // // localMe.me.schoolClasses.edges.push({
// // // node: schoolClass,
// // // __typename: 'SchoolClassNodeEdge'
// // // });
// // return {
// // joinClass: {
// // success: true,
// // schoolClass
// // }
// // }
// // },
// JoinClass: {
// joinClass: {
// success: true,
// schoolClass: {
// name,
// id
// }
// }
// },
// MySchoolClassQuery: {
// me: {
// ...selectedClass.me,
// selectedClass: {
// __typename,
// name,
// id,
// members: []
// }
// }
// }
// }
// });
//
// cy.visit('/me/profile');
//
// cy.get('[data-cy=header-user-widget]').within(() => {
// cy.get('[data-cy=user-widget-avatar]').click();
// });
// //
// cy.get('[data-cy=class-selection]').click();
// cy.get('[data-cy=class-selection-entry]').should('have.length', 1);
// cy.get('[data-cy=class-selection]').click();
//
// cy.get('[data-cy=join-class-link]').click();
//
// cy.get('[data-cy=input-class-code]').type('XXXX');
// cy.get('[data-cy=join-class]').click();
//
// cy.get('[data-cy=school-class-name]').should('contain', name);
// cy.get('[data-cy=current-class-name]').should('contain', name);
//
// cy.get('[data-cy=header-user-widget]').within(() => {
// cy.get('[data-cy=user-widget-avatar]').click();
// });
//
// cy.get('[data-cy=class-selection]').click();
// cy.get('[data-cy=class-selection-entry]').should('have.length', 2);
// //
// });
it('should leave and re-join class', () => {
const {me: teacher} = getMinimalMe({});
cy.mockGraphqlOps({ cy.mockGraphqlOps({
operations: { operations: {
MeQuery: { MeQuery,
me: teacher // JoinClass() {
// // fixme: is this necessary? the cache somehow does not seem to do anything for the MeQuery
// let schoolClass = {
// id,
// name,
// // __typename
// };
// // localMe.me.schoolClasses.edges.push({
// // node: schoolClass,
// // __typename: 'SchoolClassNodeEdge'
// // });
// return {
// joinClass: {
// success: true,
// schoolClass
// }
// }
// },
JoinClass: {
joinClass: {
success: true,
schoolClass: {
name,
id
}
}
}, },
MySchoolClassQuery: {
me: {
...selectedClass.me,
selectedClass: {
name,
id,
members: []
}
}
}
}
});
cy.visit('/me/profile');
cy.get('[data-cy=header-user-widget]').within(() => {
cy.get('[data-cy=user-widget-avatar]').click();
});
cy.get('[data-cy=class-selection]').click();
cy.get('[data-cy=class-selection-entry]').should('have.length', 1);
cy.get('[data-cy=class-selection]').click();
cy.get('[data-cy=join-class-link]').click();
cy.get('[data-cy=input-class-code]').type('XXXX');
cy.get('[data-cy=join-class]').click();
cy.get('[data-cy=school-class-name]').should('contain', name);
cy.get('[data-cy=current-class-name]').should('contain', name);
cy.get('[data-cy=header-user-widget]').within(() => {
cy.get('[data-cy=user-widget-avatar]').click();
});
cy.get('[data-cy=class-selection]').click();
cy.get('[data-cy=class-selection-entry]').should('have.length', 2);
});
it('should leave and re-join class', () => {
cy.mockGraphqlOps({
operations: {
MeQuery,
AddRemoveMember: { AddRemoveMember: {
addRemoveMember: { addRemoveMember: {
success: true, success: true,
@ -217,82 +208,85 @@ describe('Teacher Class Management', () => {
cy.get('[data-cy=group-list-name]').should('contain', className); cy.get('[data-cy=group-list-name]').should('contain', className);
}); });
it('removes student, then leaves class', () => {
cy.get('not-implemented');
});
// // fixme: cache misbehaves with mequery, but only for test // // fixme: cache misbehaves with mequery, but only for test
// //
// it.only('creates a new class', () => { it('creates a new class', () => {
// const name = 'Moordale'; const name = 'Moordale';
// const id = 'U2Nob29sQ2xhc3NOb2RlOjI='; const id = 'U2Nob29sQ2xhc3NOb2RlOjI=';
// const __typename = "SchoolClassNode"; const __typename = 'SchoolClassNode';
// let localMe = { let localMe = {
// me: { me: {
// ...me.me, ...me.me,
// isTeacher: true isTeacher: true
// } }
// }; };
//
// cy.mockGraphqlOps({ cy.mockGraphqlOps({
// operations: { operations: {
// MeQuery: () => { MeQuery: () => {
// return localMe; return localMe;
// }, },
// CreateSchoolClass() { CreateSchoolClass() {
// // fixme: is this necessary? the cache somehow does not seem to do anything for the MeQuery // fixme: is this necessary? the cache somehow does not seem to do anything for the MeQuery
// let schoolClass = { let schoolClass = {
// id, id,
// name, name,
// __typename __typename
// }; };
// // localMe.me.schoolClasses.edges.push({ // localMe.me.schoolClasses.edges.push({
// // node: schoolClass, // node: schoolClass,
// // __typename: 'SchoolClassNodeEdge' // __typename: 'SchoolClassNodeEdge'
// // }); // });
// return { return {
// createSchoolClass: { createSchoolClass: {
// success: true, success: true,
// schoolClass schoolClass
// } }
// } };
// }, },
// MySchoolClassQuery: { MySchoolClassQuery: {
// me: { me: {
// ...selectedClass.me, ...selectedClass.me,
// selectedClass: { selectedClass: {
// __typename, __typename,
// name, name,
// id, id,
// members: [] members: []
// } }
// } }
// } }
// } }
// }); });
//
// cy.visit('/me/my-class'); cy.visit('/me/my-class');
//
// cy.get('h1').should('exist'); cy.get('h1').should('exist');
//
// cy.get('[data-cy=header-user-widget]').within(() => { cy.get('[data-cy=header-user-widget]').within(() => {
// cy.get('[data-cy=user-widget-avatar]').click(); cy.get('[data-cy=user-widget-avatar]').click();
// }); });
//
// cy.get('[data-cy=class-selection]').click(); cy.get('[data-cy=class-selection]').click();
// cy.get('[data-cy=class-selection-entry]').should('have.length', 1); cy.get('[data-cy=class-selection-entry]').should('have.length', 1);
//
// cy.get('[data-cy=create-class-link]').click();
// cy.get('[data-cy=create-class-link]').click();
// cy.get('[data-cy=input-class-name]').type(name);
// cy.get('[data-cy=input-class-name]').type(name);
// cy.get('[data-cy=create-class]').click();
// cy.get('[data-cy=create-class]').click();
// cy.get('[data-cy=school-class-name]').should('contain', name);
// cy.get('[data-cy=school-class-name]').should('contain', name); cy.get('[data-cy=current-class-name]').should('contain', name);
// cy.get('[data-cy=current-class-name]').should('contain', name);
// cy.get('[data-cy=header-user-widget]').within(() => {
// cy.get('[data-cy=header-user-widget]').within(() => { cy.get('[data-cy=user-widget-avatar]').click();
// cy.get('[data-cy=user-widget-avatar]').click(); });
// });
// cy.get('[data-cy=class-selection]').click();
// cy.get('[data-cy=class-selection]').click(); cy.get('[data-cy=class-selection-entry]').should('have.length', 2);
// cy.get('[data-cy=class-selection-entry]').should('have.length', 2); });
// });
}); });