From d4e94645036ba2dc8039f29d01c480876e45d2ed Mon Sep 17 00:00:00 2001 From: Ramon Wenger Date: Thu, 17 Feb 2022 16:26:25 +0100 Subject: [PATCH] Add test for creating content blocks --- .../modules/create-content-block.page.spec.js | 57 +++++++++++++++++-- .../content-block-form/AddContentLink.vue | 1 + .../content-block-form/ContentBlockForm.vue | 3 + .../ContentBlockElementChooserWidget.vue | 5 +- client/src/components/ui/InputWithLabel.vue | 1 + 5 files changed, 61 insertions(+), 6 deletions(-) diff --git a/client/cypress/integration/frontend/modules/create-content-block.page.spec.js b/client/cypress/integration/frontend/modules/create-content-block.page.spec.js index aac14a9a..7897c895 100644 --- a/client/cypress/integration/frontend/modules/create-content-block.page.spec.js +++ b/client/cypress/integration/frontend/modules/create-content-block.page.spec.js @@ -1,19 +1,66 @@ +import {getMinimalMe} from '../../../support/helpers'; + +const MeQuery = getMinimalMe(); + describe('Create Content Block', () => { + beforeEach(() => { + cy.setup(); + + cy.mockGraphqlOps({ + operations: { + MeQuery, + ModuleDetailsQuery: { + module: {}, + }, + AddContentBlock: { + addContentBlock: { + + } + } + }, + }); + }); + it('visits the page', () => { // todo: // add mocks - // cy.visit('/module/some-module/add/bliblablub'); + cy.visit('/module/some-module/add-after/bliblablub'); // add title + cy.getByDataCy('content-block-form-heading').should('exist'); + cy.getByDataCy('content-list').should('not.exist'); + cy.getByDataCy('save-button').should('exist').should('be.disabled'); + cy.getByDataCy('content-block-title').within(() => { + cy.getByDataCy('input-with-label-input').type('Title of my book'); + }); + + cy.getByDataCy('add-content-link').click(); + cy.getByDataCy('chooser-heading').should('contain', 'Neuer Inhalt'); // add text element + cy.getByDataCy('choose-text-widget').click(); + cy.getByDataCy('text-form-input').type('Hallo Sam'); + // add list item + cy.getByDataCy('add-content-link').last().click(); + cy.getByDataCy('convert-to-list-checkbox').click(); // add text element to list item - // add second list item - // add text element to second list item - // add another text element to second list item + cy.getByDataCy('choose-text-widget').click(); + cy.getByDataCy('content-list').within(() => { + cy.getByDataCy('text-form-input').last().type('Hallo Velo'); + // add second list item + cy.getByDataCy('add-content-link').click(); + // add text element to second list item + cy.getByDataCy('choose-text-widget').click(); + cy.getByDataCy('text-form-input').last().type('Hallo Velo'); + // add another text element to second list item + cy.getByDataCy('add-content-link').last().click(); + cy.getByDataCy('choose-text-widget').click(); + cy.getByDataCy('text-form-input').last().type('Hallo Outo'); + }); // save + cy.getByDataCy('save-button').should('exist').should('not.be.disabled').click(); // another test - // go to pase + // go to page // click cancel, go back }); }); diff --git a/client/src/components/content-block-form/AddContentLink.vue b/client/src/components/content-block-form/AddContentLink.vue index 42b813ae..8554e48b 100644 --- a/client/src/components/content-block-form/AddContentLink.vue +++ b/client/src/components/content-block-form/AddContentLink.vue @@ -1,6 +1,7 @@ diff --git a/client/src/components/content-block-form/ContentBlockForm.vue b/client/src/components/content-block-form/ContentBlockForm.vue index db4a5fe9..3ca34b47 100644 --- a/client/src/components/content-block-form/ContentBlockForm.vue +++ b/client/src/components/content-block-form/ContentBlockForm.vue @@ -21,6 +21,7 @@
Speichern diff --git a/client/src/components/content-forms/ContentBlockElementChooserWidget.vue b/client/src/components/content-forms/ContentBlockElementChooserWidget.vue index 24606af5..5e392f6d 100644 --- a/client/src/components/content-forms/ContentBlockElementChooserWidget.vue +++ b/client/src/components/content-forms/ContentBlockElementChooserWidget.vue @@ -6,7 +6,10 @@ > -

+

Neuer Inhalt