diff --git a/.circleci/export-playwright-env.sh b/.circleci/export-playwright-env.sh index e03650a274..cfeff940ed 100755 --- a/.circleci/export-playwright-env.sh +++ b/.circleci/export-playwright-env.sh @@ -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") diff --git a/playwright-e2e/config/.env.dev b/playwright-e2e/config/.env.dev index 66b1db69e4..787c5ab971 100644 --- a/playwright-e2e/config/.env.dev +++ b/playwright-e2e/config/.env.dev @@ -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= diff --git a/playwright-e2e/config/.env.staging b/playwright-e2e/config/.env.staging index b260c84126..989f4f6b80 100644 --- a/playwright-e2e/config/.env.staging +++ b/playwright-e2e/config/.env.staging @@ -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= diff --git a/playwright-e2e/config/.env.test b/playwright-e2e/config/.env.test index 24e5888a91..91b8a8cda4 100644 --- a/playwright-e2e/config/.env.test +++ b/playwright-e2e/config/.env.test @@ -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= diff --git a/playwright-e2e/dss/pages/mbc/mbc-follow-up-survey-1.ts b/playwright-e2e/dss/pages/mbc/mbc-follow-up-survey-1.ts new file mode 100644 index 0000000000..1ebbcb9994 --- /dev/null +++ b/playwright-e2e/dss/pages/mbc/mbc-follow-up-survey-1.ts @@ -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 { + await expect(this.pageTitle).toHaveText(this.title); + await waitForNoSpinner(this.page); + } + + /** + *
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 { + const question = new Question(this.page, {cssClassAttribute: '.picklist-answer-CURRENT_CANCER_LOC'}); + await question.toCheckbox(answer).check(); + } + + /** + *
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 { + const question = new Question(this.page, {cssClassAttribute: '.picklist-answer-DIAGNOSIS_CANCER_LOC'}); + await question.toCheckbox(answer).check(); + } + + /** + *
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 { + const question = new Question(this.page, {cssClassAttribute: '.picklist-answer-ANYTIME_CANCER_LOC'}); + await question.toCheckbox(answer).check(); + } + + /** + *
Question: Was your breast cancer identified as any of the following at any time (select all that apply)? + */ + public async cancerIdentification(answer: string): Promise { + const question = new Question(this.page, {cssClassAttribute: '.picklist-answer-CANCER_IDENTIFICATION'}); + await question.toCheckbox(answer).check(); + } + + /** + *
Question: Are you currently receiving any medications/chemotherapies for treatment of your metastatic breast cancer? + */ + public async currentlyMedicated(answer: yesNoDontKnow, opts?: MedicationDetails): Promise { + await new Question(this.page, {cssClassAttribute: '.picklist-answer-CURRENTLY_MEDICATED'}) + .radioButton(answer, {exactMatch: true}).click(); + if (opts) { + await this.currentMedicationAnswer(opts); + } + } + + /** + *
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 { + 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 { + 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 { + 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 { + 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); + } + } +} diff --git a/playwright-e2e/dss/pages/mbc/mbc-home-page.ts b/playwright-e2e/dss/pages/mbc/mbc-home-page.ts new file mode 100644 index 0000000000..ffc0a57a5b --- /dev/null +++ b/playwright-e2e/dss/pages/mbc/mbc-home-page.ts @@ -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 { + 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 { + await this.countMeInButton.first().click(); + await waitForNoSpinner(this.page); + } + + async learnMore(): Promise { + await this.learnMoreButton.click(); + await waitForNoSpinner(this.page); + } + + async logIn(): Promise { + await auth.login(this.page); + } + + override getLogInButton(): Locator { + return this.page.locator('.Header-nav button[data-ddp-test="signInButton"]:has-text("Sign In")'); + } +} diff --git a/playwright-e2e/dss/pages/mbc/mbc-join-page.ts b/playwright-e2e/dss/pages/mbc/mbc-join-page.ts new file mode 100644 index 0000000000..f381888f73 --- /dev/null +++ b/playwright-e2e/dss/pages/mbc/mbc-join-page.ts @@ -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'}); + } +} diff --git a/playwright-e2e/dss/pages/mbc/mbc-medical-release-page.ts b/playwright-e2e/dss/pages/mbc/mbc-medical-release-page.ts new file mode 100644 index 0000000000..0d16c450a8 --- /dev/null +++ b/playwright-e2e/dss/pages/mbc/mbc-medical-release-page.ts @@ -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 { + 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 { + 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 { + 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 { + const institution = new Institution(this.page, { label: /other biopsies/}); + await institution.toButton('ADD ANOTHER INSTITUTION').click(); + await this.yourHospitalOrInstitution({label: /institution/, nth}); + } +} diff --git a/playwright-e2e/dss/pages/mbc/mbc-page-base.ts b/playwright-e2e/dss/pages/mbc/mbc-page-base.ts new file mode 100644 index 0000000000..b42b0028fa --- /dev/null +++ b/playwright-e2e/dss/pages/mbc/mbc-page-base.ts @@ -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); + } +} diff --git a/playwright-e2e/dss/pages/mbc/mbc-patient-type.ts b/playwright-e2e/dss/pages/mbc/mbc-patient-type.ts new file mode 100644 index 0000000000..399943ba05 --- /dev/null +++ b/playwright-e2e/dss/pages/mbc/mbc-patient-type.ts @@ -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', + } +}; diff --git a/playwright-e2e/dss/pages/mbc/mbc-research-consent-page.ts b/playwright-e2e/dss/pages/mbc/mbc-research-consent-page.ts new file mode 100644 index 0000000000..67a3679a66 --- /dev/null +++ b/playwright-e2e/dss/pages/mbc/mbc-research-consent-page.ts @@ -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 { + await expect(this.pageTitle).toHaveText('Research Consent Form'); + await super.waitForReady(); + } + + /** + *
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 { + await new Question(this.page, {cssClassAttribute: '.boolean-answer-CONSENT_BLOOD'}) + .radioButton(answer, {exactMatch: true}).click(); + } + + /** + *
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 { + await new Question(this.page, {cssClassAttribute: '.boolean-answer-CONSENT_TISSUE'}) + .radioButton(answer, {exactMatch: true}).click(); + } + + public async fullName(answer: string): Promise { + await this.fillInFullName(answer); + } + + public async dateOfBirth(month: string, day: string, year: string): Promise { + await this.fillInDateOfBirth(month, day, year); + } +} diff --git a/playwright-e2e/dss/pages/mbc/mbc-survey-about-page.ts b/playwright-e2e/dss/pages/mbc/mbc-survey-about-page.ts new file mode 100644 index 0000000000..1df058e150 --- /dev/null +++ b/playwright-e2e/dss/pages/mbc/mbc-survey-about-page.ts @@ -0,0 +1,199 @@ +import {expect, Locator, Page} from '@playwright/test'; +import {MBCPatientsData as PatientsData, TypePatient} from '../mbc/mbc-patient-type'; +import {waitForNoSpinner} from '../../../utils/test-utils'; +import Question from '../../component/Question'; +import {MBCPageBase} from './mbc-page-base'; + +enum CancerTypeQuestionText { + BREAST_CANCER = 'When were you first diagnosed with breast cancer?', + METASTATIC_BREAST_CANCER = 'When were you first diagnosed with metastatic breast cancer (also known as advanced or stage IV breast cancer)?', + BIOPSY = 'When was your most recent biopsy of your cancer?' +} + +type yesNoDontKnow = 'Yes' | 'No' | "I don't know"; + +export class MBCSurveyAboutPage extends MBCPageBase { + constructor(page: Page, private typePatient: TypePatient = 'patient') { + super(page); + } + + /** + * Wait for the page title + */ + public async waitForReady(): Promise { + await expect(this.page.locator('h1.PageHeader-title')).toHaveText(PatientsData[this.typePatient].surveyForm); + await waitForNoSpinner(this.page); + } + + /** + *
Question: When were you first diagnosed with breast cancer? + */ + public async firstBreastCancerDiagnosedDate(month: string, year: string): Promise { + await this.chooseMonth(CancerTypeQuestionText.BREAST_CANCER).selectOption(month); + await this.chooseYear(CancerTypeQuestionText.BREAST_CANCER).selectOption(year); + } + + /** + *
Question: When were you first diagnosed with metastatic breast cancer (also known as advanced or stage IV breast cancer)? + */ + public async firstMetastaticBreastCancerDiagnosedDate(month: string, year: string): Promise { + await this.chooseMonth(CancerTypeQuestionText.METASTATIC_BREAST_CANCER).selectOption(month); + await this.chooseYear(CancerTypeQuestionText.METASTATIC_BREAST_CANCER).selectOption(year); + } + + /** + *
Question: At any time, was your breast cancer found to be hormone receptor positive (HR+, ER+ and/or PR+)? + */ + public async hrPositive(answer: yesNoDontKnow): Promise { + await new Question(this.page, {cssClassAttribute: '.picklist-answer-HR_POSITIVE'}) + .radioButton(answer, {exactMatch: true}).click(); + } + + /** + *
Question: At any time, was your breast cancer found to be HER2 positive (HER2+)? + */ + public async hr2Positive(answer: yesNoDontKnow): Promise { + await new Question(this.page, {cssClassAttribute: '.picklist-answer-HER2_POSITIVE'}) + .radioButton(answer, {exactMatch: true}).click(); + } + + /** + *
Question: At any time, was your breast cancer found to be triple negative (e.g, NOT ER+, PR+ or HER2+)? + */ + public async tripleNegative(answer: yesNoDontKnow): Promise { + await new Question(this.page, {cssClassAttribute: '.picklist-answer-TRIPLE_NEGATIVE'}) + .radioButton(answer, {exactMatch: true}).click(); + } + + /** + *
Question: At any time, were you diagnosed with inflammatory breast cancer? + */ + public async inflammatory(answer: yesNoDontKnow): Promise { + await new Question(this.page, {cssClassAttribute: '.picklist-answer-INFLAMMATORY'}) + .radioButton(answer, {exactMatch: true}).click(); + } + + /** + *
Question: Since your diagnosis with metastatic breast cancer, have you been on any of your cancer therapies for more than 2 years? + */ + public async therapies(answer: yesNoDontKnow): Promise { + await new Question(this.page, {cssClassAttribute: '.picklist-answer-THERAPIES'}) + .radioButton(answer, {exactMatch: true}).click(); + } + + /** + *
Question: Have any of your therapies worked extraordinarily well-made your cancer disappear completely (resulting in no evidence of disease, NED) or resulted in a dramatic reduction in tumor size - for any period of time? + */ + public async workedTherapies(answer: yesNoDontKnow): Promise { + await new Question(this.page, {cssClassAttribute: '.picklist-answer-WORKED_THERAPIES'}) + .radioButton(answer, {exactMatch: true}).click(); + } + + /** + *
Question: If you have had an extraordinary response to therapy, tell us more about it. + */ + public async extraordinaryTherapy(answer: string): Promise { + await new Question(this.page, {prompt: 'If you have had an extraordinary response to therapy, tell us more about it.'}) + .toTextarea() + .fill(answer); + } + + /** + *
Question: When was your most recent biopsy of your cancer?? + */ + public async mostRecentBiopsyDate(month: string, year: string): Promise { + await this.chooseMonth(CancerTypeQuestionText.BIOPSY).selectOption(month); + await this.chooseYear(CancerTypeQuestionText.BIOPSY).selectOption(year); + } + + /** + *
Question: About You + */ + public async aboutYou(answer: string): Promise { + await new Question(this.page, {prompt: 'About You'}) + .toTextarea() + .fill(answer); + } + + /** + * Question: In what year were you born? + */ + public async birthYear(answer: string): Promise { + await new Question(this.page, {cssClassAttribute: '.date-answer-BIRTH_YEAR'}) + .toSelect() + .toLocator() + .selectOption(answer) + } + + /** + * Question: What country do you live in? + */ + public async countryLiveIn(answer: string): Promise { + await this.country() + .toSelect() + .selectOption(answer) + } + + /** + *
Question: What is your ZIP or postal code? + */ + public async fillInZipCode(answer: string): Promise { + await new Question(this.page, {prompt: 'What is your ZIP or postal code?'}) + .toInput() + .fill(answer); + } + + /** + *
Question: Which categories describe you? Select all that apply. Note, you may select more than one group. + */ + public async race(answer: string, secondAnswer = ''): Promise { + const question = new Question(this.page, {cssClassAttribute: '.picklist-answer-SELF_RACE'}); + await question.toCheckbox(answer).check(); + if (secondAnswer) { + await question.toCheckbox(secondAnswer).check(); + } + } + + /** + *
Question: What is your gender identity? Select all that apply + */ + public async gender(answer: string, secondAnswer = ''): Promise { + const question = new Question(this.page, {cssClassAttribute: '.picklist-answer-GENDER_IDENTITY'}); + await question.toCheckbox(answer).check(); + if (secondAnswer) { + await question.toCheckbox(secondAnswer).check(); + } + } + + /** + *
Question: What sex were you assigned at birth? + */ + public async sex(answer: string): Promise { + await new Question(this.page, {cssClassAttribute: '.picklist-answer-ASSIGNED_SEX'}) + .radioButton(answer, {exactMatch: true}).click(); + } + + /** + *
Question: How did you hear about the MBCproject? + */ + public async howDidYouHear(answer: string): Promise { + await new Question(this.page, {prompt: 'How did you hear about the MBCproject?'}) + .toTextarea() + .fill(answer); + } + + + /* Helper functions */ + + private chooseYear(questionText: string): Locator { + return new Question(this.page, { prompt: questionText }) + .toSelect('Choose year...') + .toLocator(); + } + + private chooseMonth(questionText: string): Locator { + return new Question(this.page, { prompt: questionText }) + .toSelect('Choose month...') + .toLocator(); + } +} diff --git a/playwright-e2e/tests/mbc/mbc-enrollment.spec.ts b/playwright-e2e/tests/mbc/mbc-enrollment.spec.ts new file mode 100644 index 0000000000..5bd5084775 --- /dev/null +++ b/playwright-e2e/tests/mbc/mbc-enrollment.spec.ts @@ -0,0 +1,137 @@ +import {test} from '@playwright/test'; +import * as utils from '../../utils/test-utils'; +import * as user from '../../data/fake-user.json'; +import {generateUserName} from '../../utils/faker-utils'; +import {MBCHomePage} from '../../dss/pages/mbc/mbc-home-page'; +import {MBCJoinPage} from '../../dss/pages/mbc/mbc-join-page'; +import * as auth from '../../authentication/auth-lms'; +import {logParticipantCreated} from '../../utils/log-utils'; +import {MBCSurveyAboutPage} from '../../dss/pages/mbc/mbc-survey-about-page'; +import {MBCPatientsData} from '../../dss/pages/mbc/mbc-patient-type'; +import {MBCResearchConsentPage} from '../../dss/pages/mbc/mbc-research-consent-page'; +import {MBCMedicalReleasePage} from '../../dss/pages/mbc/mbc-medical-release-page'; +import {MBCFollowUpSurvey1} from '../../dss/pages/mbc/mbc-follow-up-survey-1'; + +const {MBC_USER_EMAIL, MBC_USER_PASSWORD, MBC_BASE_URL, SITE_PASSWORD} = process.env; + + +test.describe.serial('MBC enrolment @mbc', () => { + test('join the movement @enrollment @mbc', async ({page}) => { + const participant = user.adult; + const firstName = generateUserName(participant.firstName); + const lastName = generateUserName(participant.lastName); + const fullName = `${firstName} ${lastName}`; + + await test.step('Create account with email', async () => { + await page.goto(MBC_BASE_URL as string); + await utils.fillSitePassword(page, SITE_PASSWORD); + await page.waitForTimeout(1000); + + const homePage = new MBCHomePage(page); + await homePage.waitForReady(); + await homePage.countMeIn(); + + const joinPage = new MBCJoinPage(page); + await joinPage.waitForReady(); + await joinPage.fillInName('testFirstName', 'testLastName'); + await joinPage.whoIsSigningUP().toRadiobutton().check(MBCPatientsData.patient.whoIsSigningUp); + await joinPage.submit(); + + const userEmail = await auth.createAccountWithEmailAlias(page, { + email: MBC_USER_EMAIL, + password: MBC_USER_PASSWORD + }); + logParticipantCreated(userEmail, fullName); + }) + + await test.step('About you page', async () => { + const aboutYouPage = new MBCSurveyAboutPage(page); + await aboutYouPage.waitForReady(); + await aboutYouPage.firstBreastCancerDiagnosedDate('2', '2003'); + await aboutYouPage.firstMetastaticBreastCancerDiagnosedDate('3', '2004'); + await aboutYouPage.hrPositive('No'); + await aboutYouPage.hr2Positive('Yes'); + await aboutYouPage.tripleNegative("I don't know"); + await aboutYouPage.inflammatory('No'); + await aboutYouPage.therapies('No'); + await aboutYouPage.workedTherapies('No'); + await aboutYouPage.extraordinaryTherapy('Extra ordinary therapy test'); + await aboutYouPage.mostRecentBiopsyDate('5', '2021'); + await aboutYouPage.aboutYou('About you test'); + await aboutYouPage.birthYear('1993'); + await aboutYouPage.countryLiveIn('United States'); + await aboutYouPage.fillInZipCode('1932'); + await aboutYouPage.race('White', 'Polish'); + await aboutYouPage.gender('Man'); + await aboutYouPage.sex('Male'); + await aboutYouPage.howDidYouHear('How did you hear test'); + + await aboutYouPage.submit(); + }) + + await test.step('Research Consent Form page', async () => { + const researchConsentPage = new MBCResearchConsentPage(page); + await researchConsentPage.waitForReady(); + // Ket Points section + await researchConsentPage.next(); + + // Full Form section + await researchConsentPage.next(); + + // Sign Consent section + await researchConsentPage.consentBlood(); + await researchConsentPage.consentTissue(); + await researchConsentPage.fullName('Test Full Name'); + await researchConsentPage.dateOfBirth('3', '12', '1993'); + await researchConsentPage.submit(); + }) + + await test.step('Medical Release Form page', async () => { + const medicalReleasePage = new MBCMedicalReleasePage(page); + await medicalReleasePage.waitForReady(); + await medicalReleasePage.fillInContactAddress({ + fullName: 'Test Full Name' + }); + await medicalReleasePage.yourPhysicianName(); + await medicalReleasePage.yourHospitalOrInstitution(); + await medicalReleasePage.addAndFillAnotherInstitution(); + + await medicalReleasePage.agreeToAllowUsToContactPhysicianToObtainRecords(); + await medicalReleasePage.submit(); + + await page.waitForTimeout(3000); + }) + + await test.step('Follow-up survey #1: Additional details about your cancer & treatments page', + async () => { + const followUpSurvey1 = new MBCFollowUpSurvey1(page); + await followUpSurvey1.waitForReady(); + await followUpSurvey1.currentCancerLocation('Liver'); + await followUpSurvey1.diagnosisCancerLocation('Brain'); + await followUpSurvey1.anytimeCancerLocation('Skin'); + await followUpSurvey1.cancerIdentification("I don't know"); + await followUpSurvey1.currentlyMedicated('Yes', { + medication: 'Test current medication', + startDate: { + month: '3', + year: '2014', + } + }); + await followUpSurvey1.previouslyMedicated('Yes', { + medication: 'Test past medication', + startDate: { + month: '4', + year: '2015', + }, + endDate: { + month: '5', + year: '2016', + } + }); + + await followUpSurvey1.submit(); + + await page.waitForTimeout(3000); + }) + }) +})