Skip to content

Commit 993f367

Browse files
committed
playwright kits ui tests
1 parent 2e09eae commit 993f367

File tree

9 files changed

+167
-14
lines changed

9 files changed

+167
-14
lines changed

playwright-e2e/dsm/component/kitType/enums/kitType-enum.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@ export enum KitTypeEnum {
22
SALIVA = 'SALIVA',
33
BLOOD = 'BLOOD',
44
STOOL = 'STOOL',
5-
BLOOD_AND_RNA = 'BLOOD & RNA'
5+
BLOOD_AND_RNA = 'BLOOD & RNA',
6+
FFPE_SECTION = 'FFPE-SECTION',
7+
FFPE_SCROLL = 'FFPE-SCROLL'
68
}

playwright-e2e/dsm/component/kitType/kitType.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export class KitType {
1414
}
1515

1616
/* XPaths */
17-
private kitTypeCheckbox(kitType: KitTypeEnum): string {
17+
public kitTypeCheckbox(kitType: KitTypeEnum): string {
1818
return `//mat-checkbox[.//label/span[text()[normalize-space()='${kitType}']]]`;
1919
}
2020
}

playwright-e2e/dsm/pages/kitUpload-page/kitUpload-page.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export default class KitUploadPage {
2424
this.page.waitForLoadState(),
2525
this.assertPageTitle()
2626
]);
27-
await expect(this.skipAddressValidationCheckbox).toBeVisible();
27+
await expect(this.skipAddressValidationCheckbox).toBeVisible({timeout: 60 * 1000});
2828
await waitForNoSpinner(this.page);
2929
await this.assertDisplayedKitTypes(knownKitTypes);
3030
}
@@ -119,9 +119,7 @@ export default class KitUploadPage {
119119
}
120120

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

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

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

153+
public get browseBtn(): Locator {
154+
return this.page.locator('//label[text()[normalize-space()=\'Browse...\']][@class=\'label-button\']');
155+
}
156+
155157
/* XPaths */
156158
private get uploadInstructionsXPath(): string {
157159
return "//div[./b[text()[normalize-space()='Upload instructions:']]]"

playwright-e2e/dsm/pages/kitsInfo-pages/kitsWithoutLabel-page.ts

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ export default class KitsWithoutLabelPage {
1515
KitsColumnsEnum.DDP_REALM, KitsColumnsEnum.TYPE, ''];
1616
// the last item is empty string because the deactivate buttons columns doesn't have one
1717

18+
private readonly expectedKitTypes = [KitTypeEnum.SALIVA, KitTypeEnum.BLOOD];
19+
1820
private readonly kitType = new KitType(this.page);
1921
private readonly kitsTable = new KitsTable(this.page);
2022

@@ -24,6 +26,10 @@ export default class KitsWithoutLabelPage {
2426
return this.kitsTable;
2527
}
2628

29+
public get kitTypeCheckbox(): KitType {
30+
return this.kitType;
31+
}
32+
2733
public async goToPage(page: number): Promise<void> {
2834
await this.kitsTable.goToPage(page);
2935
}
@@ -32,11 +38,23 @@ export default class KitsWithoutLabelPage {
3238
await this.kitsTable.rowsPerPage(rows);
3339
}
3440

35-
public async waitForReady(): Promise<void> {
36-
await this.assertPageTitle();
37-
await waitForNoSpinner(this.page);
41+
public async waitForReady(kitTypes?: KitTypeEnum[]): Promise<void> {
42+
const knownKitTypes = kitTypes ?? this.expectedKitTypes; //Use the param kit types if provided, if they are not, then use the general expected kit types
43+
await Promise.all([
44+
this.page.waitForLoadState(),
45+
this.assertPageTitle()
46+
]);
3847
await expect(async () => expect(await this.page.locator('mat-checkbox[id]').count()).toBeGreaterThanOrEqual(1))
3948
.toPass({ timeout: 60000 });
49+
await this.assertDisplayedKitTypes(knownKitTypes);
50+
}
51+
52+
public async assertDisplayedKitTypes(kitTypes: KitTypeEnum[]): Promise<void> {
53+
await waitForNoSpinner(this.page);
54+
for (const kitType of kitTypes) {
55+
await expect(this.kitType.displayedKitType(kitType),
56+
'Kit without Labels page - Displayed kit types checkboxes are wrong').toBeVisible()
57+
}
4058
}
4159

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

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

133-
private get createLabelsBtnXPath(): string {
151+
public get createLabelsBtnXPath(): string {
134152
return '//button[normalize-space()="Create Labels"]';
135153
}
136154
}

playwright-e2e/dss/component/table.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ export default class Table {
356356
}
357357

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

362362
private parseForNumber(text: string): number | null {
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import {expect} from '@playwright/test';
2+
import {test} from 'fixtures/dsm-fixture';
3+
import {WelcomePage} from 'dsm/pages/welcome-page';
4+
import {Navigation} from 'dsm/component/navigation/navigation';
5+
import {StudyEnum} from 'dsm/component/navigation/enums/selectStudyNav-enum';
6+
import {SamplesNavEnum} from 'dsm/component/navigation/enums/samplesNav-enum';
7+
import {KitTypeEnum} from 'dsm/component/kitType/enums/kitType-enum';
8+
import KitUploadPage from 'dsm/pages/kitUpload-page/kitUpload-page';
9+
10+
// don't run in parallel
11+
test.describe.serial('Blood Kits upload flow', () => {
12+
let welcomePage: WelcomePage;
13+
let navigation: Navigation;
14+
15+
const studies = [StudyEnum.OSTEO2, StudyEnum.PANCAN, StudyEnum.RGP];
16+
17+
test.beforeEach(({page, request}) => {
18+
welcomePage = new WelcomePage(page);
19+
navigation = new Navigation(page, request);
20+
});
21+
22+
for (const study of studies) {
23+
test(`Kit Upload page ui @dsm @${study} @kit`, async ({page}) => {
24+
const expectedKitSelection = getExpectedKitSelection(study);
25+
await welcomePage.selectStudy(study);
26+
27+
// Kit Upload page
28+
const kitUploadPage = await navigation.selectFromSamples<KitUploadPage>(SamplesNavEnum.KIT_UPLOAD);
29+
await kitUploadPage.waitForReady(expectedKitSelection);
30+
31+
for (const kitType of expectedKitSelection) {
32+
await expect.soft(kitUploadPage.browseBtn).toBeHidden();
33+
await kitUploadPage.selectKitType(kitType);
34+
await expect.soft(kitUploadPage.browseBtn).toBeVisible();
35+
await kitUploadPage.selectKitType(kitType); // un-check
36+
}
37+
38+
expect(test.info().errors).toHaveLength(0);
39+
})
40+
}
41+
42+
function getExpectedKitSelection(study: StudyEnum): KitTypeEnum[] {
43+
let types = [KitTypeEnum.SALIVA, KitTypeEnum.BLOOD];
44+
switch (study) {
45+
case StudyEnum.PANCAN:
46+
types = types.concat([KitTypeEnum.STOOL]);
47+
break;
48+
case StudyEnum.RGP:
49+
types = [KitTypeEnum.BLOOD, KitTypeEnum.BLOOD_AND_RNA];
50+
break;
51+
}
52+
return types;
53+
}
54+
})
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import {expect} from '@playwright/test';
2+
import {test} from 'fixtures/dsm-fixture';
3+
import {WelcomePage} from 'dsm/pages/welcome-page';
4+
import {Navigation} from 'dsm/component/navigation/navigation';
5+
import {StudyEnum} from 'dsm/component/navigation/enums/selectStudyNav-enum';
6+
import {SamplesNavEnum} from 'dsm/component/navigation/enums/samplesNav-enum';
7+
import {KitTypeEnum} from 'dsm/component/kitType/enums/kitType-enum';
8+
import KitsWithoutLabelPage from 'dsm/pages/kitsInfo-pages/kitsWithoutLabel-page';
9+
import {KitsColumnsEnum} from 'dsm/pages/kitsInfo-pages/enums/kitsColumns-enum';
10+
import { studyShortName } from 'utils/test-utils';
11+
12+
// don't run in parallel
13+
test.describe.serial('Blood Kits upload flow', () => {
14+
let welcomePage: WelcomePage;
15+
let navigation: Navigation;
16+
17+
const studies = [StudyEnum.OSTEO2, StudyEnum.PANCAN, StudyEnum.RGP];
18+
19+
test.beforeEach(({page, request}) => {
20+
welcomePage = new WelcomePage(page);
21+
navigation = new Navigation(page, request);
22+
});
23+
24+
for (const study of studies) {
25+
test(`Kit Upload page ui @dsm @${study} @kit`, async ({page}) => {
26+
const expectedKitSelection = getExpectedKitSelection(study);
27+
const { realm: expectedRealm } = studyShortName(study);
28+
await welcomePage.selectStudy(study);
29+
30+
// Kit Upload page
31+
const kitsWithoutLabelPage = await navigation.selectFromSamples<KitsWithoutLabelPage>(SamplesNavEnum.KITS_WITHOUT_LABELS);
32+
await kitsWithoutLabelPage.waitForReady(expectedKitSelection);
33+
const kitsTable = kitsWithoutLabelPage.kitsWithoutLabelTable;
34+
35+
for (const kitType of expectedKitSelection) {
36+
await kitsWithoutLabelPage.selectKitType(kitType);
37+
await expect(page.locator(kitsWithoutLabelPage.reloadKitListBtnXPath)).toBeEnabled();
38+
const rows = await kitsTable.getRowsCount();
39+
if (rows > 0) {
40+
await expect(page.locator(kitsWithoutLabelPage.createLabelsBtnXPath)).toBeDisabled();
41+
await kitsTable.rowCountButton(50).isVisible() && await kitsTable.changeRowCount(50);
42+
} else {
43+
await expect(page.locator('h4')).toHaveText('There are no kit requests');
44+
expect(await kitsTable.exists()).toBeFalsy();
45+
}
46+
for (let i = 0; i < rows; i++) {
47+
const typeValue = (await kitsTable.getRowText(i, KitsColumnsEnum.TYPE)).trim();
48+
// Kits in different types are not mixed. Kits should be uploaded for the right type.
49+
expect.soft(typeValue).toStrictEqual(kitType);
50+
const shortId = (await kitsTable.getRowText(i, KitsColumnsEnum.SHORT_ID)).trim();
51+
expect(shortId?.length).toBeTruthy();
52+
const realm = (await kitsTable.getRowText(i, KitsColumnsEnum.DDP_REALM)).trim();
53+
expect(realm).toStrictEqual(expectedRealm);
54+
}
55+
}
56+
57+
expect(test.info().errors).toHaveLength(0);
58+
})
59+
}
60+
61+
function getExpectedKitSelection(study: StudyEnum): KitTypeEnum[] {
62+
let types = [KitTypeEnum.SALIVA, KitTypeEnum.BLOOD];
63+
switch (study) {
64+
case StudyEnum.PANCAN:
65+
types = types.concat([KitTypeEnum.STOOL]);
66+
break;
67+
case StudyEnum.RGP:
68+
types = [KitTypeEnum.BLOOD, KitTypeEnum.BLOOD_AND_RNA];
69+
break;
70+
}
71+
return types;
72+
}
73+
})

playwright-e2e/tests/dsm/kitUploadFlow/blood-and-rna-kit-upload-flow.spec.ts renamed to playwright-e2e/tests/dsm/kitUploadFlow/rgp-blood-and-rna-kit-upload-flow.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ test.describe.skip('Blood & RNA Kit Upload', () => {
8888
//Upload a Blood & RNA kit
8989
const kitUploadPage = await navigation.selectFromSamples<KitUploadPage>(SamplesNavEnum.KIT_UPLOAD);
9090
await kitUploadPage.waitForReady(expectedKitTypes);
91-
await kitUploadPage.assertPageTitle();
9291
await kitUploadPage.selectKitType(kitType);
9392
await kitUploadPage.assertBrowseBtn();
9493
await kitUploadPage.assertUploadKitsBtn();

playwright-e2e/utils/test-utils.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,11 @@ export function studyShortName(study: StudyEnum): { shortName: string | null; re
262262
realm = 'cmi-esc';
263263
collaboratorPrefix = 'GECProject';
264264
break;
265+
case StudyEnum.RGP:
266+
shortName = 'rgp';
267+
realm = 'RGP';
268+
collaboratorPrefix = 'NULL';
269+
break;
265270
default:
266271
throw new Error(`Study ${study} is undefined.`);
267272
}

0 commit comments

Comments
 (0)