mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
started to refactor cypress tests
This commit is contained in:
parent
e3e03415e1
commit
d67953bb15
@ -13,19 +13,9 @@ import orderBy from 'lodash/orderBy'
|
|||||||
const languages = orderBy(locales, 'name')
|
const languages = orderBy(locales, 'name')
|
||||||
let lastPost = {};
|
let lastPost = {};
|
||||||
|
|
||||||
let loginCredentials = {
|
|
||||||
email: "peterpan@example.org",
|
|
||||||
password: "1234"
|
|
||||||
};
|
|
||||||
const termsAndConditionsAgreedVersion = {
|
const termsAndConditionsAgreedVersion = {
|
||||||
termsAndConditionsAgreedVersion: VERSION
|
termsAndConditionsAgreedVersion: VERSION
|
||||||
};
|
};
|
||||||
const narratorParams = {
|
|
||||||
id: 'id-of-peter-pan',
|
|
||||||
name: "Peter Pan",
|
|
||||||
slug: "peter-pan",
|
|
||||||
...termsAndConditionsAgreedVersion,
|
|
||||||
};
|
|
||||||
|
|
||||||
const annoyingParams = {
|
const annoyingParams = {
|
||||||
email: "spammy-spammer@example.org",
|
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 => {
|
Given("my user account has the role {string}", role => {
|
||||||
cy.factory().build("user", {
|
cy.factory().build("user", {
|
||||||
role,
|
role,
|
||||||
@ -138,10 +124,6 @@ When("I visit {string}", page => {
|
|||||||
cy.openPage(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", () => {
|
When("a blocked user visits the post page of one of my authored posts", () => {
|
||||||
cy.logout()
|
cy.logout()
|
||||||
cy.neode()
|
cy.neode()
|
||||||
@ -161,10 +143,6 @@ Given("I am on the {string} page", page => {
|
|||||||
cy.openPage(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/, () => {
|
When(/(?:when )?I refresh the page/, () => {
|
||||||
cy.visit('/')
|
cy.visit('/')
|
||||||
.reload();
|
.reload();
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
import { When } from "cypress-cucumber-preprocessor/steps";
|
||||||
|
|
||||||
|
When("I visit the {string} page", page => {
|
||||||
|
cy.openPage(page);
|
||||||
|
});
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
import { When } from "cypress-cucumber-preprocessor/steps";
|
||||||
|
|
||||||
|
When("I wait for {int} milliseconds", ms => {
|
||||||
|
cy.wait(ms)
|
||||||
|
});
|
||||||
@ -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
|
|
||||||
@ -15,17 +15,14 @@
|
|||||||
const cucumber = require('cypress-cucumber-preprocessor').default
|
const cucumber = require('cypress-cucumber-preprocessor').default
|
||||||
const dotenv = require('dotenv')
|
const dotenv = require('dotenv')
|
||||||
|
|
||||||
|
// Import backend .env (smart)?
|
||||||
|
const { parsed } = dotenv.config({ path: require.resolve('../../backend/.env') })
|
||||||
|
|
||||||
module.exports = (on, config) => {
|
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_URI = parsed.NEO4J_URI
|
||||||
config.env.NEO4J_USERNAME = parsed.NEO4J_USERNAME
|
config.env.NEO4J_USERNAME = parsed.NEO4J_USERNAME
|
||||||
config.env.NEO4J_PASSWORD = parsed.NEO4J_PASSWORD
|
config.env.NEO4J_PASSWORD = parsed.NEO4J_PASSWORD
|
||||||
config.env.JWT_SECRET = parsed.JWT_SECRET
|
config.env.JWT_SECRET = parsed.JWT_SECRET
|
||||||
// config.baseUrl = 'http://localhost:3000'
|
|
||||||
// config.chromeWebSecurity = false
|
|
||||||
on('file:preprocessor', cucumber())
|
on('file:preprocessor', cucumber())
|
||||||
return config
|
return config
|
||||||
}
|
}
|
||||||
|
|||||||
@ -57,7 +57,7 @@ Cypress.Commands.add("login", user => {
|
|||||||
.visit("/")
|
.visit("/")
|
||||||
});
|
});
|
||||||
|
|
||||||
Cypress.Commands.add("manualLogin", ({ email, password }) => {
|
/*Cypress.Commands.add("manualLogin", ({ email, password }) => {
|
||||||
cy.visit(`/login`)
|
cy.visit(`/login`)
|
||||||
.get("input[name=email]")
|
.get("input[name=email]")
|
||||||
.trigger("focus")
|
.trigger("focus")
|
||||||
@ -68,7 +68,7 @@ Cypress.Commands.add("manualLogin", ({ email, password }) => {
|
|||||||
.get("button[name=submit]")
|
.get("button[name=submit]")
|
||||||
.as("submitButton")
|
.as("submitButton")
|
||||||
.click();
|
.click();
|
||||||
});
|
});*/
|
||||||
|
|
||||||
Cypress.Commands.add("logout", () => {
|
Cypress.Commands.add("logout", () => {
|
||||||
cy.visit(`/logout`);
|
cy.visit(`/logout`);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user