Merge branch 'master' into merge-6336-into-6339-optimize-event-create-and-update

This commit is contained in:
Hannes Heine 2023-06-07 09:52:23 +02:00 committed by GitHub
commit 67b5047445
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
156 changed files with 2420 additions and 2916 deletions

View File

@ -1,20 +1,37 @@
// NOTE: We cannot use `fs` here to clean up the code. Cypress breaks on any npm
// module that is not browser-compatible. Node's `fs` module is server-side only
export default {
Image: require('./Image.js').default,
Badge: require('./Badge.js').default,
User: require('./User.js').default,
Group: require('./Group.js').default,
EmailAddress: require('./EmailAddress.js').default,
UnverifiedEmailAddress: require('./UnverifiedEmailAddress.js').default,
SocialMedia: require('./SocialMedia.js').default,
Post: require('./Post.js').default,
Comment: require('./Comment.js').default,
Category: require('./Category.js').default,
Tag: require('./Tag.js').default,
Location: require('./Location.js').default,
Donations: require('./Donations.js').default,
Report: require('./Report.js').default,
Migration: require('./Migration.js').default,
InviteCode: require('./InviteCode.js').default,
Image: typeof Cypress !== 'undefined' ? require('./Image.js') : require('./Image.js').default,
Badge: typeof Cypress !== 'undefined' ? require('./Badge.js') : require('./Badge.js').default,
User: typeof Cypress !== 'undefined' ? require('./User.js') : require('./User.js').default,
Group: typeof Cypress !== 'undefined' ? require('./Group.js') : require('./Group.js').default,
EmailAddress:
typeof Cypress !== 'undefined'
? require('./EmailAddress.js')
: require('./EmailAddress.js').default,
UnverifiedEmailAddress:
typeof Cypress !== 'undefined'
? require('./UnverifiedEmailAddress.js')
: require('./UnverifiedEmailAddress.js').default,
SocialMedia:
typeof Cypress !== 'undefined'
? require('./SocialMedia.js')
: require('./SocialMedia.js').default,
Post: typeof Cypress !== 'undefined' ? require('./Post.js') : require('./Post.js').default,
Comment:
typeof Cypress !== 'undefined' ? require('./Comment.js') : require('./Comment.js').default,
Category:
typeof Cypress !== 'undefined' ? require('./Category.js') : require('./Category.js').default,
Tag: typeof Cypress !== 'undefined' ? require('./Tag.js') : require('./Tag.js').default,
Location:
typeof Cypress !== 'undefined' ? require('./Location.js') : require('./Location.js').default,
Donations:
typeof Cypress !== 'undefined' ? require('./Donations.js') : require('./Donations.js').default,
Report: typeof Cypress !== 'undefined' ? require('./Report.js') : require('./Report.js').default,
Migration:
typeof Cypress !== 'undefined' ? require('./Migration.js') : require('./Migration.js').default,
InviteCode:
typeof Cypress !== 'undefined'
? require('./InviteCode.js')
: require('./InviteCode.js').default,
}

53
cypress/cypress.config.js Normal file
View File

@ -0,0 +1,53 @@
const dotenv = require('dotenv')
const { defineConfig } = require("cypress");
const browserify = require("@badeball/cypress-cucumber-preprocessor/browserify");
const { addCucumberPreprocessorPlugin } = require("@badeball/cypress-cucumber-preprocessor");
// Test persistent(between commands) store
const testStore = {}
async function setupNodeEvents(on, config) {
await addCucumberPreprocessorPlugin(on, config);
on("file:preprocessor", browserify.default(config));
on("task", {
pushValue({ name, value }) {
testStore[name] = value
return true
},
getValue(name) {
console.log("getValue",name,testStore)
return testStore[name]
},
});
on("after:run", (results) => {
if (results) {
console.log(results.status);
}
});
return config;
}
// Import backend .env (smart)?
const { parsed } = dotenv.config({ path: '../backend/.env' })
module.exports = defineConfig({
e2e: {
projectId: "qa7fe2",
defaultCommandTimeout: 10000,
chromeWebSecurity: false,
baseUrl: "http://localhost:3000",
specPattern: "cypress/e2e/**/*.feature",
supportFile: "cypress/support/e2e.js",
retries: {
runMode: 2,
openMode: 0,
},
video: false,
setupNodeEvents,
},
env: parsed
});

View File

@ -1,12 +0,0 @@
{
"projectId": "qa7fe2",
"defaultCommandTimeout": 10000,
"ignoreTestFiles": "*.js",
"chromeWebSecurity": false,
"baseUrl": "http://localhost:3000",
"video":false,
"retries": {
"runMode": 2,
"openMode": 0
}
}

View File

@ -22,5 +22,6 @@ Feature: User authentication
Scenario: Log out
Given I am logged in as "peter-pan"
When I log out
When I navigate to page "/"
And I log out
Then I am on page "login"

View File

@ -1,5 +0,0 @@
import { Then } from "cypress-cucumber-preprocessor/steps";
Then("I click save", () => {
cy.get(".save-button").click()
})

View File

@ -1,6 +0,0 @@
import { Then } from "cypress-cucumber-preprocessor/steps";
Then("I click the checkbox show donations progress bar and save", () => {
cy.get("#showDonations").click()
cy.get(".donations-info-button").click()
})

View File

@ -1,5 +0,0 @@
import { When } from "cypress-cucumber-preprocessor/steps";
When("I submit the form", () => {
cy.get("form").submit();
});

View File

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

View File

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

View File

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

View File

@ -8,10 +8,10 @@ CUR_JOB=$(expr $1 - 1)
MAX_JOBS=$2
# Features
FEATURE_LIST=( $(find cypress/integration/ -maxdepth 1 -name "*.feature") )
FEATURE_LIST=( $(find cypress/e2e/ -maxdepth 1 -name "*.feature") )
# Calculation
MAX_FEATURES=$(find cypress/integration/ -maxdepth 1 -name "*.feature" -print | wc -l)
MAX_FEATURES=$(find cypress/e2e/ -maxdepth 1 -name "*.feature" -print | wc -l)
# adds overhead features to the first jobs
if [[ $CUR_JOB -lt $(expr ${MAX_FEATURES} % ${MAX_JOBS}) ]]
then

View File

@ -1,41 +0,0 @@
// ***********************************************************
// This example plugins/index.js can be used to load plugins
//
// You can change the location of this file or turn off loading
// the plugins file with the 'pluginsFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/plugins-guide
// ***********************************************************
// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)
const cucumber = require('cypress-cucumber-preprocessor').default
const dotenv = require('dotenv')
// Import backend .env (smart)?
const { parsed } = dotenv.config({ path: require.resolve('../../backend/.env') })
// Test persistent(between commands) store
const testStore = {}
module.exports = (on, config) => {
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
on('file:preprocessor', cucumber())
on('task', {
pushValue({ name, value }) {
testStore[name] = value
return true
},
getValue(name) {
console.log("getValue",name,testStore)
return testStore[name]
},
})
return config
}

View File

@ -15,7 +15,7 @@
/* globals Cypress cy */
import "cypress-file-upload";
import { GraphQLClient, request } from 'graphql-request'
import config from '../../backend/src/config'
import CONFIG from '../../backend/src/config'
const authenticatedHeaders = (variables) => {
const mutation = `
@ -24,7 +24,7 @@ const authenticatedHeaders = (variables) => {
}
`
return new Cypress.Promise((resolve, reject) => {
request(config.GRAPHQL_URI, mutation, variables).then((response) => {
request(CONFIG.GRAPHQL_URI, mutation, variables).then((response) => {
resolve({ authorization: `Bearer ${response.login}` })
})
})
@ -40,7 +40,7 @@ Cypress.Commands.add(
({email, password}) => {
return new Cypress.Promise((resolve, reject) => {
authenticatedHeaders({ email, password }).then((headers) => {
resolve(new GraphQLClient(config.GRAPHQL_URI, { headers }))
resolve(new GraphQLClient(CONFIG.GRAPHQL_URI, { headers }))
})
})
})

View File

@ -1,13 +1,7 @@
import Factory from '../../backend/src/db/factories'
import { getNeode } from '../../backend/src/db/neo4j'
const neo4jConfigs = {
uri: Cypress.env('NEO4J_URI'),
username: Cypress.env('NEO4J_USERNAME'),
password: Cypress.env('NEO4J_PASSWORD')
}
const neodeInstance = getNeode(neo4jConfigs)
const neodeInstance = getNeode()
beforeEach(() => cy.then(() => neodeInstance.cypher('MATCH (everything) DETACH DELETE everything;')))
@ -16,7 +10,7 @@ Cypress.Commands.add('neode', () => {
})
Cypress.Commands.add(
'first',
'firstOf',
{ prevSubject: true },
(neode, model, properties) => {
return neode.first(model, properties)

View File

@ -1,8 +1,8 @@
import { When } from "cypress-cucumber-preprocessor/steps";
import { When } from "@badeball/cypress-cucumber-preprocessor";
When("the donation info contains goal {string} and progress {string}", (goal, progress) => {
cy.get('.top-info-bar')
.should('contain', goal)
cy.get('.top-info-bar')
.should('contain', progress)
});
});

View File

@ -1,6 +1,6 @@
import { Then } from "cypress-cucumber-preprocessor/steps";
import { Then } from "@badeball/cypress-cucumber-preprocessor";
Then("the donation info is {string}", (visibility) => {
cy.get('.top-info-bar')
.should(visibility === 'visible' ? 'exist' : 'not.exist')
})
})

View File

@ -1,7 +1,7 @@
import { When } from "cypress-cucumber-preprocessor/steps";
import { When } from "@badeball/cypress-cucumber-preprocessor";
When("I open the content menu of post {string}", (title) => {
cy.contains('.post-teaser', title)
.find('.content-menu .base-button')
.click()
})
})

View File

@ -1,4 +1,4 @@
import { Then } from "cypress-cucumber-preprocessor/steps";
import { Then } from "@badeball/cypress-cucumber-preprocessor";
Then("the post with title {string} has a ribbon for pinned posts", (title) => {
cy.get(".post-teaser").contains(title)
@ -6,4 +6,4 @@ Then("the post with title {string} has a ribbon for pinned posts", (title) => {
.parent()
.find(".ribbon.--pinned")
.should("contain", "Announcement")
})
})

View File

@ -1,7 +1,7 @@
import { Then } from "cypress-cucumber-preprocessor/steps";
import { Then } from "@badeball/cypress-cucumber-preprocessor";
Then("there is no button to pin a post", () => {
cy.get("a.ds-menu-item-link")
.should('contain', "Report Post") // sanity check
.should('not.contain', "Pin post")
})
})

View File

@ -1,5 +1,5 @@
import { Then } from "cypress-cucumber-preprocessor/steps";
import { Then } from "@badeball/cypress-cucumber-preprocessor";
Then("I see a button with the label {string}", label => {
cy.contains("button", label);
});
});

View File

@ -1,8 +1,8 @@
import { When } from "cypress-cucumber-preprocessor/steps";
import { When } from "@badeball/cypress-cucumber-preprocessor";
When("I select {string} in the language menu", language => {
cy.get(".locale-menu")
.click();
cy.contains(".locale-menu-popover a", language)
.click();
});
});

View File

@ -1,8 +1,8 @@
import { Then } from "cypress-cucumber-preprocessor/steps";
import locales from '../../../webapp/locales'
import { Then } from "@badeball/cypress-cucumber-preprocessor";
import locales from '../../../../webapp/locales'
Then("the whole user interface appears in {string}", language => {
const { code } = locales.find((entry) => entry.name === language);
cy.get(`html[lang=${code}]`);
cy.getCookie("locale").should("have.property", "value", code);
});
});

View File

@ -1,7 +1,7 @@
import { Then } from "cypress-cucumber-preprocessor/steps";
import { Then } from "@badeball/cypress-cucumber-preprocessor";
Then("I should see only {int} posts on the newsfeed", posts => {
cy.get(".post-teaser")
.should("have.length", posts);
});

View File

@ -1,4 +1,4 @@
import { Then } from "cypress-cucumber-preprocessor/steps";
import { Then } from "@badeball/cypress-cucumber-preprocessor";
Then("the page {string} returns a 404 error with a message:", (route, message) => {
cy.request({
@ -11,4 +11,4 @@ Then("the page {string} returns a 404 error with a message:", (route, message) =
failOnStatusCode: false
});
cy.get(".error-message").should("contain", message);
});
});

View File

@ -1,4 +1,4 @@
import { Then } from "cypress-cucumber-preprocessor/steps";
import { Then } from "@badeball/cypress-cucumber-preprocessor";
Then(`I can't see the moderation menu item`, () => {
cy.get('.avatar-menu-popover')
@ -8,4 +8,4 @@ Then(`I can't see the moderation menu item`, () => {
cy.get('.avatar-menu-popover')
.find('a[href="/moderation"]', 'Moderation')
.should('not.exist')
})
})

View File

@ -1,7 +1,7 @@
import { Then } from "cypress-cucumber-preprocessor/steps";
import { Then } from "@badeball/cypress-cucumber-preprocessor";
Then('I can visit the post page', () => {
cy.contains('Fake news').click()
cy.location('pathname').should('contain', '/post')
.get('.base-card .title').should('contain', 'Fake news')
})
})

View File

@ -1,11 +1,11 @@
import { When } from "cypress-cucumber-preprocessor/steps";
import { When } from "@badeball/cypress-cucumber-preprocessor";
When('I click on "Report Post" from the content menu of the post', () => {
cy.contains('.base-card', 'The Truth about the Holocaust')
.find('.content-menu .base-button')
.click({force: true})
.click()
cy.get('.popover .ds-menu-item-link')
.contains('Report Post')
.click()
})
})

View File

@ -1,7 +1,7 @@
import { When } from "cypress-cucumber-preprocessor/steps";
import { When } from "@badeball/cypress-cucumber-preprocessor";
When('I click on the author', () => {
cy.get('[data-test="avatarUserLink"]')
.click()
.url().should('include', '/profile/')
})
})

View File

@ -1,5 +1,5 @@
import { When } from "cypress-cucumber-preprocessor/steps";
import { When } from "@badeball/cypress-cucumber-preprocessor";
When("I click on the avatar menu in the top right corner", () => {
cy.get(".avatar-menu").click();
});
});

View File

@ -1,4 +1,4 @@
import { When } from "cypress-cucumber-preprocessor/steps";
import { When } from "@badeball/cypress-cucumber-preprocessor";
When(/^I confirm the reporting dialog .*:$/, message => {
cy.contains(message) // wait for element to become visible
@ -13,4 +13,4 @@ When(/^I confirm the reporting dialog .*:$/, message => {
.contains('Report')
.click()
})
})
})

View File

@ -1,7 +1,7 @@
import { Then } from "cypress-cucumber-preprocessor/steps";
import { Then } from "@badeball/cypress-cucumber-preprocessor";
Then('I see all the reported posts including from the user who muted me', () => {
cy.get('table tbody').within(() => {
cy.contains('tr', 'Fake news')
})
})
})

View File

@ -1,7 +1,7 @@
import { Then } from "cypress-cucumber-preprocessor/steps";
import { Then } from "@badeball/cypress-cucumber-preprocessor";
Then('I see all the reported posts including the one from above', () => {
cy.get('table tbody').within(() => {
cy.contains('tr', 'The Truth about the Holocaust')
})
})
})

View File

@ -1,6 +1,6 @@
import { Then } from "cypress-cucumber-preprocessor/steps";
import { Then } from "@badeball/cypress-cucumber-preprocessor";
Then('each list item links to the post page', () => {
cy.contains('The Truth about the Holocaust').click();
cy.location('pathname').should('contain', '/post')
})
})

View File

@ -1,4 +1,4 @@
import { Given } from "cypress-cucumber-preprocessor/steps";
import { Given } from "@badeball/cypress-cucumber-preprocessor";
Given('somebody reported the following posts:', table => {
table.hashes().forEach(({ submitterEmail, resourceId, reasonCategory, reasonDescription }) => {

View File

@ -1,13 +1,15 @@
import { Given } from "@badeball/cypress-cucumber-preprocessor";
Given("there is an annoying user who has muted me", () => {
cy.neode()
.first("User", {
.firstOf("User", {
role: 'moderator'
})
.then(mutedUser => {
cy.neode()
.first("User", {
.firstOf("User", {
id: 'user'
})
.relateTo(mutedUser, "muted");
});
});
});

View File

@ -1,8 +1,8 @@
import { When } from "cypress-cucumber-preprocessor/steps";
import { When } from "@badeball/cypress-cucumber-preprocessor";
When("I start to write a new post with the title {string} beginning with:", (title, intro) => {
cy.get('input[name="title"]')
.type(title);
cy.get(".ProseMirror")
.type(intro);
});
});

View File

@ -1,4 +1,4 @@
import { When } from "cypress-cucumber-preprocessor/steps";
import { When } from "@badeball/cypress-cucumber-preprocessor";
When("mention {string} in the text", mention => {
cy.get(".ProseMirror")
@ -6,4 +6,4 @@ When("mention {string} in the text", mention => {
cy.get(".suggestion-list__item")
.contains(mention)
.click();
});
});

View File

@ -1,4 +1,4 @@
import { When } from "cypress-cucumber-preprocessor/steps";
import { When } from "@badeball/cypress-cucumber-preprocessor";
When("open the notification menu and click on the first item", () => {
cy.get(".notifications-menu")
@ -7,4 +7,4 @@ When("open the notification menu and click on the first item", () => {
cy.get(".notification .link")
.first()
.click({force: true});
});
});

View File

@ -1,6 +1,6 @@
import { Then } from "cypress-cucumber-preprocessor/steps";
import { Then } from "@badeball/cypress-cucumber-preprocessor";
Then("see {int} unread notifications in the top menu", count => {
cy.get(".notifications-menu")
.should("contain", count);
});
});

View File

@ -1,8 +1,8 @@
import { Then } from "cypress-cucumber-preprocessor/steps";
import { Then } from "@badeball/cypress-cucumber-preprocessor";
Then("the notification menu button links to the all notifications page", () => {
cy.get(".notifications-menu")
.click();
cy.location("pathname")
.should("contain", "/notifications");
});
});

View File

@ -1,6 +1,6 @@
import { Then } from "cypress-cucumber-preprocessor/steps";
import { Then } from "@badeball/cypress-cucumber-preprocessor";
Then("the unread counter is removed", () => {
cy.get('.notifications-menu .counter-icon')
.should('not.exist');
});
});

View File

@ -1,7 +1,7 @@
import { When } from "cypress-cucumber-preprocessor/steps";
import { When } from "@badeball/cypress-cucumber-preprocessor";
When("I comment the following:", async text => {
const comment = text.replace("\n", " ")
cy.task('pushValue', { name: 'lastComment', value: comment })
cy.get(".editor .ProseMirror").type(comment);
});
});

View File

@ -1,6 +1,6 @@
import { Then } from "cypress-cucumber-preprocessor/steps";
import { Then } from "@badeball/cypress-cucumber-preprocessor";
Then("I should see an abbreviated version of my comment", () => {
cy.get("article.comment-card")
.should("contain", "show more")
});
});

View File

@ -1,4 +1,4 @@
import { Then } from "cypress-cucumber-preprocessor/steps";
import { Then } from "@badeball/cypress-cucumber-preprocessor";
Then("I should see my comment", () => {
cy.get("article.comment-card p")
@ -10,4 +10,4 @@ Then("I should see my comment", () => {
.and("contain", 'https://') // some url
.get(".user-teaser > .info > .text")
.should("contain", "today at");
});
});

View File

@ -1,6 +1,6 @@
import { Then } from "cypress-cucumber-preprocessor/steps";
import { Then } from "@badeball/cypress-cucumber-preprocessor";
Then("I should see the entirety of my comment", () => {
cy.get("article.comment-card")
.should("not.contain", "show more")
});
});

View File

@ -1,4 +1,4 @@
import { When } from "cypress-cucumber-preprocessor/steps";
import { When } from "@badeball/cypress-cucumber-preprocessor";
When("I type in a comment with {int} characters", size => {
var c="";
@ -6,4 +6,4 @@ When("I type in a comment with {int} characters", size => {
c += "c"
}
cy.get(".editor .ProseMirror").type(c);
});
});

View File

@ -1,7 +1,7 @@
import { Then } from "cypress-cucumber-preprocessor/steps";
import { Then } from "@badeball/cypress-cucumber-preprocessor";
Then("it should create a mention in the CommentForm", () => {
cy.get(".ProseMirror a")
.should('have.class', 'mention')
.should('contain', '@peter-pan')
})
})

View File

@ -1,5 +1,5 @@
import { Then } from "cypress-cucumber-preprocessor/steps";
import { Then } from "@badeball/cypress-cucumber-preprocessor";
Then("my comment should be successfully created", () => {
cy.get(".iziToast-message").contains("Comment submitted!");
});
});

View File

@ -1,5 +1,5 @@
import { Then } from "cypress-cucumber-preprocessor/steps";
import { Then } from "@badeball/cypress-cucumber-preprocessor";
Then("the editor should be cleared", () => {
cy.get(".ProseMirror p").should("have.class", "is-empty");
});
});

View File

@ -1,8 +1,8 @@
import { When } from "cypress-cucumber-preprocessor/steps";
import { When } from "@badeball/cypress-cucumber-preprocessor";
When("I choose {string} as the title", async title => {
const lastPost = {}
lastPost.title = title.replace("\n", " ");
cy.task('pushValue', { name: 'lastPost', value: lastPost })
cy.get('input[name="title"]').type(lastPost.title);
});
});

View File

@ -1,8 +1,8 @@
import { Then } from "cypress-cucumber-preprocessor/steps";
import { Then } from "@badeball/cypress-cucumber-preprocessor";
Then("the post was saved successfully", async () => {
cy.task('getValue', 'lastPost').then(lastPost => {
cy.get(".base-card > .title").should("contain", lastPost.title);
cy.get(".content").should("contain", lastPost.content);
})
});
});

View File

@ -1,8 +1,8 @@
import { Then } from "cypress-cucumber-preprocessor/steps";
import { Then } from "@badeball/cypress-cucumber-preprocessor";
Then("I add all required fields", () => {
cy.get('input[name="title"]')
.type('new post')
.get(".editor .ProseMirror")
.type('new post content')
})
})

View File

@ -1,4 +1,4 @@
import { Then } from "cypress-cucumber-preprocessor/steps";
import { Then } from "@badeball/cypress-cucumber-preprocessor";
Then("I should be able to {string} a teaser image", condition => {
// cy.reload()
@ -27,4 +27,4 @@ Then("I should be able to {string} a teaser image", condition => {
break;
}
})
})

View File

@ -1,7 +1,7 @@
import { When } from "cypress-cucumber-preprocessor/steps";
import { When } from "@badeball/cypress-cucumber-preprocessor";
When('my post has a teaser image', () => {
cy.get('.contribution-form .image')
.should('exist')
.and('have.attr', 'src')
})
})

View File

@ -1,4 +1,4 @@
import { Then } from "cypress-cucumber-preprocessor/steps";
import { Then } from "@badeball/cypress-cucumber-preprocessor";
Then("the first image should not be displayed anymore", () => {
cy.get(".hero-image")
@ -6,4 +6,4 @@ Then("the first image should not be displayed anymore", () => {
.get('.hero-image > .image')
.should('have.length', 1)
.and('have.attr', 'src')
})
})

View File

@ -1,4 +1,4 @@
import { Then } from "cypress-cucumber-preprocessor/steps";
import { Then } from "@badeball/cypress-cucumber-preprocessor";
Then("the post was saved successfully with the {string} teaser image", condition => {
cy.get(".base-card > .title")
@ -8,4 +8,4 @@ Then("the post was saved successfully with the {string} teaser image", condition
.get('.post-page img')
.should("have.attr", "src")
.and("contains", condition === 'updated' ? 'humanconnection' : 'onourjourney')
})
})

View File

@ -1,4 +1,4 @@
import { Then } from "cypress-cucumber-preprocessor/steps";
import { Then } from "@badeball/cypress-cucumber-preprocessor";
Then('the {string} post was saved successfully without a teaser image', condition => {
cy.get(".base-card > .title")
@ -9,4 +9,4 @@ Then('the {string} post was saved successfully without a teaser image', conditio
.should('exist')
.get('.hero-image > .image')
.should('not.exist')
})
})

View File

@ -1,8 +1,8 @@
import { Then } from "cypress-cucumber-preprocessor/steps";
import { Then } from "@badeball/cypress-cucumber-preprocessor";
Then("the post shows up on the newsfeed at position {int}", index => {
const selector = `.post-teaser:nth-child(${index}) > .base-card`;
cy.get(selector).should("contain", 'previously created post');
cy.get(selector).should("contain", 'with some content');
});
});

View File

@ -1,7 +1,7 @@
import { When } from "cypress-cucumber-preprocessor/steps";
import { When } from "@badeball/cypress-cucumber-preprocessor";
When("I select a post entry", () => {
cy.get(".searchable-input .search-post")
.first()
.trigger("click");
});
});

View File

@ -1,7 +1,7 @@
import { Then } from "cypress-cucumber-preprocessor/steps";
import { Then } from "@badeball/cypress-cucumber-preprocessor";
Then("I select a user entry", () => {
cy.get(".searchable-input .user-teaser")
.first()
.trigger("click");
})
})

View File

@ -1,7 +1,7 @@
import { Then } from "cypress-cucumber-preprocessor/steps";
import { Then } from "@badeball/cypress-cucumber-preprocessor";
Then("I should have one item in the select dropdown", () => {
cy.get(".searchable-input .ds-select-dropdown").should($li => {
expect($li).to.have.length(1);
});
});
});

View File

@ -1,6 +1,6 @@
import { Then } from "cypress-cucumber-preprocessor/steps";
import { Then } from "@badeball/cypress-cucumber-preprocessor";
Then("I should not see posts without the searched-for term in the select dropdown", () => {
cy.get(".ds-select-dropdown")
.should("not.contain","No searched for content");
});
});

View File

@ -1,6 +1,6 @@
import { Then } from "cypress-cucumber-preprocessor/steps";
import { Then } from "@badeball/cypress-cucumber-preprocessor";
Then("I should see posts with the searched-for term in the select dropdown", () => {
cy.get(".ds-select-dropdown")
.should("contain","101 Essays that will change the way you think");
});
});

View File

@ -1,8 +1,8 @@
import { Then } from "cypress-cucumber-preprocessor/steps";
import { Then } from "@badeball/cypress-cucumber-preprocessor";
Then("I should see the following posts on the search results page:", table => {
table.hashes().forEach(({ title }) => {
cy.get(".post-teaser")
.should("contain",title)
});
});
});

View File

@ -1,8 +1,8 @@
import { Then } from "cypress-cucumber-preprocessor/steps";
import { Then } from "@badeball/cypress-cucumber-preprocessor";
Then("I should see the following users in the select dropdown:", table => {
cy.get(".search-heading").should("contain", "Users");
table.hashes().forEach(({ slug }) => {
cy.get(".ds-select-dropdown").should("contain", slug);
});
});
});

View File

@ -1,8 +1,8 @@
import { When } from "cypress-cucumber-preprocessor/steps";
import { When } from "@badeball/cypress-cucumber-preprocessor";
When("I type {string} and press Enter", value => {
cy.get(".searchable-input .ds-select input")
.focus()
.type(value)
.type("{enter}", { force: true });
});
});

View File

@ -1,8 +1,8 @@
import { When } from "cypress-cucumber-preprocessor/steps";
import { When } from "@badeball/cypress-cucumber-preprocessor";
When("I type {string} and press escape", value => {
cy.get(".searchable-input .ds-select input")
.focus()
.type(value)
.type("{esc}");
});
});

View File

@ -1,6 +1,6 @@
import { Then } from "cypress-cucumber-preprocessor/steps";
import { Then } from "@badeball/cypress-cucumber-preprocessor";
Then("the search field should clear", () => {
cy.get(".searchable-input .ds-select input")
.should("have.text", "");
});
});

View File

@ -1,6 +1,6 @@
import { Then } from "cypress-cucumber-preprocessor/steps";
import { Then } from "@badeball/cypress-cucumber-preprocessor";
Then("the search parameter equals {string}", search => {
cy.location("search")
.should("eq", search);
});
});

View File

@ -1,7 +1,7 @@
import { Then } from "cypress-cucumber-preprocessor/steps";
import { Then } from "@badeball/cypress-cucumber-preprocessor";
Then("I am logged in with username {string}", name => {
cy.get(".avatar-menu").click();
cy.get(".avatar-menu-popover").contains(name);
cy.get(".avatar-menu").click(); // Close menu again
});
});

View File

@ -1,11 +1,11 @@
import { When } from "cypress-cucumber-preprocessor/steps";
import { When } from "@badeball/cypress-cucumber-preprocessor";
When("I block the user {string}", name => {
cy.neode()
.first("User", { name })
.firstOf("User", { name })
.then(blockedUser => {
cy.neode()
.first("User", {id: "id-of-peter-pan"})
.firstOf("User", {id: "id-of-peter-pan"})
.relateTo(blockedUser, "blocked");
});
});
});

View File

@ -1,6 +1,6 @@
import { Then } from "cypress-cucumber-preprocessor/steps";
import { Then } from "@badeball/cypress-cucumber-preprocessor";
Then('I should not see {string} button', button => {
cy.get('.base-card .action-buttons')
.should('have.length', 1)
})
})

View File

@ -1,6 +1,6 @@
import { Then } from "cypress-cucumber-preprocessor/steps";
import { Then } from "@badeball/cypress-cucumber-preprocessor";
Then("I should see no users in my blocked users list", () => {
cy.get('.ds-placeholder')
.should('contain', "So far, you have not blocked anybody.")
})
})

View File

@ -1,6 +1,6 @@
import { Then } from "cypress-cucumber-preprocessor/steps";
import { Then } from "@badeball/cypress-cucumber-preprocessor";
Then('I should see the {string} button', button => {
cy.get('.base-card .action-buttons .base-button')
.should('contain', button)
})
})

View File

@ -1,7 +1,7 @@
import { Then } from "cypress-cucumber-preprocessor/steps";
import { Then } from "@badeball/cypress-cucumber-preprocessor";
Then("I {string} see {string} from the content menu in the user info box", (condition, link) => {
cy.get(".user-content-menu .base-button").click()
cy.get(".popover .ds-menu-item-link")
.should(condition === 'should' ? 'contain' : 'not.contain', link)
})
})

View File

@ -1,15 +1,15 @@
import { When } from "cypress-cucumber-preprocessor/steps";
import { When } from "@badeball/cypress-cucumber-preprocessor";
When("a user has blocked me", () => {
cy.neode()
.first("User", {
.firstOf("User", {
name: "Peter Pan"
})
.then(blockedUser => {
cy.neode()
.first("User", {
.firstOf("User", {
name: 'Harassing User'
})
.relateTo(blockedUser, "blocked");
});
});
});

View File

@ -1,5 +1,5 @@
import { Then } from "cypress-cucumber-preprocessor/steps";
import { Then } from "@badeball/cypress-cucumber-preprocessor";
Then("they should not see the comment form", () => {
cy.get(".base-card").children().should('not.have.class', 'comment-form')
})
})

View File

@ -1,5 +1,5 @@
import { Then } from "cypress-cucumber-preprocessor/steps";
import { Then } from "@badeball/cypress-cucumber-preprocessor";
Then("they should see a text explaining why commenting is not possible", () => {
cy.get('.ds-placeholder').should('contain', "Commenting is not possible at this time on this post.")
})
})

View File

@ -1,13 +1,13 @@
import { When } from "cypress-cucumber-preprocessor/steps";
import { When } from "@badeball/cypress-cucumber-preprocessor";
When("I mute the user {string}", name => {
cy.neode()
.first("User", { name })
.firstOf("User", { name })
.then(mutedUser => {
cy.neode()
.first("User", {
.firstOf("User", {
name: "Peter Pan"
})
.relateTo(mutedUser, "muted");
});
});
});

Some files were not shown because too many files have changed in this diff Show More