Merge branch 'api-tests-for-reference' of github.com:nowcommunity/nowdatabase into api-tests-for-reference

This commit is contained in:
juhanikat
2024-10-28 14:36:01 +02:00
3 changed files with 48 additions and 6 deletions
+38 -4
View File
@@ -5,7 +5,7 @@ before('Reset database', () => {
describe('Broadly test what different user rights see', () => { describe('Broadly test what different user rights see', () => {
describe('Admin visibility', () => { describe('Admin visibility', () => {
beforeEach('Login as admin', () => { beforeEach('Login as admin', () => {
cy.session('admin-session', () => {}) cy.session('admin-session', () => { })
cy.login('testSu') cy.login('testSu')
}) })
it('Sees new button in tableviews', () => { it('Sees new button in tableviews', () => {
@@ -14,28 +14,34 @@ describe('Broadly test what different user rights see', () => {
cy.contains('Time Unit') cy.contains('Time Unit')
cy.contains('Creating new locality') cy.contains('Creating new locality')
}) })
it('Region works', () => { it('Regions view shows correctly', () => {
cy.get('div[id="/admin-menu-button"]').click() cy.get('div[id="/admin-menu-button"]').click()
cy.contains('Regions').click() cy.contains('Regions').click()
cy.contains('region 4452477e') cy.contains('region 4452477e')
cy.get('[data-cy="detailview-button-1"]').first().click() cy.get('[data-cy="detailview-button-1"]').first().click()
cy.contains('Regional Coordinators') cy.contains('Regional Coordinators')
cy.contains('prs') cy.contains('prs')
cy.get('[id="edit-button"]').should('exist')
cy.get('[id="delete-button"]').should('exist')
}) })
it('Project works', () => { it('Projects view shows correctly', () => {
cy.get('div[id="/admin-menu-button"]').click() cy.get('div[id="/admin-menu-button"]').click()
cy.get('a[id="/project-menu-link"]').click() cy.get('a[id="/project-menu-link"]').click()
cy.contains('Workgroup on Insectivores') cy.contains('Workgroup on Insectivores')
cy.get('[data-cy="detailview-button-3"]').first().click() cy.get('[data-cy="detailview-button-3"]').first().click()
cy.contains('Coordinator') cy.contains('Coordinator')
cy.contains('NOW Database') cy.contains('NOW Database')
cy.get('[id="edit-button"]').should('exist')
cy.get('[id="delete-button"]').should('exist')
}) })
it('Time Bound works', () => { it('Time Bound view shows correctly', () => {
cy.contains('Time Bounds').click() cy.contains('Time Bounds').click()
cy.contains('C2N-y') cy.contains('C2N-y')
cy.get('[data-cy="detailview-button-11"]').first().click() cy.get('[data-cy="detailview-button-11"]').first().click()
cy.contains('Bound') cy.contains('Bound')
cy.contains('1.778') cy.contains('1.778')
cy.get('[id="edit-button"]').should('exist')
cy.get('[id="delete-button"]').should('exist')
}) })
it('Email page opens', () => { it('Email page opens', () => {
cy.get('div[id="/admin-menu-button"]').click() cy.get('div[id="/admin-menu-button"]').click()
@@ -63,5 +69,33 @@ describe('Broadly test what different user rights see', () => {
it('Does not see email page', () => { it('Does not see email page', () => {
cy.pageForbidden('/email') cy.pageForbidden('/email')
}) })
it('Does not see the New button in table view', () => {
cy.visit('/locality')
cy.contains('New').should('not.exist')
cy.visit('/species')
cy.contains('New').should('not.exist')
cy.visit('/reference')
cy.contains('New').should('not.exist')
cy.visit('/time-unit')
cy.contains('New').should('not.exist')
})
it('Does not see edit or delete buttons in detailview', () => {
cy.visit('locality/20920')
cy.contains('Lantian-Shuijiazui')
cy.get('[id="edit-button"]').should('not.exist')
cy.get('[id="delete-button"]').should('not.exist')
cy.visit('species/21052')
cy.contains('Simplomys simplicidens')
cy.get('[id="edit-button"]').should('not.exist')
cy.get('[id="delete-button"]').should('not.exist')
cy.visit('reference/10039')
cy.contains('A new geomagnetic polarity time scale')
cy.get('[id="edit-button"]').should('not.exist')
cy.get('[id="delete-button"]').should('not.exist')
cy.visit('time-unit/bahean')
cy.contains('Bahean')
cy.get('[id="edit-button"]').should('not.exist')
cy.get('[id="delete-button"]').should('not.exist')
})
}) })
}) })
+3 -1
View File
@@ -48,7 +48,9 @@ Any user can get a list of reference types.
Any user can view the details of a reference. Any user can view the details of a reference.
References cannot be created, updated or deleted by anyone at the moment. Creating or updating a reference requires the **Admin** or **EditUnrestricted** roles.
Deleting a reference requires the **Admin** role.
## Time Unit ## Time Unit
@@ -177,7 +177,13 @@ export const DetailView = <T extends object>({
</Button> </Button>
)} )}
{editRights.delete && !isNew && ( {editRights.delete && !isNew && (
<Button onClick={onDelete} variant="contained" sx={{ width: '8em', color: 'white' }} color="error"> <Button
id="delete-button"
onClick={onDelete}
variant="contained"
sx={{ width: '8em', color: 'white' }}
color="error"
>
Delete Delete
</Button> </Button>
)} )}