From fa7f383cba0938ad561d8a80dbebc1ae6629d73b Mon Sep 17 00:00:00 2001 From: GiCharkviani Date: Tue, 1 Aug 2023 16:39:42 +0400 Subject: [PATCH 01/12] PW-DSS-PEPPER-1003-enrollment initial --- playwright-e2e/config/.env.dev | 5 + playwright-e2e/config/.env.staging | 5 + playwright-e2e/config/.env.test | 5 + .../dss/pages/mbc/mbc-follow-up-survey-1.ts | 98 +++++++++ playwright-e2e/dss/pages/mbc/mbc-home-page.ts | 41 ++++ playwright-e2e/dss/pages/mbc/mbc-join-page.ts | 16 ++ .../dss/pages/mbc/mbc-medical-release-page.ts | 83 +++++++ playwright-e2e/dss/pages/mbc/mbc-page-base.ts | 13 ++ .../dss/pages/mbc/mbc-patient-type.ts | 44 ++++ .../pages/mbc/mbc-research-consent-page.ts | 44 ++++ .../dss/pages/mbc/mbc-survey-about-page.ts | 204 ++++++++++++++++++ .../tests/mbc/mbc-enrollment.spec.ts | 134 ++++++++++++ 12 files changed, 692 insertions(+) create mode 100644 playwright-e2e/dss/pages/mbc/mbc-follow-up-survey-1.ts create mode 100644 playwright-e2e/dss/pages/mbc/mbc-home-page.ts create mode 100644 playwright-e2e/dss/pages/mbc/mbc-join-page.ts create mode 100644 playwright-e2e/dss/pages/mbc/mbc-medical-release-page.ts create mode 100644 playwright-e2e/dss/pages/mbc/mbc-page-base.ts create mode 100644 playwright-e2e/dss/pages/mbc/mbc-patient-type.ts create mode 100644 playwright-e2e/dss/pages/mbc/mbc-research-consent-page.ts create mode 100644 playwright-e2e/dss/pages/mbc/mbc-survey-about-page.ts create mode 100644 playwright-e2e/tests/mbc/mbc-enrollment.spec.ts diff --git a/playwright-e2e/config/.env.dev b/playwright-e2e/config/.env.dev index 66b1db69e4..0cf91ed963 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= +MBC_USER_EMAIL= +MBC_USER_PASSWORD= diff --git a/playwright-e2e/config/.env.staging b/playwright-e2e/config/.env.staging index b260c84126..c4730f56fb 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= +MBC_USER_EMAIL= +MBC_USER_PASSWORD= diff --git a/playwright-e2e/config/.env.test b/playwright-e2e/config/.env.test index 24e5888a91..2b23ddd4ab 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= +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..c0a76a7fdf --- /dev/null +++ b/playwright-e2e/dss/pages/mbc/mbc-follow-up-survey-1.ts @@ -0,0 +1,98 @@ +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, + 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.medicationAnswer('.composite-answer-CURRENT_MED_LIST', 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.medicationAnswer('.composite-answer-PAST_MED_LIST', opts); + } + } + + /* Helper functions */ + private async medicationAnswer(cssClass: string, opts: MedicationDetails): Promise { + const question = new Question(this.page, {cssClassAttribute: cssClass}) + await this.page.waitForTimeout(3000); + if(opts) { + await question.toInput().fill(opts.medication); + + await question.toSelect('Choose month...') + .toLocator() + .selectOption(opts.month); + + await question.toSelect('Choose year...') + .toLocator() + .selectOption(opts.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..d10c0debb8 --- /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..32cd61fe13 --- /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..4e0927fdae --- /dev/null +++ b/playwright-e2e/dss/pages/mbc/mbc-medical-release-page.ts @@ -0,0 +1,83 @@ +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: number = 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..68c04c314e --- /dev/null +++ b/playwright-e2e/dss/pages/mbc/mbc-page-base.ts @@ -0,0 +1,13 @@ +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..a2bb34eef7 --- /dev/null +++ b/playwright-e2e/dss/pages/mbc/mbc-patient-type.ts @@ -0,0 +1,44 @@ +import { TestID } from 'dss/pages/patient-type'; + +export interface PatientData { + whoIsSigningUp: string; + researchContentForm: string; + additionalConsentForm: string; + surveyForm: string; + testId: Partial; +} + +export type TypePatient = 'patient' | 'other'; + +export type Patient = { + [index in TypePatient]: PatientData; +}; + +export const MBCPatientsData: Patient = { + 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.", + researchContentForm: 'Research Consent Form', + additionalConsentForm: 'Additional Consent Form: Learning About Your Tumor', + surveyForm: 'Join the movement: tell us about yourself', + testId: { + firstName: 'answer:CONSENT_FIRSTNAME', + lastName: 'answer:CONSENT_LASTNAME', + bloodSamples: 'boolean-answer-CONSENT_BLOOD', + assentTissue: 'boolean-answer-CONSENT_TISSUE', + agreeToShareWithMeResults: 'answer:SOMATIC_CONSENT_ADDENDUM_TUMOR' + } + }, + 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.", + researchContentForm: 'Research Consent Form', + additionalConsentForm: 'Additional Consent Form: Learning About Your Tumor', + surveyForm: 'Survey: Your LMS', + testId: { + firstName: 'answer:CONSENT_FIRSTNAME', + lastName: 'answer:CONSENT_LASTNAME', + bloodSamples: 'boolean-answer-CONSENT_BLOOD', + assentTissue: 'boolean-answer-CONSENT_TISSUE', + agreeToShareWithMeResults: 'answer:SOMATIC_CONSENT_ADDENDUM_TUMOR' + } + } +}; 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..1001ad2265 --- /dev/null +++ b/playwright-e2e/dss/pages/mbc/mbc-research-consent-page.ts @@ -0,0 +1,44 @@ +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..1f0ed0cd88 --- /dev/null +++ b/playwright-e2e/dss/pages/mbc/mbc-survey-about-page.ts @@ -0,0 +1,204 @@ +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: string = ''): 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: string = ''): 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..c224352f19 --- /dev/null +++ b/playwright-e2e/tests/mbc/mbc-enrollment.spec.ts @@ -0,0 +1,134 @@ +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 @visual @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 medication', + month: '3', + year: '2014', + }); + await followUpSurvey1.previouslyMedicated('Yes', { + medication: 'Test medication 2', + month: '4', + year: '2015', + }) + + await followUpSurvey1.submit(); + + await page.waitForTimeout(3000); + }) + + + }) + + +}) From 77140cd2663ef87e40c85b954aa783e6518a82f1 Mon Sep 17 00:00:00 2001 From: GiCharkviani Date: Tue, 1 Aug 2023 16:41:43 +0400 Subject: [PATCH 02/12] PW-DSS-PEPPER-1003-enrollment linter fix --- .../dss/pages/mbc/mbc-follow-up-survey-1.ts | 11 +++---- playwright-e2e/dss/pages/mbc/mbc-home-page.ts | 8 ++--- playwright-e2e/dss/pages/mbc/mbc-join-page.ts | 6 ++-- .../dss/pages/mbc/mbc-medical-release-page.ts | 14 ++++----- playwright-e2e/dss/pages/mbc/mbc-page-base.ts | 5 ++- .../dss/pages/mbc/mbc-patient-type.ts | 26 +++------------- .../pages/mbc/mbc-research-consent-page.ts | 7 ++--- .../dss/pages/mbc/mbc-survey-about-page.ts | 23 ++++++-------- .../tests/mbc/mbc-enrollment.spec.ts | 31 ++++++++----------- 9 files changed, 50 insertions(+), 81 deletions(-) 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 index c0a76a7fdf..ca377b7fe9 100644 --- a/playwright-e2e/dss/pages/mbc/mbc-follow-up-survey-1.ts +++ b/playwright-e2e/dss/pages/mbc/mbc-follow-up-survey-1.ts @@ -1,7 +1,7 @@ -import {MBCPageBase} from "./mbc-page-base"; -import {expect, Locator, Page} from "@playwright/test"; -import {waitForNoSpinner} from "../../../utils/test-utils"; -import Question from "../../component/Question"; +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 { @@ -82,7 +82,7 @@ export class MBCFollowUpSurvey1 extends MBCPageBase { private async medicationAnswer(cssClass: string, opts: MedicationDetails): Promise { const question = new Question(this.page, {cssClassAttribute: cssClass}) await this.page.waitForTimeout(3000); - if(opts) { + if (opts) { await question.toInput().fill(opts.medication); await question.toSelect('Choose month...') @@ -94,5 +94,4 @@ export class MBCFollowUpSurvey1 extends MBCPageBase { .selectOption(opts.year) } } - } diff --git a/playwright-e2e/dss/pages/mbc/mbc-home-page.ts b/playwright-e2e/dss/pages/mbc/mbc-home-page.ts index d10c0debb8..ffc0a57a5b 100644 --- a/playwright-e2e/dss/pages/mbc/mbc-home-page.ts +++ b/playwright-e2e/dss/pages/mbc/mbc-home-page.ts @@ -1,7 +1,7 @@ -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"; +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; diff --git a/playwright-e2e/dss/pages/mbc/mbc-join-page.ts b/playwright-e2e/dss/pages/mbc/mbc-join-page.ts index 32cd61fe13..f381888f73 100644 --- a/playwright-e2e/dss/pages/mbc/mbc-join-page.ts +++ b/playwright-e2e/dss/pages/mbc/mbc-join-page.ts @@ -1,6 +1,6 @@ -import {MBCPageBase} from "./mbc-page-base"; -import {Locator, Page} from "@playwright/test"; -import Question from "../../component/Question"; +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; diff --git a/playwright-e2e/dss/pages/mbc/mbc-medical-release-page.ts b/playwright-e2e/dss/pages/mbc/mbc-medical-release-page.ts index 4e0927fdae..0d16c450a8 100644 --- a/playwright-e2e/dss/pages/mbc/mbc-medical-release-page.ts +++ b/playwright-e2e/dss/pages/mbc/mbc-medical-release-page.ts @@ -1,8 +1,8 @@ -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"; +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 { @@ -73,11 +73,9 @@ export class MBCMedicalReleasePage extends MBCPageBase { * 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: number = 0): Promise { + 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 index 68c04c314e..b42b0028fa 100644 --- a/playwright-e2e/dss/pages/mbc/mbc-page-base.ts +++ b/playwright-e2e/dss/pages/mbc/mbc-page-base.ts @@ -1,5 +1,5 @@ -import PageBase from "../page-base"; -import {Page} from "@playwright/test"; +import PageBase from '../page-base'; +import {Page} from '@playwright/test'; export class MBCPageBase extends PageBase { protected constructor(page: Page) { @@ -9,5 +9,4 @@ export class MBCPageBase extends PageBase { } 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 index a2bb34eef7..280900f98a 100644 --- a/playwright-e2e/dss/pages/mbc/mbc-patient-type.ts +++ b/playwright-e2e/dss/pages/mbc/mbc-patient-type.ts @@ -14,31 +14,15 @@ export type Patient = { [index in TypePatient]: PatientData; }; -export const MBCPatientsData: Patient = { +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.", + 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.", researchContentForm: 'Research Consent Form', - additionalConsentForm: 'Additional Consent Form: Learning About Your Tumor', - surveyForm: 'Join the movement: tell us about yourself', - testId: { - firstName: 'answer:CONSENT_FIRSTNAME', - lastName: 'answer:CONSENT_LASTNAME', - bloodSamples: 'boolean-answer-CONSENT_BLOOD', - assentTissue: 'boolean-answer-CONSENT_TISSUE', - agreeToShareWithMeResults: 'answer:SOMATIC_CONSENT_ADDENDUM_TUMOR' - } }, 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.", + 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.', researchContentForm: 'Research Consent Form', - additionalConsentForm: 'Additional Consent Form: Learning About Your Tumor', - surveyForm: 'Survey: Your LMS', - testId: { - firstName: 'answer:CONSENT_FIRSTNAME', - lastName: 'answer:CONSENT_LASTNAME', - bloodSamples: 'boolean-answer-CONSENT_BLOOD', - assentTissue: 'boolean-answer-CONSENT_TISSUE', - agreeToShareWithMeResults: 'answer:SOMATIC_CONSENT_ADDENDUM_TUMOR' - } } }; diff --git a/playwright-e2e/dss/pages/mbc/mbc-research-consent-page.ts b/playwright-e2e/dss/pages/mbc/mbc-research-consent-page.ts index 1001ad2265..67a3679a66 100644 --- a/playwright-e2e/dss/pages/mbc/mbc-research-consent-page.ts +++ b/playwright-e2e/dss/pages/mbc/mbc-research-consent-page.ts @@ -1,6 +1,6 @@ -import {MBCPageBase} from "./mbc-page-base"; -import {expect, Locator, Page} from "@playwright/test"; -import Question from "../../component/Question"; +import {MBCPageBase} from './mbc-page-base'; +import {expect, Locator, Page} from '@playwright/test'; +import Question from '../../component/Question'; type yesNo = 'Yes' | 'No'; @@ -40,5 +40,4 @@ export class MBCResearchConsentPage extends MBCPageBase { 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 index 1f0ed0cd88..1df058e150 100644 --- a/playwright-e2e/dss/pages/mbc/mbc-survey-about-page.ts +++ b/playwright-e2e/dss/pages/mbc/mbc-survey-about-page.ts @@ -1,8 +1,8 @@ -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"; +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?', @@ -13,7 +13,6 @@ enum CancerTypeQuestionText { type yesNoDontKnow = 'Yes' | 'No' | "I don't know"; export class MBCSurveyAboutPage extends MBCPageBase { - constructor(page: Page, private typePatient: TypePatient = 'patient') { super(page); } @@ -147,10 +146,10 @@ export class MBCSurveyAboutPage extends MBCPageBase { /** *
Question: Which categories describe you? Select all that apply. Note, you may select more than one group. */ - public async race(answer: string, secondAnswer: string = ''): Promise { + 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) { + if (secondAnswer) { await question.toCheckbox(secondAnswer).check(); } } @@ -158,13 +157,12 @@ export class MBCSurveyAboutPage extends MBCPageBase { /** *
Question: What is your gender identity? Select all that apply */ - public async gender(answer: string, secondAnswer: string = ''): Promise { + 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) { + if (secondAnswer) { await question.toCheckbox(secondAnswer).check(); } - } /** @@ -198,7 +196,4 @@ export class MBCSurveyAboutPage extends MBCPageBase { .toSelect('Choose month...') .toLocator(); } - - - } diff --git a/playwright-e2e/tests/mbc/mbc-enrollment.spec.ts b/playwright-e2e/tests/mbc/mbc-enrollment.spec.ts index c224352f19..ff3a059332 100644 --- a/playwright-e2e/tests/mbc/mbc-enrollment.spec.ts +++ b/playwright-e2e/tests/mbc/mbc-enrollment.spec.ts @@ -1,22 +1,21 @@ -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"; +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 @visual @enrollment @mbc', async ({page}) => { const participant = user.adult; const firstName = generateUserName(participant.firstName); @@ -126,9 +125,5 @@ test.describe.serial('MBC enrolment @mbc', () => { await page.waitForTimeout(3000); }) - - }) - - }) From 4a1fcd8f978153043bd0f7cab7d971038b3160b5 Mon Sep 17 00:00:00 2001 From: GiCharkviani Date: Tue, 1 Aug 2023 16:42:17 +0400 Subject: [PATCH 03/12] PW-DSS-PEPPER-1003-enrollment removed unused --- playwright-e2e/dss/pages/mbc/mbc-patient-type.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/playwright-e2e/dss/pages/mbc/mbc-patient-type.ts b/playwright-e2e/dss/pages/mbc/mbc-patient-type.ts index 280900f98a..34de32c034 100644 --- a/playwright-e2e/dss/pages/mbc/mbc-patient-type.ts +++ b/playwright-e2e/dss/pages/mbc/mbc-patient-type.ts @@ -18,11 +18,9 @@ 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.", - researchContentForm: 'Research Consent Form', }, 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.', - researchContentForm: 'Research Consent Form', } }; From 9b177da5dffb32cfdf3a8d01b81011d318d6084e Mon Sep 17 00:00:00 2001 From: GiCharkviani Date: Tue, 1 Aug 2023 16:48:02 +0400 Subject: [PATCH 04/12] PW-DSS-PEPPER-1003-enrollment updated smth --- playwright-e2e/dss/pages/mbc/mbc-patient-type.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/playwright-e2e/dss/pages/mbc/mbc-patient-type.ts b/playwright-e2e/dss/pages/mbc/mbc-patient-type.ts index 34de32c034..97177fdb42 100644 --- a/playwright-e2e/dss/pages/mbc/mbc-patient-type.ts +++ b/playwright-e2e/dss/pages/mbc/mbc-patient-type.ts @@ -16,11 +16,13 @@ export type Patient = { 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.", + 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.', + 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', } }; From 788e96a548fa3904ed3068263e6ebb351315d7d9 Mon Sep 17 00:00:00 2001 From: GiCharkviani Date: Tue, 1 Aug 2023 16:48:25 +0400 Subject: [PATCH 05/12] PW-DSS-PEPPER-1003-enrollment linter fix --- playwright-e2e/dss/pages/mbc/mbc-patient-type.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/playwright-e2e/dss/pages/mbc/mbc-patient-type.ts b/playwright-e2e/dss/pages/mbc/mbc-patient-type.ts index 97177fdb42..795da59979 100644 --- a/playwright-e2e/dss/pages/mbc/mbc-patient-type.ts +++ b/playwright-e2e/dss/pages/mbc/mbc-patient-type.ts @@ -16,13 +16,13 @@ export type Patient = { export const MBCPatientsData: any = { patient: { - whoIsSigningUp: "I have been diagnosed with metastatic breast cancer (also known as advanced or stage IV breast " + + 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.", + 'the Metastatic Breast Cancer Project by joining the email list.', surveyForm: 'Survey: Your LMS', } }; From b45ac7241d944a967f8c9b4c7d5292844aabda53 Mon Sep 17 00:00:00 2001 From: GiCharkviani Date: Thu, 3 Aug 2023 13:35:32 +0400 Subject: [PATCH 06/12] PW-DSS-PEPPER-1003-enrollment start and end dates selected --- playwright-e2e/config/.env.dev | 2 +- playwright-e2e/config/.env.staging | 2 +- playwright-e2e/config/.env.test | 2 +- .../dss/pages/mbc/mbc-follow-up-survey-1.ts | 72 +++++++++++++++---- .../tests/mbc/mbc-enrollment.spec.ts | 50 +++++++------ 5 files changed, 91 insertions(+), 37 deletions(-) diff --git a/playwright-e2e/config/.env.dev b/playwright-e2e/config/.env.dev index 0cf91ed963..787c5ab971 100644 --- a/playwright-e2e/config/.env.dev +++ b/playwright-e2e/config/.env.dev @@ -59,6 +59,6 @@ LMS_USER_EMAIL= LMS_USER_PASSWORD= # MBC -MBC_BASE_URL= +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 c4730f56fb..91e3c8b0a4 100644 --- a/playwright-e2e/config/.env.staging +++ b/playwright-e2e/config/.env.staging @@ -59,6 +59,6 @@ LMS_USER_PASSWORD= LMS_BASE_URL=https://lms.staging.datadonationplatform.org # MBC -MBC_BASE_URL= +MBC_BASE_URL=https://mbc.dev.datadonationplatform.org MBC_USER_EMAIL= MBC_USER_PASSWORD= diff --git a/playwright-e2e/config/.env.test b/playwright-e2e/config/.env.test index 2b23ddd4ab..ccd15382a3 100644 --- a/playwright-e2e/config/.env.test +++ b/playwright-e2e/config/.env.test @@ -59,6 +59,6 @@ LMS_USER_PASSWORD= LMS_BASE_URL=https://lms.test.datadonationplatform.org # MBC -MBC_BASE_URL= +MBC_BASE_URL=https://mbc.dev.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 index ca377b7fe9..e221bae116 100644 --- a/playwright-e2e/dss/pages/mbc/mbc-follow-up-survey-1.ts +++ b/playwright-e2e/dss/pages/mbc/mbc-follow-up-survey-1.ts @@ -4,10 +4,17 @@ import {waitForNoSpinner} from '../../../utils/test-utils'; import Question from '../../component/Question'; type yesNoDontKnow = 'Yes' | 'No' | "I don't know"; + interface MedicationDetails { medication: string, - month: string, - year: string + startDate: { + month: string, + year: string + }, + endDate?: { + month: string, + year: string + } } export class MBCFollowUpSurvey1 extends MBCPageBase { @@ -63,7 +70,7 @@ export class MBCFollowUpSurvey1 extends MBCPageBase { await new Question(this.page, {cssClassAttribute: '.picklist-answer-CURRENTLY_MEDICATED'}) .radioButton(answer, {exactMatch: true}).click(); if (opts) { - await this.medicationAnswer('.composite-answer-CURRENT_MED_LIST', opts); + await this.currentMedicationAnswer(opts); } } @@ -74,24 +81,63 @@ export class MBCFollowUpSurvey1 extends MBCPageBase { await new Question(this.page, {cssClassAttribute: '.picklist-answer-PREVIOUSLY_MEDICATED'}) .radioButton(answer, {exactMatch: true}).click(); if (opts) { - await this.medicationAnswer('.composite-answer-PAST_MED_LIST', opts); + await this.pastMedicationAnswer(opts); } } /* Helper functions */ - private async medicationAnswer(cssClass: string, opts: MedicationDetails): Promise { - const question = new Question(this.page, {cssClassAttribute: cssClass}) - await this.page.waitForTimeout(3000); - if (opts) { - await question.toInput().fill(opts.medication); + 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) + } - await question.toSelect('Choose month...') + 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(opts.month); + .selectOption(endDate.month); - await question.toSelect('Choose year...') + await endDateQuestion.toSelect('Choose year...') .toLocator() - .selectOption(opts.year) + .selectOption(endDate.year); } } } diff --git a/playwright-e2e/tests/mbc/mbc-enrollment.spec.ts b/playwright-e2e/tests/mbc/mbc-enrollment.spec.ts index ff3a059332..885e64d152 100644 --- a/playwright-e2e/tests/mbc/mbc-enrollment.spec.ts +++ b/playwright-e2e/tests/mbc/mbc-enrollment.spec.ts @@ -16,7 +16,7 @@ const {MBC_USER_EMAIL, MBC_USER_PASSWORD, MBC_BASE_URL, SITE_PASSWORD} = process test.describe.serial('MBC enrolment @mbc', () => { - test('join the movement @visual @enrollment @mbc', async ({page}) => { + test('join the movement @enrollment @mbc', async ({page}) => { const participant = user.adult; const firstName = generateUserName(participant.firstName); const lastName = generateUserName(participant.lastName); @@ -104,26 +104,34 @@ test.describe.serial('MBC enrolment @mbc', () => { 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 medication', - month: '3', - year: '2014', - }); - await followUpSurvey1.previouslyMedicated('Yes', { - medication: 'Test medication 2', - month: '4', - year: '2015', + 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); }) - - await followUpSurvey1.submit(); - - await page.waitForTimeout(3000); - }) }) }) From 9a98b49523a529c48bd9af3307dc2d4401222e54 Mon Sep 17 00:00:00 2001 From: GiCharkviani Date: Thu, 3 Aug 2023 13:38:04 +0400 Subject: [PATCH 07/12] PW-DSS-PEPPER-1003-enrollment linter fix --- playwright-e2e/tests/mbc/mbc-enrollment.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/playwright-e2e/tests/mbc/mbc-enrollment.spec.ts b/playwright-e2e/tests/mbc/mbc-enrollment.spec.ts index 885e64d152..5bd5084775 100644 --- a/playwright-e2e/tests/mbc/mbc-enrollment.spec.ts +++ b/playwright-e2e/tests/mbc/mbc-enrollment.spec.ts @@ -127,7 +127,7 @@ test.describe.serial('MBC enrolment @mbc', () => { month: '5', year: '2016', } - }) + }); await followUpSurvey1.submit(); From bc88bbcbe12d570dfebf509cf666e0dc70dc015e Mon Sep 17 00:00:00 2001 From: GiCharkviani Date: Thu, 3 Aug 2023 13:41:12 +0400 Subject: [PATCH 08/12] PW-DSS-PEPPER-1003-enrollment removed unused things --- playwright-e2e/dss/pages/mbc/mbc-patient-type.ts | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/playwright-e2e/dss/pages/mbc/mbc-patient-type.ts b/playwright-e2e/dss/pages/mbc/mbc-patient-type.ts index 795da59979..07d523730b 100644 --- a/playwright-e2e/dss/pages/mbc/mbc-patient-type.ts +++ b/playwright-e2e/dss/pages/mbc/mbc-patient-type.ts @@ -1,19 +1,3 @@ -import { TestID } from 'dss/pages/patient-type'; - -export interface PatientData { - whoIsSigningUp: string; - researchContentForm: string; - additionalConsentForm: string; - surveyForm: string; - testId: Partial; -} - -export type TypePatient = 'patient' | 'other'; - -export type Patient = { - [index in TypePatient]: PatientData; -}; - export const MBCPatientsData: any = { patient: { whoIsSigningUp: 'I have been diagnosed with metastatic breast cancer (also known as advanced or stage IV breast ' + From f391d900e6075ab90302bbbc52694f981814c044 Mon Sep 17 00:00:00 2001 From: GiCharkviani Date: Thu, 3 Aug 2023 13:44:05 +0400 Subject: [PATCH 09/12] PW-DSS-PEPPER-1003-enrollment fixed issue --- playwright-e2e/dss/pages/mbc/mbc-patient-type.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/playwright-e2e/dss/pages/mbc/mbc-patient-type.ts b/playwright-e2e/dss/pages/mbc/mbc-patient-type.ts index 07d523730b..399943ba05 100644 --- a/playwright-e2e/dss/pages/mbc/mbc-patient-type.ts +++ b/playwright-e2e/dss/pages/mbc/mbc-patient-type.ts @@ -1,3 +1,6 @@ +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 ' + From 1379458d511c622d9d8880fa2e1e394e3912e54a Mon Sep 17 00:00:00 2001 From: GiCharkviani Date: Thu, 3 Aug 2023 17:26:01 +0400 Subject: [PATCH 10/12] PW-DSS-PEPPER-1003-enrollment envs fixed --- playwright-e2e/config/.env.staging | 2 +- playwright-e2e/config/.env.test | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/playwright-e2e/config/.env.staging b/playwright-e2e/config/.env.staging index 91e3c8b0a4..989f4f6b80 100644 --- a/playwright-e2e/config/.env.staging +++ b/playwright-e2e/config/.env.staging @@ -59,6 +59,6 @@ LMS_USER_PASSWORD= LMS_BASE_URL=https://lms.staging.datadonationplatform.org # MBC -MBC_BASE_URL=https://mbc.dev.datadonationplatform.org +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 ccd15382a3..91b8a8cda4 100644 --- a/playwright-e2e/config/.env.test +++ b/playwright-e2e/config/.env.test @@ -59,6 +59,6 @@ LMS_USER_PASSWORD= LMS_BASE_URL=https://lms.test.datadonationplatform.org # MBC -MBC_BASE_URL=https://mbc.dev.datadonationplatform.org +MBC_BASE_URL=https://mbc.test.datadonationplatform.org MBC_USER_EMAIL= MBC_USER_PASSWORD= From 4028554995dfcaab5ebad1e89896c761625b2ca9 Mon Sep 17 00:00:00 2001 From: GiCharkviani Date: Thu, 3 Aug 2023 17:28:29 +0400 Subject: [PATCH 11/12] PW-DSS-PEPPER-1003-enrollment relative path fixed --- playwright-e2e/dss/pages/mbc/mbc-follow-up-survey-1.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index e221bae116..1ebbcb9994 100644 --- a/playwright-e2e/dss/pages/mbc/mbc-follow-up-survey-1.ts +++ b/playwright-e2e/dss/pages/mbc/mbc-follow-up-survey-1.ts @@ -1,6 +1,6 @@ import {MBCPageBase} from './mbc-page-base'; import {expect, Locator, Page} from '@playwright/test'; -import {waitForNoSpinner} from '../../../utils/test-utils'; +import {waitForNoSpinner} from 'utils/test-utils'; import Question from '../../component/Question'; type yesNoDontKnow = 'Yes' | 'No' | "I don't know"; From 5361294dd42bbaf7b0f8d02bbaf31531177aabfc Mon Sep 17 00:00:00 2001 From: GiCharkviani Date: Fri, 4 Aug 2023 17:49:57 +0400 Subject: [PATCH 12/12] PW-DSS-PEPPER-1003-enrollment updated sh script --- .circleci/export-playwright-env.sh | 6 ++++++ 1 file changed, 6 insertions(+) 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")