Add simple tests to check frontend email user rights #no-deploy

This commit is contained in:
arttu
2024-08-05 20:02:07 +03:00
parent 979c112791
commit 0fcbbbf27f
3 changed files with 9 additions and 2 deletions
-1
View File
@@ -33,6 +33,5 @@ describe('Open each page, table view and detail view, and check at least some co
cy.get('[data-cy="detailview-button-langhian"]').first().click()
cy.contains('Sequence')
cy.contains('gcss')
})
})
+8
View File
@@ -35,6 +35,11 @@ describe('Broadly test what different user rights see', () => {
cy.contains('Bound')
cy.contains('1.778')
})
it('Email page opens', () => {
cy.get('div[id="/admin-menu-button"]').click()
cy.contains('Email').click()
cy.contains('Send email')
})
})
describe('Test unlogged visibility', () => {
beforeEach('Ensure logout', () => {
@@ -53,5 +58,8 @@ describe('Broadly test what different user rights see', () => {
cy.pageForbidden('/time-bound')
cy.pageForbidden('/project')
})
it('Does not see email page', () => {
cy.pageForbidden('/email')
})
})
})
+1 -1
View File
@@ -10,7 +10,7 @@ export const EmailPage = () => {
const [message, setMessage] = useState('')
const [recipients, setRecipients] = useState<string>('')
const [sendEmailMutation, { isSuccess, isLoading, isError }] = useEmailMutation()
if (user.role !== Role.Admin) return <Box>This page is visible only to admins</Box>
if (user.role !== Role.Admin) return <Box>Your user is not authorized to view this page.</Box>
const parseRecipients = () => {
return recipients.replace(' ', '').replace('\n', ',').replace(',', '\n').split(';')