Skip to content

Commit

Permalink
MAN-82 add filter menu integration tests wip
Browse files Browse the repository at this point in the history
  • Loading branch information
neil-mills committed Jan 24, 2025
1 parent 2230587 commit da4cd78
Show file tree
Hide file tree
Showing 5 changed files with 172 additions and 5 deletions.
74 changes: 74 additions & 0 deletions integration_tests/e2e/activityLog.cy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,81 @@
import Page from '../pages/page'
import ActivityLogPage from '../pages/activityLog'
import errorMessages from '../../server/properties/errorMessages'

context('Activity log', () => {
const today = new Date()
const day = today.getDate()
const month = today.getMonth() + 1
const year = today.getFullYear()
const date = `${day}/${month}/${year}`

it('should render the filter menu', () => {
cy.visit('/case/X000001/activity-log')
const page = Page.verifyOnPage(ActivityLogPage)
cy.get('[data-qa="filter-form"]').within(() => cy.get('h2').should('contain.text', 'Filter activity log'))
page.getApplyFiltersButton().should('contain.text', 'Apply filters')
cy.get('[data-qa="keywords"]').within(() => cy.get('label').should('contain.text', 'Keywords'))
page.getKeywordsInput().should('exist').should('have.value', '')
cy.get('[data-qa="date-from"]').within(() => cy.get('label').should('contain.text', 'Date from'))
cy.get('[data-qa="date-from"]').within(() => cy.get('input').should('exist').should('have.value', ''))
cy.get('[data-qa="date-to"]').within(() => cy.get('label').should('contain.text', 'Date to'))
cy.get('[data-qa="date-to"]').within(() => cy.get('input').should('exist').should('have.value', ''))
cy.get('[data-qa="compliance"]').within(() =>
cy.get('legend').should('exist').should('contain.text', 'Compliance filters'),
)
const filters = ['Without an outcome', 'Complied', 'Not complied']
cy.get('[data-qa="compliance"] .govuk-checkboxes__item').each(($el, i) => {
cy.wrap($el).find('input').should('not.be.checked')
cy.wrap($el).find('label').should('contain.text', filters[i])
})
})
it('should show the correct validation if date to is selected, but no date from is selected', () => {
cy.visit('/case/X000001/activity-log')
const page = Page.verifyOnPage(ActivityLogPage)
page.getDateToToggle().click()
page.getDateToDialog().should('be.visible').find(`button[data-testid="${date}"]`).click()
page.getDateToInput().should('have.value', date)
page.getDateToDialog().should('not.be.visible')
page.getApplyFiltersButton().click()
page.getErrorSummaryBox().should('be.visible')
page.getAllErrorSummaryLinks().should('have.length', 1)
page.getErrorSummaryLink(1).should('contain.text', errorMessages['activity-log']['date-from'].errors.isEmpty)
page.getErrorSummaryLink(1).click()
page.getDateFromInput().should('be.focused')
})
it('should show the correct validation if date from is selected, but no date to is selected', () => {
cy.visit('/case/X000001/activity-log')
const page = Page.verifyOnPage(ActivityLogPage)
page.getDateFromToggle().click()
page.getDateFromDialog().should('be.visible').find(`button[data-testid="${date}"]`).click()
page.getDateFromInput().should('have.value', date)
page.getDateFromDialog().should('not.be.visible')
page.getApplyFiltersButton().click()
page.getErrorSummaryBox().should('be.visible')
page.getAllErrorSummaryLinks().should('have.length', 1)
page.getErrorSummaryLink(1).should('contain.text', errorMessages['activity-log']['date-to'].errors.isEmpty)
page.getErrorSummaryLink(1).click()
page.getDateToInput().should('be.focused')
})
it('should show the correct validation if an invalid date from is entered', () => {
cy.visit('/case/X000001/activity-log')
const page = Page.verifyOnPage(ActivityLogPage)
page.getDateFromInput().type('01/04/2025')
page.getApplyFiltersButton().click()
page.getErrorSummaryBox().should('be.visible')
page.getAllErrorSummaryLinks().should('have.length', 1)
page.getErrorSummaryLink(1).should('contain.text', errorMessages['activity-log']['date-from'].errors.isInvalid)
})
// it('should show the correct validation if an invalid date to is entered', () => {
// cy.visit('/case/X000001/activity-log')
// const page = Page.verifyOnPage(ActivityLogPage)
// page.getDateToInput().type('01/04/')
// page.getApplyFiltersButton().click()
// page.getErrorSummaryBox().should('be.visible')
// page.getAllErrorSummaryLinks().should('have.length', 1)
// cy.pause()
// page.getErrorSummaryLink(1).should('contain.text', errorMessages['activity-log']['date-to'].errors.isInvalid)
// })
it('Activity log page is rendered in default view', () => {
cy.visit('/case/X000001/activity-log')
const page = Page.verifyOnPage(ActivityLogPage)
Expand Down
1 change: 1 addition & 0 deletions integration_tests/e2e/licence-condition-note.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ context('Sentence', () => {
const page = Page.verifyOnPage(SentencePage)
page.headerCrn().should('contain.text', 'X000001')
page.headerName().should('contain.text', 'Caroline Wolff')

cy.get('[data-qa=pageHeading]').eq(0).should('contain.text', 'Sentence')

cy.get(`[class=app-summary-card__header]`).within(() =>
Expand Down
18 changes: 18 additions & 0 deletions integration_tests/pages/activityLog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,23 @@ export default class ActivityLogPage extends Page {
super('Activity log')
}

getApplyFiltersButton = (): PageElement => cy.get('[data-qa="submit-button"]')

getKeywordsInput = (): PageElement => cy.get('[data-qa="keywords"] input')

getDateFromInput = (): PageElement => cy.get('[data-qa="date-from"] input')

getDateFromToggle = (): PageElement => cy.get('[data-qa="date-from"] .moj-datepicker__toggle')

getDateFromDialog = (): PageElement => cy.get('[data-qa="date-from"] .moj-datepicker__dialog')

getDateToInput = (): PageElement => cy.get('[data-qa="date-to"] input')

getDateToToggle = (): PageElement => cy.get('[data-qa="date-to"] .moj-datepicker__toggle')

getDateToDialog = (): PageElement => cy.get('[data-qa="date-to"] .moj-datepicker__dialog')

getActivity = (index: string): PageElement => cy.get(`[data-qa=timeline${index}Card]`)

getComplianceFilter = (index: string): PageElement => cy.get(`[data-qa="compliance"] input:nth-of-type(${index})`)
}
24 changes: 19 additions & 5 deletions server/views/pages/activity-log/_filters.njk
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
classes: "govuk-label--s govuk-!-font-weight-bold"
},
formGroup: {
classes: "govuk-!-margin-bottom-3"
classes: "govuk-!-margin-bottom-3",
attributes: {
'data-qa': 'keywords'
}
},
value: query.keywords
}) }}
Expand All @@ -25,7 +28,10 @@
classes: "govuk-label--s govuk-!-font-weight-bold"
},
formGroup: {
classes: "govuk-!-margin-bottom-3"
classes: "govuk-!-margin-bottom-3",
attributes: {
'data-qa': 'date-from'
}
},
value: query.dateFrom,
maxDate: filters.maxDate,
Expand All @@ -41,7 +47,10 @@
classes: "govuk-label--s govuk-!-font-weight-bold"
},
formGroup: {
classes: "govuk-!-margin-bottom-3"
classes: "govuk-!-margin-bottom-3",
attributes: {
'data-qa': 'date-to'
}
},
value: query.dateTo,
maxDate: filters.maxDate,
Expand All @@ -59,14 +68,19 @@
classes: 'govuk-fieldset__legend--s'
}
},
formGroup: {
attributes: {
'data-qa': 'compliance'
}
},
items: filters.complianceOptions
}) }}


{% endset -%}

<div class="govuk-grid-column-one-third">
<form method="get">
<form method="get" data-qa="filter-form">
{{ mojFilter({
heading: {
html: 'Filter activity log',
Expand All @@ -75,7 +89,7 @@
submit: {
value: "submit",
attributes: {
"data-test-id": "submit-button"
"data-qa": "submit-button"
}
},
selectedFilters: {
Expand Down
60 changes: 60 additions & 0 deletions wiremock/mappings/X000001-activity-log.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,66 @@
}
}
},
{
"request": {
"method": "POST",
"urlPathPattern": "/mas/activity/X000001",
"bodyPatterns": [
{
"matchesJsonPath": {
"expression": "keywords",
"contains": "Phone call"
}
}
]
},
"response": {
"status": 200,
"jsonBody": {
"size": 10,
"page": 0,
"totalResults": 1,
"totalPages": 1,
"personSummary": {
"name": {
"forename": "Eula",
"surname": "Schmeler"
},
"crn": "X000001",
"dateOfBirth": "1979-08-18"
},
"activities": [
{
"id": 11,
"type": "Phone call",
"startDateTime": "2044-12-22T09:15:00.382936Z[Europe/London]",
"endDateTime": "2044-12-22T09:30:00.382936Z[Europe/London]",
"rarToolKit": "Choices and Changes",
"rarCategory": "Stepping Stonessssss",
"isSensitive": false,
"hasOutcome": false,
"wasAbsent": true,
"notes": "Phone call from Stuart to say that he is sorry for not attending. He sounded under the influence of alcohol. He has recently heard that his ex partner is getting remarried and stated that he “went on a bit of a bender” He states that he has not attempted to contact the victim but I will make enquiries with the police to confirm this as given that he is audibly drunk i don't think i can take his word for it. I asked him to come in and see me at 9am in the morning and reiterated that if he turns up drunk I will have to mark that as another failure to comply due to behavioural issues. This will result in him being in breach of his order. I reiterated that up until now he has been doing so well with his probation and it’s really important he remember and make use of all the tools and techniques we had discussed during his RAR sessions.\n\nHe agreed to see me at 9am as his next shift at Timpsons isn’t until the afternoon. He apologized many times for “letting me down” and has confirmed that he has put a reminder on his phone about the meeting.",
"isAppointment": false,
"isCommunication": true,
"isPhoneCallFromPop": true,
"officerName": {
"forename": "Terry",
"surname": "Jones"
},
"lastUpdated": "2023-03-20",
"lastUpdatedBy": {
"forename": "Paul",
"surname": "Smith"
}
}
]
},
"headers": {
"Content-Type": "application/json"
}
}
},
{
"request": {
"urlPattern": "/mas/schedule/X000001/appointment/11",
Expand Down

0 comments on commit da4cd78

Please sign in to comment.