Skip to content
Merged
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
6 changes: 6 additions & 0 deletions .circleci/export-playwright-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ export lmsUserPassword=$(vault read --format=json secret/pepper/test/v1/e2e | jq
echo "export LMS_USER_PASSWORD=$lmsUserPassword" >> playwright-env/envvars
echo "export LMS_USER_EMAIL=$lmsUser" >> playwright-env/envvars

# MBC
export mbcUser=$(vault read --format=json secret/pepper/test/v1/e2e | jq -r ".data.users | .[] | select(.app==\"mbc\") | .userName")
export mbcUserPassword=$(vault read --format=json secret/pepper/test/v1/e2e | jq -r ".data.users | .[] | select(.app==\"mbc\") | .password")
echo "export MBC_USER_PASSWORD=$mbcUserPassword" >> playwright-env/envvars
echo "export MBC_USER_EMAIL=$mbcUser" >> playwright-env/envvars

# ATCP
export atcpUser=$(vault read --format=json secret/pepper/test/v1/e2e | jq -r ".data.users | .[] | select(.app==\"atcp\") | .userName")
export atcpUserPassword=$(vault read --format=json secret/pepper/test/v1/e2e | jq -r ".data.users | .[] | select(.app==\"atcp\") | .password")
Expand Down
5 changes: 5 additions & 0 deletions playwright-e2e/config/.env.dev
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,8 @@ BRAIN_USER_PASSWORD=
LMS_BASE_URL=https://lms.dev.datadonationplatform.org
LMS_USER_EMAIL=
LMS_USER_PASSWORD=

# MBC
MBC_BASE_URL=https://mbc.dev.datadonationplatform.org
MBC_USER_EMAIL=
MBC_USER_PASSWORD=
5 changes: 5 additions & 0 deletions playwright-e2e/config/.env.staging
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,8 @@ BRAIN_USER_PASSWORD=
LMS_USER_EMAIL=
LMS_USER_PASSWORD=
LMS_BASE_URL=https://lms.staging.datadonationplatform.org

# MBC
MBC_BASE_URL=https://mbc.staging.datadonationplatform.org
MBC_USER_EMAIL=
MBC_USER_PASSWORD=
5 changes: 5 additions & 0 deletions playwright-e2e/config/.env.test
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,8 @@ BRAIN_USER_PASSWORD=
LMS_USER_EMAIL=
LMS_USER_PASSWORD=
LMS_BASE_URL=https://lms.test.datadonationplatform.org

# MBC
MBC_BASE_URL=https://mbc.test.datadonationplatform.org
MBC_USER_EMAIL=
MBC_USER_PASSWORD=
143 changes: 143 additions & 0 deletions playwright-e2e/dss/pages/mbc/mbc-follow-up-survey-1.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
import {MBCPageBase} from './mbc-page-base';
import {expect, Locator, Page} from '@playwright/test';
import {waitForNoSpinner} from 'utils/test-utils';
import Question from '../../component/Question';

type yesNoDontKnow = 'Yes' | 'No' | "I don't know";

interface MedicationDetails {
medication: string,
startDate: {
month: string,
year: string
},
endDate?: {
month: string,
year: string
}
}

export class MBCFollowUpSurvey1 extends MBCPageBase {
private readonly pageTitle: Locator;
private readonly title = 'Follow-up survey #1: Additional details about your cancer & treatments';

constructor(page: Page) {
super(page);
this.pageTitle = this.page.locator('h1.PageHeader-title');
}

public async waitForReady(): Promise<void> {
await expect(this.pageTitle).toHaveText(this.title);
await waitForNoSpinner(this.page);
}

/**
* <br> Question: Please select all the places in your body where you currently have metastatic breast cancer to the best of your knowledge (select all that apply). If you don’t have any detectable disease please select No Evidence of Disease (NED).
*/
public async currentCancerLocation(answer: string): Promise<void> {
const question = new Question(this.page, {cssClassAttribute: '.picklist-answer-CURRENT_CANCER_LOC'});
await question.toCheckbox(answer).check();
}

/**
* <br> Question: When you were first diagnosed with metastatic breast cancer, where were all of the places in your body that it was detected (select all that apply)?
*/
public async diagnosisCancerLocation(answer: string): Promise<void> {
const question = new Question(this.page, {cssClassAttribute: '.picklist-answer-DIAGNOSIS_CANCER_LOC'});
await question.toCheckbox(answer).check();
}

/**
* <br> Question: Please select all of the places in your body that metastatic breast cancer has been found at any time (select all that apply)?
*/
public async anytimeCancerLocation(answer: string): Promise<void> {
const question = new Question(this.page, {cssClassAttribute: '.picklist-answer-ANYTIME_CANCER_LOC'});
await question.toCheckbox(answer).check();
}

/**
* <br> Question: Was your breast cancer identified as any of the following at any time (select all that apply)?
*/
public async cancerIdentification(answer: string): Promise<void> {
const question = new Question(this.page, {cssClassAttribute: '.picklist-answer-CANCER_IDENTIFICATION'});
await question.toCheckbox(answer).check();
}

/**
* <br> Question: Are you currently receiving any medications/chemotherapies for treatment of your metastatic breast cancer?
*/
public async currentlyMedicated(answer: yesNoDontKnow, opts?: MedicationDetails): Promise<void> {
await new Question(this.page, {cssClassAttribute: '.picklist-answer-CURRENTLY_MEDICATED'})
.radioButton(answer, {exactMatch: true}).click();
if (opts) {
await this.currentMedicationAnswer(opts);
}
}

/**
* <br> Question: Have you received any other medications/chemotherapies in the past for treatment of your metastatic breast cancer?
*/
public async previouslyMedicated(answer: yesNoDontKnow, opts?: MedicationDetails): Promise<void> {
await new Question(this.page, {cssClassAttribute: '.picklist-answer-PREVIOUSLY_MEDICATED'})
.radioButton(answer, {exactMatch: true}).click();
if (opts) {
await this.pastMedicationAnswer(opts);
}
}

/* Helper functions */
private async currentMedicationAnswer(opts: MedicationDetails): Promise<void> {
await this.page.waitForLoadState('networkidle');

if (opts?.medication) {
const medication = new Question(this.page, {cssClassAttribute: '.composite-answer-CURRENT_MED_LIST'});
await medication.toInput().fill(opts.medication);
}

await this.fillCurrentAndPastMedicationDates('CURRENT', opts);
}

private async pastMedicationAnswer(opts: MedicationDetails): Promise<void> {
if (opts?.medication) {
const medication = new Question(this.page, {cssClassAttribute: '.composite-answer-PAST_MED_LIST'});
await medication.toInput().fill(opts.medication);
}
await this.fillCurrentAndPastMedicationDates('PAST', opts);
}

private async fillCurrentAndPastMedicationDates(cssClassPart: 'CURRENT' | 'PAST', {
startDate,
endDate
}: MedicationDetails): Promise<void> {
if (startDate) {
const startDateQuestion = new Question(this.page,
{
cssClassAttribute: '.picklist',
parentSelector: this.page.locator(`.date-answer-${cssClassPart}_MED_START`)
});
await startDateQuestion.toSelect('Choose month...')
.toLocator()
.selectOption(startDate.month);

await startDateQuestion.toSelect('Choose year...')
.toLocator()
.selectOption(startDate.year)
}

if (endDate) {
const endDateQuestion = new Question(this.page,
{
cssClassAttribute: '.picklist',
parentSelector: this.page.locator(`.date-answer-${cssClassPart}_MED_END`)
}
);
await endDateQuestion.toSelect('Choose month...')
.toLocator()
.selectOption(endDate.month);

await endDateQuestion.toSelect('Choose year...')
.toLocator()
.selectOption(endDate.year);
}
}
}
41 changes: 41 additions & 0 deletions playwright-e2e/dss/pages/mbc/mbc-home-page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import {MBCPageBase} from './mbc-page-base';
import {expect, Locator, Page} from '@playwright/test';
import {waitForNoSpinner} from '../../../utils/test-utils';
import * as auth from '../../../authentication/auth-lms';

export class MBCHomePage extends MBCPageBase {
countMeInButton: Locator;
learnMoreButton: Locator;

constructor(page: Page) {
super(page);
this.countMeInButton = this.page.locator('//span[text()=\'count me \' and @class="CountButton"]');
this.learnMoreButton = this.page.locator('//span[text()[normalize-space()=\'Learn More\']]');
}

async waitForReady(): Promise<void> {
await expect(this.page).toHaveTitle('The Metastatic Breast Cancer Project');
await expect(this.countMeInButton.first()).toBeVisible();
await expect(this.learnMoreButton).toBeVisible();
await expect(this.getLogInButton()).toBeVisible();
await waitForNoSpinner(this.page);
}

async countMeIn(): Promise<void> {
await this.countMeInButton.first().click();
await waitForNoSpinner(this.page);
}

async learnMore(): Promise<void> {
await this.learnMoreButton.click();
await waitForNoSpinner(this.page);
}

async logIn(): Promise<void> {
await auth.login(this.page);
}

override getLogInButton(): Locator {
return this.page.locator('.Header-nav button[data-ddp-test="signInButton"]:has-text("Sign In")');
}
}
16 changes: 16 additions & 0 deletions playwright-e2e/dss/pages/mbc/mbc-join-page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import {MBCPageBase} from './mbc-page-base';
import {Locator, Page} from '@playwright/test';
import Question from '../../component/Question';

export class MBCJoinPage extends MBCPageBase {
readonly pageTitle: Locator;

constructor(page: Page) {
super(page);
this.pageTitle = this.page.locator('h1');
}

whoIsSigningUP(): Question {
return new Question(this.page, {cssClassAttribute: '.picklist-answer-PREQUAL_SELF_DESCRIBE'});
}
}
81 changes: 81 additions & 0 deletions playwright-e2e/dss/pages/mbc/mbc-medical-release-page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import {expect, Locator, Page} from '@playwright/test';
import {MBCPageBase} from './mbc-page-base';
import {waitForNoSpinner} from '../../../utils/test-utils';
import * as user from '../../../data/fake-user.json';
import Institution from '../../component/institution';


export class MBCMedicalReleasePage extends MBCPageBase {
private readonly pageTitle: Locator;

constructor(page: Page) {
super(page);
this.pageTitle = this.page.locator('h1.PageHeader-title');
}

public async waitForReady(): Promise<void> {
await expect(this.pageTitle).toHaveText('Medical Release Form');
await waitForNoSpinner(this.page);
}

public async yourPhysicianName(
opts: {
physicianName?: string;
institutionName?: string;
city?: string;
state?: string;
nth?: number;
} = {}
): Promise<void> {
const {
physicianName = user.doctor.name,
institutionName = user.doctor.hospital,
city = user.doctor.city,
state = user.doctor.state,
nth = 0,
} = opts;

const institution = new Institution(this.page, { label: /Physician/, nth });
await institution.toInput('Physician Name').fill(physicianName);
await institution.toInput('Institution').fill(institutionName);
await institution.toInput('City').fill(city);
await institution.toInput('State').fill(state);
}

/**
* Question: Where was your initial biopsy for breast cancer performed?
* @param opts
*/
public async yourHospitalOrInstitution(
opts: {
institutionName?: string;
city?: string;
state?: string;
nth?: number;
label?: string | RegExp
} = {}
): Promise<void> {
const {
institutionName = user.doctor.hospital,
city = user.doctor.city,
state = user.doctor.state,
nth = 0,
label = /Hospital/
} = opts;

const institution = new Institution(this.page, { label, nth});
await institution.toInput('Institution').fill(institutionName);
await institution.toInput('City').fill(city);
await institution.toInput('State').fill(state);
}

/**
* Question: Where were any other biopsies or surgeries for your breast cancer performed (i.e. biopsy, lumpectomy, partial mastectomy, mastectomy)?
* @param nth
*/
public async addAndFillAnotherInstitution(nth = 0): Promise<void> {
const institution = new Institution(this.page, { label: /other biopsies/});
await institution.toButton('ADD ANOTHER INSTITUTION').click();
await this.yourHospitalOrInstitution({label: /institution/, nth});
}
}
12 changes: 12 additions & 0 deletions playwright-e2e/dss/pages/mbc/mbc-page-base.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import PageBase from '../page-base';
import {Page} from '@playwright/test';

export class MBCPageBase extends PageBase {
protected constructor(page: Page) {
const { MBC_BASE_URL } = process.env;
if (MBC_BASE_URL == null) {
throw Error(`Invalid MBC base URL: process.env.MBC_BASE_URL=${MBC_BASE_URL}`);
}
super(page, MBC_BASE_URL);
}
}
15 changes: 15 additions & 0 deletions playwright-e2e/dss/pages/mbc/mbc-patient-type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export type TypePatient = 'patient' | 'other';


export const MBCPatientsData: any = {
patient: {
whoIsSigningUp: 'I have been diagnosed with metastatic breast cancer (also known as advanced or stage IV breast ' +
"cancer). I'm willing to answer additional questions about myself and my experience with metastatic breast cancer.",
surveyForm: 'Join the movement: tell us about yourself',
},
other: {
whoIsSigningUp: "I haven't been diagnosed with metastatic breast cancer, but I want to stay informed about " +
'the Metastatic Breast Cancer Project by joining the email list.',
surveyForm: 'Survey: Your LMS',
}
};
43 changes: 43 additions & 0 deletions playwright-e2e/dss/pages/mbc/mbc-research-consent-page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import {MBCPageBase} from './mbc-page-base';
import {expect, Locator, Page} from '@playwright/test';
import Question from '../../component/Question';

type yesNo = 'Yes' | 'No';

export class MBCResearchConsentPage extends MBCPageBase {
readonly pageTitle: Locator;

constructor(page: Page) {
super(page);
this.pageTitle = this.page.locator('h1.PageHeader-title');
}

async waitForReady(): Promise<void> {
await expect(this.pageTitle).toHaveText('Research Consent Form');
await super.waitForReady();
}

/**
* <br> Question: You can work with me to arrange a sample of blood to be drawn at my physician’s office, local clinic, or nearby lab facility.
*/
public async consentBlood(answer: yesNo = 'Yes'): Promise<void> {
await new Question(this.page, {cssClassAttribute: '.boolean-answer-CONSENT_BLOOD'})
.radioButton(answer, {exactMatch: true}).click();
}

/**
* <br> Question: You can request my stored tissue samples from my physicians and the hospitals and other places where I received my care, perform (or collaborate with others to perform) gene tests on the samples, and store the samples until this research study is complete.
*/
public async consentTissue(answer: yesNo = 'Yes'): Promise<void> {
await new Question(this.page, {cssClassAttribute: '.boolean-answer-CONSENT_TISSUE'})
.radioButton(answer, {exactMatch: true}).click();
}

public async fullName(answer: string): Promise<void> {
await this.fillInFullName(answer);
}

public async dateOfBirth(month: string, day: string, year: string): Promise<void> {
await this.fillInDateOfBirth(month, day, year);
}
}
Loading