started to refactor cypress tests

This commit is contained in:
Ulf Gebhardt 2021-04-10 02:18:04 +02:00
parent e3e03415e1
commit d67953bb15
No known key found for this signature in database
GPG Key ID: 81308EFE29ABFEBD
30 changed files with 15 additions and 53 deletions

View File

@ -13,19 +13,9 @@ import orderBy from 'lodash/orderBy'
const languages = orderBy(locales, 'name')
let lastPost = {};
let loginCredentials = {
email: "peterpan@example.org",
password: "1234"
};
const termsAndConditionsAgreedVersion = {
termsAndConditionsAgreedVersion: VERSION
};
const narratorParams = {
id: 'id-of-peter-pan',
name: "Peter Pan",
slug: "peter-pan",
...termsAndConditionsAgreedVersion,
};
const annoyingParams = {
email: "spammy-spammer@example.org",
@ -121,10 +111,6 @@ Given("we have the following user accounts:", table => {
});
});
Given("I have a user account", () => {
cy.factory().build("user", narratorParams, loginCredentials);
});
Given("my user account has the role {string}", role => {
cy.factory().build("user", {
role,
@ -138,10 +124,6 @@ When("I visit {string}", page => {
cy.openPage(page);
});
When("I visit the {string} page", page => {
cy.openPage(page);
});
When("a blocked user visits the post page of one of my authored posts", () => {
cy.logout()
cy.neode()
@ -161,10 +143,6 @@ Given("I am on the {string} page", page => {
cy.openPage(page);
});
When("I fill in my email and password combination and click submit", () => {
cy.manualLogin(loginCredentials);
});
When(/(?:when )?I refresh the page/, () => {
cy.visit('/')
.reload();

View File

@ -0,0 +1,5 @@
import { When } from "cypress-cucumber-preprocessor/steps";
When("I visit the {string} page", page => {
cy.openPage(page);
});

View File

@ -0,0 +1,5 @@
import { When } from "cypress-cucumber-preprocessor/steps";
When("I wait for {int} milliseconds", ms => {
cy.wait(ms)
});

View File

@ -1,23 +0,0 @@
Feature: Authentication
As a database administrator
I want users to sign in
In order to attribute posts and other contributions to their authors
Background:
Given I have a user account
Scenario: Log in
When I visit the "login" page
And I fill in my email and password combination and click submit
Then I can click on my profile picture in the top right corner
And I can see my name "Peter Lustig" in the dropdown menu
Scenario: Refresh and stay logged in
Given I am logged in
When I refresh the page
Then I am still logged in
Scenario: Log out
Given I am logged in
When I log out through the menu in the top right corner
Then I see the login screen again

View File

@ -15,17 +15,14 @@
const cucumber = require('cypress-cucumber-preprocessor').default
const dotenv = require('dotenv')
// Import backend .env (smart)?
const { parsed } = dotenv.config({ path: require.resolve('../../backend/.env') })
module.exports = (on, config) => {
// (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
const { parsed } = dotenv.config({ path: require.resolve('../../backend/.env') })
config.env.NEO4J_URI = parsed.NEO4J_URI
config.env.NEO4J_USERNAME = parsed.NEO4J_USERNAME
config.env.NEO4J_PASSWORD = parsed.NEO4J_PASSWORD
config.env.JWT_SECRET = parsed.JWT_SECRET
// config.baseUrl = 'http://localhost:3000'
// config.chromeWebSecurity = false
on('file:preprocessor', cucumber())
return config
}

View File

@ -57,7 +57,7 @@ Cypress.Commands.add("login", user => {
.visit("/")
});
Cypress.Commands.add("manualLogin", ({ email, password }) => {
/*Cypress.Commands.add("manualLogin", ({ email, password }) => {
cy.visit(`/login`)
.get("input[name=email]")
.trigger("focus")
@ -68,7 +68,7 @@ Cypress.Commands.add("manualLogin", ({ email, password }) => {
.get("button[name=submit]")
.as("submitButton")
.click();
});
});*/
Cypress.Commands.add("logout", () => {
cy.visit(`/logout`);