# Test info

- Name: Feature case for request-listing >> REQ_047 - Verify mail when chat in discussion
- Location: /root/code/portal-automation-test/tests/request/function.spec.ts:1574:9

# Error details

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

Locator: locator('//div[text()=\'Please check this discusssion 0182011390\']').last()
Expected: visible
Received: <element(s) not found>
Call log:
  - expect.toBeVisible with timeout 10000ms
  - waiting for locator('//div[text()=\'Please check this discusssion 0182011390\']').last()

    at /root/code/portal-automation-test/tests/request/function.spec.ts:1583:101
    at /root/code/portal-automation-test/tests/request/function.spec.ts:1579: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 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 19 minutes ago
  - img
  - text: Son HaiBon Phan assigned a case to you 2 hours ago
  - 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 19 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: "#527231 Letter of Protection"
- img
- img
- img
- link "Test Request":
  - /url: /clients/801a8b15-a5c5-4282-aacd-6a9b2e6ae3b3
- text: "-"
- 'link "DOB: 03/01/1999"':
  - /url: /clients/801a8b15-a5c5-4282-aacd-6a9b2e6ae3b3
- 'link "Case: #538240"':
  - /url: /cases/538240
- text: "-"
- 'link "DOI: 01/05/2026"':
  - /url: /cases/538240
- 'link "Category: Unspecified Accident"':
  - /url: /cases/538240
- text: Tag
- img
- 'button "Status: Open"'
- button "Status Details:":
  - text: "Status Details:"
  - listbox:
    - listitem:
      - text: Awaiting
      - img
  - img
- 'button "Assignee: --"':
  - text: "Assignee: --"
  - img
- button:
  - img
- button:
  - img
- button "Activity":
  - img
  - text: Activity
- button "Share":
  - img
  - text: Share
- paragraph: Minh Phong
- text: Posted
- paragraph: 08/25/2025
- img
- list:
  - listitem
- text: Read more comment Minh Phong 23 hours ago Please check this comment 6158247734
- img
- text: Minh Phong 12 hours ago Please check this comment 8589813584
- img
- textbox "Message"
- button [disabled]:
  - img
- heading "Snapshot" [level=2]
- list:
  - listitem: Minh Phong 08/25/2025 Submitted a request Respond
- heading "Discussion" [level=2]
- text: Start a discussion
- img
- heading "Newest Discusssion" [level=4]
- text: Please check this discusssion 2302927449 12 hours ago
- img
- heading "Secret Room" [level=4]
- text: Please check this discusssion 0103927663 01/06/2026
- img
- heading "Minh Phong (You)" [level=4]
- img
- text: See all rooms
- heading "Discussion" [level=2]
- img
- img
- text: Newest Discusssion
- img
- text: 01/06/2026 123
- img
- text: 01/06/2026 Please check this discusssion 2071960820
- img
- text: 01/06/2026 Please check this discusssion 0002572113
- img
- text: 01/06/2026 Please check this discusssion 7556048844
- img
- text: 01/06/2026 Please check this discusssion 5883098447
- img
- text: 01/06/2026 Please check this discusssion 2129345349
- img
- text: 01/06/2026 Please check this discusssion 0572803345
- img
- text: 01/06/2026 Please check this discusssion 9979087828
- img
- text: 01/07/2026 Please check this discusssion 5319757088
- img
- text: 01/08/2026 Please check this discusssion 6076551726
- img
- text: 01/08/2026 Please check this discusssion 9038846816
- img
- text: 01/08/2026 Please check this discusssion 3759595904
- img
- text: 01/08/2026 Please check this discusssion 6396364235
- img
- text: 01/09/2026 Please check this discusssion 9976261461
- img
- text: 01/09/2026 Please check this discusssion 2452754460
- img
- text: 01/10/2026 Please check this discusssion 3718803490
- img
- text: 01/10/2026 Please check this discusssion 1062152043
- img
- text: 01/11/2026 Please check this discusssion 9262710057
- img
- text: 01/11/2026 Please check this discusssion 3811172617
- img
- text: 01/12/2026 Please check this discusssion 2873464830
- img
- text: 01/12/2026 Please check this discusssion 6635758744
- img
- text: 01/13/2026 Please check this discusssion 7368396997
- img
- text: 01/13/2026 Please check this discusssion 0027289055
- img
- text: 01/14/2026 Please check this discusssion 7515028248
- img
- text: 01/14/2026 Please check this discusssion 7971018273
- img
- text: 01/15/2026 Please check this discusssion 5901675212
- img
- text: 01/15/2026 Please check this discusssion 3621775632
- img
- text: 01/16/2026 Please check this discusssion 2778830592
- img
- text: 01/16/2026 Please check this discusssion 8848334950
- img
- text: 01/17/2026 Please check this discusssion 9489679529
- img
- text: 01/17/2026 Please check this discusssion 1979436415
- img
- text: 01/18/2026 Please check this discusssion 4974300991
- img
- text: 01/18/2026 Please check this discusssion 2405435785
- img
- text: 01/19/2026 Please check this discusssion 5453036635
- img
- text: 01/19/2026 Please check this discusssion 6691575314
- img
- text: 01/20/2026 Please check this discusssion 9652654937
- img
- text: 01/20/2026 Please check this discusssion 6029224520
- img
- text: 01/21/2026 Please check this discusssion 5321057632
- img
- text: 01/21/2026 Please check this discusssion 6993965602
- img
- text: 01/21/2026 Please check this discusssion 7759728711
- img
- text: 01/22/2026 Please check this discusssion 0975988803
- img
- text: 01/22/2026 Please check this discusssion 2727949190
- img
- text: 01/23/2026 Please check this discusssion 0423700174
- img
- text: 01/23/2026 Please check this discusssion 8524389311
- img
- text: 01/24/2026 Please check this discusssion 1778167359
- img
- text: 01/24/2026 Please check this discusssion 0035824539
- img
- text: 01/25/2026 Please check this discusssion 2998388511
- img
- text: 01/25/2026 Please check this discusssion 6057802668
- img
- text: 01/26/2026 Please check this discusssion 7968958706
- img
- text: 01/26/2026 Please check this discusssion 5713917487
- img
- text: 01/27/2026 Please check this discusssion 9244357204
- img
- text: 01/27/2026 Please check this discusssion 9024801000
- img
- text: 01/28/2026 Please check this discusssion 8206351577
- img
- text: 01/28/2026 Please check this discusssion 4260434212
- img
- text: 01/29/2026 Please check this discusssion 2273964942
- img
- text: 01/29/2026 Please check this discusssion 3772385862
- img
- text: 01/29/2026 Please check this discusssion 4245699829
- img
- text: 1 day ago Please check this discusssion 7172553595
- img
- text: 1 day ago Please check this discusssion 3854835132
- img
- text: 23 hours ago Please check this discusssion 4447745955
- img
- text: 12 hours ago Please check this discusssion 2302927449
- img
- textbox "Message"
- button:
  - img
- img "image-share-this-request"
- paragraph: Share this request using the Share button.
- text: Share
```

# Test source

```ts
  1483 |     }, async ({ conf, request, browser }) => {
  1484 |         test.setTimeout(200_000);
  1485 |         await test.step("Open request detail and share with message", async () => {
  1486 |             await requestPage.getDetailCase(conf.data.case);
  1487 |             await requestPage.shareRequestToEmail(requestPage, conf.data.user_share, conf.data.message_sent);
  1488 |             await requestPage.page.close();
  1489 |         });
  1490 |
  1491 |         await test.step('Verify email received and click open request', async () => {
  1492 |             const newContext = await browser.newContext();
  1493 |             const newPage = await newContext.newPage();
  1494 |
  1495 |             const mail = new Mail(newPage, request);
  1496 |             await mail.open();
  1497 |             await mail.waitForSecond(conf.data.wait_for_email_second);
  1498 |
  1499 |             // Find and verify the share email
  1500 |             await mail.mailLoc.titleMail("John Doe 65423").first().click();
  1501 |             const mailFrame = mail.mailLoc.mailFrame;
  1502 |             const tbodyHtml = mailFrame.locator("//table[@class='es-header-body']/tbody");
  1503 |             const mask = mailFrame.locator("//table[@class='es-header-body']/tbody/descendant::p").first();
  1504 |             await verifyScreenshot('share-request-with-message.png', tbodyHtml, [mask], 0.02)
  1505 |
  1506 |             const buttonShareRequest = mailFrame.locator('//a/span[contains(text(),"Share")]');
  1507 |             const newTabPage = await requestPage.openLinkAndCompletePasscode(requestPage, request, buttonShareRequest);
  1508 |             await newTabPage.waitForSecond(3);
  1509 |             expect(newTabPage.page.url()).toContain(`requests/${conf.data.case}`);
  1510 |             await expect(newTabPage.dashboardLoc.modal.headerModal("Share with others")).toBeVisible();
  1511 |         });
  1512 |     });
  1513 |
  1514 |     test("REQ_045 - Share request: Sharing multiple requests with a single user", {
  1515 |         tag: ["@REQ_045", "@request", "@function"]
  1516 |     }, async ({ conf, request, browser }) => {
  1517 |         test.setTimeout(200_000);
  1518 |         await test.step("Verify sharing multiple requests for single user", async () => {
  1519 |             const SHARE_COUNT = 3;
  1520 |             await requestPage.bulkShareFirstNRequests(requestPage, SHARE_COUNT, conf.data.user_share);
  1521 |             await requestPage.page.close()
  1522 |         });
  1523 |
  1524 |         await test.step('Verify email received', async () => {
  1525 |             const newContext = await browser.newContext();
  1526 |             const newPage = await newContext.newPage();
  1527 |
  1528 |             const mail = new Mail(newPage, request);
  1529 |             await mail.open();
  1530 |             await mail.waitForSecond(conf.data.wait_for_email_second);
  1531 |
  1532 |             // Find and verify the share email
  1533 |             await mail.mailLoc.titleMail("3 requests").first().click();
  1534 |             const mailFrame = mail.mailLoc.mailFrame;
  1535 |             const tbodyHtml = mailFrame.locator("//table[@class='es-header-body']/tbody").first();
  1536 |             const dataInRow = mailFrame.locator("//td[@style='font-weight:400; color:#181C32; font-size:14px;']")
  1537 |             await verifyScreenshot('share-multi-requests.png', tbodyHtml, [dataInRow.first(), dataInRow.nth(1), dataInRow.nth(2)], 0.02)
  1538 |         });
  1539 |     });
  1540 |
  1541 |     test("REQ_046 - Sharing a request with multiple people", {
  1542 |         tag: ["@REQ_046", "@request", "@function"]
  1543 |     }, async ({ conf, request }) => {
  1544 |         test.setTimeout(200_000);
  1545 |         await test.step("Open request detail and share without message", async () => {
  1546 |             await requestPage.getDetailCase(conf.data.case);
  1547 |             const emails = Object.values(conf.data.user_share).map((v: any) => String(v));
  1548 |             await requestPage.waitForSecond(1);
  1549 |             await expect(requestPage.dashboardLoc.buttonByText("Share")).toBeVisible();
  1550 |             await requestPage.shareToMultipleEmails(requestPage, emails);
  1551 |         });
  1552 |
  1553 |         await test.step('Verify email received', async () => {
  1554 |             const mail = new Mail(requestPage.page, request);
  1555 |             await mail.open();
  1556 |             await mail.waitForSecond(conf.data.wait_for_email_second);
  1557 |
  1558 |             // Find and verify the share email
  1559 |             await mail.mailLoc.titleMail("Letter of Protection #543267").first().click();
  1560 |             const mailFrame = mail.mailLoc.mailFrame;
  1561 |             const buttonOpenRequest = mailFrame.locator('//a[contains(text(),"Open")]');
  1562 |
  1563 |             // Wait for new tab and click Open button
  1564 |             const [newPage] = await Promise.all([
  1565 |                 requestPage.page.context().waitForEvent('page'),
  1566 |                 buttonOpenRequest.click()
  1567 |             ]);
  1568 |
  1569 |             const newTabPage = new RequestPage(newPage);
  1570 |             await expect(newTabPage.requestLoc.detail.share.boxEnterEmail).toBeVisible();
  1571 |         });
  1572 |     })
  1573 |
  1574 |     test("REQ_047 - Verify mail when chat in discussion", {
  1575 |         tag: ["@REQ_047", "@request", "@function"]
  1576 |     }, async ({ conf, request }) => {
  1577 |         const msgUnique = `${conf.data.message} discusssion ${randomString(10)}`
  1578 |
  1579 |         await test.step("Open request detail and chat in discussion", async () => {
  1580 |             await requestPage.getDetailCase(conf.data.case);
  1581 |             await requestPage.dashboardLoc.discussion.newestDiscussion.click();
  1582 |             await requestPage.addMessageToDiscussion(msgUnique);
> 1583 |             await expect(requestPage.dashboardLoc.discussion.messageInDiscussion(msgUnique).last()).toBeVisible();
       |                                                                                                     ^ Error: Timed out 10000ms waiting for expect(locator).toBeVisible()
  1584 |         });
  1585 |
  1586 |         await test.step('Verify email received', async () => {
  1587 |             const mail = new Mail(requestPage.page, request);
  1588 |             await mail.open();
  1589 |             await mail.waitForSecond(conf.data.wait_for_email_second);
  1590 |
  1591 |             // Find and verify the share email
  1592 |             await mail.mailLoc.titleMail("a message in").first().click();
  1593 |             const mailFrame = mail.mailLoc.mailFrame;
  1594 |             const tbodyHtml = mailFrame.locator("//table[@class='es-header-body']/tbody");
  1595 |             const rowData = mailFrame.locator(`//p[contains(text(),"${msgUnique}")]`);
  1596 |             await expect(rowData).toBeVisible();
  1597 |             await verifyScreenshot('chat-in-discussion.png', tbodyHtml, [rowData], 0.03);
  1598 |         });
  1599 |     });
  1600 |
  1601 |     test("REQ_048 - Verify mail when comment in post", {
  1602 |         tag: ["@REQ_047", "@request", "@function"]
  1603 |     }, async ({ conf, request }) => {
  1604 |         const commentUnique = `${conf.data.message} comment ${randomString(10)}`
  1605 |
  1606 |         await test.step("Open request detail and chat in discussion", async () => {
  1607 |             await requestPage.getDetailCase(conf.data.case);
  1608 |             await requestPage.addCommentToNewestPost(commentUnique);
  1609 |             await expect(requestPage.dashboardLoc.comment.cmtInPost.last()).toContainText(commentUnique);
  1610 |         });
  1611 |
  1612 |         await test.step('Verify email received', async () => {
  1613 |             const mail = new Mail(requestPage.page, request);
  1614 |             await mail.open();
  1615 |             await mail.waitForSecond(conf.data.wait_for_email_second);
  1616 |
  1617 |             // Find and verify the share email
  1618 |             await mail.mailLoc.titleMail("a comment").first().click();
  1619 |             const mailFrame = mail.mailLoc.mailFrame;
  1620 |             const tbodyHtml = mailFrame.locator("//table[@class='es-header-body']/tbody");
  1621 |             const rowData = mailFrame.locator(`//p[contains(text(),"${commentUnique}")]`);
  1622 |             await expect(rowData).toBeVisible();
  1623 |             await verifyScreenshot('comment-in-post.png', tbodyHtml, [rowData], 0.04);
  1624 |         });
  1625 |     });
  1626 |
  1627 |     test("REQ_049 - Verify DOI when apply with multi requests", {
  1628 |         tag: ["@REQ_049", "@request", "@function"]
  1629 |     }, async ({ conf }) => {
  1630 |         await test.step("Goto create new with Fast Submission", async () => {
  1631 |             await requestPage.gotoCreateRequest("multi");
  1632 |             await expect(requestPage.dashboardLoc.buttonByText("Switch to Step-by-Step")).toBeVisible();
  1633 |         })
  1634 |
  1635 |         await test.step("Verify when click add more request", async () => {
  1636 |             await requestPage.dashboardLoc.buttonByText("Add more").click();
  1637 |             const listOfCreationRequests = (await requestPage.requestLoc.create.boxCreateMultiRequests.all()).length;
  1638 |             expect(listOfCreationRequests).toBe(2);
  1639 |         })
  1640 |
  1641 |         await test.step("Verify add patient, apply all and check DOI in row 2", async () => {
  1642 |             await requestPage.requestLoc.create.itemStep(2).first().click();
  1643 |             await requestPage.fillDataCreateRequest("Type or select a name", "Name", conf.data.patient);
  1644 |             await requestPage.requestLoc.create.inputCheckAll("patient").click();
  1645 |             await requestPage.waitForSecond(2);
  1646 |             await requestPage.requestLoc.create.inputCheckAll("patient").click()
  1647 |             await expect(requestPage.requestLoc.create.itemRow2).toBeVisible();
  1648 |             await requestPage.requestLoc.create.itemRow2.click();
  1649 |             await expect(requestPage.requestLoc.create.inputDOIInStep2).toBeVisible();
  1650 |             await requestPage.waitForSecond(2);
  1651 |             await expect(requestPage.requestLoc.create.inputDOIInStep2).toHaveValue("01/01/1992")
  1652 |         })
  1653 |     })
  1654 |
  1655 |     test("REQ_050 - Verify choose message template when create new request", {
  1656 |         tag: ["@REQ_050", "@request", "@function"]
  1657 |     }, async ({ conf }) => {
  1658 |         // Handle missing info popup if it appears
  1659 |         await requestPage.handleMissingInfoPopup();
  1660 |
  1661 |         await test.step("Verify create request with Edit template message", async () => {
  1662 |             await requestPage.initiateRequestCreation(conf.data.patient);
  1663 |
  1664 |             // Select and edit template
  1665 |             await requestPage.requestLoc.create.arrowIcon.click();
  1666 |             await requestPage.dashboardLoc.common.spanText("Template-2 Rxs Pad (Editor)").click();
  1667 |
  1668 |             const textEditor = requestPage.requestLoc.create.textEditorCreateFast.first();
  1669 |             await textEditor.click();
  1670 |             await textEditor.press('ControlOrMeta+a');
  1671 |             await textEditor.press('Delete');
  1672 |             await textEditor.fill(conf.data.message_edit_text);
  1673 |             await requestPage.requestLoc.create.closeModalMessage.click();
  1674 |
  1675 |             await requestPage.submitAndVerifyRequest("post-details-create-template-editor-snapshot.png");
  1676 |         });
  1677 |
  1678 |         await test.step("Verify create request with Form text message", async () => {
  1679 |             await requestPage.initiateRequestCreation(conf.data.patient);
  1680 |
  1681 |             // Select and configure form template
  1682 |             await requestPage.requestLoc.create.arrowIcon.click();
  1683 |             await requestPage.dashboardLoc.common.spanText("Template-3 DME Rx Pad (Form)").click();
```