Skip to content

Commit

Permalink
Hide information from the overview page unless users belong to the ca…
Browse files Browse the repository at this point in the history
…seload
  • Loading branch information
danielburnley committed May 22, 2023
1 parent 9cc8684 commit cb290c0
Show file tree
Hide file tree
Showing 10 changed files with 376 additions and 219 deletions.
12 changes: 8 additions & 4 deletions integration_tests/e2e/login.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,36 +25,37 @@ context('SignIn', () => {
})

it('User name visible in header', () => {
cy.setupUserAuth()
cy.signIn()
cy.visit('/prisoner/G6123VU')
const indexPage = Page.verifyOnPage(IndexPage)
indexPage.headerUserName().should('contain.text', 'J. Smith')
})

it('User with prison role has access', () => {
cy.task('stubSignIn', ['ROLE_PRISON'])
cy.setupUserAuth({ roles: ['ROLE_PRISON'] })

cy.signIn()
cy.visit('/prisoner/G6123VU')
Page.verifyOnPage(IndexPage)
})

it('User with Global Search role has access', () => {
cy.task('stubSignIn', ['ROLE_GLOBAL_SEARCH'])

cy.setupUserAuth({ roles: ['ROLE_GLOBAL_SEARCH'] })
cy.signIn()
cy.visit('/prisoner/G6123VU')
Page.verifyOnPage(IndexPage)
})

it('User with neither prison or global search role denied access', () => {
cy.task('stubSignIn', ['ROLE_SOMETHING_ELSE'])
cy.setupUserAuth({ roles: ['ROLE_SOMETHING_ELSE'] })

cy.signIn({ failOnStatusCode: false, redirectPath: '/prisoner/G6123VU' })
Page.verifyOnPage(AuthErrorPage)
})

it('User can log out', () => {
cy.setupUserAuth({ roles: ['ROLE_PRISON'] })
cy.signIn()
cy.visit('/prisoner/G6123VU')
const indexPage = Page.verifyOnPage(IndexPage)
Expand All @@ -63,6 +64,7 @@ context('SignIn', () => {
})

it('User can manage their details', () => {
cy.setupUserAuth({ roles: ['ROLE_PRISON'] })
cy.signIn()
cy.visit('/prisoner/G6123VU')
const indexPage = Page.verifyOnPage(IndexPage)
Expand All @@ -73,6 +75,7 @@ context('SignIn', () => {
})

it('Token verification failure takes user to sign in page', () => {
cy.setupUserAuth({ roles: ['ROLE_PRISON'] })
cy.signIn()
cy.visit('/prisoner/G6123VU')
Page.verifyOnPage(IndexPage)
Expand All @@ -83,6 +86,7 @@ context('SignIn', () => {
})

it('Token verification failure clears user session', () => {
cy.setupUserAuth({ roles: ['ROLE_PRISON'] })
cy.signIn()
cy.visit('/prisoner/G6123VU')
const indexPage = Page.verifyOnPage(IndexPage)
Expand Down
Loading

0 comments on commit cb290c0

Please sign in to comment.