diff --git a/cypress/integration/common/steps.js b/cypress/integration/common/steps.js index 5ff64fb1c..f0446fcc6 100644 --- a/cypress/integration/common/steps.js +++ b/cypress/integration/common/steps.js @@ -364,13 +364,25 @@ Then("there are no notifications in the top menu", () => { }); Given("there is an annoying user called {string}", (name) => { - cy.factory().create('User', { id: 'annoying-user', name }) + const annoyingParams = { + email: 'spammy-spammer@example.org', + password: '1234', + } + cy.factory().create('User', { + ...annoyingParams, + id: 'annoying-user', + name + }) }) Given("I am on the profile page of the annoying user", (name) => { cy.openPage('/profile/annoying-user'); }) +When("I visit the profile page of the annoying user", (name) => { + cy.openPage('/profile/annoying-user'); +}) + When("I ", (name) => { cy.openPage('/profile/annoying-user'); }) @@ -383,10 +395,37 @@ When("I click on {string} from the content menu in the user info box", (button) .click() }) - When ("I navigate to my {string} settings page", (settingsPage) => { cy.get(".avatar-menu").click(); cy.get(".avatar-menu-popover") .find('a[href]').contains("Settings").click() cy.contains('.ds-menu-item-link', settingsPage).click() }) + +Given("I follow the user {string}", (name) => { + cy.neode() + .first('User', { name }).then((followed) => { + cy.neode() + .first('User', {name: narratorParams.name}) + .relateTo(followed, 'following') + }) +}) + +Given("\"Spammy Spammer\" wrote a post {string}", (title) => { + cy.factory() + .authenticateAs({ + email: 'spammy-spammer@example.org', + password: '1234', + }) + .create("Post", { title }) +}) + +Then("the list of posts of this user is empty", () => { + cy.get('.ds-card-content').not('.post-link') + cy.get('.main-container').find('.ds-space.hc-empty') +}) + +Then("nobody is following the user profile anymore", () => { + cy.get('.ds-card-content').not('.post-link') + cy.get('.main-container').contains('.ds-card-content', 'is not followed by anyone') +}) diff --git a/cypress/support/factories.js b/cypress/support/factories.js index 825f65b83..237d057cf 100644 --- a/cypress/support/factories.js +++ b/cypress/support/factories.js @@ -1,5 +1,5 @@ import Factory from '../../backend/src/seed/factories' -import { getDriver } from '../../backend/src/bootstrap/neo4j' +import { getDriver, neode as getNeode } from '../../backend/src/bootstrap/neo4j' import setupNeode from '../../backend/src/bootstrap/neode' import neode from 'neode' @@ -16,6 +16,25 @@ beforeEach(async () => { await factory.cleanDatabase({ seedServerHost, neo4jDriver }) }) +Cypress.Commands.add('neode', () => { + return setupNeode(neo4jConfigs) +}) +Cypress.Commands.add( + 'first', + { prevSubject: true }, + async (neode, model, properties) => { + console.log(neode) + return neode.first(model, properties) + } +) +Cypress.Commands.add( + 'relateTo', + { prevSubject: true }, + async (node, otherNode, relationship) => { + return node.relateTo(otherNode, relationship) + } +) + Cypress.Commands.add('factory', () => { return Factory({ seedServerHost, neo4jDriver, neodeInstance: setupNeode(neo4jConfigs) }) })