# 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:1568:9

# Error details

```
Error: locator.click: Test timeout of 80000ms exceeded.
Call log:
  - waiting for locator('//span[@class=\'arrow-icon\']')
    - locator resolved to <span class="arrow-icon">…</span>
  - attempting click action
    2 × waiting for element to be visible, enabled and stable
      - element is not visible
    - retrying click action
    - waiting 20ms
    2 × waiting for element to be visible, enabled and stable
      - element is not visible
    - retrying click action
      - waiting 100ms
    141 × waiting for element to be visible, enabled and stable
        - element is not visible
      - retrying click action
        - waiting 500ms

    at /root/code/portal-automation-test/tests/request/function.spec.ts:1578:59
    at /root/code/portal-automation-test/tests/request/function.spec.ts:1574: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:
      - button "Shared with me":
        - img
        - text: Shared with me
- banner:
  - button:
    - img
  - button:
    - img
  - img
  - text: Tri01 Duc shared details regarding Auto_YXQ Test Letter of Protection. Read it now. 1 hour ago
  - img
  - text: Son HaiBon Phan assigned a request to you 20 minutes ago
  - img
  - text: Son HaiBon Phan assigned a case to you 14 hours ago
  - img
  - 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 Patient Business Message Email Patient
- img
- text: Selection of patients
- paragraph: Test Request
- paragraph: John Doe 65423
- paragraph: Auto Test Duy Nhat 123
- paragraph: John Doe 55306
- paragraph: John Doe 93662
- paragraph: John Doe 06512
- text: Name
- textbox "Name"
- text: Date Of Injury (DoI)
- textbox "Date Of Injury (DoI)"
- text: If you don't know, leave it blank.
- button "Add more"
- button "Create"
```

# Test source

```ts
  1478 |             const [newPage] = await Promise.all([
  1479 |                 requestPage.page.context().waitForEvent('page'),
  1480 |                 buttonOpenRequest.click()
  1481 |             ]);
  1482 |
  1483 |             const newTabPage = new RequestPage(newPage);
  1484 |             await expect(newTabPage.requestLoc.detail.share.boxEnterEmail).toBeVisible();
  1485 |         });
  1486 |     })
  1487 |
  1488 |     test("REQ_047 - Verify mail when chat in discussion", {
  1489 |         tag: ["@REQ_047", "@request", "@function"]
  1490 |     }, async ({ conf, request }) => {
  1491 |         const msgUnique = `${conf.data.message} discusssion ${randomString(10)}`
  1492 |
  1493 |         await test.step("Open request detail and chat in discussion", async () => {
  1494 |             await requestPage.getDetailCase(conf.data.case);
  1495 |             await requestPage.dashboardLoc.discussion.newestDiscussion.click();
  1496 |             await requestPage.addMessageToDiscussion(msgUnique);
  1497 |             await expect(requestPage.dashboardLoc.discussion.messageInDiscussion(msgUnique).last()).toBeVisible();
  1498 |         });
  1499 |
  1500 |         await test.step('Verify email received', async () => {
  1501 |             const mail = new Mail(requestPage.page, request);
  1502 |             await mail.open();
  1503 |             await mail.waitForSecond(conf.data.wait_for_email_second);
  1504 |
  1505 |             // Find and verify the share email
  1506 |             await mail.mailLoc.titleMail("a message in").first().click();
  1507 |             const mailFrame = mail.mailLoc.mailFrame;
  1508 |             const tbodyHtml = mailFrame.locator("//table[@class='es-header-body']/tbody");
  1509 |             const rowData = mailFrame.locator(`//p[contains(text(),"${msgUnique}")]`);
  1510 |             await expect(rowData).toBeVisible();
  1511 |             await verifyScreenshot('chat-in-discussion.png', tbodyHtml, [rowData]);
  1512 |         });
  1513 |     });
  1514 |
  1515 |     test("REQ_048 - Verify mail when comment in post", {
  1516 |         tag: ["@REQ_047", "@request", "@function"]
  1517 |     }, async ({ conf, request }) => {
  1518 |         const commentUnique = `${conf.data.message} comment ${randomString(10)}`
  1519 |
  1520 |         await test.step("Open request detail and chat in discussion", async () => {
  1521 |             await requestPage.getDetailCase(conf.data.case);
  1522 |             await requestPage.addCommentToNewestPost(commentUnique);
  1523 |             await expect(requestPage.dashboardLoc.comment.cmtInPost.last()).toContainText(commentUnique);
  1524 |         });
  1525 |
  1526 |         await test.step('Verify email received', async () => {
  1527 |             const mail = new Mail(requestPage.page, request);
  1528 |             await mail.open();
  1529 |             await mail.waitForSecond(conf.data.wait_for_email_second);
  1530 |
  1531 |             // Find and verify the share email
  1532 |             await mail.mailLoc.titleMail("a comment").first().click();
  1533 |             const mailFrame = mail.mailLoc.mailFrame;
  1534 |             const tbodyHtml = mailFrame.locator("//table[@class='es-header-body']/tbody");
  1535 |             const rowData = mailFrame.locator(`//p[contains(text(),"${commentUnique}")]`);
  1536 |             await expect(rowData).toBeVisible();
  1537 |             await verifyScreenshot('comment-in-post.png', tbodyHtml, [rowData]);
  1538 |         });
  1539 |     });
  1540 |
  1541 |     test("REQ_049 - Verify DOI when apply with multi requests", {
  1542 |         tag: ["@REQ_049", "@request", "@function"]
  1543 |     }, async ({ conf }) => {
  1544 |         await test.step("Goto create new with Fast Submission", async () => {
  1545 |             await requestPage.gotoCreateRequest("multi");
  1546 |             await expect(requestPage.dashboardLoc.buttonByText("Switch to Step-by-Step")).toBeVisible();
  1547 |         })
  1548 |
  1549 |         await test.step("Verify when click add more request", async () => {
  1550 |             await requestPage.dashboardLoc.buttonByText("Add more").click();
  1551 |             const listOfCreationRequests = (await requestPage.requestLoc.create.boxCreateMultiRequests.all()).length;
  1552 |             expect(listOfCreationRequests).toBe(2);
  1553 |         })
  1554 |
  1555 |         await test.step("Verify add patient, apply all and check DOI in row 2", async () => {
  1556 |             await requestPage.requestLoc.create.itemStep(2).first().click();
  1557 |             await requestPage.fillDataCreateRequest("Type or select a name", "Name", conf.data.patient);
  1558 |             await requestPage.requestLoc.create.inputCheckAll("patient").click();
  1559 |             await requestPage.waitForSecond(2);
  1560 |             await requestPage.requestLoc.create.inputCheckAll("patient").click()
  1561 |             await expect(requestPage.requestLoc.create.itemRow2).toBeVisible();
  1562 |             await requestPage.requestLoc.create.itemRow2.click();
  1563 |             await expect(requestPage.requestLoc.create.inputDOIInStep2).toBeVisible();
  1564 |             await expect(requestPage.requestLoc.create.inputDOIInStep2).toHaveValue("01/01/1992")
  1565 |         })
  1566 |     })
  1567 |
  1568 |     test("REQ_050 - Verify choose message template when create new request", {
  1569 |         tag: ["@REQ_050", "@request", "@function"]
  1570 |     }, async ({ conf }) => {
  1571 |         // Handle missing info popup if it appears
  1572 |         await requestPage.handleMissingInfoPopup();
  1573 |
  1574 |         await test.step("Verify create request with Edit template message", async () => {
  1575 |             await requestPage.initiateRequestCreation(conf.data.patient);
  1576 |
  1577 |             // Select and edit template
> 1578 |             await requestPage.requestLoc.create.arrowIcon.click();
       |                                                           ^ Error: locator.click: Test timeout of 80000ms exceeded.
  1579 |             await requestPage.dashboardLoc.common.spanText("Template-2 Rxs Pad (Editor)").click();
  1580 |
  1581 |             const textEditor = requestPage.requestLoc.create.textEditorCreateFast.first();
  1582 |             await textEditor.click();
  1583 |             await textEditor.press('ControlOrMeta+a');
  1584 |             await textEditor.press('Delete');
  1585 |             await textEditor.fill(conf.data.message_edit_text);
  1586 |             await requestPage.requestLoc.create.closeModalMessage.click();
  1587 |
  1588 |             await requestPage.submitAndVerifyRequest("post-details-create-template-editor-snapshot.png");
  1589 |         });
  1590 |
  1591 |         await test.step("Verify create request with Form text message", async () => {
  1592 |             await requestPage.initiateRequestCreation(conf.data.patient);
  1593 |
  1594 |             // Select and configure form template
  1595 |             await requestPage.requestLoc.create.arrowIcon.click();
  1596 |             await requestPage.dashboardLoc.common.spanText("Template-3 DME Rx Pad (Form)").click();
  1597 |
  1598 |             const textEditorForm = requestPage.page.locator('iframe[title="iframe-editor"]');
  1599 |             const formContent = textEditorForm.contentFrame();
  1600 |
  1601 |             // Clear existing content and set form options
  1602 |             await formContent.getByText('Dr. Jason Phan').dblclick();
  1603 |             await formContent.locator('body').press('ControlOrMeta+a');
  1604 |             await formContent.locator('body').press('Delete');
  1605 |
  1606 |             // Check all language options
  1607 |             const languageOptions = ['Vietnamese', 'Chinese', 'Spanish'];
  1608 |             for (const lang of languageOptions) {
  1609 |                 await formContent.getByRole('checkbox', { name: `Label in ${lang}` }).check();
  1610 |             }
  1611 |
  1612 |             await requestPage.requestLoc.create.closeModalMessage.click();
  1613 |             await requestPage.submitAndVerifyRequest("post-details-create-template-form-snapshot.png");
  1614 |         });
  1615 |     });
  1616 |
  1617 |     test("REQ_051 - Add more than 20 requests to the cart and create multiple requests", {
  1618 |         tag: ["@REQ_051", "@request", "@function"]
  1619 |     }, async ({ conf, checkCart }) => {
  1620 |         test.setTimeout(280_000);
  1621 |         const businesses = ["(Dat Lawyers)", "The Vu Law Firm", "A Taylor Law Firm"];
  1622 |         await test.step("Add 24 requests by hovering in case id to cart", async () => {
  1623 |             await checkCart.search(conf.data.request);
  1624 |             await expect(checkCart.dashboardLoc.table.itemInRow(conf.data.case)).toBeVisible();
  1625 |             await checkCart.waitForSecond(1);
  1626 |             await checkCart.dashboardLoc.table.itemInRow(conf.data.case).hover();
  1627 |             for (let i = 0; i < businesses.length; i++) {
  1628 |                 await checkCart.requestLoc.detail.cartRequest.optionBusinessInCart(businesses[i]).click();
  1629 |                 for (let j = 0; j < 8; j++) {
  1630 |                     await checkCart.requestLoc.detail.cartRequest.listRequestTypeByHovering.first().click();
  1631 |                 }
  1632 |             }
  1633 |             await checkCart.page.mouse.move(30, 30);
  1634 |             await expect(checkCart.requestLoc.detail.cartRequest.quickSubmitButton("24")).toBeVisible();
  1635 |         })
  1636 |
  1637 |         await test.step("Submit 24 requests, and verify that only 20 are successfully added to the cart, with 4 remaining", async () => {
  1638 |             await requestPage.handleMissingInfoPopup();
  1639 |
  1640 |             await checkCart.requestLoc.detail.cartRequest.quickSubmitButton("24").click();
  1641 |             await requestPage.requestLoc.create.inputCheckAll("action").click();
  1642 |
  1643 |             //Add message
  1644 |             await requestPage.requestLoc.create.itemStep(4).first().click();
  1645 |             await requestPage.requestLoc.textEditorCreateCaseArea.first().waitFor({ state: 'visible' });
  1646 |             await requestPage.requestLoc.textEditorCreateCaseArea.fill("Message");
  1647 |
  1648 |             await requestPage.requestLoc.create.inputCheckAll("message").click();
  1649 |             await checkCart.dashboardLoc.buttonByText("Create").first().click();
  1650 |             await expect(checkCart.dashboardLoc.buttonByText("Create Another")).toBeVisible({ timeout: 180_000 }); // Create 20 request in once can take longer time
  1651 |
  1652 |             //Verify cart have 4 requests left
  1653 |             await checkCart.dashboardLoc.cart.buttonCart.hover({ force: true });
  1654 |             await expect(checkCart.dashboardLoc.cart.requestButtonCart).toBeVisible();
  1655 |             await checkCart.dashboardLoc.cart.requestButtonCart.click();
  1656 |             await expect(checkCart.requestLoc.detail.cartRequest.tdInTable("A Taylor Law Firm").first()).toBeVisible();
  1657 |             await verifyScreenshot('list-request-left-4-requests.png', checkCart.requestLoc.create.overviewCreateFast);
  1658 |         });
  1659 |     });
  1660 |
  1661 |     test("REQ_052 - Resend mail", {
  1662 |         tag: ["@REQ_052", "@request", "@function"]
  1663 |     }, async ({ conf, request }) => {
  1664 |         await test.step("Click resend mail", async () => {
  1665 |             await requestPage.getDetailCase(conf.data.case);
  1666 |             await expect(requestPage.dashboardLoc.buttonByText("Share")).toBeVisible();
  1667 |
  1668 |             await requestPage.dashboardLoc.buttonByText("Share").click();
  1669 |             await expect(requestPage.dashboardLoc.modal.headerModal("Share with others")).toBeVisible();
  1670 |             await expect(requestPage.requestLoc.detail.rowMemberShare(conf.data.member_share)).toBeVisible();
  1671 |
  1672 |             await requestPage.requestLoc.detail.rowMemberShare(conf.data.member_share).hover();
  1673 |             await requestPage.requestLoc.detail.btnResend.first().click();
  1674 |             await expect(requestPage.requestLoc.detail.tagMemberShared(conf.data.member_share)).toBeVisible();
  1675 |
  1676 |             await requestPage.requestLoc.detail.rowMemberShare(conf.data.member_share).hover();
  1677 |             await expect(requestPage.requestLoc.detail.btnResend.first()).not.toBeVisible();
  1678 |         });
```