Skip to content

Commit de6c8e8

Browse files
authored
PW-DSS-PEPPER-1003 -Enrollment (#2176)
* PW-DSS-PEPPER-1003-enrollment initial * PW-DSS-PEPPER-1003-enrollment linter fix * PW-DSS-PEPPER-1003-enrollment removed unused * PW-DSS-PEPPER-1003-enrollment updated smth * PW-DSS-PEPPER-1003-enrollment linter fix * PW-DSS-PEPPER-1003-enrollment start and end dates selected * PW-DSS-PEPPER-1003-enrollment linter fix * PW-DSS-PEPPER-1003-enrollment removed unused things * PW-DSS-PEPPER-1003-enrollment fixed issue * PW-DSS-PEPPER-1003-enrollment envs fixed * PW-DSS-PEPPER-1003-enrollment relative path fixed * PW-DSS-PEPPER-1003-enrollment updated sh script
1 parent a3c654d commit de6c8e8

File tree

13 files changed

+708
-0
lines changed

13 files changed

+708
-0
lines changed

.circleci/export-playwright-env.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ export lmsUserPassword=$(vault read --format=json secret/pepper/test/v1/e2e | jq
7878
echo "export LMS_USER_PASSWORD=$lmsUserPassword" >> playwright-env/envvars
7979
echo "export LMS_USER_EMAIL=$lmsUser" >> playwright-env/envvars
8080

81+
# MBC
82+
export mbcUser=$(vault read --format=json secret/pepper/test/v1/e2e | jq -r ".data.users | .[] | select(.app==\"mbc\") | .userName")
83+
export mbcUserPassword=$(vault read --format=json secret/pepper/test/v1/e2e | jq -r ".data.users | .[] | select(.app==\"mbc\") | .password")
84+
echo "export MBC_USER_PASSWORD=$mbcUserPassword" >> playwright-env/envvars
85+
echo "export MBC_USER_EMAIL=$mbcUser" >> playwright-env/envvars
86+
8187
# ATCP
8288
export atcpUser=$(vault read --format=json secret/pepper/test/v1/e2e | jq -r ".data.users | .[] | select(.app==\"atcp\") | .userName")
8389
export atcpUserPassword=$(vault read --format=json secret/pepper/test/v1/e2e | jq -r ".data.users | .[] | select(.app==\"atcp\") | .password")

playwright-e2e/config/.env.dev

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,8 @@ BRAIN_USER_PASSWORD=
5757
LMS_BASE_URL=https://lms.dev.datadonationplatform.org
5858
LMS_USER_EMAIL=
5959
LMS_USER_PASSWORD=
60+
61+
# MBC
62+
MBC_BASE_URL=https://mbc.dev.datadonationplatform.org
63+
MBC_USER_EMAIL=
64+
MBC_USER_PASSWORD=

playwright-e2e/config/.env.staging

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,8 @@ BRAIN_USER_PASSWORD=
5757
LMS_USER_EMAIL=
5858
LMS_USER_PASSWORD=
5959
LMS_BASE_URL=https://lms.staging.datadonationplatform.org
60+
61+
# MBC
62+
MBC_BASE_URL=https://mbc.staging.datadonationplatform.org
63+
MBC_USER_EMAIL=
64+
MBC_USER_PASSWORD=

playwright-e2e/config/.env.test

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,8 @@ BRAIN_USER_PASSWORD=
5757
LMS_USER_EMAIL=
5858
LMS_USER_PASSWORD=
5959
LMS_BASE_URL=https://lms.test.datadonationplatform.org
60+
61+
# MBC
62+
MBC_BASE_URL=https://mbc.test.datadonationplatform.org
63+
MBC_USER_EMAIL=
64+
MBC_USER_PASSWORD=
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
import {MBCPageBase} from './mbc-page-base';
2+
import {expect, Locator, Page} from '@playwright/test';
3+
import {waitForNoSpinner} from 'utils/test-utils';
4+
import Question from '../../component/Question';
5+
6+
type yesNoDontKnow = 'Yes' | 'No' | "I don't know";
7+
8+
interface MedicationDetails {
9+
medication: string,
10+
startDate: {
11+
month: string,
12+
year: string
13+
},
14+
endDate?: {
15+
month: string,
16+
year: string
17+
}
18+
}
19+
20+
export class MBCFollowUpSurvey1 extends MBCPageBase {
21+
private readonly pageTitle: Locator;
22+
private readonly title = 'Follow-up survey #1: Additional details about your cancer & treatments';
23+
24+
constructor(page: Page) {
25+
super(page);
26+
this.pageTitle = this.page.locator('h1.PageHeader-title');
27+
}
28+
29+
public async waitForReady(): Promise<void> {
30+
await expect(this.pageTitle).toHaveText(this.title);
31+
await waitForNoSpinner(this.page);
32+
}
33+
34+
/**
35+
* <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).
36+
*/
37+
public async currentCancerLocation(answer: string): Promise<void> {
38+
const question = new Question(this.page, {cssClassAttribute: '.picklist-answer-CURRENT_CANCER_LOC'});
39+
await question.toCheckbox(answer).check();
40+
}
41+
42+
/**
43+
* <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)?
44+
*/
45+
public async diagnosisCancerLocation(answer: string): Promise<void> {
46+
const question = new Question(this.page, {cssClassAttribute: '.picklist-answer-DIAGNOSIS_CANCER_LOC'});
47+
await question.toCheckbox(answer).check();
48+
}
49+
50+
/**
51+
* <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)?
52+
*/
53+
public async anytimeCancerLocation(answer: string): Promise<void> {
54+
const question = new Question(this.page, {cssClassAttribute: '.picklist-answer-ANYTIME_CANCER_LOC'});
55+
await question.toCheckbox(answer).check();
56+
}
57+
58+
/**
59+
* <br> Question: Was your breast cancer identified as any of the following at any time (select all that apply)?
60+
*/
61+
public async cancerIdentification(answer: string): Promise<void> {
62+
const question = new Question(this.page, {cssClassAttribute: '.picklist-answer-CANCER_IDENTIFICATION'});
63+
await question.toCheckbox(answer).check();
64+
}
65+
66+
/**
67+
* <br> Question: Are you currently receiving any medications/chemotherapies for treatment of your metastatic breast cancer?
68+
*/
69+
public async currentlyMedicated(answer: yesNoDontKnow, opts?: MedicationDetails): Promise<void> {
70+
await new Question(this.page, {cssClassAttribute: '.picklist-answer-CURRENTLY_MEDICATED'})
71+
.radioButton(answer, {exactMatch: true}).click();
72+
if (opts) {
73+
await this.currentMedicationAnswer(opts);
74+
}
75+
}
76+
77+
/**
78+
* <br> Question: Have you received any other medications/chemotherapies in the past for treatment of your metastatic breast cancer?
79+
*/
80+
public async previouslyMedicated(answer: yesNoDontKnow, opts?: MedicationDetails): Promise<void> {
81+
await new Question(this.page, {cssClassAttribute: '.picklist-answer-PREVIOUSLY_MEDICATED'})
82+
.radioButton(answer, {exactMatch: true}).click();
83+
if (opts) {
84+
await this.pastMedicationAnswer(opts);
85+
}
86+
}
87+
88+
/* Helper functions */
89+
private async currentMedicationAnswer(opts: MedicationDetails): Promise<void> {
90+
await this.page.waitForLoadState('networkidle');
91+
92+
if (opts?.medication) {
93+
const medication = new Question(this.page, {cssClassAttribute: '.composite-answer-CURRENT_MED_LIST'});
94+
await medication.toInput().fill(opts.medication);
95+
}
96+
97+
await this.fillCurrentAndPastMedicationDates('CURRENT', opts);
98+
}
99+
100+
private async pastMedicationAnswer(opts: MedicationDetails): Promise<void> {
101+
if (opts?.medication) {
102+
const medication = new Question(this.page, {cssClassAttribute: '.composite-answer-PAST_MED_LIST'});
103+
await medication.toInput().fill(opts.medication);
104+
}
105+
await this.fillCurrentAndPastMedicationDates('PAST', opts);
106+
}
107+
108+
private async fillCurrentAndPastMedicationDates(cssClassPart: 'CURRENT' | 'PAST', {
109+
startDate,
110+
endDate
111+
}: MedicationDetails): Promise<void> {
112+
if (startDate) {
113+
const startDateQuestion = new Question(this.page,
114+
{
115+
cssClassAttribute: '.picklist',
116+
parentSelector: this.page.locator(`.date-answer-${cssClassPart}_MED_START`)
117+
});
118+
await startDateQuestion.toSelect('Choose month...')
119+
.toLocator()
120+
.selectOption(startDate.month);
121+
122+
await startDateQuestion.toSelect('Choose year...')
123+
.toLocator()
124+
.selectOption(startDate.year)
125+
}
126+
127+
if (endDate) {
128+
const endDateQuestion = new Question(this.page,
129+
{
130+
cssClassAttribute: '.picklist',
131+
parentSelector: this.page.locator(`.date-answer-${cssClassPart}_MED_END`)
132+
}
133+
);
134+
await endDateQuestion.toSelect('Choose month...')
135+
.toLocator()
136+
.selectOption(endDate.month);
137+
138+
await endDateQuestion.toSelect('Choose year...')
139+
.toLocator()
140+
.selectOption(endDate.year);
141+
}
142+
}
143+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import {MBCPageBase} from './mbc-page-base';
2+
import {expect, Locator, Page} from '@playwright/test';
3+
import {waitForNoSpinner} from '../../../utils/test-utils';
4+
import * as auth from '../../../authentication/auth-lms';
5+
6+
export class MBCHomePage extends MBCPageBase {
7+
countMeInButton: Locator;
8+
learnMoreButton: Locator;
9+
10+
constructor(page: Page) {
11+
super(page);
12+
this.countMeInButton = this.page.locator('//span[text()=\'count me \' and @class="CountButton"]');
13+
this.learnMoreButton = this.page.locator('//span[text()[normalize-space()=\'Learn More\']]');
14+
}
15+
16+
async waitForReady(): Promise<void> {
17+
await expect(this.page).toHaveTitle('The Metastatic Breast Cancer Project');
18+
await expect(this.countMeInButton.first()).toBeVisible();
19+
await expect(this.learnMoreButton).toBeVisible();
20+
await expect(this.getLogInButton()).toBeVisible();
21+
await waitForNoSpinner(this.page);
22+
}
23+
24+
async countMeIn(): Promise<void> {
25+
await this.countMeInButton.first().click();
26+
await waitForNoSpinner(this.page);
27+
}
28+
29+
async learnMore(): Promise<void> {
30+
await this.learnMoreButton.click();
31+
await waitForNoSpinner(this.page);
32+
}
33+
34+
async logIn(): Promise<void> {
35+
await auth.login(this.page);
36+
}
37+
38+
override getLogInButton(): Locator {
39+
return this.page.locator('.Header-nav button[data-ddp-test="signInButton"]:has-text("Sign In")');
40+
}
41+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import {MBCPageBase} from './mbc-page-base';
2+
import {Locator, Page} from '@playwright/test';
3+
import Question from '../../component/Question';
4+
5+
export class MBCJoinPage extends MBCPageBase {
6+
readonly pageTitle: Locator;
7+
8+
constructor(page: Page) {
9+
super(page);
10+
this.pageTitle = this.page.locator('h1');
11+
}
12+
13+
whoIsSigningUP(): Question {
14+
return new Question(this.page, {cssClassAttribute: '.picklist-answer-PREQUAL_SELF_DESCRIBE'});
15+
}
16+
}
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
import {expect, Locator, Page} from '@playwright/test';
2+
import {MBCPageBase} from './mbc-page-base';
3+
import {waitForNoSpinner} from '../../../utils/test-utils';
4+
import * as user from '../../../data/fake-user.json';
5+
import Institution from '../../component/institution';
6+
7+
8+
export class MBCMedicalReleasePage extends MBCPageBase {
9+
private readonly pageTitle: Locator;
10+
11+
constructor(page: Page) {
12+
super(page);
13+
this.pageTitle = this.page.locator('h1.PageHeader-title');
14+
}
15+
16+
public async waitForReady(): Promise<void> {
17+
await expect(this.pageTitle).toHaveText('Medical Release Form');
18+
await waitForNoSpinner(this.page);
19+
}
20+
21+
public async yourPhysicianName(
22+
opts: {
23+
physicianName?: string;
24+
institutionName?: string;
25+
city?: string;
26+
state?: string;
27+
nth?: number;
28+
} = {}
29+
): Promise<void> {
30+
const {
31+
physicianName = user.doctor.name,
32+
institutionName = user.doctor.hospital,
33+
city = user.doctor.city,
34+
state = user.doctor.state,
35+
nth = 0,
36+
} = opts;
37+
38+
const institution = new Institution(this.page, { label: /Physician/, nth });
39+
await institution.toInput('Physician Name').fill(physicianName);
40+
await institution.toInput('Institution').fill(institutionName);
41+
await institution.toInput('City').fill(city);
42+
await institution.toInput('State').fill(state);
43+
}
44+
45+
/**
46+
* Question: Where was your initial biopsy for breast cancer performed?
47+
* @param opts
48+
*/
49+
public async yourHospitalOrInstitution(
50+
opts: {
51+
institutionName?: string;
52+
city?: string;
53+
state?: string;
54+
nth?: number;
55+
label?: string | RegExp
56+
} = {}
57+
): Promise<void> {
58+
const {
59+
institutionName = user.doctor.hospital,
60+
city = user.doctor.city,
61+
state = user.doctor.state,
62+
nth = 0,
63+
label = /Hospital/
64+
} = opts;
65+
66+
const institution = new Institution(this.page, { label, nth});
67+
await institution.toInput('Institution').fill(institutionName);
68+
await institution.toInput('City').fill(city);
69+
await institution.toInput('State').fill(state);
70+
}
71+
72+
/**
73+
* Question: Where were any other biopsies or surgeries for your breast cancer performed (i.e. biopsy, lumpectomy, partial mastectomy, mastectomy)?
74+
* @param nth
75+
*/
76+
public async addAndFillAnotherInstitution(nth = 0): Promise<void> {
77+
const institution = new Institution(this.page, { label: /other biopsies/});
78+
await institution.toButton('ADD ANOTHER INSTITUTION').click();
79+
await this.yourHospitalOrInstitution({label: /institution/, nth});
80+
}
81+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import PageBase from '../page-base';
2+
import {Page} from '@playwright/test';
3+
4+
export class MBCPageBase extends PageBase {
5+
protected constructor(page: Page) {
6+
const { MBC_BASE_URL } = process.env;
7+
if (MBC_BASE_URL == null) {
8+
throw Error(`Invalid MBC base URL: process.env.MBC_BASE_URL=${MBC_BASE_URL}`);
9+
}
10+
super(page, MBC_BASE_URL);
11+
}
12+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
export type TypePatient = 'patient' | 'other';
2+
3+
4+
export const MBCPatientsData: any = {
5+
patient: {
6+
whoIsSigningUp: 'I have been diagnosed with metastatic breast cancer (also known as advanced or stage IV breast ' +
7+
"cancer). I'm willing to answer additional questions about myself and my experience with metastatic breast cancer.",
8+
surveyForm: 'Join the movement: tell us about yourself',
9+
},
10+
other: {
11+
whoIsSigningUp: "I haven't been diagnosed with metastatic breast cancer, but I want to stay informed about " +
12+
'the Metastatic Breast Cancer Project by joining the email list.',
13+
surveyForm: 'Survey: Your LMS',
14+
}
15+
};

0 commit comments

Comments
 (0)