mirror of
https://github.com/nowcommunity/nowdatabase.git
synced 2026-10-12 19:13:52 +03:00
Add tests and commands
This commit is contained in:
@@ -6,11 +6,6 @@ module.exports = defineConfig({
|
||||
// implement node event listeners here
|
||||
},
|
||||
baseUrl: 'http://localhost:5173/',
|
||||
defaultCommandTimeout: 52000,
|
||||
execTimeout: 90000,
|
||||
pageLoadTimeout: 140000,
|
||||
requestTimeout: 80000,
|
||||
responseTimeout: 80000,
|
||||
testIsolation: false,
|
||||
},
|
||||
viewportHeight: 900,
|
||||
|
||||
@@ -2,13 +2,7 @@
|
||||
describe('Open each page, table view and detail view, and check at least some correct text appears', () => {
|
||||
before('Login as admin, directs to front page', () => {
|
||||
cy.session("logged-as-admin", () => {})
|
||||
cy.visit('/')
|
||||
cy.contains('construction')
|
||||
cy.contains('Login').click()
|
||||
cy.get('[data-cy="username-basic"]').type("testSu")
|
||||
cy.get('[data-cy="password-basic"]').type("test")
|
||||
cy.get('[data-cy="login-button"]').click()
|
||||
cy.contains('construction')
|
||||
cy.login('testSu')
|
||||
})
|
||||
beforeEach(() => {
|
||||
cy.visit('/')
|
||||
@@ -45,27 +39,4 @@ describe('Open each page, table view and detail view, and check at least some co
|
||||
cy.contains('gcss')
|
||||
|
||||
})
|
||||
it('Region works', () => {
|
||||
cy.contains('Admin').click()
|
||||
cy.contains('Region').click()
|
||||
cy.contains('region 4452477e')
|
||||
cy.get('[data-cy="detailview-button-1"]').first().click()
|
||||
cy.contains('Regional Coordinators')
|
||||
cy.contains('prs')
|
||||
})
|
||||
it('Project works', () => {
|
||||
cy.get('div[id="/admin-menu-button"]').click()
|
||||
cy.get('a[id="/project-menu-link"]').click()
|
||||
cy.contains('Workgroup on Insectivores')
|
||||
cy.get('[data-cy="detailview-button-3"]').first().click()
|
||||
cy.contains('Coordinator')
|
||||
cy.contains('NOW Database')
|
||||
})
|
||||
it('Time Bound works', () => {
|
||||
cy.contains('Time Bound').click()
|
||||
cy.contains('C2N-y')
|
||||
cy.get('[data-cy="detailview-button-11"]').first().click()
|
||||
cy.contains('Bound')
|
||||
cy.contains('1.778')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -2,7 +2,57 @@
|
||||
describe('Broadly test what different user rights see', () => {
|
||||
describe('Admin visibility', () => {
|
||||
before('Login as admin', () => {
|
||||
cy.session('admin-session', () => {})
|
||||
cy.login('testSu')
|
||||
})
|
||||
it('Sees new and delete buttons in tableviews', () => {
|
||||
cy.visit('/locality')
|
||||
cy.contains('Delete')
|
||||
cy.contains('New').click()
|
||||
cy.contains('Time Unit')
|
||||
cy.contains('Creating new locality')
|
||||
})
|
||||
it('Region works', () => {
|
||||
cy.get('div[id="/admin-menu-button"]').click()
|
||||
cy.contains('Region').click()
|
||||
cy.contains('region 4452477e')
|
||||
cy.get('[data-cy="detailview-button-1"]').first().click()
|
||||
cy.contains('Regional Coordinators')
|
||||
cy.contains('prs')
|
||||
})
|
||||
it('Project works', () => {
|
||||
cy.get('div[id="/admin-menu-button"]').click()
|
||||
cy.get('a[id="/project-menu-link"]').click()
|
||||
cy.contains('Workgroup on Insectivores')
|
||||
cy.get('[data-cy="detailview-button-3"]').first().click()
|
||||
cy.contains('Coordinator')
|
||||
cy.contains('NOW Database')
|
||||
})
|
||||
it('Time Bound works', () => {
|
||||
cy.contains('Time Bound').click()
|
||||
cy.contains('C2N-y')
|
||||
cy.get('[data-cy="detailview-button-11"]').first().click()
|
||||
cy.contains('Bound')
|
||||
cy.contains('1.778')
|
||||
})
|
||||
})
|
||||
describe('Test unlogged visibility', () => {
|
||||
before('Ensure logout', () => {
|
||||
cy.clearAllLocalStorage()
|
||||
cy.visit('/')
|
||||
cy.contains('Guest user')
|
||||
})
|
||||
it('Does not see admin button in navbar', () => {
|
||||
cy.contains('Admin').should('not.exist')
|
||||
})
|
||||
it('Does not see time bounds in navbar', () => {
|
||||
cy.contains('Time Bound').should('not.exist')
|
||||
})
|
||||
it('Direct routes to protected views do not work', () => {
|
||||
cy.pageForbidden('person')
|
||||
cy.pageForbidden('region')
|
||||
cy.pageForbidden('time-bound')
|
||||
cy.pageForbidden('project')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
|
||||
|
||||
Cypress.Commands.add('login', (username) => {
|
||||
cy.clearLocalStorage()
|
||||
cy.visit('/login')
|
||||
cy.contains('Login').click()
|
||||
cy.get('[data-cy="username-basic"]').type(username)
|
||||
@@ -32,3 +33,8 @@ Cypress.Commands.add('login', (username) => {
|
||||
cy.get('[data-cy="login-button"]').click()
|
||||
cy.contains(`Logged in as ${username}`)
|
||||
})
|
||||
|
||||
Cypress.Commands.add('pageForbidden', (url) => {
|
||||
cy.visit(url)
|
||||
cy.contains('Your user is not authorized to view this page.')
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user