From 8236b6b5881b884a110db5530f578ee67b562b8d Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Mon, 12 Apr 2021 02:08:44 +0200 Subject: [PATCH] removed redundant step definitions and old clutter --- cypress/integration/common/.report.js | 92 ------------------------- cypress/integration/common/.settings.js | 18 ----- cypress/integration/common/.steps.js | 65 ----------------- 3 files changed, 175 deletions(-) delete mode 100644 cypress/integration/common/.report.js delete mode 100644 cypress/integration/common/.settings.js delete mode 100644 cypress/integration/common/.steps.js diff --git a/cypress/integration/common/.report.js b/cypress/integration/common/.report.js deleted file mode 100644 index 07ae554e4..000000000 --- a/cypress/integration/common/.report.js +++ /dev/null @@ -1,92 +0,0 @@ -import { Given, When, Then } from 'cypress-cucumber-preprocessor/steps' -import { VERSION } from '../../constants/terms-and-conditions-version.js' - -/* global cy */ - -let lastReportTitle -let davidIrvingPostTitle = 'The Truth about the Holocaust' -let davidIrvingPostSlug = 'the-truth-about-the-holocaust' -let annoyingUserWhoMutedModeratorTitle = 'Fake news' - -const savePostTitle = $post => { - return $post - .first() - .find('.title') - .first() - .invoke('text') - .then(title => { - lastReportTitle = title - }) -} - -Given("I see David Irving's post on the newsfeed", page => { - cy.openPage('newsfeed') -}) - -Given('I am logged in with a {string} role', role => { - cy.factory().build('user', { - termsAndConditionsAgreedVersion: VERSION, - role, - name: `${role} is my name` - }, { - email: `${role}@example.org`, - password: '1234', - }) - cy.neode() - .first("User", { - name: `${role} is my name`, - }) - .then(user => { - return new Cypress.Promise((resolve, reject) => { - return user.toJson().then((user) => resolve(user)) - }) - }) - .then(user => cy.login(user)) -}) - -When('I click on "Report User" from the content menu in the user info box', () => { - cy.contains('.base-card', davidIrvingPostTitle) - .get('.user-content-menu .base-button') - .click({ force: true }) - - cy.get('.popover .ds-menu-item-link') - .contains('Report User') - .click() -}) - -When('I report the author', () => { - cy.get('.page-name-profile-id-slug').then(() => { - invokeReportOnElement('.base-card').then(() => { - cy.get('button') - .contains('Send') - .click() - }) - }) -}) - -When('I click on send in the confirmation dialog', () => { - cy.get('button') - .contains('Send') - .click() -}) - -Then('I get a success message', () => { - cy.get('.iziToast-message').contains('Thanks') -}) - -Then('I see my reported user', () => { - cy.get('table').then(() => { - cy.get('tbody tr') - .first() - .contains(lastReportTitle.trim()) - }) -}) - -When("they have a post someone has reported", () => { - cy.factory() - .build("post", { - title, - }, { - authorId: 'annnoying-user', - }); -}) diff --git a/cypress/integration/common/.settings.js b/cypress/integration/common/.settings.js deleted file mode 100644 index a5a1cf16b..000000000 --- a/cypress/integration/common/.settings.js +++ /dev/null @@ -1,18 +0,0 @@ -import { When, Then } from 'cypress-cucumber-preprocessor/steps' - -/* global cy */ - -When('I click on the {string} link', link => { - cy.get('a') - .contains(link) - .click() -}) - -Then('I should be on the {string} page', page => { - cy.location() - .should(loc => { - expect(loc.pathname).to.eq(page) - }) - .get('h2') - .should('contain', 'Social media') -}) \ No newline at end of file diff --git a/cypress/integration/common/.steps.js b/cypress/integration/common/.steps.js deleted file mode 100644 index 416195d56..000000000 --- a/cypress/integration/common/.steps.js +++ /dev/null @@ -1,65 +0,0 @@ -import { - Given, - When, - Then -} from "cypress-cucumber-preprocessor/steps"; -import locales from '../../../webapp/locales' -import orderBy from 'lodash/orderBy' - -/* global cy */ - -const languages = orderBy(locales, 'name') -let lastPost = {}; - -const annoyingParams = { - email: "spammy-spammer@example.org", - slug: 'spammy-spammer', - password: "1234", -}; - -When("I log out", cy.logout); - -When(`I click on the menu item {string}`, linkOrButton => { - cy.contains(".ds-menu-item", linkOrButton).click(); -}); - -When("I press {string}", label => { - cy.contains(label).click(); -}); - -Given("we have the following posts in our database:", table => { - table.hashes().forEach((attributesOrOptions, i) => { - cy.factory().build("post", { - ...attributesOrOptions, - deleted: Boolean(attributesOrOptions.deleted), - disabled: Boolean(attributesOrOptions.disabled), - pinned: Boolean(attributesOrOptions.pinned), - }, { - ...attributesOrOptions, - }); - }) -}) - -Given("there is an annoying user called {string}", name => { - cy.factory().build("user", { - id: "annoying-user", - name, - ...termsAndConditionsAgreedVersion, - }, annoyingParams); -}); - -Given("I wrote a post {string}", title => { - cy.factory() - .build("post", { - title, - }, { - authorId: narratorParams.id, - }); -}); - -Then("I see only one post with the title {string}", title => { - cy.get(".main-container") - .find(".post-link") - .should("have.length", 1); - cy.get(".main-container").contains(".post-link", title); -}); \ No newline at end of file