generated from ministryofjustice/hmpps-template-typescript
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Man 48 improve mms dashboard my cases (#170)
* MAN-48 - add recent case tab * MAN-48 - add recent case tab * MAN-48 - add recent case tab * MAN-48 - add recent case tab * MAN-48 - remove order logic in overview file, as this is done in the b/e api. * MAN-48 - update overview cypress test * MAN-48 - add new cypress test * MAN-48 - update cypress test * MAN-48 - remove log statement
- Loading branch information
1 parent
689843f
commit 3b7c816
Showing
13 changed files
with
1,124 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import Page from '../pages/page' | ||
import RecentCasesPage from '../pages/recentCases' | ||
|
||
context('Recent Cases', () => { | ||
it('Recent Cases page is rendered', () => { | ||
cy.visit('/recent-cases', { | ||
onBeforeLoad(win) { | ||
const recentCases = [] | ||
const recentCase = { | ||
name: 'Wolff,Caroline', | ||
crn: 'X000001', | ||
dob: '9 January 2002', | ||
age: 22, | ||
tierScore: 'B2', | ||
sentence: '12 month Community order', | ||
} | ||
|
||
recentCases.push(recentCase) | ||
win.localStorage.setItem('recentCases', JSON.stringify(recentCases)) | ||
}, | ||
}) | ||
|
||
const page = Page.verifyOnPage(RecentCasesPage) | ||
|
||
cy.get('h1').contains('Recently viewed cases') | ||
|
||
cy.get('thead') | ||
.eq(0) | ||
.within(() => cy.get('th').eq(0).should('contain.text', 'Name / CRN')) | ||
cy.get('thead') | ||
.eq(0) | ||
.within(() => cy.get('th').eq(1).should('contain.text', 'DOB/ Age')) | ||
cy.get('thead') | ||
.eq(0) | ||
.within(() => cy.get('th').eq(2).should('contain.text', 'Tier')) | ||
cy.get('thead') | ||
.eq(0) | ||
.within(() => cy.get('th').eq(3).should('contain.text', 'Sentence')) | ||
|
||
page.createAliasAtIndexWithin('tbody', 0, 'td', 0, 'row1col1') | ||
cy.get('@row1col1').within(() => cy.get('a').invoke('attr', 'href').should('equal', './case/X000001')) | ||
cy.get('@row1col1').within(() => cy.contains('a', 'Wolff,Caroline')) | ||
cy.get('@row1col1').within(() => cy.contains('span', 'X000001')) | ||
|
||
page.createAliasAtIndexWithin('tbody', 0, 'td', 1, 'row1col2') | ||
cy.get('@row1col2').within(() => cy.contains('9 January 2002')) | ||
cy.get('@row1col2').within(() => cy.contains('span', 22)) | ||
|
||
cy.get('tbody') | ||
.eq(0) | ||
.within(() => cy.get('td').eq(2).should('contain.text', 'B2')) | ||
cy.get('tbody') | ||
.eq(0) | ||
.within(() => cy.get('td').eq(3).should('contain.text', '12 month Community order')) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import Page from './page' | ||
|
||
export default class RecentCasesPage extends Page { | ||
constructor() { | ||
super('Recently viewed cases') | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
{% extends "./caseload.njk" %} | ||
{% set title = 'Recently viewed cases' %} | ||
{% block pageTitle %}{{ title }}{% endblock %} | ||
|
||
{% block pageContent %} | ||
|
||
<table class="govuk-table"> | ||
<thead class="govuk-table__head"> | ||
<tr class="govuk-table__row"> | ||
<th scope="col" class="govuk-table__header">Name / CRN</th> | ||
<th scope="col" class="govuk-table__header">DOB/ Age</th> | ||
<th scope="col" class="govuk-table__header">Tier</th> | ||
<th scope="col" class="govuk-table__header">Sentence</th> | ||
</tr> | ||
</thead> | ||
<tbody id="tabBody" class="govuk-table__body"> | ||
<script nonce="{{ cspNonce }}"> | ||
const recentCases = JSON.parse(localStorage.getItem('recentCases')) | ||
if (recentCases != null) { | ||
recentCases.forEach((recentCase) => { | ||
const tableBody = document.getElementById("tabBody") | ||
const row = document.createElement("tr") | ||
row.className = "govuk-table__row" | ||
const rd1 = document.createElement("td") | ||
rd1.className = "govuk-table__cell" | ||
const anchor = document.createElement("a") | ||
anchor.className = "govuk-!-font-weight-bold" | ||
anchor.href = "./case/" + recentCase.crn | ||
anchor.text = recentCase.name | ||
const span1 = document.createElement("span") | ||
span1.className = "govuk-!-font-weight-bold secondary-text" | ||
span1.innerText = recentCase.crn | ||
rd1.appendChild(anchor) | ||
rd1.appendChild(document.createElement("br")) | ||
rd1.appendChild(span1) | ||
const rd2 = document.createElement("td") | ||
rd2.className = "govuk-table__cell" | ||
rd2.innerText = recentCase.dob | ||
const span2 = document.createElement("span") | ||
span2.className = "secondary-text" | ||
span2.innerText = "Age " + recentCase.age | ||
rd2.appendChild(document.createElement("br")) | ||
rd2.appendChild(span2) | ||
const rd3 = document.createElement("td") | ||
rd3.className = "govuk-table__cell" | ||
rd3.innerText = recentCase.tierScore | ||
const rd4 = document.createElement("td") | ||
rd4.className = "govuk-table__cell" | ||
rd4.innerText = recentCase.sentence | ||
row.appendChild(rd1) | ||
row.appendChild(rd2) | ||
row.appendChild(rd3) | ||
row.appendChild(rd4) | ||
tableBody.appendChild(row) | ||
} | ||
) | ||
} | ||
</script> | ||
</table> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.