# Test info

- Name: Feature case for request-listing >> REQ_050 - Verify choose message template when create new request
- Location: /root/code/portal-automation-test/tests/request/function.spec.ts:1655:9

# Error details

```
Error: Timed out 50000ms waiting for expect(locator).toBeVisible()

Locator: locator('//div[@class=\'letter-thumb-image\']')
Expected: visible
Received: <element(s) not found>
Call log:
  - expect.toBeVisible with timeout 50000ms
  - waiting for locator('//div[@class=\'letter-thumb-image\']')

    at RequestPage.submitAndVerifyRequest (/root/code/portal-automation-test/pom/request/request.page.ts:601:52)
    at /root/code/portal-automation-test/tests/request/function.spec.ts:1675:13
    at /root/code/portal-automation-test/tests/request/function.spec.ts:1661:9
```

# Page snapshot

```yaml
- complementary:
  - img
  - link "WellCare Pharmacy12321@@@@ Portal QA":
    - /url: /
    - paragraph: WellCare Pharmacy12321@@@@
    - paragraph: Portal QA
  - list:
    - listitem:
      - link "Home":
        - /url: https://qa.loprx.com
        - img
        - text: Home
    - listitem:
      - link "Case":
        - /url: https://qa.loprx.com/cases
        - img
        - text: Case
    - listitem:
      - link "Request":
        - /url: https://qa.loprx.com/requests
        - img
        - text: Request
    - listitem:
      - link "Patient":
        - /url: https://qa.loprx.com/clients
        - img
        - text: Patient
    - listitem:
      - button "Business/Contact":
        - img
        - text: Business/Contact
    - listitem:
      - button "Inbox/Sent":
        - img
        - text: Inbox/Sent
    - listitem:
      - button "Settings":
        - img
        - text: Settings
  - list:
    - listitem:
      - link "Shared with me":
        - /url: https://qa.loprx.com/shared/requests
        - img
        - text: Shared with me
- banner:
  - button:
    - img
  - button:
    - img
  - img
  - text: Minh Phong shared details regarding New Case 123 Letter of Protection. See the information now. 3 days ago
  - img
  - text: "Get the details: Lawyer Phan's response to the Letter of Protection Test Request is now available. 3 days ago"
  - img
  - text: Son HaiBon Phan assigned a request to you 23 minutes ago
  - img
  - text: Son HaiBon Phan assigned a case to you 2 hours ago
  - img
  - text: Minh Phong shared some information about New Case 123 Letter of Protection. Find out what it says. 3 days ago
  - img
  - text: "Get the details: Lawyer Phan's response to the Letter of Protection Test Request is now available. 3 days ago"
  - img
  - text: Son HaiBon Phan assigned a request to you 23 minutes ago
  - img
  - text: Son HaiBon Phan assigned a case to you 2 hours ago
  - img
  - img
  - textbox "Search..."
  - img
  - img
  - paragraph: No notifications yet
  - paragraph: When you get notifications, they'll show up here
  - button "Refresh"
  - list:
    - listitem:
      - img
      - paragraph: Pause notifications...
      - list:
        - listitem: For 30 minutes
        - listitem: For 1 hour
        - listitem: For 2 hours
        - listitem: Until tomorrow
    - listitem:
      - img
    - listitem:
      - img
    - listitem:
      - img
    - listitem:
      - img
    - listitem:
      - img
    - listitem:
      - img
  - img
  - button "0 Cart":
    - img
    - text: 0 Cart
  - text: Feedback
  - img
  - link "Open user menu":
    - /url: "#"
    - text: Minh
- img
- text: New Request
- button "Switch to Step-by-Step"
- img
- paragraph: "1"
- text: Select an Action
- paragraph: "2"
- text: Identify Patient
- paragraph: "3"
- text: Identify a Business
- paragraph: "4"
- text: Create Message
- paragraph: "5"
- text: Share with Others Prescription Test Request Business Templated Message Email
- button "Add more"
- button "Create"
```

# Test source

```ts
  501 |   }
  502 |
  503 |   async shareRequestToEmail(requestPage: RequestPage, email: string, message?: string) {
  504 |     await expect(requestPage.dashboardLoc.buttonByText("Share")).toBeVisible();
  505 |     await requestPage.waitForSecond(1);
  506 |     await requestPage.dashboardLoc.buttonByText("Share").click();
  507 |     await requestPage.requestLoc.detail.share.inputEmail.first().fill(email);
  508 |     await expect(requestPage.requestLoc.create.dropdownMemberShare(email)).toBeVisible();
  509 |     await requestPage.requestLoc.create.dropdownMemberShare(email).click();
  510 |     if (message) {
  511 |       await requestPage.requestLoc.detail.share.inputMessage.fill(message);
  512 |     }
  513 |     await requestPage.dashboardLoc.buttonByText("Done").first().click();
  514 |   }
  515 |
  516 |   async openLinkAndCompletePasscode(requestPage: RequestPage, requestCtx: any, buttonLocator: Locator): Promise<RequestPage> {
  517 |     const buttonPage = await buttonLocator.elementHandle().then(el => el?.ownerFrame()).then(frame => frame?.page()) || buttonLocator.page();
  518 |     const [newPage] = await Promise.all([
  519 |       buttonPage.context().waitForEvent('page'),
  520 |       buttonLocator.click()
  521 |     ]);
  522 |
  523 |     const newTabPage = new RequestPage(newPage);
  524 |     await newTabPage.dashboardLoc.buttonByText("Next").click();
  525 |     await newTabPage.waitForSecond(3);
  526 |
  527 |     const foundMail = await newTabPage.findMail(requestCtx);
  528 |     expect(foundMail).toBeTruthy();
  529 |
  530 |     const verificationCode = extractVerificationCode(foundMail.Subject) || '';
  531 |     await newTabPage.dashboardLoc.inputCode.fill(verificationCode);
  532 |     await newTabPage.dashboardLoc.buttonByText("Next").click();
  533 |
  534 |     return newTabPage;
  535 |   }
  536 |
  537 |   async bulkShareFirstNRequests(requestPage: RequestPage, n: number, email: string): Promise<void> {
  538 |     await requestPage.dashboardLoc.buttonByText("Bulk Edit").click();
  539 |     await requestPage.waitForSecond(3);
  540 |
  541 |     for (let i = 0; i < n; i++) {
  542 |       await requestPage.requestLoc.detail.bulkEdit.listCheckbox.nth(i).check();
  543 |       await requestPage.requestLoc.detail.bulkEdit.listCheckbox.nth(i).isChecked();
  544 |     }
  545 |     await requestPage.waitForSecond(1);
  546 |     await requestPage.dashboardLoc.buttonByText("Next").click();
  547 |     await requestPage.requestLoc.detail.bulkEdit.bulkAction("Share/Remove Shared").check();
  548 |     await requestPage.dashboardLoc.buttonByText("Next").click();
  549 |     await requestPage.requestLoc.detail.bulkEdit.bulkAction("Share").check();
  550 |
  551 |     for (let i = 0; i < n; i++) {
  552 |       await requestPage.requestLoc.detail.bulkEdit.listMailShare.first().click();
  553 |       await expect(requestPage.dashboardLoc.modal.headerModal("Share")).toBeVisible();
  554 |       await requestPage.requestLoc.detail.share.inputEmail.first().fill(email);
  555 |       await expect(requestPage.requestLoc.create.dropdownMemberShare(email)).toBeVisible();
  556 |       await requestPage.requestLoc.create.dropdownMemberShare(email).click();
  557 |       await requestPage.dashboardLoc.modal.headerModal("Share").click();;
  558 |       await requestPage.requestLoc.detail.btnSubmitShare.click();
  559 |       await expect(requestPage.dashboardLoc.modal.headerModal("Share")).not.toBeVisible();
  560 |     }
  561 |
  562 |     await requestPage.dashboardLoc.buttonByText("Next").click();
  563 |     await requestPage.dashboardLoc.buttonByText("Confirmation").click();
  564 |   }
  565 |
  566 |   async shareToMultipleEmails(requestPage: RequestPage, emails: string[]): Promise<void> {
  567 |     await requestPage.dashboardLoc.buttonByText("Share").click({ force: true });
  568 |     await requestPage.dashboardLoc.modal.headerModal("Share with others").waitFor({ state: 'visible' });
  569 |
  570 |     for (const email of emails) {
  571 |       await requestPage.requestLoc.detail.share.inputEmail.first().type(email, { delay: 150 });
  572 |       await expect(requestPage.requestLoc.create.dropdownMemberShare(email)).toBeVisible();
  573 |       await requestPage.requestLoc.create.dropdownMemberShare(email).click();
  574 |     }
  575 |     await requestPage.dashboardLoc.buttonByText("Done").first().click();
  576 |   }
  577 |
  578 |   async handleMissingInfoPopup(): Promise<void> {
  579 |     const popupMissingInfo = this.dashboardLoc.modal.headerModal("Missing Information");
  580 |     await this.page.addLocatorHandler(popupMissingInfo, async () => {
  581 |       await this.waitForSecond(1);
  582 |       await this.dashboardLoc.buttonByText("Continue").click();
  583 |     });
  584 |   };
  585 |
  586 |   async initiateRequestCreation(patientName: string): Promise<void> {
  587 |     await this.gotoCreateRequest("multi");
  588 |     await expect(this.dashboardLoc.buttonByText("Switch to Step-by-Step")).toBeVisible();
  589 |
  590 |     await this.requestLoc.create.itemStep(1).first().click();
  591 |     await this.dashboardLoc.common.pText("Prescription").first().click();
  592 |
  593 |     await this.requestLoc.create.itemStep(2).first().click();
  594 |     await this.fillDataCreateRequest("Type or select a name", "Name", patientName);
  595 |
  596 |     await this.requestLoc.create.itemStep(4).first().click();
  597 |   };
  598 |
  599 |   async submitAndVerifyRequest(screenshotName: string): Promise<void> {
  600 |     await this.dashboardLoc.buttonByText("Create").first().click();
> 601 |     await expect(this.requestLoc.thumbImagePosted).toBeVisible({ timeout: 50_000 });
      |                                                    ^ Error: Timed out 50000ms waiting for expect(locator).toBeVisible()
  602 |     await this.requestLoc.thumbImagePosted.first().click();
  603 |     await this.waitForSecond(8);
  604 |     await verifyScreenshot(screenshotName, this.requestLoc.detailPostedAttachment, [], 0.02);
  605 |   };
  606 |
  607 |   async handlePopupMinimize(): Promise<void> {
  608 |     const popupNewPost = this.dashboardLoc.modal.headerModal("New Post: Minimize Previous Post?");
  609 |     await this.page.addLocatorHandler(popupNewPost, async () => {
  610 |       await this.dashboardLoc.buttonByText("Leave it").click();
  611 |     })
  612 |   };
  613 |
  614 |   async getDetailRequest(caseID: string): Promise<void> {
  615 |     await this.dashboardLoc.search.inputSearch.fill(caseID);
  616 |     await this.waitForSecond(2);
  617 |     await this.requestLoc.itemInRowRequest(caseID).waitFor({ state: 'visible' });
  618 |     await this.requestLoc.itemInRowRequest(caseID).click({ force: true });
  619 |   };
  620 |
  621 |   async createSimpleAndShareRequest(emailRecive: string, businessName: string, clientName: string): Promise<void> {
  622 |     await this.requestLoc.create.itemStep(1).first().click();
  623 |     await this.dashboardLoc.common.pText("Medical Bill").first().click();
  624 |
  625 |     //Choose Patient
  626 |     await this.requestLoc.create.itemStep(2).first().click();
  627 |     await this.requestLoc.create.inputByPlaceholder("Type or select a name").first().fill(clientName);
  628 |     await this.waitForSecond(2);
  629 |     await this.requestLoc.create.boxTextBusiness(clientName).click({ force: true });
  630 |
  631 |     //Choose Business
  632 |     await this.requestLoc.create.itemStep(3).first().click();
  633 |     await this.requestLoc.create.inputByPlaceholder("Type or select a business").first().fill(businessName);
  634 |     await this.waitForSecond(2);
  635 |     await this.requestLoc.create.boxTextBusiness(businessName).click({ force: true });
  636 |
  637 |     await this.requestLoc.create.itemStep(5).first().click();
  638 |     await this.requestLoc.create.inputByPlaceholder("Type or select an email address").first().type(emailRecive, { delay: 200 });
  639 |     await this.requestLoc.create.optionMember(emailRecive).click();
  640 |
  641 |     await this.requestLoc.create.btnCloseAction.last().click();
  642 |     await this.dashboardLoc.buttonByText("Create").first().click();
  643 |
  644 |     await this.dashboardLoc.modal.headerModal("Missing Information").waitFor({ state: 'visible' });
  645 |     await this.dashboardLoc.buttonByText("Continue").click();
  646 |   };
  647 | }
  648 |
  649 |
  650 |
```