Skip to content
Open
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
57 changes: 27 additions & 30 deletions cypress/component/fines/consolidation/AccountResult.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,11 @@ const companyResultsTableHeaders = [
'Ref',
];

const INDIVIDUAL_TAGS = [CONSOLIDATION_EPIC_TAG, INDIVIDUAL_STORY_TAG];
const COMPANY_TAGS = [CONSOLIDATION_EPIC_TAG, COMPANY_STORY_TAG];
const RESULTS_TAB_FUNCTIONALITY_TAGS = [CONSOLIDATION_EPIC_TAG, RESULTS_TAB_FUNCTIONALITY_STORY_TAG];
const INVALID_RESULTS_TAGS = [CONSOLIDATION_EPIC_TAG, INVALID_RESULTS_STORY_TAG];
const buildTags = (...tags: string[]): string[] => [...tags, CONSOLIDATION_JIRA_LABEL];
const buildIndividualTags = (...tags: string[]): string[] =>
buildTags(CONSOLIDATION_EPIC_TAG, INDIVIDUAL_STORY_TAG, ...tags);
const buildCompanyTags = (...tags: string[]): string[] => buildTags(CONSOLIDATION_EPIC_TAG, COMPANY_STORY_TAG, ...tags);
const buildResultsTabFunctionalityTags = (...tags: string[]): string[] =>
buildTags(CONSOLIDATION_EPIC_TAG, RESULTS_TAB_FUNCTIONALITY_STORY_TAG, ...tags);
const buildInvalidResultsTags = (...tags: string[]): string[] =>
buildTags(CONSOLIDATION_EPIC_TAG, INVALID_RESULTS_STORY_TAG, ...tags);
const normaliseText = (value: string): string => value.replace(/\s+/g, ' ').trim();
type ExpectedResultsOrderRow = {
account: string;
Expand Down Expand Up @@ -183,7 +180,7 @@ describe('FinesConConsolidateAccComponent - Account Results', () => {

it(
'AC1, AC1a, AC1b. should render the individual account results tab with populated mock data',
{ tags: buildIndividualTags() },
{ tags: buildTags(...INDIVIDUAL_TAGS) },
() => {
setupComponent();

Expand All @@ -209,7 +206,7 @@ describe('FinesConConsolidateAccComponent - Account Results', () => {

it(
'AC2, AC2a, AC5a, AC5b, AC5c, AC5d, AC5e, AC5f, AC5g, AC5h, AC5i. should display the individual results columns in the AC order and format populated data',
{ tags: buildIndividualTags() },
{ tags: buildTags(...INDIVIDUAL_TAGS) },
() => {
defendantAccountResults[0].has_paying_parent_guardian = true; // Set to true to confirm Y is displayed in the relevant cell
defendantAccountResults[0].checks = { errors: [], warnings: [] }; //checks should be empty for check boxes to appear
Expand Down Expand Up @@ -249,7 +246,7 @@ describe('FinesConConsolidateAccComponent - Account Results', () => {

it(
'AC2b, AC2c, AC5b, AC5d, AC5fi, AC5g. should display an em dash for optional or unavailable account data',
{ tags: buildIndividualTags() },
{ tags: buildTags(...INDIVIDUAL_TAGS) },
() => {
defendantAccountResults.push(createFalseyResult());

Expand Down Expand Up @@ -278,7 +275,7 @@ describe('FinesConConsolidateAccComponent - Account Results', () => {

it(
'AC2d, AC2e. should display a maximum of 100 accounts on a single scrollable page with no pagination',
{ tags: buildIndividualTags() },
{ tags: buildTags(...INDIVIDUAL_TAGS) },
() => {
defendantAccountResults = createMaxResultsMock();

Expand All @@ -297,7 +294,7 @@ describe('FinesConConsolidateAccComponent - Account Results', () => {

it(
'AC3. should display individual results in Name, Date of birth, then Account number ascending order',
{ tags: buildIndividualTags() },
{ tags: buildTags(...INDIVIDUAL_TAGS) },
() => {
defendantAccountResults = [
buildIndividualResult({
Expand Down Expand Up @@ -344,7 +341,7 @@ describe('FinesConConsolidateAccComponent - Account Results', () => {

it(
'AC1a, AC1b, AC3, AC3a, AC3b, AC3c. should display the individual over-100 results state with the try adding more information link',
{ tags: buildInvalidResultsTags() },
{ tags: buildTags(...INVALID_RESULTS_TAGS) },
() => {
defendantAccountResults = createTooManyResultsMock();

Expand All @@ -358,7 +355,7 @@ describe('FinesConConsolidateAccComponent - Account Results', () => {

it(
'AC1a, AC1b, AC2, AC2a, AC2b, AC2c. should display the individual no-results state with the check your search link',
{ tags: buildInvalidResultsTags() },
{ tags: buildTags(...INVALID_RESULTS_TAGS) },
() => {
defendantAccountResults = [];

Expand All @@ -372,7 +369,7 @@ describe('FinesConConsolidateAccComponent - Account Results', () => {

it(
'AC7. should display warning and error checks beneath the relevant account row',
{ tags: buildIndividualTags() },
{ tags: buildTags(...INDIVIDUAL_TAGS) },
() => {
setupComponent();

Expand All @@ -388,7 +385,7 @@ describe('FinesConConsolidateAccComponent - Account Results', () => {

it(
'AC7a, AC7b. should show only errors when both errors and warnings exist, listing multiple errors as bullets',
{ tags: buildIndividualTags() },
{ tags: buildTags(...INDIVIDUAL_TAGS) },
() => {
defendantAccountResults = [createMultipleErrorsAndWarningsResult()];

Expand All @@ -412,7 +409,7 @@ describe('FinesConConsolidateAccComponent - Account Results', () => {

it(
'AC7c. should display all warnings when multiple warnings apply and no errors exist',
{ tags: buildIndividualTags() },
{ tags: buildTags(...INDIVIDUAL_TAGS) },
() => {
defendantAccountResults = [createMultipleWarningsResult()];

Expand All @@ -439,7 +436,7 @@ describe('FinesConConsolidateAccComponent - Account Results', () => {

it(
'AC1, AC1a, AC1b. should render the company account results tab with populated mock data',
{ tags: buildCompanyTags() },
{ tags: buildTags(...COMPANY_TAGS) },
() => {
setupComponent({ defendantType: 'company' });

Expand All @@ -463,7 +460,7 @@ describe('FinesConConsolidateAccComponent - Account Results', () => {

it(
'AC2, AC2a, AC5a, AC5b, AC5d, AC5e, AC5f, AC5i. should display the company results columns in the AC order and format populated data',
{ tags: buildCompanyTags() },
{ tags: buildTags(...COMPANY_TAGS) },
() => {
setupComponent({ defendantType: 'company' });

Expand Down Expand Up @@ -497,7 +494,7 @@ describe('FinesConConsolidateAccComponent - Account Results', () => {

it(
'AC2b, AC2c, AC5b, AC5d, AC5fi. should display an em dash for unavailable company account data',
{ tags: buildCompanyTags() },
{ tags: buildTags(...COMPANY_TAGS) },
() => {
defendantAccountResults.push(createCompanyFalseyResult());

Expand All @@ -520,7 +517,7 @@ describe('FinesConConsolidateAccComponent - Account Results', () => {

it(
'AC2d, AC2e. should display a maximum of 100 company accounts on a single scrollable page with no pagination',
{ tags: buildCompanyTags() },
{ tags: buildTags(...COMPANY_TAGS) },
() => {
defendantAccountResults = createCompanyMaxResultsMock();

Expand All @@ -536,7 +533,7 @@ describe('FinesConConsolidateAccComponent - Account Results', () => {

it(
'AC3. should display company results in Name, then Account number ascending order',
{ tags: buildCompanyTags() },
{ tags: buildTags(...COMPANY_TAGS) },
() => {
defendantAccountResults = [
buildCompanyResult({
Expand Down Expand Up @@ -575,7 +572,7 @@ describe('FinesConConsolidateAccComponent - Account Results', () => {

it(
'AC1a, AC1b, AC3, AC3a, AC3b, AC3c. should display the company over-100 results state with the try adding more information link',
{ tags: buildInvalidResultsTags() },
{ tags: buildTags(...INVALID_RESULTS_TAGS) },
() => {
defendantAccountResults = createCompanyTooManyResultsMock();

Expand All @@ -589,7 +586,7 @@ describe('FinesConConsolidateAccComponent - Account Results', () => {

it(
'AC1a, AC1b, AC2, AC2a, AC2b, AC2c. should display the company no-results state with the check your search link',
{ tags: buildInvalidResultsTags() },
{ tags: buildTags(...INVALID_RESULTS_TAGS) },
() => {
defendantAccountResults = [];

Expand All @@ -603,7 +600,7 @@ describe('FinesConConsolidateAccComponent - Account Results', () => {

it(
'AC7. should display warning and error checks beneath the relevant company account row',
{ tags: buildCompanyTags() },
{ tags: buildTags(...COMPANY_TAGS) },
() => {
defendantAccountResults[0].checks = {
errors: [{ reference: 'CON.ER.4', message: 'Account has days in default' }],
Expand All @@ -623,7 +620,7 @@ describe('FinesConConsolidateAccComponent - Account Results', () => {

it(
'AC7a, AC7b. should show only errors for company results when both errors and warnings exist, listing multiple errors as bullets',
{ tags: buildCompanyTags() },
{ tags: buildTags(...COMPANY_TAGS) },
() => {
defendantAccountResults = [createCompanyMultipleErrorsAndWarningsResult()];

Expand All @@ -645,7 +642,7 @@ describe('FinesConConsolidateAccComponent - Account Results', () => {

it(
'AC7c. should display all warnings for company results when multiple warnings apply and no errors exist',
{ tags: buildCompanyTags() },
{ tags: buildTags(...COMPANY_TAGS) },
() => {
defendantAccountResults = [createCompanyMultipleWarningsResult()];

Expand All @@ -671,7 +668,7 @@ describe('FinesConConsolidateAccComponent - Account Results', () => {

it(
'AC3, AC3a, AC3b. should show row checkboxes for selectable accounts, hide them for errors, and keep warning rows enabled',
{ tags: buildResultsTabFunctionalityTags() },
{ tags: buildTags(...RESULTS_TAB_FUNCTIONALITY_TAGS) },
() => {
defendantAccountResults[0].checks = { errors: [], warnings: [] };
defendantAccountResults.push(createMultipleErrorsAndWarningsResult(), createMultipleWarningsResult());
Expand Down Expand Up @@ -703,7 +700,7 @@ describe('FinesConConsolidateAccComponent - Account Results', () => {

it(
'AC4, AC4a, AC4b, AC4c, AC5a, AC5b, AC5c. should bulk select and deselect all enabled accounts while excluding accounts with errors',
{ tags: buildResultsTabFunctionalityTags() },
{ tags: buildTags(...RESULTS_TAB_FUNCTIONALITY_TAGS) },
() => {
defendantAccountResults[0].checks = { errors: [], warnings: [] };
defendantAccountResults.push(createMultipleErrorsAndWarningsResult(), createMultipleWarningsResult());
Expand Down Expand Up @@ -744,7 +741,7 @@ describe('FinesConConsolidateAccComponent - Account Results', () => {

it(
'AC6, AC6a, AC6b. should display Add to list above the counter and show a validation error when no accounts are selected',
{ tags: buildResultsTabFunctionalityTags() },
{ tags: buildTags(...RESULTS_TAB_FUNCTIONALITY_TAGS) },
() => {
defendantAccountResults[0].checks = { errors: [], warnings: [] };

Expand Down
43 changes: 26 additions & 17 deletions cypress/component/fines/consolidation/ErrorPage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import { ErrorPageLocators } from 'cypress/shared/selectors/consolidation/ErrorP
const CONSOLIDATION_JIRA_LABEL = '@JIRA-LABEL:consolidation';
const CONSOLIDATION_STORY_LABEL = '@JIRA-STORY:PO-2417';

const buildTags = (...tags: string[]): string[] => [...tags, CONSOLIDATION_JIRA_LABEL, CONSOLIDATION_STORY_LABEL];
const ERROR_PAGE_TAGS = [CONSOLIDATION_STORY_LABEL];
const buildTags = (...tags: string[]): string[] => [...tags, CONSOLIDATION_JIRA_LABEL];

describe('FinesConSearchErrorComponent', () => {
const setupComponent = (defendantType: 'individual' | 'company') => {
Expand Down Expand Up @@ -42,23 +43,31 @@ describe('FinesConSearchErrorComponent', () => {
});
};

it('AC2a. displays the individual search error heading and message text', { tags: buildTags() }, () => {
setupComponent('individual');
it(
'AC2a. displays the individual search error heading and message text',
{ tags: buildTags(...ERROR_PAGE_TAGS) },
() => {
setupComponent('individual');

assertHeadingAndIntro();
cy.get(ErrorPageLocators.bulletItems).then(($items) => {
const items = [...$items].map((item) => item.textContent?.replace(/\s+/g, ' ').trim());
expect(items).to.deep.equal(['account number, or', 'National Insurance number, or', 'advanced search']);
});
});
assertHeadingAndIntro();
cy.get(ErrorPageLocators.bulletItems).then(($items) => {
const items = [...$items].map((item) => item.textContent?.replace(/\s+/g, ' ').trim());
expect(items).to.deep.equal(['account number, or', 'National Insurance number, or', 'advanced search']);
});
},
);

it('AC2b. displays the company search error heading and message text', { tags: buildTags() }, () => {
setupComponent('company');
it(
'AC2b. displays the company search error heading and message text',
{ tags: buildTags(...ERROR_PAGE_TAGS) },
() => {
setupComponent('company');

assertHeadingAndIntro();
cy.get(ErrorPageLocators.bulletItems).then(($items) => {
const items = [...$items].map((item) => item.textContent?.replace(/\s+/g, ' ').trim());
expect(items).to.deep.equal(['account number, or', 'advanced search']);
});
});
assertHeadingAndIntro();
cy.get(ErrorPageLocators.bulletItems).then(($items) => {
const items = [...$items].map((item) => item.textContent?.replace(/\s+/g, ' ').trim());
expect(items).to.deep.equal(['account number, or', 'advanced search']);
});
},
);
});
Loading