From 44f25bd11388cd564687708228b28d71f5d035d4 Mon Sep 17 00:00:00 2001 From: Ramon Wenger Date: Tue, 3 Aug 2021 15:12:09 +0200 Subject: [PATCH] Add read-only banner --- .../read-only/read-only-banner.spec.js | 67 +++++++++++++++++++ client/src/App.vue | 13 ++-- client/src/components/ReadOnlyBanner.vue | 41 ++++++++++++ client/src/mixins/add-school-class.js | 2 +- client/src/pages/instrumentOverview.vue | 4 +- client/src/pages/joinClass.vue | 9 +-- client/src/pages/start.vue | 10 +-- client/src/pages/submissions.vue | 2 +- client/src/styles/_default-layout.scss | 3 +- client/src/styles/_variables.scss | 2 + server/schema.graphql | 25 +++++++ 11 files changed, 159 insertions(+), 19 deletions(-) create mode 100644 client/cypress/integration/frontend/read-only/read-only-banner.spec.js create mode 100644 client/src/components/ReadOnlyBanner.vue diff --git a/client/cypress/integration/frontend/read-only/read-only-banner.spec.js b/client/cypress/integration/frontend/read-only/read-only-banner.spec.js new file mode 100644 index 00000000..be0dc7d9 --- /dev/null +++ b/client/cypress/integration/frontend/read-only/read-only-banner.spec.js @@ -0,0 +1,67 @@ +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'); + }); +}); diff --git a/client/src/App.vue b/client/src/App.vue index 0a7b186a..682d24bd 100644 --- a/client/src/App.vue +++ b/client/src/App.vue @@ -3,6 +3,7 @@ :class="{'no-scroll': showModal || showMobileNavigation}" class="app" id="app"> + diff --git a/client/src/mixins/add-school-class.js b/client/src/mixins/add-school-class.js index e1e39966..f9cc4120 100644 --- a/client/src/mixins/add-school-class.js +++ b/client/src/mixins/add-school-class.js @@ -5,7 +5,7 @@ export default { addSchoolClass(store, schoolClass) { const query = ME_QUERY; if (schoolClass) { - console.log('updating school class'); + this.$log.debug('updating school class', schoolClass); const data = store.readQuery({query}); if (data) { data.me.schoolClasses.edges = [ diff --git a/client/src/pages/instrumentOverview.vue b/client/src/pages/instrumentOverview.vue index 0ed95fe1..c28387de 100644 --- a/client/src/pages/instrumentOverview.vue +++ b/client/src/pages/instrumentOverview.vue @@ -76,7 +76,7 @@ } &__title { - max-width: 1200px; + max-width: $screen-width; line-height: 1.2; margin-bottom: 0; } @@ -87,7 +87,7 @@ &__list { padding: $large-spacing 0; - max-width: 1200px; + max-width: $screen-width; width: 100%; display: flex; flex-direction: column; diff --git a/client/src/pages/joinClass.vue b/client/src/pages/joinClass.vue index 7676acaf..655e9154 100644 --- a/client/src/pages/joinClass.vue +++ b/client/src/pages/joinClass.vue @@ -34,7 +34,7 @@ this.error = ''; }, joinClass(code) { - let self = this; + this.$log.debug('joining class'); this.$apollo.mutate({ mutation: JOIN_CLASS_MUTATION, variables: { @@ -42,9 +42,10 @@ code, }, }, - update(store, {data: {joinClass: {schoolClass}}}) { - self.addSchoolClass(store, schoolClass); - self.$router.push({name: 'my-class'}); + update: (store, {data: {joinClass: {schoolClass}}}) => { + this.addSchoolClass(store, schoolClass); + this.$log.debug('added school class'); + this.$router.push({name: 'my-class'}); }, refetchQueries: [{query: MY_SCHOOL_CLASS_QUERY}], }) diff --git a/client/src/pages/start.vue b/client/src/pages/start.vue index bdd3948a..5143b104 100644 --- a/client/src/pages/start.vue +++ b/client/src/pages/start.vue @@ -4,7 +4,9 @@
-

Letzte Module

+

Letzte Module