Skip to content

[BLOCKED] [DSM] PEPPER-848 Playwright test for return of results #2271

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

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export enum AdditionalFilter {
}

export enum CustomViewColumns {
ADDITIONAL_CONSENT = 'Additional Consent: Learning About Your Tumor Columns',
CONTACT_INFORMATION = 'Contact Information Columns',
COHORT_TAGS = 'Cohort Tags Columns',
DSM_COLUMNS = 'Participant - DSM Columns',
Expand Down
87 changes: 87 additions & 0 deletions playwright-e2e/tests/dsm/return-of-results.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import { expect } from '@playwright/test';
import { test } from 'fixtures/dsm-fixture';
import { CustomViewColumns } from 'dsm/component/filters/sections/search/search-enums';
import { StudyEnum } from 'dsm/component/navigation/enums/selectStudyNav-enum';
import ParticipantListPage from 'dsm/pages/participant-list-page';
import { shuffle, studyShortName } from 'utils/test-utils';
import { logInfo } from 'utils/log-utils';
import ParticipantPage from 'dsm/pages/participant-page/participant-page';
import OncHistoryTab from 'dsm/component/tabs/onc-history-tab';
import { TabEnum } from 'dsm/component/tabs/enums/tab-enum';
import { OncHistoryInputColumnsEnum, OncHistorySelectRequestEnum } from 'dsm/component/tabs/enums/onc-history-input-columns-enum';
import { SortOrder } from 'dss/component/table';
import { ParticipantListTable } from 'dsm/component/tables/participant-list-table';

test.describe('Return of Results Letter', () => {
// Some studies are excluded due to lack of the suitable paricipants
const studies: StudyEnum[] = [StudyEnum.OSTEO2, StudyEnum.PANCAN, StudyEnum.MBC, StudyEnum.BRAIN];

for (const study of studies) {
let participantListPage: ParticipantListPage;
let participantListTable: ParticipantListTable;
let rowIndex: number;

test(`Check in @dsm @${study}`, async ({ page, request }) => {
participantListPage = await ParticipantListPage.goto(page, study, request);
participantListTable = participantListPage.participantListTable;
const customizeViewPanel = participantListPage.filters.customizeViewPanel;

await test.step('Find an enrolled adult participant that has consented yes to tissue, and yes to receiving tumor shared learning', async () => {
const consentTissueColumn = 'CONSENT_TISSUE';
const consentTumorColumn = 'SOMATIC_CONSENT_TUMOR';
await customizeViewPanel.open();
await customizeViewPanel.selectColumns(CustomViewColumns.RESEARCH_CONSENT_FORM, [consentTissueColumn]);
await customizeViewPanel.selectColumns(CustomViewColumns.ADDITIONAL_CONSENT, [consentTumorColumn]);

const searchPanel = participantListPage.filters.searchPanel;
await searchPanel.open();
await searchPanel.checkboxes('Status', { checkboxValues: ['Enrolled'] });
await searchPanel.checkboxes(consentTissueColumn, { checkboxValues: ['Yes'] });
// Bug: https://broadworkbench.atlassian.net/browse/PEPPER-1083
// await searchPanel.checkboxes(consentTumorColumn, { checkboxValues: ['Yes'] });
await searchPanel.search();
await participantListTable.changeRowCount(50);
// bug workaround
rowIndex = await findRowIndex(participantListTable, consentTumorColumn, 'Yes');
expect(rowIndex).toBeGreaterThanOrEqual(0);
});

// Open Participant page
const participantPage: ParticipantPage = await participantListTable.openParticipantPageAt(rowIndex);
const oncHistoryTab = await participantPage.clickTab<OncHistoryTab>(TabEnum.ONC_HISTORY);
const oncHistoryTable = oncHistoryTab.table;


await test.step('TODO', async () => {
//
});
});
}

async function findRowIndex(participantListTable: ParticipantListTable, columnName: string, value: string): Promise<number> {
let participantsCount = await participantListTable.numOfParticipants();
expect(participantsCount).toBeGreaterThanOrEqual(1);
const endTime = Date.now() + 90 * 1000;
while (participantsCount > 0 && Date.now() < endTime) {
let rowIndex = -1;
// Iterate rows in random order
const array = shuffle([...Array(participantsCount).keys()]);
for (const index of array) {
const columnText = await participantListTable.getTextAt(index, columnName);
rowIndex = columnText.some(text => text.indexOf(value) !== -1) ? index : -1;
if (rowIndex !== -1) {
return rowIndex;
}
}
// Next page in table if needed
const hasNextPage = await participantListTable.paginator.hasNext();
if (hasNextPage) {
await participantListTable.nextPage();
participantsCount = await participantListTable.rowsCount;
} else {
participantsCount = 0;
}
}
return -1;
}
});