skillbox/client/cypress/integration/frontend/read-only/read-only-banner.spec.js

68 lines
1.6 KiB
JavaScript

const getOperations = ({readOnly, classReadOnly = false}) => ({
MeQuery: {
me: {
onboardingVisited: true,
readOnly,
isTeacher: true,
selectedClass: {
id: 'selectedClassId',
readOnly: classReadOnly
}
},
},
NewsTeasers: {
newsTeasers: {
edges: []
}
}
});
const checkReadOnly = (shouldBannerExist, text) => {
cy.visit('/');
cy.getByDataCy('start-page-heading').should('exist');
if (shouldBannerExist) {
cy.getByDataCy('read-only-banner').should('exist').should('contain', text);
} else {
cy.getByDataCy('read-only-banner').should('not.exist');
}
};
describe('Read Only Banner', () => {
beforeEach(() => {
cy.setup();
});
it('is not shown', () => {
cy.mockGraphqlOps({
operations: getOperations({readOnly: false}),
});
checkReadOnly(false);
});
it('is shown for expired license', () => {
cy.mockGraphqlOps({
operations: getOperations({readOnly: true}),
});
checkReadOnly(true, 'Lizenz');
// cy.visit('/');
//
// cy.getByDataCy('start-page-heading').should('exist');
// cy.getByDataCy('read-only-banner').should('exist').should('contain', 'nicht mehr aktiv');
});
it('is shown for inactive school class', () => {
cy.mockGraphqlOps({
operations: getOperations({readOnly: false, classReadOnly: true}),
});
checkReadOnly(true, 'Klasse');
//
// cy.visit('/');
// cy.getByDataCy('start-page-heading').should('exist');
// cy.getByDataCy('read-only-banner').should('exist').should('contain', 'nicht mehr aktiv');
});
});