|
| 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 KitsWithoutLabelPage from 'dsm/pages/kitsInfo-pages/kitsWithoutLabel-page'; |
| 8 | +import {KitsColumnsEnum} from 'dsm/pages/kitsInfo-pages/enums/kitsColumns-enum'; |
| 9 | +import {getExpectedKitSelection, studyShortName} from 'utils/test-utils'; |
| 10 | + |
| 11 | +test.describe('Kits without Labels UI', () => { |
| 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(`Page verifications @dsm @${study} @kit`, async ({page}) => { |
| 24 | + const expectedKitSelection = getExpectedKitSelection(study); |
| 25 | + const { realm: expectedRealm } = studyShortName(study); |
| 26 | + await welcomePage.selectStudy(study); |
| 27 | + |
| 28 | + const kitsWithoutLabelPage = await navigation.selectFromSamples<KitQueuePage>(SamplesNavEnum.QUEUE); |
| 29 | + await kitsWithoutLabelPage.waitForReady(expectedKitSelection); |
| 30 | + const kitsTable = kitsWithoutLabelPage.kitsWithoutLabelTable; |
| 31 | + |
| 32 | + for (const kitType of expectedKitSelection) { |
| 33 | + await kitsWithoutLabelPage.selectKitType(kitType); |
| 34 | + await expect(page.locator(kitsWithoutLabelPage.reloadKitListBtnXPath)).toBeEnabled(); |
| 35 | + const rows = await kitsTable.getRowsCount(); |
| 36 | + if (rows > 0) { |
| 37 | + await expect(page.locator(kitsWithoutLabelPage.createLabelsBtnXPath)).toBeDisabled(); |
| 38 | + await kitsTable.rowCountButton(50).isVisible() && await kitsTable.changeRowCount(50); |
| 39 | + } else { |
| 40 | + await expect(page.locator('h4')).toHaveText('There are no kit requests'); |
| 41 | + expect(await kitsTable.exists()).toBeFalsy(); |
| 42 | + } |
| 43 | + for (let i = 0; i < rows; i++) { |
| 44 | + const typeValue = (await kitsTable.getRowText(i, KitsColumnsEnum.TYPE)).trim(); |
| 45 | + // Kits in different types are not mixed. Kits should be uploaded for the right type. |
| 46 | + expect.soft(typeValue).toStrictEqual(kitType); |
| 47 | + const shortId = (await kitsTable.getRowText(i, KitsColumnsEnum.SHORT_ID)).trim(); |
| 48 | + expect(shortId?.length).toBeTruthy(); |
| 49 | + const realm = (await kitsTable.getRowText(i, KitsColumnsEnum.DDP_REALM)).trim(); |
| 50 | + expect(realm).toStrictEqual(expectedRealm); |
| 51 | + } |
| 52 | + } |
| 53 | + |
| 54 | + expect(test.info().errors).toHaveLength(0); |
| 55 | + }) |
| 56 | + } |
| 57 | +}) |
0 commit comments