diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 8565bda8e..000000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "eslint.validate": [ - "javascript", - "javascriptreact", - { - "language": "vue", - "autoFix": true - } - ], - "editor.formatOnSave": false, -} diff --git a/cypress/integration/common/post.js b/cypress/integration/common/post.js index f728449d2..7a47c116e 100644 --- a/cypress/integration/common/post.js +++ b/cypress/integration/common/post.js @@ -5,7 +5,7 @@ import orderBy from 'lodash/orderBy' const languages = orderBy(locales, 'name') const narratorAvatar = "https://s3.amazonaws.com/uifaces/faces/twitter/nerrsoft/128.jpg"; -let expectedValue = { title: 'new post', content: 'new post content', src: 'onourjourney' } + When("I type in a comment with {int} characters", size => { var c=""; for (var i = 0; i < size; i++) { @@ -89,8 +89,7 @@ Then("I see a toaster with {string}", (title) => { Then("I should be able to {string} a teaser image", condition => { cy.reload() - let teaserImageUpload = "onourjourney.png"; - if (condition === 'change') teaserImageUpload = "humanconnection.png"; + const teaserImageUpload = (condition === 'change') ? "humanconnection.png" : "onourjourney.png"; cy.fixture(teaserImageUpload).as('postTeaserImage').then(function() { cy.get("#postdropzone").upload( { fileContent: this.postTeaserImage, fileName: teaserImageUpload, mimeType: "image/png" }, @@ -120,15 +119,13 @@ Then("I add all required fields", () => { }) Then("the post was saved successfully with the {string} teaser image", condition => { - if (condition === 'updated') - expectedValue = { title: 'to be updated', content: 'successfully updated', src: 'humanconnection' } cy.get(".ds-card-content > .ds-heading") - .should("contain", expectedValue.title) + .should("contain", condition === 'updated' ? 'to be updated' : 'new post') .get(".content") - .should("contain", expectedValue.content) + .should("contain", condition === 'updated' ? 'successfully updated' : 'new post content') .get('.post-page img') .should("have.attr", "src") - .and("contains", expectedValue.src) + .and("contains", condition === 'updated' ? 'humanconnection' : 'onourjourney') }) Then("the first image should be removed from the preview", () => { @@ -142,11 +139,11 @@ Then("the first image should be removed from the preview", () => { }) }) -Then('the post was saved successfully without a teaser image', () => { +Then('the {string} post was saved successfully without a teaser image', condition => { cy.get(".ds-card-content > .ds-heading") - .should("contain", 'new post') + .should("contain", condition === 'updated' ? 'to be updated' : 'new post') .get(".content") - .should("contain", 'new post content') + .should("contain", condition === 'updated' ? 'successfully updated' : 'new post content') .get('.post-page') .should('exist') .get('.post-page img.ds-card-image') @@ -156,4 +153,15 @@ Then('the post was saved successfully without a teaser image', () => { Then('I should be able to remove it', () => { cy.get('.crop-cancel') .click() +}) + +When('my post has a teaser image', () => { + cy.get('.contribution-image') + .should('exist') + .and('have.attr', 'src') +}) + +Then('I should be able to remove the image', () => { + cy.get('.delete-image') + .click() }) \ No newline at end of file diff --git a/cypress/integration/post/DeleteImage.feature b/cypress/integration/post/DeleteImage.feature new file mode 100644 index 000000000..a3fa6f9b6 --- /dev/null +++ b/cypress/integration/post/DeleteImage.feature @@ -0,0 +1,19 @@ +Feature: Delete Teaser Image + As a user + I would like to be able to remove an image I have previously added to my Post + So that I have control over the content of my Post + + Background: + Given I have a user account + Given I am logged in + Given we have the following posts in our database: + | authorId | id | title | content | + | id-of-peter-pan | p1 | Post to be updated | successfully updated | + + Scenario: Delete existing image + Given I am on the 'post/edit/p1' page + And my post has a teaser image + Then I should be able to remove the image + And I click on "Save" + Then I get redirected to ".../post-to-be-updated" + And the "updated" post was saved successfully without a teaser image diff --git a/cypress/integration/post/ImageUploader.feature b/cypress/integration/post/ImageUploader.feature index 061001ffb..2e9f1f5b9 100644 --- a/cypress/integration/post/ImageUploader.feature +++ b/cypress/integration/post/ImageUploader.feature @@ -44,4 +44,4 @@ Feature: Upload Teaser Image And I add all required fields And I click on "Save" Then I get redirected to ".../new-post" - And the post was saved successfully without a teaser image \ No newline at end of file + And the "new" post was saved successfully without a teaser image \ No newline at end of file diff --git a/webapp/components/ContributionForm/ContributionForm.spec.js b/webapp/components/ContributionForm/ContributionForm.spec.js index b2ce7d530..23b3d8906 100644 --- a/webapp/components/ContributionForm/ContributionForm.spec.js +++ b/webapp/components/ContributionForm/ContributionForm.spec.js @@ -384,6 +384,15 @@ describe('ContributionForm.vue', () => { await wrapper.find('form').trigger('submit') expect(mocks.$apollo.mutate).toHaveBeenCalledWith(expect.objectContaining(expectedParams)) }) + + it('supports deleting a teaser image', async () => { + expectedParams.variables.image = null + propsData.contribution.image = '/uploads/someimage.png' + wrapper = Wrapper() + wrapper.find('.contribution-form .delete-image').trigger('click') + await wrapper.find('form').trigger('submit') + expect(mocks.$apollo.mutate).toHaveBeenCalledWith(expect.objectContaining(expectedParams)) + }) }) }) }) diff --git a/webapp/components/ContributionForm/ContributionForm.vue b/webapp/components/ContributionForm/ContributionForm.vue index 96046f118..39dcd581b 100644 --- a/webapp/components/ContributionForm/ContributionForm.vue +++ b/webapp/components/ContributionForm/ContributionForm.vue @@ -7,11 +7,22 @@ @submit="submit" >