Skip to content

Pepper 1588 use pancan for followup survey test #2449

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 5 commits 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
3 changes: 3 additions & 0 deletions playwright-e2e/dsm/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export enum CustomizeView {
REGISTRATION = 'Registration Columns',
RESEARCH_CONSENT_ASSENT_FORM = 'Research Consent & Assent Form Columns',
RESEARCH_CONSENT_FORM = 'Research Consent Form Columns',
RESEARCH_CONSENT_FORM_BLOOD_DRAW = 'Research Consent Form (Blood Draw) Columns',
SAMPLE = 'Sample Columns',
SIBLING = 'Sibling Columns',
SURVEY_ABOUT_YOU = `Survey: About your child/you Columns`,
Expand All @@ -95,6 +96,7 @@ export enum CustomizeViewID {
ADDITIONAL_DETAILS = 'FAMILY_HISTORY_SELF_ADDITIONAL_DETAILS',
BIRTH_PARENT_FEMALE = 'FAMILY_HISTORY_SELF_PARENT1',
BIRTH_PARENT_MALE = 'FAMILY_HISTORY_SELF_PARENT2',
BLOOD_CONSENT = 'BLOOD_CONSENT',
CHILD = 'FAMILY_HISTORY_SELF_CHILD',
CLINICAL_ORDER = 'cl',
COHORT_TAG = 'c',
Expand Down Expand Up @@ -232,6 +234,7 @@ export enum Label {
BLOCK_ID = 'Block Id',
BLOCK_ID_TO_SHL = 'Block ID to SHL',
BLOCKS_WITH_TUMOR = 'Blocks with Tumor',
BLOOD_CONSENT_SURVEY_CREATED = 'BLOOD_CONSENT Survey Created',
CERTAIN_TEXT = 'CertainText',
CHILD_ADOLESCENT_ASSENT = `Child/Adolescent Assent`,
CHILD_CONTACT_COMPLETED = 'CHILD_CONTACT Survey Completed',
Expand Down
34 changes: 28 additions & 6 deletions playwright-e2e/dss/pages/family-history.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect, Locator, Page } from '@playwright/test';
import Question from 'dss/component/Question';
import { booleanToYesOrNo, waitForResponse } from 'utils/test-utils';
import { booleanToYesOrNo, check, waitForResponse } from 'utils/test-utils';
import { CancerSelector } from 'dss/pages/cancer-selector';
import { BrainBasePage } from 'dss/pages/brain/brain-base-page';

Expand All @@ -12,11 +12,17 @@ export enum Section {
INTRODUCTION = 'Introduction',
INSTRUCTIONS = 'Instructions',
YOUR_PARENTS = 'Your Parents',
YOUR_CHILDS_PARENTS = `Your Child's Parents`,
YOUR_PARENTS_SIBLINGS = "Your Parents' Siblings",
YOUR_CHILDS_PARENTS_SIBLINGS = `Your Child's Parents' Siblings`,
YOUR_GRANDPARENTS = 'Your Grandparents',
YOUR_CHILDS_GRANDPARENTS = `Your Child's Grandparents`,
YOUR_SIBLINGS = 'Your Siblings',
YOUR_CHILDS_SIBLINGS = `Your Child's Siblings`,
YOUR_HALF_SIBLINGS = 'Your Half-Siblings',
YOUR_CHILDS_HALF_SIBLINGS = `Your Child's Half-Siblings`,
YOUR_CHILDREN = 'Your Children',
YOUR_CHILDS_CHILDREN = `Your Child's Children`,
ADDITIONAL_DETAILS = 'Additional details'
}

Expand Down Expand Up @@ -94,13 +100,19 @@ export class FamilyHistory extends BrainBasePage {
await this.page.getByRole('button', { name: 'Add a Child' }).click();
}

async addFamilyMember(relationship: string, p: FamilyMember): Promise<void> {
async addFamilyMember(relationship: string, p: FamilyMember, customSelectorBase?: string): Promise<void> {
if (relationship === 'PARENT1') {
await this.page.locator('mat-card-content').filter({ hasText: 'Biological / Birth Parent 1' }).getByRole('button', { name: 'Edit' }).click();
} else if (relationship === 'PARENT2') {
await this.page.locator('mat-card-content').filter({ hasText: 'Biological / Birth Parent 2' }).getByRole('button', { name: 'Edit' }).click();
}
const selectorBase = `FH_${relationship}`;

let selectorBase = '';
if (customSelectorBase) {
selectorBase = customSelectorBase;
} else {
selectorBase = `FH_${relationship}`;
}

await this.page.getByTestId(`answer:${selectorBase}_ALIAS`).fill(p.nickname);
await this.page.locator(`.picklist-answer-${selectorBase}_LIVING`).getByText(booleanToYesOrNo(p.currentlyLiving), { exact: true }).click();
Expand Down Expand Up @@ -167,13 +179,23 @@ export class FamilyHistory extends BrainBasePage {
await expect(sectionTitle).toBeVisible();
}

async clickDoNotHaveChildren(): Promise<void> {
const checkbox = this.page.locator(`//mat-checkbox[contains(., 'Not applicable; I do not have any children.')]`);
async clickDoNotHaveChildren(hasCustomTextDifference?: boolean): Promise<void> {
let checkbox: Locator;
if (hasCustomTextDifference) {
checkbox = this.page.locator(`//mat-checkbox[contains(., 'Not applicable, I do not have any children.')]`);
} else {
checkbox = this.page.locator(`//mat-checkbox[contains(., 'Not applicable; I do not have any children.')]`);
}
await expect(checkbox).toBeVisible();
await checkbox.click();
}

async clickChildDoesNotHaveChildren(): Promise<void> {
const checkbox = this.page.locator(`//mat-checkbox[contains(., 'Not applicable, my child does not have any children.')]`);
await checkbox.click();
}

additionalDetails(): Locator {
return this.page.locator(`//ddp-activity-answer//textarea[@data-ddp-test='answer:FH_OTHER_FACTORS_CANCER_RISK']`);
return this.page.locator(`//ddp-activity-answer//textarea[contains(@data-ddp-test, 'OTHER_FACTORS_CANCER_RISK')]`);
}
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@
import { expect } from '@playwright/test';
import { expect, Page } from '@playwright/test';
import Modal from 'dsm/component/modal';
import { test } from 'fixtures/dsm-fixture';
import FollowUpSurveyPage from 'dsm/pages/follow-up-survey-page';
import { getDate } from 'utils/date-utils';
import { generateAlphaNumeric, generateRandomNum } from 'utils/faker-utils';
import { waitForResponse } from 'utils/test-utils';
import { Label } from 'dsm/enums';
import { StudyName } from 'dsm/navigation';
import { CustomizeView as CV, CustomizeViewID as ID, DataFilter, Label } from 'dsm/enums';
import { Navigation, Study, StudyName } from 'dsm/navigation';
import Select from 'dss/component/select';
import ParticipantListPage from 'dsm/pages/participant-list-page';

//TODO Replace with Pancan - since that study is ongoing
test.describe.skip('Create Follow-Up Survey', () => {
const studies = [StudyName.PROSTATE];
test.describe('Create Follow-Up Survey', () => {
const studies = [StudyName.PANCAN];
let followupSurveyPage: FollowUpSurveyPage;

for (const study of studies) {
const survey = surveysForStudy(study);
test(`${survey} in @${study} @dsm @functional`, async ({ page, request }) => {
followupSurveyPage = await FollowUpSurveyPage.goto(page, study, request);
const navigation = new Navigation(page, request);
await new Select(page, { label: 'Select study' }).selectOption(`${study}`);
const participantListPage = await navigation.selectFromStudy<ParticipantListPage>(Study.PARTICIPANT_LIST);
await participantListPage.waitForReady();

//Find a partiicpant without a Blood Consent who can be used to trigger both Blood Consent and Diet/Lifestyle Survey
const shortID = findParticipantWithoutBloodConsent(page, participantListPage);
/*followupSurveyPage = await FollowUpSurveyPage.goto(page, study, request);
await followupSurveyPage.waitForReady();

await followupSurveyPage.selectSurvey(survey);
Expand All @@ -25,9 +33,9 @@ test.describe.skip('Create Follow-Up Survey', () => {
expect(rowsCount).toBeGreaterThanOrEqual(1);

// Find any participant ID to create new survey (repeating)
const randRowIndex = generateRandomNum(0, rowsCount);
const participantId = await previousSurveysTable.getRowText(randRowIndex, Label.PARTICIPANT_ID);
expect(participantId).not.toBeNull();
//const randRowIndex = generateRandomNum(0, rowsCount);
//const participantId = await previousSurveysTable.getRowText(randRowIndex, Label.PARTICIPANT_ID);
//expect(participantId).not.toBeNull();

// Create new survey by fill out participant ID and reason
const reason = `playwright testing ${generateAlphaNumeric()}`;
Expand All @@ -45,6 +53,7 @@ test.describe.skip('Create Follow-Up Survey', () => {
return item.surveyInfo.participantId === participantId && item.reason === reason
});
expect(filterResult.length).toBe(1);
*/
});
}

Expand All @@ -65,4 +74,18 @@ test.describe.skip('Create Follow-Up Survey', () => {
}
return survey;
}

async function findParticipantWithoutBloodConsent(page: Page, participantListPage: ParticipantListPage): Promise<string> {
const customizeViewPanel = participantListPage.filters.customizeViewPanel;
await customizeViewPanel.open();
await customizeViewPanel.openColumnGroup({ columnSection: CV.RESEARCH_CONSENT_FORM_BLOOD_DRAW, stableID: ID.BLOOD_CONSENT });
await customizeViewPanel.selectColumns('Research Consent Form (Blood Draw) Columns', [Label.BLOOD_CONSENT_SURVEY_CREATED]);
await customizeViewPanel.close();

const searchPanel = participantListPage.filters.searchPanel;
await searchPanel.open();
//Find enrolled participant without a blood consent
await searchPanel.checkboxes(Label.STATUS, { checkboxValues: [DataFilter.ENROLLED] });
return 'test';
}
});
Loading