From fb9ba7d2bbaa3baa69ae9a157955195786a12f3b Mon Sep 17 00:00:00 2001 From: Ramon Wenger Date: Wed, 19 May 2021 11:48:45 +0200 Subject: [PATCH] Add new frontend test --- .../integration/frontend/snapshots.spec.js | 39 +++++++++++++++++++ client/cypress/support/index.d.ts | 5 ++- client/cypress/tsconfig.json | 2 + .../components/modules/SnapshotCreated.vue | 1 + .../src/components/modules/SnapshotMenu.vue | 1 + client/src/pages/snapshot/snapshots.vue | 1 + 6 files changed, 47 insertions(+), 2 deletions(-) diff --git a/client/cypress/integration/frontend/snapshots.spec.js b/client/cypress/integration/frontend/snapshots.spec.js index 051f43d4..eed4c11b 100644 --- a/client/cypress/integration/frontend/snapshots.spec.js +++ b/client/cypress/integration/frontend/snapshots.spec.js @@ -15,6 +15,32 @@ const operations = isTeacher => ({ ModuleDetailsQuery: { module, }, + CreateSnapshot: { + createSnapshot: { + snapshot: { + id: '', + title: '', + created: '', + creator: '', + }, + success: true, + }, + }, + ModuleSnapshotsQuery: { + module: { + ...module, + snapshots: [ + { + id: 'snapshot-id', + title: 'title', + created: '2020-01-01', + mine: true, + shared: false, + creator: 'me', + }, + ], + }, + }, }, }); @@ -49,6 +75,19 @@ describe('Snapshot', () => { cy.getByDataCy('snapshot-menu').should('not.exist'); }); + it.only('Creates Snapshot', () => { + cy.fakeLogin('nico.zickgraf', 'test'); + + cy.mockGraphqlOps(operations(true)); + cy.visit('module/miteinander-reden/'); + cy.getByDataCy('module-snapshots-button').click(); + cy.getByDataCy('create-snapshot-button').click(); + cy.getByDataCy('show-all-snapshots-button').click(); + cy.getByDataCy('snapshot-list').should('exist').within(() => { + cy.get('.snapshots__snapshot').should('have.length', 1); + }); + }); + it('Applies Snapshot', () => { cy.fakeLogin('nico.zickgraf', 'test'); diff --git a/client/cypress/support/index.d.ts b/client/cypress/support/index.d.ts index 22da3dab..3dd7fd92 100644 --- a/client/cypress/support/index.d.ts +++ b/client/cypress/support/index.d.ts @@ -20,7 +20,8 @@ declare namespace Cypress { selectClass(schoolClass: string): void - login(username:string, password:string, visitLogin?: boolean): void - fakeLogin(username:string, password:string): void + login(username: string, password: string, visitLogin?: boolean): void + + fakeLogin(username: string, password: string): void } } diff --git a/client/cypress/tsconfig.json b/client/cypress/tsconfig.json index 3dcd08d5..b1f04a7d 100644 --- a/client/cypress/tsconfig.json +++ b/client/cypress/tsconfig.json @@ -3,6 +3,8 @@ "allowJs": true, "checkJs": true, "resolveJsonModule": true, + "lib": ["es2015", "dom"], + "target": "ES5", "types": [ "cypress" ] diff --git a/client/src/components/modules/SnapshotCreated.vue b/client/src/components/modules/SnapshotCreated.vue index 2d75f969..2a4c53de 100644 --- a/client/src/components/modules/SnapshotCreated.vue +++ b/client/src/components/modules/SnapshotCreated.vue @@ -15,6 +15,7 @@
Alle Snapshots anzeigen Neuen Snapshot erstellen