Skip to content

Commit

Permalink
update configuration of steps files
Browse files Browse the repository at this point in the history
  • Loading branch information
kdaHMCTS committed Feb 5, 2025
1 parent 8a1ed44 commit a2545cb
Show file tree
Hide file tree
Showing 18 changed files with 302 additions and 245 deletions.
1 change: 1 addition & 0 deletions playwright-e2e/base/base-api-steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export default abstract class BaseApiSteps extends BaseSteps {
let eventData = {};
for (const pageId of Object.keys(pageDataMap)) {
eventData = ObjectHelper.deepSpread(eventData, pageDataMap[pageId]);
if (pageId === 'Upload') console.log(pageDataMap[pageId]);
const pageData = await ccdRequests.validatePageData(
ccdEvent,
user,
Expand Down
62 changes: 59 additions & 3 deletions playwright-e2e/base/base-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,26 @@ export default abstract class BasePage {
});
}

@BoxedDetailedStep(classKey, 'text')
@TruthyParams(classKey, 'text')
protected async expectNoHeading(
text: string | number,
options: {
message?: string;
timeout?: number;
} = {},
) {
const locator = this.page.locator('h1', { has: this.page.locator(`text="${text}"`) });

try {
await locator.waitFor({ state: 'visible', timeout: 20 });
// eslint-disable-next-line no-empty
} catch (err) {}
await pageExpect(locator, { message: options.message }).toBeHidden({
timeout: options.timeout,
});
}

@BoxedDetailedStep(classKey, 'text')
protected async expectSubheading(
text: string,
Expand Down Expand Up @@ -437,6 +457,42 @@ export default abstract class BasePage {
}
}

@BoxedDetailedStep(classKey, 'text')
@TruthyParams(classKey, 'text')
protected async expectNoSubheading(
text: string | number,
options: {
message?: string;
exact?: boolean;
containerSelector?: string;
all?: boolean;
index?: number;
first?: boolean;
timeout?: number;
} = {},
) {
if (options.first && options.index !== undefined) {
throw new ExpectError("Cannot use 'first' and 'index' options at the same time");
}

let locator = this.page.locator('h2', { has: this.page.locator(`text="${text}"`) });
locator = this.getNewLocator(locator, options.containerSelector, options.index, options.first);

try {
await locator.waitFor({ state: 'visible', timeout: 20 });
// eslint-disable-next-line no-empty
} catch (err) {}
if (options.all) {
await pageExpect(locator, { message: options.message }).allToBeHidden({
timeout: options.timeout,
});
} else {
await pageExpect(locator, { message: options.message }).toBeHidden({
timeout: options.timeout,
});
}
}

@BoxedDetailedStep(classKey, 'selector')
protected async expectSelector(
selector: string,
Expand Down Expand Up @@ -579,7 +635,7 @@ export default abstract class BasePage {
locator = this.getNewLocator(locator, options.containerSelector, options.index, options.first);

try {
await locator.waitFor({ state: 'visible', timeout: 500 });
await locator.waitFor({ state: 'visible', timeout: 20 });
// eslint-disable-next-line no-empty
} catch (err) {}
if (options.all) {
Expand Down Expand Up @@ -785,7 +841,7 @@ export default abstract class BasePage {
protected async retryAction(
action: () => Promise<void>,
assertions: () => Promise<void>[] | Promise<void>,
message: string,
message?: string,
{ retries = 1, assertFirst = false }: { retries?: number; assertFirst?: boolean } = {},
) {
while (retries >= 0) {
Expand All @@ -796,7 +852,7 @@ export default abstract class BasePage {
break;
} catch (error) {
if (retries <= 0) throw error;
console.log(message);
console.log(message ?? 'Action failed, trying again');
console.log(`Retries: ${retries} remaining`);
retries--;
assertFirst = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,37 @@ import ClaimType from '../../../../../../enums/claim-type';
import { UploadDocumentValue } from '../../../../../../models/ccd/ccd-case-data';
import { ClaimantDefendantPartyType } from '../../../../../../models/claimant-defendant-party-types';
import createClaimData from './create-claim-data-components';

@AllMethodsStep()
export default class CreateClaimDataBuilder extends BaseDataBuilder {
async buildSmallTrack1v1(particularsOfClaimDocument: UploadDocumentValue) {
return this.buildData(particularsOfClaimDocument);
async buildSmallTrack1v1() {
return this.buildData();
}

async buildSmallTrack1v2DifferentSolicitor(particularsOfClaimDocument: UploadDocumentValue) {
return this.buildData(particularsOfClaimDocument,
{ claimType : ClaimType.ONE_VS_TWO_DIFF_SOL});
async buildSmallTrack1v2DifferentSolicitor() {
return this.buildData({ claimType: ClaimType.ONE_VS_TWO_DIFF_SOL });
}

async buildSmallTrack2v1(particularsOfClaimDocument: UploadDocumentValue) {
return this.buildData(particularsOfClaimDocument,
{ claimType : ClaimType.TWO_VS_ONE});
async buildSmallTrack2v1() {
return this.buildData({ claimType: ClaimType.TWO_VS_ONE });
}

protected async buildData(
particularsOfClaimDocument: UploadDocumentValue,
{
claimType = ClaimType.ONE_VS_ONE,
claimTrack = ClaimTrack.SMALL_CLAIM,
claimant1PartyType = claimantDefendantPartyTypes.INDIVIDUAL,
claimant2PartyType = claimantDefendantPartyTypes.INDIVIDUAL,
defendant1PartyType = claimantDefendantPartyTypes.INDIVIDUAL,
defendant2PartyType = claimantDefendantPartyTypes.INDIVIDUAL,
}: {
claimType?: ClaimType;
claimTrack?: ClaimTrack;
claimant1PartyType?: ClaimantDefendantPartyType;
claimant2PartyType?: ClaimantDefendantPartyType;
defendant1PartyType?: ClaimantDefendantPartyType;
defendant2PartyType?: ClaimantDefendantPartyType;
} = {},
) {
protected async buildData({
claimType = ClaimType.ONE_VS_ONE,
claimTrack = ClaimTrack.SMALL_CLAIM,
claimant1PartyType = claimantDefendantPartyTypes.INDIVIDUAL,
claimant2PartyType = claimantDefendantPartyTypes.INDIVIDUAL,
defendant1PartyType = claimantDefendantPartyTypes.INDIVIDUAL,
defendant2PartyType = claimantDefendantPartyTypes.INDIVIDUAL,
particularsOfClaimDocument,
}: {
claimType?: ClaimType;
claimTrack?: ClaimTrack;
claimant1PartyType?: ClaimantDefendantPartyType;
claimant2PartyType?: ClaimantDefendantPartyType;
defendant1PartyType?: ClaimantDefendantPartyType;
defendant2PartyType?: ClaimantDefendantPartyType;
particularsOfClaimDocument?: UploadDocumentValue;
} = {}) {
return {
...createClaimData.references,
...createClaimData.claimantCourt,
Expand All @@ -53,7 +49,7 @@ export default class CreateClaimDataBuilder extends BaseDataBuilder {
...createClaimData.defendant2Represented(claimType),
...createClaimData.defendant2SameSolicitor(claimType),
...createClaimData.defendantSolicitor2(claimType),
...createClaimData.claimDetails(claimTrack, particularsOfClaimDocument),
...createClaimData.claimDetails(claimTrack),
...createClaimData.statementOfTruth,
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ const defendantSolicitor2 = (claimType: ClaimType) => {
return {};
};

const claimDetails = (claimTrack: ClaimTrack, particularsOfClaimDocument: UploadDocumentValue) => ({
const claimDetails = (claimTrack: ClaimTrack) => ({
ClaimTypeUnSpec: {
claimTypeUnSpec: 'PERSONAL_INJURY',
},
Expand All @@ -231,11 +231,11 @@ const claimDetails = (claimTrack: ClaimTrack, particularsOfClaimDocument: Upload
Details: {
detailsOfClaim: 'Test details of claim',
},
Upload: {
servedDocumentFiles: {
particularsOfClaimDocument: [CaseDataHelper.setIdToData(particularsOfClaimDocument)],
},
},
// Upload: {
// servedDocumentFiles: {
// particularsOfClaimDocument: [CaseDataHelper.setIdToData(particularsOfClaimDocument)],
// },
// },
ClaimValue: {
claimValue: {
statementOfValueInPennies: `${CaseDataHelper.getClaimValue(claimTrack) * 100}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,18 @@ export default class CaseDetailsPage extends ExuiPage(BasePage) {

async retryChooseNextStep(ccdEvent: CCDEvent) {
console.log(`Starting event: ${ccdEvent.name}`);
await super.selectFromDropdown(ccdEvent.name, dropdowns.nextStep.selector);
await super.retryClickBySelector(
buttons.go.selector,
() =>
await super.retryAction(
async () => {
await this.selectFromDropdown(0, dropdowns.nextStep.selector);
await super.selectFromDropdown(ccdEvent.name, dropdowns.nextStep.selector);
await super.clickBySelector(buttons.go.selector);
},
async () =>
super.expectNoTab(tabs.summary.title, {
timeout: 15_000,
exact: true,
}),
{ retries: 3 },
`Starting event: ${ccdEvent.name}, trying again`,
);
}

Expand Down
5 changes: 4 additions & 1 deletion playwright-e2e/pages/exui/exui-page/exui-content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ export const components = {
selector: '.spinner-container',
},
error: {
selector: 'div.error-summary.ng-star-inserted',
selector: "div[aria-labelledby='edit-case-event_error-summary-heading']",
},
fieldError: {
selector: "div[data-module='govuk-error-summary']",
},
};

Expand Down
9 changes: 7 additions & 2 deletions playwright-e2e/pages/exui/exui-page/exui-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,20 @@ export default function ExuiPage<TBase extends abstract new (...args: any[]) =>
buttons.submit.selector,
async () => {
await super.waitForSelectorToDetach(components.loading.selector, {
timeout: 30_000,
timeout: 15_000,
});
await super.expectNoSelector(components.error.selector, {
timeout: 500,
all: true,
});
await super.expectNoSelector(components.fieldError.selector, {
timeout: 500,
all: true,
message: 'Field Validation Error on UI',
});
if (expect) await expect();
},
{ timeout: 45_000 },
{ timeout: 30_000 },
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ export default class RespondentResponseType2v1Page extends ExuiPage(BasePage) {
async verifyContent(ccdCaseData: CCDCaseData) {
super.runVerifications([
super.verifyHeadings(ccdCaseData),
super.expectLabel(radioButtons.rejectAll.label, { count: 2 }),
super.expectLabel(radioButtons.admitAll.label, { count: 2 }),
super.expectLabel(radioButtons.partAdmit.label, { count: 2 }),
super.expectLabel(radioButtons.counterClaim.label, { count: 2 }),
super.expectLabel(radioButtons.rejectAll.label, { index: 0 }),
super.expectLabel(radioButtons.admitAll.label, { index: 0 }),
super.expectLabel(radioButtons.partAdmit.label, { index: 0 }),
super.expectLabel(radioButtons.counterClaim.label, { index: 0 }),
]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ export default class HearingFastSpecPage extends ExuiPage(BasePage) {
}

async submit() {
await super.retryClickSubmit();
await super.retryClickSubmit();
await super.retryClickSubmit(() => this.expectNoHeading(heading, { timeout: 500 }));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ export default class HearingSpecPage extends ExuiPage(BasePage) {
}

async submit() {
await super.retryClickSubmit();
await super.retryClickSubmit();
await super.retryClickSubmit(() => this.expectNoHeading(heading, { timeout: 500 }));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ export default class HearingFastPage extends ExuiPage(BasePage) {
}

async submit() {
await super.retryClickSubmit();
await super.retryClickSubmit();
await super.retryClickSubmit(() =>
super.expectNoSubheading(subheadings.availability, { all: true, timeout: 500 }),
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ export default class HearingPage extends ExuiPage(BasePage) {
}

async submit() {
//TODO - The Continue button is not being clicked the first time this should be checked again.
await super.retryClickSubmit();
await super.retryClickSubmit();
await super.retryClickSubmit(() =>
super.expectNoSubheading(subheadings.availability, { all: true, timeout: 500 }),
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,9 @@ export default class ApiCreateClaimSteps extends BaseApiSteps {
this.createClaimDataBuilder = createClaimDataBuilder;
}

async Create1v1Claim() {
async SmallTrack1v1() {
await this.setupUserData(claimantSolicitorUser);
const { civilServiceRequests } = this.requestsFactory;
const particularsOfClaimDocument =
await civilServiceRequests.uploadTestDocument(claimantSolicitorUser);
const createClaimData = await this.createClaimDataBuilder.buildSmallTrack1v1(
particularsOfClaimDocument,
);
const createClaimData = await this.createClaimDataBuilder.buildSmallTrack1v1();

const { ccdRequests } = this.requestsFactory;
const eventToken = await ccdRequests.startEvent(claimantSolicitorUser, ccdEvents.CREATE_CLAIM);
Expand All @@ -50,14 +45,10 @@ export default class ApiCreateClaimSteps extends BaseApiSteps {
UserAssignedCasesHelper.addAssignedCaseToUser(claimantSolicitorUser, this.ccdCaseData.id);
}

async Create1v2Claim() {
async SmallTrack1v2DS() {
await this.setupUserData(claimantSolicitorUser);
const { civilServiceRequests } = this.requestsFactory;
const particularsOfClaimDocument =
await civilServiceRequests.uploadTestDocument(claimantSolicitorUser);
const createClaimData = await this.createClaimDataBuilder.buildSmallTrack1v2DifferentSolicitor(
particularsOfClaimDocument,
);
const createClaimData =
await this.createClaimDataBuilder.buildSmallTrack1v2DifferentSolicitor();

const { ccdRequests } = this.requestsFactory;
const eventToken = await ccdRequests.startEvent(claimantSolicitorUser, ccdEvents.CREATE_CLAIM);
Expand All @@ -79,14 +70,9 @@ export default class ApiCreateClaimSteps extends BaseApiSteps {
UserAssignedCasesHelper.addAssignedCaseToUser(claimantSolicitorUser, this.ccdCaseData.id);
}

async Create2v1Claim() {
async SmallTrack2v1() {
await this.setupUserData(claimantSolicitorUser);
const { civilServiceRequests } = this.requestsFactory;
const particularsOfClaimDocument =
await civilServiceRequests.uploadTestDocument(claimantSolicitorUser);
const createClaimData = await this.createClaimDataBuilder.buildSmallTrack2v1(
particularsOfClaimDocument,
);
const createClaimData = await this.createClaimDataBuilder.buildSmallTrack2v1();

const { ccdRequests } = this.requestsFactory;
const eventToken = await ccdRequests.startEvent(claimantSolicitorUser, ccdEvents.CREATE_CLAIM);
Expand Down
Loading

0 comments on commit a2545cb

Please sign in to comment.