mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
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:
parent
16ada68a3a
commit
dfe9205bf6
@ -44,7 +44,7 @@ module.exports = defineConfig({
|
|||||||
chromeWebSecurity: false,
|
chromeWebSecurity: false,
|
||||||
baseUrl: 'http://localhost:3000',
|
baseUrl: 'http://localhost:3000',
|
||||||
specPattern: '**/*.feature',
|
specPattern: '**/*.feature',
|
||||||
supportFile: 'cypress/support/e2e.js',
|
supportFile: false,
|
||||||
retries: 0,
|
retries: 0,
|
||||||
video: false,
|
video: false,
|
||||||
viewportHeight: 720,
|
viewportHeight: 720,
|
||||||
|
|||||||
@ -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) => { ... })
|
|
||||||
|
|||||||
@ -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))
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
@ -1,5 +1,7 @@
|
|||||||
import { Given } from "@badeball/cypress-cucumber-preprocessor";
|
import { Given } from '@badeball/cypress-cucumber-preprocessor'
|
||||||
import 'cypress-network-idle';
|
import './../../commands'
|
||||||
|
import './../../factories'
|
||||||
|
import 'cypress-network-idle'
|
||||||
|
|
||||||
Given('somebody reported the following posts:', table => {
|
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}$/
|
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}$/
|
||||||
|
|||||||
@ -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'
|
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()
|
cy.neode()
|
||||||
.firstOf("User", { slug })
|
.firstOf('User', { slug })
|
||||||
.then(user => {
|
.then(user => {
|
||||||
return new Cypress.Promise((resolve, reject) => {
|
return new Cypress.Promise((resolve, reject) => {
|
||||||
if(!user) {
|
if(!user) {
|
||||||
|
|||||||
@ -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){
|
switch(table){
|
||||||
case "posts":
|
case 'posts':
|
||||||
data.hashes().forEach( entry => {
|
data.hashes().forEach( entry => {
|
||||||
cy.factory().build("post", {
|
cy.factory().build('post', {
|
||||||
...entry,
|
...entry,
|
||||||
deleted: Boolean(entry.deleted),
|
deleted: Boolean(entry.deleted),
|
||||||
disabled: Boolean(entry.disabled),
|
disabled: Boolean(entry.disabled),
|
||||||
@ -15,25 +16,25 @@ Given("the following {string} are in the database:", (table,data) => {
|
|||||||
});
|
});
|
||||||
})
|
})
|
||||||
break
|
break
|
||||||
case "comments":
|
case 'comments':
|
||||||
data.hashes().forEach( entry => {
|
data.hashes().forEach( entry => {
|
||||||
cy.factory()
|
cy.factory()
|
||||||
.build("comment", entry, entry);
|
.build('comment', entry, entry);
|
||||||
})
|
})
|
||||||
break
|
break
|
||||||
case "users":
|
case 'users':
|
||||||
data.hashes().forEach( entry => {
|
data.hashes().forEach( entry => {
|
||||||
cy.factory().build("user", entry, entry);
|
cy.factory().build('user', entry, entry);
|
||||||
});
|
});
|
||||||
break
|
break
|
||||||
case "tags":
|
case 'tags':
|
||||||
data.hashes().forEach( entry => {
|
data.hashes().forEach( entry => {
|
||||||
cy.factory().build("tag", entry, entry)
|
cy.factory().build('tag', entry, entry)
|
||||||
});
|
});
|
||||||
break
|
break
|
||||||
case "donations":
|
case 'donations':
|
||||||
data.hashes().forEach( entry => {
|
data.hashes().forEach( entry => {
|
||||||
cy.factory().build("donations", entry, entry)
|
cy.factory().build('donations', entry, entry)
|
||||||
});
|
});
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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) => {
|
Given('{string} wrote a post {string}', (author, title) => {
|
||||||
cy.factory()
|
cy.factory()
|
||||||
.build("post", {
|
.build('post', {
|
||||||
title,
|
title,
|
||||||
}, {
|
}, {
|
||||||
authorId: author,
|
authorId: author,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user