refactor(other): cleanup cypress configuration (#8345)

* cypress:remove redundant comment from command config

* cypress: move command and factory imports from global to local

* cypress: linting

* cypress: set support file to false in config
This commit is contained in:
mahula 2025-04-08 22:20:41 +02:00 committed by GitHub
parent 16ada68a3a
commit dfe9205bf6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 24 additions and 66 deletions

View File

@ -44,7 +44,7 @@ module.exports = defineConfig({
chromeWebSecurity: false,
baseUrl: 'http://localhost:3000',
specPattern: '**/*.feature',
supportFile: 'cypress/support/e2e.js',
supportFile: false,
retries: 0,
video: false,
viewportHeight: 720,

View File

@ -53,16 +53,3 @@ Cypress.Commands.add(
})
})
//
//
// -- This is a child command --
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This is will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })

View File

@ -1,33 +0,0 @@
// ***********************************************************
// This example support/index.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************
// Import commands.js using ES2015 syntax:
import './commands'
import './factories'
// intermittent failing tests
// import 'cypress-plugin-retries'
// Alternatively you can use CommonJS syntax:
// require('./commands')
import { WebSocket } from 'mock-socket'
before(() => {
cy.visit('/', {
onBeforeLoad(win) {
cy.stub(win, "WebSocket", url => new WebSocket(url))
}
})
})

View File

@ -1,5 +1,7 @@
import { Given } from "@badeball/cypress-cucumber-preprocessor";
import 'cypress-network-idle';
import { Given } from '@badeball/cypress-cucumber-preprocessor'
import './../../commands'
import './../../factories'
import 'cypress-network-idle'
Given('somebody reported the following posts:', table => {
const reportIdRegex = /^[0-9a-zA-Z]{8}-[0-9a-zA-Z]{4}-[0-9a-zA-Z]{4}-[0-9a-zA-Z]{4}-[0-9a-zA-Z]{12}$/

View File

@ -1,9 +1,9 @@
import { Given } from "@badeball/cypress-cucumber-preprocessor";
import { Given } from '@badeball/cypress-cucumber-preprocessor'
import encode from '../../../../backend/build/src/jwt/encode'
Given("I am logged in as {string}", slug => {
Given('I am logged in as {string}', slug => {
cy.neode()
.firstOf("User", { slug })
.firstOf('User', { slug })
.then(user => {
return new Cypress.Promise((resolve, reject) => {
if(!user) {

View File

@ -1,10 +1,11 @@
import { Given } from "@badeball/cypress-cucumber-preprocessor";
import { Given } from '@badeball/cypress-cucumber-preprocessor'
import './../../factories'
Given("the following {string} are in the database:", (table,data) => {
Given('the following {string} are in the database:', (table,data) => {
switch(table){
case "posts":
case 'posts':
data.hashes().forEach( entry => {
cy.factory().build("post", {
cy.factory().build('post', {
...entry,
deleted: Boolean(entry.deleted),
disabled: Boolean(entry.disabled),
@ -15,25 +16,25 @@ Given("the following {string} are in the database:", (table,data) => {
});
})
break
case "comments":
case 'comments':
data.hashes().forEach( entry => {
cy.factory()
.build("comment", entry, entry);
.build('comment', entry, entry);
})
break
case "users":
case 'users':
data.hashes().forEach( entry => {
cy.factory().build("user", entry, entry);
cy.factory().build('user', entry, entry);
});
break
case "tags":
case 'tags':
data.hashes().forEach( entry => {
cy.factory().build("tag", entry, entry)
cy.factory().build('tag', entry, entry)
});
break
case "donations":
case 'donations':
data.hashes().forEach( entry => {
cy.factory().build("donations", entry, entry)
cy.factory().build('donations', entry, entry)
});
break
}

View File

@ -1,8 +1,9 @@
import { Given } from "@badeball/cypress-cucumber-preprocessor";
import { Given } from '@badeball/cypress-cucumber-preprocessor'
import './../../factories'
Given('{string} wrote a post {string}', (author, title) => {
cy.factory()
.build("post", {
.build('post', {
title,
}, {
authorId: author,