|
| 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 | +}) |
0 commit comments