Skip to content

[Playwright] Kits UI verification tests #2263

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
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
4 changes: 3 additions & 1 deletion playwright-e2e/dsm/component/kitType/enums/kitType-enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@ export enum KitTypeEnum {
SALIVA = 'SALIVA',
BLOOD = 'BLOOD',
STOOL = 'STOOL',
BLOOD_AND_RNA = 'BLOOD & RNA'
BLOOD_AND_RNA = 'BLOOD & RNA',
FFPE_SECTION = 'FFPE-SECTION',
FFPE_SCROLL = 'FFPE-SCROLL'
}
2 changes: 1 addition & 1 deletion playwright-e2e/dsm/component/kitType/kitType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class KitType {
}

/* XPaths */
private kitTypeCheckbox(kitType: KitTypeEnum): string {
public kitTypeCheckbox(kitType: KitTypeEnum): string {
return `//mat-checkbox[.//label/span[text()[normalize-space()='${kitType}']]]`;
}
}
44 changes: 44 additions & 0 deletions playwright-e2e/dsm/pages/kit-page-base.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { Page, expect } from '@playwright/test';
import DsmPageBase from './dsm-page-base';
import { KitsTable } from 'dsm/component/tables/kits-table';
import { KitTypeEnum } from 'dsm/component/kitType/enums/kitType-enum';
import Checkbox from 'dss/component/checkbox';
import { waitForNoSpinner } from 'utils/test-utils';

export default abstract class KitPageBase extends DsmPageBase {
protected abstract defaultKitTypes: KitTypeEnum[];
private readonly kitsQueueTable = new KitsTable(this.page);

constructor(readonly page: Page) {
super(page);
}

public get kitsTable(): KitsTable {
return this.kitsQueueTable;
}

public async waitForReady(kitTypes?: KitTypeEnum[]): Promise<void> {
const knownKitTypes = kitTypes ?? this.defaultKitTypes;
await Promise.all([
this.page.waitForLoadState(),
expect(this.page.locator('h1')).toHaveText('Kit Queue')
]);
await expect(async () => expect(await this.page.locator('mat-checkbox[id]').count()).toBeGreaterThanOrEqual(1)).toPass({ timeout: 60000 });
await this.assertDisplayedKitTypes(knownKitTypes);
await waitForNoSpinner(this.page);
}

public async assertDisplayedKitTypes(kitTypes: KitTypeEnum[]): Promise<void> {
for (const kitType of kitTypes) {
await expect(this.getKitCheckbox(kitType).toLocator()).toBeVisible();
}
}

public getKitCheckbox(buttonLabel: KitTypeEnum): Checkbox {
return new Checkbox(this.page, { label: buttonLabel });
}

public async selectKitType(buttonLabel: KitTypeEnum): Promise<void> {
await this.getKitCheckbox(buttonLabel).check();
}
}
33 changes: 33 additions & 0 deletions playwright-e2e/dsm/pages/kit-queue-page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { Page, expect } from '@playwright/test';
import { KitTypeEnum } from 'dsm/component/kitType/enums/kitType-enum';
import { KitType } from 'dsm/component/kitType/kitType';
import Checkbox from 'dss/component/checkbox';
import { waitForNoSpinner } from 'utils/test-utils';
import KitPageBase from './kit-page-base';

export default class KitQueuePage extends KitPageBase {
private readonly defaultKitTypes = [KitTypeEnum.SALIVA, KitTypeEnum.BLOOD];

private readonly kitType = new KitType(this.page);

constructor(page: Page) {
super(page);
}

public async waitForReady(kitTypes?: KitTypeEnum[]): Promise<void> {
const knownKitTypes = kitTypes ?? this.defaultKitTypes;
await Promise.all([
this.page.waitForLoadState(),
expect(this.page.locator('h1')).toHaveText('Kit Queue')
]);
await expect(async () => expect(await this.page.locator('mat-checkbox[id]').count()).toBeGreaterThanOrEqual(1)).toPass({ timeout: 60000 });
await this.assertDisplayedKitTypes(knownKitTypes);
await waitForNoSpinner(this.page);
}

public async assertDisplayedKitTypes(kitTypes: KitTypeEnum[]): Promise<void> {
for (const kitType of kitTypes) {
await expect(this.kitType.displayedKitType(kitType)).toBeVisible()
}
}
}
12 changes: 7 additions & 5 deletions playwright-e2e/dsm/pages/kitUpload-page/kitUpload-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default class KitUploadPage {
this.page.waitForLoadState(),
this.assertPageTitle()
]);
await expect(this.skipAddressValidationCheckbox).toBeVisible();
await expect(this.skipAddressValidationCheckbox).toBeVisible({timeout: 60 * 1000});
await waitForNoSpinner(this.page);
await this.assertDisplayedKitTypes(knownKitTypes);
}
Expand Down Expand Up @@ -119,9 +119,7 @@ export default class KitUploadPage {
}

public async assertInstructionSnapshot() {
expect(await this.page.locator(this.uploadInstructionsXPath).screenshot(),
"Kit Upload page - Kit upload instructions screenshot doesn't match the provided one")
.toMatchSnapshot('upload_instructions.png');
await expect(this.page.locator(this.uploadInstructionsXPath)).toHaveScreenshot('upload_instructions.png');
}

public async assertDisplayedKitTypes(kitTypes: KitTypeEnum[]): Promise<void> {
Expand All @@ -133,7 +131,7 @@ export default class KitUploadPage {
}

public async assertBrowseBtn(): Promise<void> {
await expect(this.page.locator('//label[text()[normalize-space()=\'Browse...\']][@class=\'label-button\']'),
await expect(this.browseBtn,
'Kit Upload page - Browse button is not visible')
.toBeVisible();
}
Expand All @@ -152,6 +150,10 @@ export default class KitUploadPage {
return this.page.locator('//mat-checkbox[.//*[@class="mat-checkbox-label" and text()="Skip address validation on upload"]]');
}

public get browseBtn(): Locator {
return this.page.locator('//label[text()[normalize-space()=\'Browse...\']][@class=\'label-button\']');
}

/* XPaths */
private get uploadInstructionsXPath(): string {
return "//div[./b[text()[normalize-space()='Upload instructions:']]]"
Expand Down
28 changes: 23 additions & 5 deletions playwright-e2e/dsm/pages/kitsInfo-pages/kitsWithoutLabel-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export default class KitsWithoutLabelPage {
KitsColumnsEnum.DDP_REALM, KitsColumnsEnum.TYPE, ''];
// the last item is empty string because the deactivate buttons columns doesn't have one

private readonly expectedKitTypes = [KitTypeEnum.SALIVA, KitTypeEnum.BLOOD];

private readonly kitType = new KitType(this.page);
private readonly kitsTable = new KitsTable(this.page);

Expand All @@ -24,6 +26,10 @@ export default class KitsWithoutLabelPage {
return this.kitsTable;
}

public get kitTypeCheckbox(): KitType {
return this.kitType;
}

public async goToPage(page: number): Promise<void> {
await this.kitsTable.goToPage(page);
}
Expand All @@ -32,11 +38,23 @@ export default class KitsWithoutLabelPage {
await this.kitsTable.rowsPerPage(rows);
}

public async waitForReady(): Promise<void> {
await this.assertPageTitle();
await waitForNoSpinner(this.page);
public async waitForReady(kitTypes?: KitTypeEnum[]): Promise<void> {
const knownKitTypes = kitTypes ?? this.expectedKitTypes; //Use the param kit types if provided, if they are not, then use the general expected kit types
await Promise.all([
this.page.waitForLoadState(),
this.assertPageTitle()
]);
await expect(async () => expect(await this.page.locator('mat-checkbox[id]').count()).toBeGreaterThanOrEqual(1))
.toPass({ timeout: 60000 });
await this.assertDisplayedKitTypes(knownKitTypes);
}

public async assertDisplayedKitTypes(kitTypes: KitTypeEnum[]): Promise<void> {
await waitForNoSpinner(this.page);
for (const kitType of kitTypes) {
await expect(this.kitType.displayedKitType(kitType),
'Kit without Labels page - Displayed kit types checkboxes are wrong').toBeVisible()
}
}

public async selectKitType(kitType: KitTypeEnum): Promise<void> {
Expand Down Expand Up @@ -126,11 +144,11 @@ export default class KitsWithoutLabelPage {
+ "//div[@class='app-modal-footer']/button[text()[normalize-space()='Deactivate']]";
}

private get reloadKitListBtnXPath(): string {
public get reloadKitListBtnXPath(): string {
return '//button[normalize-space()="Reload Kit List"]';
}

private get createLabelsBtnXPath(): string {
public get createLabelsBtnXPath(): string {
return '//button[normalize-space()="Create Labels"]';
}
}
2 changes: 1 addition & 1 deletion playwright-e2e/dss/component/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ export default class Table {
}

public rowCountButton(rowCount = 10): Locator {
return this.footerLocator().locator(`xpath=//button[contains(., "${rowCount}")]`);
return this.footerLocator().locator(`xpath=//button[contains(., "${rowCount}")] | //a[contains(., "${rowCount}")]`);
}

private parseForNumber(text: string): number | null {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,3 @@ test.describe.serial('Initial Scan page', () => {
});
}
})

// kit-d9b76c66-6
// PAHV44
62 changes: 62 additions & 0 deletions playwright-e2e/tests/dsm/kitUploadFlow/kit-queue-ui.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import {expect} from '@playwright/test';
import {test} from 'fixtures/dsm-fixture';
import {WelcomePage} from 'dsm/pages/welcome-page';
import {Navigation} from 'dsm/component/navigation/navigation';
import {StudyEnum} from 'dsm/component/navigation/enums/selectStudyNav-enum';
import {SamplesNavEnum} from 'dsm/component/navigation/enums/samplesNav-enum';
import {KitsColumnsEnum} from 'dsm/pages/kitsInfo-pages/enums/kitsColumns-enum';
import {defaultKitTypes, studyShortName} from 'utils/test-utils';
import KitQueuePage from 'dsm/pages/kit-queue-page';
import { KitTypeEnum } from 'dsm/component/kitType/enums/kitType-enum';

test.describe('Kits without Labels UI', () => {
let welcomePage: WelcomePage;
let navigation: Navigation;

const studies = [StudyEnum.OSTEO2, StudyEnum.PANCAN, StudyEnum.RGP];

test.beforeEach(({page, request}) => {
welcomePage = new WelcomePage(page);
navigation = new Navigation(page, request);
});

for (const study of studies) {
test(`Page verifications @dsm @${study} @kit`, async ({page}) => {
const expectedKitSelection = defaultKitTypes(study);
const { realm: expectedRealm } = studyShortName(study);
await welcomePage.selectStudy(study);

const kitQueuePage = await navigation.selectFromSamples<KitQueuePage>(SamplesNavEnum.QUEUE);
await kitQueuePage.waitForReady(expectedKitSelection);

expect(await kitQueuePage.getKitCheckbox(KitTypeEnum.SALIVA).isChecked()).toBeFalsy();
expect(await kitQueuePage.getKitCheckbox(KitTypeEnum.BLOOD).isChecked()).toBeFalsy();

const kitsTable = kitQueuePage.kitsTable;

for (const kitType of expectedKitSelection) {
await kitQueuePage.selectKitType(kitType);
await expect(page.locator(kitsWithoutLabelPage.reloadKitListBtnXPath)).toBeEnabled();
const rows = await kitsTable.getRowsCount();
if (rows > 0) {
await expect(page.locator(kitsWithoutLabelPage.createLabelsBtnXPath)).toBeDisabled();
await kitsTable.rowCountButton(50).isVisible() && await kitsTable.changeRowCount(50);
} else {
await expect(page.locator('h4')).toHaveText('There are no kit requests');
expect(await kitsTable.exists()).toBeFalsy();
}
for (let i = 0; i < rows; i++) {
const typeValue = (await kitsTable.getRowText(i, KitsColumnsEnum.TYPE)).trim();
// Kits in different types are not mixed. Kits should be uploaded for the right type.
expect.soft(typeValue).toStrictEqual(kitType);
const shortId = (await kitsTable.getRowText(i, KitsColumnsEnum.SHORT_ID)).trim();
expect(shortId?.length).toBeTruthy();
const realm = (await kitsTable.getRowText(i, KitsColumnsEnum.DDP_REALM)).trim();
expect(realm).toStrictEqual(expectedRealm);
}
}

expect(test.info().errors).toHaveLength(0);
})
}
})
40 changes: 40 additions & 0 deletions playwright-e2e/tests/dsm/kitUploadFlow/kit-upload-ui.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import {expect} from '@playwright/test';
import {test} from 'fixtures/dsm-fixture';
import {WelcomePage} from 'dsm/pages/welcome-page';
import {Navigation} from 'dsm/component/navigation/navigation';
import {StudyEnum} from 'dsm/component/navigation/enums/selectStudyNav-enum';
import {SamplesNavEnum} from 'dsm/component/navigation/enums/samplesNav-enum';
import KitUploadPage from 'dsm/pages/kitUpload-page/kitUpload-page';
import {defaultKitTypes} from 'utils/test-utils';

test.describe('Kits Upload UI', () => {
let welcomePage: WelcomePage;
let navigation: Navigation;

const studies = [StudyEnum.OSTEO2, StudyEnum.PANCAN, StudyEnum.RGP];

test.beforeEach(({page, request}) => {
welcomePage = new WelcomePage(page);
navigation = new Navigation(page, request);
});

for (const study of studies) {
test(`Page verifications @dsm @${study} @kit`, async ({page}) => {
const expectedKitSelection = defaultKitTypes(study);
await welcomePage.selectStudy(study);

const kitUploadPage = await navigation.selectFromSamples<KitUploadPage>(SamplesNavEnum.KIT_UPLOAD);
await kitUploadPage.waitForReady(expectedKitSelection);

for (const kitType of expectedKitSelection) {
await expect.soft(kitUploadPage.browseBtn).toBeHidden();
await kitUploadPage.selectKitType(kitType);
await expect.soft(kitUploadPage.browseBtn).toBeVisible();
await expect.soft(page.locator('app-filepicker .FilePicker--Text')).toHaveText('No File selected');
await kitUploadPage.selectKitType(kitType); // un-check
}

expect(test.info().errors).toHaveLength(0);
})
}
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import {expect} from '@playwright/test';
import {test} from 'fixtures/dsm-fixture';
import {WelcomePage} from 'dsm/pages/welcome-page';
import {Navigation} from 'dsm/component/navigation/navigation';
import {StudyEnum} from 'dsm/component/navigation/enums/selectStudyNav-enum';
import {SamplesNavEnum} from 'dsm/component/navigation/enums/samplesNav-enum';
import KitsWithoutLabelPage from 'dsm/pages/kitsInfo-pages/kitsWithoutLabel-page';
import {KitsColumnsEnum} from 'dsm/pages/kitsInfo-pages/enums/kitsColumns-enum';
import {defaultKitTypes, studyShortName} from 'utils/test-utils';

test.describe('Kits without Labels UI', () => {
let welcomePage: WelcomePage;
let navigation: Navigation;

const studies = [StudyEnum.OSTEO2, StudyEnum.PANCAN, StudyEnum.RGP];

test.beforeEach(({page, request}) => {
welcomePage = new WelcomePage(page);
navigation = new Navigation(page, request);
});

for (const study of studies) {
test(`Page verifications @dsm @${study} @kit`, async ({page}) => {
const expectedKitSelection = defaultKitTypes(study);
const { realm: expectedRealm } = studyShortName(study);
await welcomePage.selectStudy(study);

const kitsWithoutLabelPage = await navigation.selectFromSamples<KitsWithoutLabelPage>(SamplesNavEnum.KITS_WITHOUT_LABELS);
await kitsWithoutLabelPage.waitForReady(expectedKitSelection);
const kitsTable = kitsWithoutLabelPage.kitsWithoutLabelTable;

for (const kitType of expectedKitSelection) {
await kitsWithoutLabelPage.selectKitType(kitType);
await expect(page.locator(kitsWithoutLabelPage.reloadKitListBtnXPath)).toBeEnabled();
const rows = await kitsTable.getRowsCount();
if (rows > 0) {
await expect(page.locator(kitsWithoutLabelPage.createLabelsBtnXPath)).toBeDisabled();
await kitsTable.rowCountButton(50).isVisible() && await kitsTable.changeRowCount(50);
} else {
await expect(page.locator('h4')).toHaveText('There are no kit requests');
expect(await kitsTable.exists()).toBeFalsy();
}
for (let i = 0; i < rows; i++) {
const typeValue = (await kitsTable.getRowText(i, KitsColumnsEnum.TYPE)).trim();
// Kits in different types are not mixed. Kits should be uploaded for the right type.
expect(typeValue).toStrictEqual(kitType);
const shortId = (await kitsTable.getRowText(i, KitsColumnsEnum.SHORT_ID)).trim();
expect(shortId?.length).toBeTruthy();
const realm = (await kitsTable.getRowText(i, KitsColumnsEnum.DDP_REALM)).trim();
expect(realm).toStrictEqual(expectedRealm);
}
}
})
}
})
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ test.describe.skip('Blood & RNA Kit Upload', () => {
//Upload a Blood & RNA kit
const kitUploadPage = await navigation.selectFromSamples<KitUploadPage>(SamplesNavEnum.KIT_UPLOAD);
await kitUploadPage.waitForReady(expectedKitTypes);
await kitUploadPage.assertPageTitle();
await kitUploadPage.selectKitType(kitType);
await kitUploadPage.assertBrowseBtn();
await kitUploadPage.assertUploadKitsBtn();
Expand Down
Loading