From f28ff69f3a169255d1e7eb68544f9b034e79b154 Mon Sep 17 00:00:00 2001 From: ogerly Date: Fri, 30 Aug 2019 06:54:25 +0200 Subject: [PATCH] Adaptation of Cypress tests, first attempt --- backend/src/schema/types/type/User.gql | 2 +- cypress.env.template.json | 2 +- cypress/integration/common/report.js | 1 + cypress/integration/common/steps.js | 27 ++++++++++++++++++-------- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/backend/src/schema/types/type/User.gql b/backend/src/schema/types/type/User.gql index c41292652..7bdfa4aee 100644 --- a/backend/src/schema/types/type/User.gql +++ b/backend/src/schema/types/type/User.gql @@ -24,7 +24,7 @@ type User { createdAt: String updatedAt: String - termsAndConditionsAgreedVersion: String! + termsAndConditionsAgreedVersion: String notifications(read: Boolean): [Notification]! @relation(name: "NOTIFIED", direction: "IN") diff --git a/cypress.env.template.json b/cypress.env.template.json index bd03f6381..f5916bb89 100644 --- a/cypress.env.template.json +++ b/cypress.env.template.json @@ -3,4 +3,4 @@ "NEO4J_URI": "bolt://localhost:7687", "NEO4J_USERNAME": "neo4j", "NEO4J_PASSWORD": "letmein" -} +} \ No newline at end of file diff --git a/cypress/integration/common/report.js b/cypress/integration/common/report.js index 2c8b848b4..4957438f1 100644 --- a/cypress/integration/common/report.js +++ b/cypress/integration/common/report.js @@ -31,6 +31,7 @@ Given('I am logged in with a {string} role', role => { cy.factory().create('User', { email: `${role}@example.org`, password: '1234', + termsAndConditionsAgreedVersion: "0.0.2", role }) cy.login({ diff --git a/cypress/integration/common/steps.js b/cypress/integration/common/steps.js index ccb10e0bb..91b5b67ca 100644 --- a/cypress/integration/common/steps.js +++ b/cypress/integration/common/steps.js @@ -1,6 +1,7 @@ import { Given, When, Then } from "cypress-cucumber-preprocessor/steps"; import { getLangByName } from "../../support/helpers"; import slugify from "slug"; +// import { VERSION } from '../../../webapp/pages/terms-and-conditions.vue'; /* global cy */ @@ -10,13 +11,18 @@ let loginCredentials = { email: "peterpan@example.org", password: "1234" }; + +const termsAndConditionsAgreedVersion = { termsAndConditionsAgreedVersion: "0.0.2" }; + const narratorParams = { name: "Peter Pan", slug: "peter-pan", avatar: "https://s3.amazonaws.com/uifaces/faces/twitter/nerrsoft/128.jpg", + ...termsAndConditionsAgreedVersion, ...loginCredentials }; + Given("I am logged in", () => { cy.login(loginCredentials); }); @@ -35,12 +41,14 @@ Given("we have a selection of tags and categories as well as posts", () => { const someAuthor = { id: "authorId", email: "author@example.org", - password: "1234" + password: "1234", + ...termsAndConditionsAgreedVersion }; const yetAnotherAuthor = { id: "yetAnotherAuthor", email: "yet-another-author@example.org", - password: "1234" + password: "1234", + ...termsAndConditionsAgreedVersion }; cy.factory() .create("User", someAuthor) @@ -66,7 +74,7 @@ Given("we have a selection of tags and categories as well as posts", () => { Given("we have the following user accounts:", table => { table.hashes().forEach(params => { - cy.factory().create("User", params); + cy.factory().create("User", { ...params, ...termsAndConditionsAgreedVersion }); }); }); @@ -77,6 +85,7 @@ Given("I have a user account", () => { Given("my user account has the role {string}", role => { cy.factory().create("User", { role, + ...termsAndConditionsAgreedVersion, ...loginCredentials }); }); @@ -182,7 +191,8 @@ Given("we have the following posts in our database:", table => { const moderatorParams = { email: "moderator@example.org", role: "moderator", - password: "1234" + password: "1234", + termsAndConditionsAgreedVersion: '0.0.2', }; cy.factory() .create("User", moderatorParams) @@ -269,8 +279,7 @@ Then( Given("my user account has the following login credentials:", table => { loginCredentials = table.hashes()[0]; - cy.debug(); - cy.factory().create("User", loginCredentials); + cy.factory().create("User", { ...termsAndConditionsAgreedVersion, ...loginCredentials }); }); When("I fill the password form with:", table => { @@ -367,12 +376,14 @@ Then("there are no notifications in the top menu", () => { Given("there is an annoying user called {string}", name => { const annoyingParams = { email: "spammy-spammer@example.org", - password: "1234" + password: "1234", + ...termsAndConditionsAgreedVersion }; cy.factory().create("User", { ...annoyingParams, id: "annoying-user", - name + name, + ...termsAndConditionsAgreedVersion }); });