* Initial import of playwright tests * Pipeline changes for automated tests * Modified pipeline for testing * Attempt #2 * Attempt #3 * Added missing paren * Removed debug stuff from pipeline * Changes from playwright repo * Changed pipeline for debugging * Fix for ServiceLocationPage playwright locators * Change pipeline to run with TEST APIs * Moved more of Siraj's changes to this repo * Changed where updating env occurs * Changed location of env update again * Escaped double quotes * Added visible report in Azure * Moved changes into main pipeline * Made it so dotenv only runs config in local
105 lines
No EOL
5 KiB
TypeScript
105 lines
No EOL
5 KiB
TypeScript
import test, { expect, type Locator, type Page } from '@playwright/test';
|
|
import { BasePage } from './BasePage';
|
|
import { IClaimDetails, ICustomerDetails } from '@business-logic/types/CustomerDetails';
|
|
import { getClientAuthByClientTag, getClientSignature } from '@impl/api/AdminServiceApiUtil';
|
|
import { ICertificateInfo, IClientSignatureRequest } from '@business-logic/types/Authentication';
|
|
import { buildToken, getTimestamp } from '@impl/utils/TokenUtils';
|
|
|
|
export class WelcomePage extends BasePage {
|
|
readonly page: Page;
|
|
readonly policyNumber: Locator;
|
|
readonly policyZip: Locator;
|
|
readonly damageDate: Locator;
|
|
readonly damageCause: Locator;
|
|
readonly phoneNumber: Locator;
|
|
readonly emailAddress: Locator;
|
|
readonly city: Locator;
|
|
readonly state: Locator;
|
|
readonly cookieCloseButton: Locator;
|
|
url = process.env['BASE_URL']! + '/?issPage=welcome-page';
|
|
|
|
constructor(page: Page) {
|
|
super(page);
|
|
this.page = page;
|
|
this.policyNumber = page.getByRole('textbox', { name: 'Policy number' });
|
|
this.policyZip = page.getByRole('textbox', { name: 'Policy ZIP' });
|
|
this.damageDate = page.getByRole('textbox', { name: 'When did the damage occur?<' });
|
|
this.damageCause = page.locator('#damageCauseQuestionField');
|
|
this.phoneNumber = page.getByRole('textbox', { name: 'Best number to reach you' });
|
|
this.emailAddress = page.getByRole('textbox', { name: 'Email address' });
|
|
this.city = page.getByRole('textbox', { name: 'In which city did the damage' });
|
|
this.state = page.locator('select[name="\\38 fdf9dc2e13e430eb57529499dceb3eb"]');
|
|
this.cookieCloseButton = page.getByRole('button', { name: 'Close' });
|
|
|
|
}
|
|
|
|
async goto(clientTag: string) {
|
|
await this.page.goto(process.env['BASE_URL']! + `/?issPage=entry-page&ClientTag=${clientTag}`);
|
|
await this.validateURL(this.url);
|
|
await this.cookieCloseButton.click();
|
|
}
|
|
|
|
async gotoWithAuthentication(clientTag: string) {
|
|
const clientAuth = await getClientAuthByClientTag(clientTag);
|
|
const certificate = clientAuth.certificateInfo[0] as ICertificateInfo;
|
|
let formData: Map<string, string> = new Map<string, string>();
|
|
formData.set("Timestamp", getTimestamp())
|
|
const request: IClientSignatureRequest = {
|
|
clientTag: clientTag,
|
|
token: buildToken(clientAuth, formData),
|
|
certificateFileName: certificate.name,
|
|
certificateKey: certificate.key,
|
|
certificateAlgorithm: certificate.algorithm,
|
|
certificateType: certificate.type
|
|
}
|
|
const result = await getClientSignature(request);
|
|
await this.page.goto(process.env['BASE_URL']! + `/?issPage=entry-page&ClientTag=${clientTag}&token=${request.token}&signature=${result.signature}`);
|
|
await this.validateURL(this.url);
|
|
await this.logReferralNumber();
|
|
await this.cookieCloseButton.click();
|
|
}
|
|
|
|
async hasCityInfo() {
|
|
await expect.soft(this.damageCause).toBeVisible();
|
|
return this.city.isVisible();
|
|
}
|
|
|
|
async populatePage(customerDetails: ICustomerDetails, claimDetails: IClaimDetails, isFillCityInfo: boolean) {
|
|
await this.policyNumber.fill(claimDetails.policyNumber);
|
|
await this.policyZip.fill(customerDetails.address.postalCode);
|
|
await this.damageDate.click();
|
|
await this.damageDate.fill(claimDetails.damageDate);
|
|
await this.damageCause.selectOption(claimDetails.damageCause);
|
|
await this.damageCause.press('Tab');
|
|
await this.phoneNumber.fill(customerDetails.phoneNumber);
|
|
// Phone number fixed 12/5. Can't start with 1 or 0
|
|
await this.emailAddress.fill(customerDetails.email);
|
|
|
|
if (isFillCityInfo) {
|
|
await this.city.fill(customerDetails.address.city);
|
|
await this.state.selectOption(customerDetails.address.state);
|
|
}
|
|
await this.logReferralNumber();
|
|
}
|
|
|
|
async logReferralNumber() {
|
|
let mainLocalStorage = JSON.parse(await this.page.evaluate('localStorage.getItem(\'main\')'));
|
|
let referralNumber = mainLocalStorage.order.referralNumber as number;
|
|
let referralSequenceNumber = mainLocalStorage.order.referralSequenceNumber as number;
|
|
if (referralNumber == null) {
|
|
for (let i = 1; i <= 20; i++) {
|
|
if (!referralNumber == null) break;
|
|
await this.page.waitForTimeout(500);
|
|
mainLocalStorage = JSON.parse(await this.page.evaluate('localStorage.getItem(\'main\')'));
|
|
referralNumber = mainLocalStorage.order.referralNumber as number;
|
|
referralSequenceNumber = mainLocalStorage.order.referralSequenceNumber as number;
|
|
}
|
|
}
|
|
|
|
await test.step(`Referral Number:${referralNumber} Referral Sequence Number:${referralSequenceNumber}`, async () => {
|
|
console.log(`Referral Number:${referralNumber}`);
|
|
console.log(`Referral Sequence Number:${referralSequenceNumber}`);
|
|
});
|
|
|
|
}
|
|
} |