Skip to content

Commit

Permalink
[SSCSSI-237]: Add send to judge test (#1586)
Browse files Browse the repository at this point in the history
* Add send to judge test

* remove unused imports

* update send to judge test

* update send to judge tests

---------

Co-authored-by: Pavi <pva08@Pavithrans-MacBook-Pro.local>
  • Loading branch information
pavihmcts and Pavi committed Jun 4, 2024
1 parent 49725f5 commit 6a16dc7
Show file tree
Hide file tree
Showing 9 changed files with 116 additions and 3 deletions.
4 changes: 3 additions & 1 deletion Jenkinsfile_CNP
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ def secrets = [
secret('test-e2e-hmrc-username', 'TEST_HMRC_USERNAME'),
secret('test-e2e-hmrc-password', 'TEST_HMRC_PASSWORD'),
secret('test-e2e-am-caseofficer-username', 'TEST_AM_CASEOFFICER_USERNAME'),
secret('test-e2e-am-caseofficer-password', 'TEST_AM_CASEOFFICER_PASSWORD')
secret('test-e2e-am-caseofficer-password', 'TEST_AM_CASEOFFICER_PASSWORD'),
secret('test-e2e-superuser-username', 'SUPER_USER_USERNAME'),
secret('test-e2e-superuser-password', 'SUPER_USER_PASSWORD')
]
]

Expand Down
5 changes: 5 additions & 0 deletions functional-test/e2e/send-to-judge.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { test } from "../lib/steps.factory";

test("Send to Judge", async ({ sendToJudgeSteps }) => {
await sendToJudgeSteps.performSendToJudge();
});
9 changes: 8 additions & 1 deletion functional-test/fixtures/steps/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,12 @@ export abstract class BaseStep {
await this.homePage.navigateToTab("Appeal Details");
await this.appealDetailsTab.verifyAppealDetailsPageContentByKeyValue(state, value);
await this.appealDetailsTab.verifyFTADueDateOnAppealDetails();
}
}

async loginAsSuperUserWithoutCaseId(caseId?: string, caseType?: string){
var caseId = await createCaseBasedOnCaseType(caseType);
await this.loginPage.goToLoginPage();
await this.loginPage.verifySuccessfulLoginForSuperUser(true);
await this.homePage.goToHomePage(caseId);
}
}
36 changes: 36 additions & 0 deletions functional-test/fixtures/steps/send.to.judge.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { Page } from '@playwright/test';
import eventTestData from "../../pages/content/event.name.event.description_en.json";
import { SendToJudgePage } from '../../pages/send.to.judge.page';
import { BaseStep } from './base';

export class SendToJudge extends BaseStep {

readonly page: Page;

constructor(page: Page) {
super(page);
this.page = page;
}

async performSendToJudge() {

let sendToJudgePage = new SendToJudgePage(this.page);

await this.loginAsSuperUserWithoutCaseId(undefined, "TAX CREDIT");
await this.homePage.reloadPage();
await this.homePage.chooseEvent('Send to Judge');

await sendToJudgePage.verifyPageContent();
await sendToJudgePage.selectHearingType();
await sendToJudgePage.inputData();
await sendToJudgePage.selectInterlocutoryReviewState();
await sendToJudgePage.confirmSubmission();

await this.eventNameAndDescriptionPage.verifyPageContent('Send to Judge');
await this.eventNameAndDescriptionPage.inputData(eventTestData.eventSummaryInput,
eventTestData.eventDescriptionInput);
await this.eventNameAndDescriptionPage.confirmSubmission();

await this.verifyHistoryTabDetails('With FTA', 'Send to Judge', eventTestData.eventDescriptionInput);
}
}
6 changes: 6 additions & 0 deletions functional-test/lib/steps.factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { ConfirmCaseLapsed } from '../fixtures/steps/confirm.case.lapsed';
import { EvidenceReminder } from '../fixtures/steps/evidence.reminder';
import { AssociateCase } from '../fixtures/steps/associate-case';
import { SendToAdmin } from '../fixtures/steps/send.to.admin';
import { SendToJudge } from '../fixtures/steps/send.to.judge';
import { UploadResponse } from '../fixtures/steps/upload.response';
import {ListingError} from "../fixtures/steps/listing.error";
import {use} from "chai";
Expand All @@ -15,6 +16,7 @@ type MyStepsFixtures = {
confirmCaseLapsedSteps: ConfirmCaseLapsed
evidenceReminderSteps: EvidenceReminder
sendToAdminSteps: SendToAdmin
sendToJudgeSteps: SendToJudge
uploadResponseSteps: UploadResponse
listingErrorSteps: ListingError
};
Expand All @@ -40,6 +42,10 @@ export const test = stepsFactory.extend<MyStepsFixtures>({
const sendToAdminSteps = new SendToAdmin(page);
await use(sendToAdminSteps);
},
sendToJudgeSteps:async ({page}, use) => {
const sendToJudgeSteps = new SendToJudge(page);
await use(sendToJudgeSteps);
},
uploadResponseSteps:async ({page}, use) => {
const uploadResponseSteps = new UploadResponse(page);
await use(uploadResponseSteps);
Expand Down
3 changes: 2 additions & 1 deletion functional-test/pages/common/homePage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class HomePage {
this.page = page;
this.notePadTab = page.locator('//div[contains(text(), "Notepad")]');
this.summaryTab = page.locator('//div[contains(text(), "Summary")]');
this.historyTab = page.locator('//div[contains(text(), "History")]');
this.historyTab = page.getByRole('tab', { name: 'History', exact: true })
this.appealDetailsTab = page.getByText('Appeal Details', {exact: true});
this.nextStepDropDown = '#next-step';
this.submitNextStepButton = '//button[@class="submit"]';
Expand Down Expand Up @@ -75,6 +75,7 @@ export class HomePage {
break;
}
case "History": {
await expect(this.historyTab).toBeVisible();
await this.historyTab.click();
break;
}
Expand Down
8 changes: 8 additions & 0 deletions functional-test/pages/common/loginPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,12 @@ export class LoginPage {
await webActions.inputField('#password', credentials.judge.password);
await webActions.clickButton('Sign in');
}

async verifySuccessfulLoginForSuperUser(isLoggedIn?: boolean): Promise<void> {
if(isLoggedIn) await this.page.context().clearCookies();
await webActions.inputField('#username', credentials.superUser.email);
await webActions.inputField('#password', credentials.superUser.password);
await webActions.clickButton('Sign in');
await expect(this.pageTitle).toHaveText('My work');
}
}
10 changes: 10 additions & 0 deletions functional-test/pages/content/send.to.judge_en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"sendToJudgeCaption" : "Send to Judge",
"sendToJudgeHeading" : "Send to Judge",
"sendToJudgeTextFieldLabel" : "Enter note (Optional)",
"sendToJudgePrePostHearingFieldLabel" : "Pre or post hearing?",
"sendToJudgeReviewStateFieldLabel" : "Interlocutory review state",
"sendToJudgeInput" : "Automation testing of the Send to Judge Event",
"sendToJudgePrePostHearingSelectValue" : "Pre Hearing",
"sendToJudgeReviewStateSelectValue" : "Awaiting Information"
}
38 changes: 38 additions & 0 deletions functional-test/pages/send.to.judge.page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { Page } from '@playwright/test';
import { WebAction } from '../common/web.action';
import sendToJudgeData from "./content/send.to.judge_en.json";

let webAction: WebAction;

export class SendToJudgePage {

readonly page: Page;

constructor(page: Page) {
this.page = page;
webAction = new WebAction(this.page);
}

async verifyPageContent() {
await webAction.verifyPageLabel('h1.govuk-heading-l', sendToJudgeData.sendToJudgeHeading); //Heading Text
await webAction.verifyPageLabel('label[for=\'prePostHearing\']', sendToJudgeData.sendToJudgePrePostHearingFieldLabel); //Field Label
await webAction.verifyPageLabel('label[for=\'tempNoteDetail\']', sendToJudgeData.sendToJudgeTextFieldLabel);
await webAction.verifyPageLabel('label[for=\'interlocReviewState\']', sendToJudgeData.sendToJudgeReviewStateFieldLabel);
}

async selectHearingType(): Promise<void> {
await webAction.chooseOptionByLabel('#prePostHearing', sendToJudgeData.sendToJudgePrePostHearingSelectValue);
}

async inputData(): Promise<void> {
await webAction.inputField('#tempNoteDetail', sendToJudgeData.sendToJudgeInput);
}

async selectInterlocutoryReviewState(): Promise<void> {
await webAction.chooseOptionByLabel('#interlocReviewState', sendToJudgeData.sendToJudgeReviewStateSelectValue);
}

async confirmSubmission(): Promise<void> {
await webAction.clickButton('Submit');
}
}

0 comments on commit 6a16dc7

Please sign in to comment.