Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CDPS-209 - fix for two banners #169

Merged
merged 2 commits into from
Jun 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions integration_tests/e2e/profileBanner.cy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Page from '../pages/page'
import OverviewPage from '../pages/overviewPage'
import IndexPage from '../pages'

const visitOverviewPage = (): OverviewPage => {
cy.signIn({ redirectPath: '/prisoner/G6123VU' })
Expand Down Expand Up @@ -40,4 +41,70 @@ context('Profile banner', () => {
cy.getDataQa('hidden-outside-establishment-banner').should('exist')
})
})

context('Given the prisoner is released from prison', () => {
beforeEach(() => {
cy.task('reset')
cy.setupUserAuth({
roles: ['ROLE_GLOBAL_SEARCH'],
caseLoads: [{ caseloadFunction: '', caseLoadId: 'OUT', currentlyActive: true, description: '', type: '' }],
})
cy.setupOverviewPageStubs({
prisonerNumber: 'G6123VU',
bookingId: 1102484,
prisonerDataOverrides: { prisonId: 'OUT' },
})
})

context('Hide the incorrect banners', () => {
it('Hide the TRN banner', () => {
visitOverviewPage()
cy.getDataQa('TRN-establishment-banner').should('not.exist')
})
it('Hide the outside your establishment banner', () => {
visitOverviewPage()
cy.getDataQa('outside-establishment-banner').should('not.exist')
})
})

it('Display the prisoner is released banner', () => {
visitOverviewPage()
cy.getDataQa('OUT-establishment-banner').should('exist')
const indexPage = new IndexPage()
indexPage.prisonerOUTBanner().should('exist')
})
})

context('Given the prisoner is being transferred', () => {
beforeEach(() => {
cy.task('reset')
cy.setupUserAuth({
roles: ['ROLE_GLOBAL_SEARCH'],
caseLoads: [{ caseloadFunction: '', caseLoadId: 'TRN', currentlyActive: true, description: '', type: '' }],
})
cy.setupOverviewPageStubs({
prisonerNumber: 'G6123VU',
bookingId: 1102484,
prisonerDataOverrides: { prisonId: 'TRN' },
})
})

context('Hide the incorrect banners', () => {
it('Hide the OUT banner', () => {
visitOverviewPage()
cy.getDataQa('OUT-establishment-banner').should('not.exist')
})
it('Hide the outside your establishment banner', () => {
visitOverviewPage()
cy.getDataQa('outside-establishment-banner').should('not.exist')
})
})

it('Display the prisoner TRN banner', () => {
visitOverviewPage()
cy.getDataQa('TRN-establishment-banner').should('exist')
const indexPage = new IndexPage()
indexPage.prisonerTRNBanner().should('exist')
})
})
})
4 changes: 4 additions & 0 deletions integration_tests/pages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ export default class IndexPage extends Page {
}

headerUserName = (): PageElement => cy.get('[data-qa=header-user-name]')

prisonerOUTBanner = (): PageElement => cy.get('[data-qa="OUT-establishment-banner"]')

prisonerTRNBanner = (): PageElement => cy.get('[data-qa="TRN-establishment-banner"]')
}
54 changes: 27 additions & 27 deletions server/views/partials/profileBanner/profileBannerTop.njk
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
{% from "../../macros/conditionallyShow.njk" import conditionallyShow %}
<div class="govuk-grid-row">
<div class="govuk-grid-column-full">
{%- call conditionallyShow({condition: prisonerIsTRN(prisonId) == true, id: 'TRN-establishment-banner'}) -%}
<div class="govuk-grid-row govuk-!-padding-top-2 govuk-!-padding-bottom-2 hmpps-profile-banner-alert">
<div class="govuk-grid-column-full">
<p class="govuk-heading-m govuk-!-margin-bottom-2">
This prisoner is being transferred
</p>
<p class="govuk-body">Some information may be hidden</p>
{% if prisonerIsTRN(prisonId) %}
<div class="govuk-grid-row govuk-!-padding-top-2 govuk-!-padding-bottom-2 hmpps-profile-banner-alert" data-qa="TRN-establishment-banner">
<div class="govuk-grid-column-full">
<p class="govuk-heading-m govuk-!-margin-bottom-2">
This prisoner is being transferred
</p>
<p class="govuk-body">Some information may be hidden</p>
</div>
</div>
</div>
{%- endcall -%}
{%- call conditionallyShow({condition: prisonerIsTRN(prisonId) != true and prisonerBelongsToUsersCaseLoad(prisonId, user.caseLoads) != true, id: 'outside-establishment-banner'}) -%}
<div class="govuk-grid-row govuk-!-padding-top-2 govuk-!-padding-bottom-2 hmpps-profile-banner-alert">
<div class="govuk-grid-column-full">
<p class="govuk-heading-m govuk-!-margin-bottom-2">
This prisoner is not in your establishment
</p>
<p class="govuk-body">Some information may be hidden</p>
{% elseif prisonerIsOut(prisonId) %}
<div class="govuk-grid-row govuk-!-padding-top-2 govuk-!-padding-bottom-2 hmpps-profile-banner-alert" data-qa="OUT-establishment-banner">
<div class="govuk-grid-column-full">
<p class="govuk-heading-m govuk-!-margin-bottom-2">
This person has been released
</p>
<p class="govuk-body">Some information may be hidden</p>
</div>
</div>
</div>
{%- endcall -%}
{%- call conditionallyShow({condition: prisonerIsTRN(prisonId) != true and prisonerIsOut(prisonId) == true, id: 'OUT-establishment-banner'}) -%}
<div class="govuk-grid-row govuk-!-padding-top-2 govuk-!-padding-bottom-2 hmpps-profile-banner-alert">
<div class="govuk-grid-column-full">
<p class="govuk-heading-m govuk-!-margin-bottom-2">
This person has been released
</p>
<p class="govuk-body">Some information may be hidden</p>
{% else %}
{%- call conditionallyShow({condition: prisonerBelongsToUsersCaseLoad(prisonId, user.caseLoads) != true, id: 'outside-establishment-banner'}) -%}
<div class="govuk-grid-row govuk-!-padding-top-2 govuk-!-padding-bottom-2 hmpps-profile-banner-alert">
<div class="govuk-grid-column-full">
<p class="govuk-heading-m govuk-!-margin-bottom-2">
This prisoner is not in your establishment
</p>
<p class="govuk-body">Some information may be hidden</p>
</div>
</div>
</div>
{%- endcall -%}
{%- endcall -%}
{% endif %}
<div class="govuk-grid-row">
<div class="govuk-grid-column-full hmpps-profile-banner-top">
<a href="/prisoner/{{ prisonerNumber }}/image" class="hmpps-clickable-image" data-qa="prisoner-photo-link">
Expand Down