diff --git a/backend/src/config/index.js b/backend/src/config/index.js index 2f8d0ed22..058dc00ab 100644 --- a/backend/src/config/index.js +++ b/backend/src/config/index.js @@ -4,6 +4,9 @@ if (require.resolve) { dotenv.config({ path: require.resolve('../../.env') }) } +// eslint-disable-next-line no-undef +const env = typeof Cypress !== 'undefined' ? Cypress.env() : process.env + const { MAPBOX_TOKEN, JWT_SECRET, @@ -20,7 +23,7 @@ const { NEO4J_PASSWORD = 'neo4j', CLIENT_URI = 'http://localhost:3000', GRAPHQL_URI = 'http://localhost:4000', -} = process.env +} = env export const requiredConfigs = { MAPBOX_TOKEN, diff --git a/backend/src/factories/users.js b/backend/src/factories/users.js index 9ed701441..91b9e9a8b 100644 --- a/backend/src/factories/users.js +++ b/backend/src/factories/users.js @@ -34,8 +34,8 @@ Factory.define('userWithoutEmailAddress') }) Factory.define('user') - .option('email', faker.internet.exampleEmail) .extend('userWithoutEmailAddress') + .option('email', faker.internet.exampleEmail) .after(async (buildObject, options) => { const [user, email] = await Promise.all([ buildObject, @@ -47,7 +47,7 @@ Factory.define('user') export default function create() { return { - factory: async ({ args, options }) => { + factory: ({ args, options }) => { return Factory.build('user', args, options) }, } diff --git a/cypress/integration/common/report.js b/cypress/integration/common/report.js index 710928ff2..6b808c75f 100644 --- a/cypress/integration/common/report.js +++ b/cypress/integration/common/report.js @@ -31,10 +31,11 @@ Given("I see David Irving's post on the post page", page => { Given('I am logged in with a {string} role', role => { cy.factory().create('User', { - email: `${role}@example.org`, - password: '1234', termsAndConditionsAgreedVersion: VERSION, role + }, { + email: `${role}@example.org`, + password: '1234', }) cy.login({ email: `${role}@example.org`, @@ -127,7 +128,7 @@ Given('somebody reported the following posts:', table => { password: '1234' } cy.factory() - .create('User', submitter) + .create('User', {}, submitter) .authenticateAs(submitter) .mutate(gql`mutation($resourceId: ID!, $reasonCategory: ReasonCategory!, $reasonDescription: String!) { fileReport(resourceId: $resourceId, reasonCategory: $reasonCategory, reasonDescription: $reasonDescription) { diff --git a/cypress/integration/common/steps.js b/cypress/integration/common/steps.js index 9a5c02d08..3867b3513 100644 --- a/cypress/integration/common/steps.js +++ b/cypress/integration/common/steps.js @@ -192,11 +192,6 @@ When("I press {string}", label => { cy.contains(label).click(); }); -Given("we have this user in our database:", table => { - const [firstRow] = table.hashes() - cy.factory().create('User', firstRow) -}) - Given("we have the following posts in our database:", table => { cy.factory().create('Category', { id: `cat-456`, diff --git a/cypress/support/factories.js b/cypress/support/factories.js index 1b76a1a01..d5d4ee768 100644 --- a/cypress/support/factories.js +++ b/cypress/support/factories.js @@ -40,17 +40,9 @@ Cypress.Commands.add('factory', () => { Cypress.Commands.add( 'create', { prevSubject: true }, - async (factory, node, properties) => { - await factory.create(node, properties) + async (factory, node, properties, options) => { + await factory.create(node, properties, options) return factory } ) -Cypress.Commands.add( - 'relate', - { prevSubject: true }, - async (factory, node, relationship, properties) => { - await factory.relate(node, relationship, properties) - return factory - } -)