diff --git a/integration_tests/e2e/activityLog.cy.ts b/integration_tests/e2e/activityLog.cy.ts index 822710e2..255e8285 100644 --- a/integration_tests/e2e/activityLog.cy.ts +++ b/integration_tests/e2e/activityLog.cy.ts @@ -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) diff --git a/integration_tests/e2e/licence-condition-note.cy.ts b/integration_tests/e2e/licence-condition-note.cy.ts index 3a097829..7877054b 100644 --- a/integration_tests/e2e/licence-condition-note.cy.ts +++ b/integration_tests/e2e/licence-condition-note.cy.ts @@ -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(() => diff --git a/integration_tests/pages/activityLog.ts b/integration_tests/pages/activityLog.ts index ac8624fc..438b0401 100644 --- a/integration_tests/pages/activityLog.ts +++ b/integration_tests/pages/activityLog.ts @@ -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})`) } diff --git a/server/views/pages/activity-log/_filters.njk b/server/views/pages/activity-log/_filters.njk index d99d1d0c..c2386192 100644 --- a/server/views/pages/activity-log/_filters.njk +++ b/server/views/pages/activity-log/_filters.njk @@ -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 }) }} @@ -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, @@ -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, @@ -59,6 +68,11 @@ classes: 'govuk-fieldset__legend--s' } }, + formGroup: { + attributes: { + 'data-qa': 'compliance' + } + }, items: filters.complianceOptions }) }} @@ -66,7 +80,7 @@ {% endset -%}