Skip to content

Playwright_RGP_Check proband referral source against ptp entered sources #2234

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

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
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
56 changes: 54 additions & 2 deletions playwright-e2e/dsm/pages/participant-page/rgp/family-member-tab.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { expect, Locator, Page } from '@playwright/test';
import { FamilyMember } from 'dsm/component/tabs/enums/familyMember-enum';
import TextArea from 'dss/component/textarea';
import { find } from 'lodash';
import { waitForResponse } from 'utils/test-utils';

/**
Expand Down Expand Up @@ -109,6 +110,11 @@ export default class FamilyMemberTab {
return this.page.getByRole('tabpanel').getByText('Jump to:');
}

//todo Should probably make this a more general method to be applied across studies
public getSurveyDataTab(): Locator {
return this.page.locator(`//app-participant-page//ul//a[contains(., 'Survey Data')]`);
}

public getParticipantInfoMenuLink(): Locator {
return this.page.getByRole('tabpanel').locator('a').filter({ hasText: 'Participant Info' });
}
Expand Down Expand Up @@ -278,19 +284,21 @@ export default class FamilyMemberTab {
*/
public async inputMixedRaceNotes(notes: string): Promise<void> {
const textarea = new TextArea(this.page, {label: 'Mixed Race Notes'});
console.log(`Previous text: ${await textarea.getText()}`);
await textarea.clear();
await Promise.all([
waitForResponse(this.page, {uri: 'ui/patch'}),
textarea.fill(notes)
textarea.fill(notes),
]);
console.log(`New text: ${await textarea.getText()}`);
}

/**
* Returns the text content of the Mixed Race Notes textarea
* @returns contents of the Mixed Race Notes textarea
*/
public async getMixedRaceNotesContent(): Promise<string> {
return (await this.page.locator("//textarea[contains(@data-placeholder, 'Mixed Race Notes')]").inputValue()).toString();
return new TextArea(this.page, {label: 'Mixed Race Notes'}).getText();
}

/**
Expand Down Expand Up @@ -642,7 +650,51 @@ export default class FamilyMemberTab {
return this.page.locator("//td[contains(text(), 'RedCap Survey Completed Date')]/following-sibling::td//div/input");
}

public getTellUsAboutYourFamilySection(): Locator {
return this.page.locator(`//app-activity-data//mat-expansion-panel[@id='ENROLLMENT']`);
}

private howDidYouFindOutAboutThisProjectSection(): Locator {
return this.page.locator(`//app-activity-data//h5[contains(., 'FIND_OUT')]`);
}

private async getAllParticipantReferralSources(): Promise<Locator[]> {
//const findOutSection = this.howDidYouFindOutAboutThisProjectSection();
//Uses the following xpath to get all listed sources: //app-activity-data//h5[contains(., 'FIND_OUT')]/parent::div//div//ul[@class='ng-star-inserted']
//return findOutSection.locator(`/parent::div//div//ul[contains(@class, 'ng-star-inserted')]`).all();
return this.page.locator(`//app-activity-data//h5[contains(., 'FIND_OUT')]/parent::div//div//ul[@class='ng-star-inserted']`).all();
}

private getSingleReferralSource(): Locator {
const findOutSection = this.howDidYouFindOutAboutThisProjectSection();
return findOutSection.locator(`/parent::div//div//ul[@class='ng-star-inserted']//li//b`);
}

/* Utility methods */
public async getStudyParticipantResponseForReferralSource(): Promise<string> {
const surveyData = this.getSurveyDataTab();
await surveyData.click();
await expect(surveyData, 'ERROR - RGP: Survey Data tab is not selected').toHaveAttribute('aria-selected', 'true');

const tellUsAboutYourFamilySection = this.getTellUsAboutYourFamilySection();
await expect(tellUsAboutYourFamilySection, 'ERROR - RGP: Tell Us About Your Family section is not visible in Survey Data tab').toBeVisible();
await tellUsAboutYourFamilySection.click();

const participantReferralSources = this.getAllParticipantReferralSources();
const amountOfReferralSources = (await participantReferralSources).length;
let referralSource = 'unknown';

//Determine the official referral source based on how many sources the study participant selected/provided
if (amountOfReferralSources === 0) {
referralSource = 'Not provided';
} else if (amountOfReferralSources === 1) {
referralSource = await this.getSingleReferralSource().innerText();
} else if (amountOfReferralSources > 1) {
referralSource = 'More than one';
}
return referralSource;
}

public async setRandomRelationshipID(): Promise<void> {
const usedRelationshipIDs = await this.getListOfUsedSubjectIDs();
let searchingForID = true;
Expand Down
29 changes: 21 additions & 8 deletions playwright-e2e/tests/rgp/dsm-family-enrollment.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { v4 as uuid } from 'uuid';
import ParticipantPage from 'dsm/pages/participant-page/participant-page';
import { WelcomePage } from 'dsm/pages/welcome-page';
import { StudyEnum } from 'dsm/component/navigation/enums/selectStudyNav-enum';
import * as crypto from 'crypto';


test.describe.serial('DSM Family Enrollment Handling', () => {
Expand Down Expand Up @@ -104,8 +105,8 @@ test.describe.serial('DSM Family Enrollment Handling', () => {
saveParticipantGuid(participantGuid);
await participantListPage.filterListByParticipantGUID(user.patient.participantGuid);
//Check that the filtered list returns at least one participant
const filteredList = page.locator('tr.ng-star-inserted');
await expect(filteredList).toHaveCount(1);
const filteredList = await participantListTable.numOfParticipants();
expect(filteredList).toBe(1);
await participantListTable.openParticipantPageAt(0);

//Verify that the proband tab is present (and includes the text RGP and 3 as proband subject ids have the format RGP_{family id}_3)
Expand Down Expand Up @@ -239,7 +240,7 @@ test.describe.serial('DSM Family Enrollment Handling', () => {
const familyAccount = new RgpParticipantPage(page);
await familyAccount.backToList();
await participantListPage.filters.searchPanel.search();
await expect(filteredList).toHaveCount(1);
expect(filteredList).toBe(1);
await participantListTable.openParticipantPageAt(0);

//After refreshing participant list and page, check that the input for the above textareas are as expected
Expand All @@ -251,10 +252,12 @@ test.describe.serial('DSM Family Enrollment Handling', () => {
//Checking textarea content
const importantNotesTextarea = proband.getImportantNotes();
const processNotesTextarea = proband.getProcessNotes();
const mixedRaceTextarea = proband.getMixedRaceNotes();
//const mixedRaceTextarea = proband.getMixedRaceNotes();
const mixedRaceTextarea = await proband.getMixedRaceNotesContent();
expect(await importantNotesTextarea.inputValue()).toBe(importantNotes);
expect(await processNotesTextarea.inputValue()).toBe(processNotes);
expect(await mixedRaceTextarea.inputValue()).toBe(mixedRaceNotes);
expect(mixedRaceTextarea).toBe(mixedRaceTestingNotes);
//expect(await mixedRaceTextarea.inputValue()).toBe(mixedRaceNotes);

//Fill out Contact Info section
const contactInfoSection = proband.getContactInfoSection();
Expand Down Expand Up @@ -364,10 +367,20 @@ test.describe.serial('DSM Family Enrollment Handling', () => {
const familyProvidedURL = proband.getFamilyUrlProvided();
await familyProvidedURL.fill('https://en.wikipedia.org/wiki/Broad_Institute');

//todo Update testing Referral Source to check for functionality from ticket PEPPER-575 (ticket in-progress)
//Check Survey Data to get the referral source and then check the proband tab to make sure the related source is selected as expected
const surveyData = proband.getSurveyDataTab();
await surveyData.scrollIntoViewIfNeeded();
await surveyData.click();

const participantReferralSource = await proband.getStudyParticipantResponseForReferralSource();
console.log(`Participant Referral Source: ${participantReferralSource}`);
await probandTab.click();
await medicalRecordsSection.click();

const referralSource = proband.getReferralSource();
await referralSource.click();
await dropdownOptions.filter({ hasText: 'Doctor' }).click();
await referralSource.scrollIntoViewIfNeeded();
await expect(referralSource, `RGP Referral Source - Expected '${participantReferralSource}' but got: ${await referralSource.innerText()}`)
.toHaveText(participantReferralSource);

await proband.inputReferralNotes('Testing notes here - Referral Notes');

Expand Down