Commit 94fe3d95 authored by Alexandros Georgantas's avatar Alexandros Georgantas

test(app): more tests added for dashboard

parent 02cbaee2
[
{
"title": "Author Book",
"teamMember": ["author"]
},
{
"title": "Production Editor Book",
"teamMember": ["productionEditor"]
},
{
"title": "Copy Editor Book",
"teamMember": ["copyEditor"]
}
]
describe('Dashboard', () => {
beforeEach(() => {
before(() => {
cy.exec('node ./scripts/truncateDB.js')
cy.exec('node ./scripts/createBooksWithUsersAndTeams.js')
})
it('shows dashboard', () => {
cy.login('admin')
cy.visit('/books')
cy.contains('Books')
})
it('admin can add books', () => {
cy.login('admin')
cy.visit('/books')
cy.wait(1000)
cy.get('[data-cy="add-book-btn"]').should('have.length', 1)
cy.get('[data-cy="add-book-btn"]').should('not.be.disabled')
})
it('global production editor can add books', () => {
cy.login('globalProductionEditor')
cy.visit('/books')
cy.wait(1000)
cy.get('[data-cy="add-book-btn"]').should('have.length', 1)
cy.get('[data-cy="add-book-btn"]').should('not.be.disabled')
})
it('production editor can not add books', () => {
cy.login('productionEditor')
cy.visit('/books')
cy.wait(1000)
cy.get('[data-cy="add-book-btn"]').should('have.length', 0)
})
it('copy editor can not add books', () => {
cy.login('copyEditor')
cy.visit('/books')
cy.wait(1000)
cy.get('[data-cy="add-book-btn"]').should('have.length', 0)
})
it('author can not add books', () => {
cy.login('author')
cy.visit('/books')
cy.wait(1000)
cy.get('[data-cy="add-book-btn"]').should('have.length', 0)
})
it('admin can see all three books', () => {
cy.login('admin')
cy.visit('/books')
cy.wait(1000)
cy.get('[data-cy="book"]').should('have.length', 3)
})
it('global production editor can not see any book', () => {
cy.login('globalProductionEditor')
cy.visit('/books')
cy.wait(1000)
cy.get('[data-cy="book"]').should('have.length', 0)
})
it('production editor can see only assigned books (1)', () => {
cy.login('productionEditor')
cy.visit('/books')
cy.wait(1000)
cy.get('[data-cy="book"]').should('have.length', 1)
cy.get('[data-cy="book"]').contains('Production Editor Book')
})
it('copy editor can see only assigned books (1)', () => {
cy.login('copyEditor')
cy.visit('/books')
cy.wait(1000)
cy.get('[data-cy="book"]').should('have.length', 1)
cy.get('[data-cy="book"]').contains('Copy Editor Book')
})
it('author can see only assigned books (1)', () => {
cy.login('author')
cy.visit('/books')
cy.wait(1000)
cy.get('[data-cy="book"]').should('have.length', 1)
cy.get('[data-cy="book"]').contains('Author Book')
})
})
......@@ -14,6 +14,18 @@ const credentials = {
username: 'author',
password: 'password',
},
productionEditor: {
username: 'productionEditor',
password: 'password',
},
globalProductionEditor: {
username: 'globalProductionEditor',
password: 'password',
},
copyEditor: {
username: 'copyEditor',
password: 'password',
},
}
module.exports = credentials
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