Commit e675a8c9 authored by Jure's avatar Jure Committed by Alexandros Georgantas

test: fix seeding for dashboard test

parent e9ea694e
......@@ -27,6 +27,7 @@ module.exports = {
cfg => `http://localhost:${cfg['pubsweet-server'].port}`,
),
logger,
pool: { min: 0, max: 10, idleTimeoutMillis: 1000 },
},
'pubsweet-component-ink-backend': {
inkEndpoint: 'http://dummyURL.com/',
......
describe('Dashboard', () => {
beforeEach(() => {
cy.task('seed:createBooksWithUsersAndTeams')
cy.exec('yarn seed:createBooksWithUsersAndTeams')
})
it('shows dashboard', () => {
cy.login('author')
......
......@@ -10,14 +10,10 @@
// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)
const createBooksWithUsersAndTeams = require('../../scripts/createBooksWithUsersAndTeams')
// const createBooksWithUsersAndTeams = require('../../scripts/createBooksWithUsersAndTeams')
module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
on('task', {
'seed:createBooksWithUsersAndTeams': async () => {
return createBooksWithUsersAndTeams()
},
})
on('task', {})
}
......@@ -182,6 +182,7 @@
"resetdb": "pubsweet setupdb --clobber && npm run seed",
"start:services": "docker-compose up postgres",
"seed": "node ./scripts/seedGlobalTeams.js && node ./scripts/seedBookCollection.js",
"seed:createBooksWithUsersAndTeams": "node ./scripts/createBooksWithUsersAndTeams.js",
"test": "NODE_ENV=test jest",
"test:watch": "NODE_ENV=test jest --watch",
"test:cover": "NODE_ENV=test jest --coverage",
......
......@@ -20,6 +20,7 @@ const createBooksWithUsersAndTeams = async () => {
try {
const collections = await BookCollection.all()
const globalTeams = await Team.query().where('global', true)
// eslint-disable-next-line no-unused-vars
let globalTeam
let collection
if (collections.length === 0) {
......@@ -30,6 +31,7 @@ const createBooksWithUsersAndTeams = async () => {
title: 'Books',
}).save()
} else {
// eslint-disable-next-line prefer-destructuring
collection = collections[0]
}
......@@ -99,6 +101,7 @@ const createBooksWithUsersAndTeams = async () => {
teamId: tempGlobal.id,
}).save()
} else {
// eslint-disable-next-line prefer-destructuring
globalTeam = globalTeams[0]
}
}
......@@ -243,4 +246,5 @@ const createBooksWithUsersAndTeams = async () => {
}
}
module.exports = createBooksWithUsersAndTeams
// createBooksWithUsersAndTeams()/
createBooksWithUsersAndTeams()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment