# Test info

- Name: Verify feature inbox >> INBOX_005 - Verify feature sort inbox
- Location: /root/code/portal-automation-test/tests/inbox/function.spec.ts:66:9

# Error details

```
Error: expect(received).toEqual(expected) // deep equality

- Expected  - 10
+ Received  + 10

  Array [
-   "Auto Test.Pharmacyportal_auto_pharmacy@testmail.loprx.com",
-   "Minh Phongminhphong.simple@gmail.com",
-   "Minh Phongminhphong.simple@gmail.com",
-   "Minh Phongminhphong.simple@gmail.com",
-   "Minh Phongportal_auto_lawyer@testmail.loprx.com",
-   "Son HaiBon Phansonphanjbwkz001+24@gmail.com",
-   "Son01 Phansonphanjbwkz001+1@gmail.com",
-   "Tri01 Ductriducgog0301+1@gmail.com",
-   "Tri01 Ductriducgog0301+1@gmail.com",
-   "Tri01 Ductriducgog0301+1@gmail.com",
+   "Auto Test.Pharmacy",
+   "Minh Phong",
+   "Minh Phong",
+   "Minh Phong",
+   "Minh Phong",
+   "Son HaiBon Phan",
+   "Son01 Phan",
+   "Tri01 Duc",
+   "Tri01 Duc",
+   "Tri01 Duc",
  ]
    at /root/code/portal-automation-test/tests/inbox/function.spec.ts:99:42
```

# 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
      - link "Inbox":
        - /url: https://qa.loprx.com/requests/inbox
        - img
        - text: Inbox
      - link "Sent":
        - /url: https://qa.loprx.com/requests/sent
        - img
        - text: 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. 15 minutes ago
  - img
  - text: Son HaiBon Phan assigned a request to you 11 hours ago
  - img
  - text: Son HaiBon Phan assigned a case to you 1 hour 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: Inbox
- heading "Manage" [level=2]
- text: Show
- textbox: "10"
- text: entries
- button "Filter":
  - img
  - text: Filter
- img
- textbox "Search..."
- table:
  - rowgroup:
    - 'row "Request #  Sender  Message  Inbox Date "':
      - 'cell "Request # "'
      - cell "Sender "
      - cell "Message "
      - cell "Inbox Date "
  - rowgroup:
    - row "584474 Auto Test.Pharmacy portal_auto_pharmacy@testmail.loprx.com -- 09/11/2025 21:32:58":
      - cell "584474":
        - link "584474":
          - /url: https://qa.loprx.com/shared/requests/584474
      - cell "Auto Test.Pharmacy portal_auto_pharmacy@testmail.loprx.com":
        - link "Auto Test.Pharmacy portal_auto_pharmacy@testmail.loprx.com":
          - /url: https://qa.loprx.com/shared/requests/584474
      - cell "--":
        - link "--":
          - /url: https://qa.loprx.com/shared/requests/584474
      - cell "09/11/2025 21:32:58":
        - link "09/11/2025 21:32:58":
          - /url: https://qa.loprx.com/shared/requests/584474
    - row "451940 Minh Phong minhphong.simple@gmail.com -- 07/28/2025 04:01:38":
      - cell "451940":
        - link "451940":
          - /url: https://qa.loprx.com/requests/451940
      - cell "Minh Phong minhphong.simple@gmail.com":
        - link "Minh Phong minhphong.simple@gmail.com":
          - /url: https://qa.loprx.com/requests/451940
      - cell "--":
        - link "--":
          - /url: https://qa.loprx.com/requests/451940
      - cell "07/28/2025 04:01:38":
        - link "07/28/2025 04:01:38":
          - /url: https://qa.loprx.com/requests/451940
    - row "684401 Minh Phong minhphong.simple@gmail.com be 07/28/2025 05:01:00":
      - cell "684401":
        - link "684401":
          - /url: https://qa.loprx.com/requests/684401
      - cell "Minh Phong minhphong.simple@gmail.com":
        - link "Minh Phong minhphong.simple@gmail.com":
          - /url: https://qa.loprx.com/requests/684401
      - cell "be":
        - link "be":
          - /url: https://qa.loprx.com/requests/684401
      - cell "07/28/2025 05:01:00":
        - link "07/28/2025 05:01:00":
          - /url: https://qa.loprx.com/requests/684401
    - row "333676 Minh Phong minhphong.simple@gmail.com -- 08/06/2025 22:45:22":
      - cell "333676":
        - link "333676":
          - /url: https://qa.loprx.com/requests/333676
      - cell "Minh Phong minhphong.simple@gmail.com":
        - link "Minh Phong minhphong.simple@gmail.com":
          - /url: https://qa.loprx.com/requests/333676
      - cell "--":
        - link "--":
          - /url: https://qa.loprx.com/requests/333676
      - cell "08/06/2025 22:45:22":
        - link "08/06/2025 22:45:22":
          - /url: https://qa.loprx.com/requests/333676
    - row "340673 Minh Phong portal_auto_lawyer@testmail.loprx.com -- 09/11/2025 21:30:18":
      - cell "340673":
        - link "340673":
          - /url: https://qa.loprx.com/shared/requests/340673
      - cell "Minh Phong portal_auto_lawyer@testmail.loprx.com":
        - link "Minh Phong portal_auto_lawyer@testmail.loprx.com":
          - /url: https://qa.loprx.com/shared/requests/340673
      - cell "--":
        - link "--":
          - /url: https://qa.loprx.com/shared/requests/340673
      - cell "09/11/2025 21:30:18":
        - link "09/11/2025 21:30:18":
          - /url: https://qa.loprx.com/shared/requests/340673
    - row "691689 Son HaiBon Phan sonphanjbwkz001+24@gmail.com -- 08/01/2025 03:46:34":
      - cell "691689":
        - link "691689":
          - /url: https://qa.loprx.com/requests/691689
      - cell "Son HaiBon Phan sonphanjbwkz001+24@gmail.com":
        - link "Son HaiBon Phan sonphanjbwkz001+24@gmail.com":
          - /url: https://qa.loprx.com/requests/691689
      - cell "--":
        - link "--":
          - /url: https://qa.loprx.com/requests/691689
      - cell "08/01/2025 03:46:34":
        - link "08/01/2025 03:46:34":
          - /url: https://qa.loprx.com/requests/691689
    - row "773076 Son01 Phan sonphanjbwkz001+1@gmail.com ádasdasdasdsa 08/22/2025 05:04:06":
      - cell "773076":
        - link "773076":
          - /url: https://qa.loprx.com/shared/requests/773076
      - cell "Son01 Phan sonphanjbwkz001+1@gmail.com":
        - link "Son01 Phan sonphanjbwkz001+1@gmail.com":
          - /url: https://qa.loprx.com/shared/requests/773076
      - cell "ádasdasdasdsa":
        - link "ádasdasdasdsa":
          - /url: https://qa.loprx.com/shared/requests/773076
      - cell "08/22/2025 05:04:06":
        - link "08/22/2025 05:04:06":
          - /url: https://qa.loprx.com/shared/requests/773076
    - row "351295 Tri01 Duc triducgog0301+1@gmail.com -- 08/04/2025 04:41:23":
      - cell "351295":
        - link "351295":
          - /url: https://qa.loprx.com/requests/351295
      - cell "Tri01 Duc triducgog0301+1@gmail.com":
        - link "Tri01 Duc triducgog0301+1@gmail.com":
          - /url: https://qa.loprx.com/requests/351295
      - cell "--":
        - link "--":
          - /url: https://qa.loprx.com/requests/351295
      - cell "08/04/2025 04:41:23":
        - link "08/04/2025 04:41:23":
          - /url: https://qa.loprx.com/requests/351295
    - row "170330 Tri01 Duc triducgog0301+1@gmail.com -- 08/25/2025 22:16:14":
      - cell "170330":
        - link "170330":
          - /url: https://qa.loprx.com/shared/requests/170330
      - cell "Tri01 Duc triducgog0301+1@gmail.com":
        - link "Tri01 Duc triducgog0301+1@gmail.com":
          - /url: https://qa.loprx.com/shared/requests/170330
      - cell "--":
        - link "--":
          - /url: https://qa.loprx.com/shared/requests/170330
      - cell "08/25/2025 22:16:14":
        - link "08/25/2025 22:16:14":
          - /url: https://qa.loprx.com/shared/requests/170330
    - row "734960 Tri01 Duc triducgog0301+1@gmail.com -- 10/26/2025 22:28:05":
      - cell "734960":
        - link "734960":
          - /url: https://qa.loprx.com/requests/734960
      - cell "Tri01 Duc triducgog0301+1@gmail.com":
        - link "Tri01 Duc triducgog0301+1@gmail.com":
          - /url: https://qa.loprx.com/requests/734960
      - cell "--":
        - link "--":
          - /url: https://qa.loprx.com/requests/734960
      - cell "10/26/2025 22:28:05":
        - link "10/26/2025 22:28:05":
          - /url: https://qa.loprx.com/requests/734960
- paragraph: Showing 1 to 10 of 10 entries
```

# Test source

```ts
   1 | import { test, expect } from '../../fixtures/index';
   2 | import { InboxPage } from '../../pom/inbox/inbox.page';
   3 | import { LoginPage } from '../../pom/login.page';
   4 |
   5 | test.describe("Verify feature inbox", () => {
   6 |     let loginPage: LoginPage;
   7 |     let inboxPage: InboxPage;
   8 |
   9 |     test.beforeEach(async ({ page, conf }) => {
   10 |         loginPage = new LoginPage(page);
   11 |         inboxPage = new InboxPage(page);
   12 |
   13 |         await loginPage.open();
   14 |         await loginPage.login(conf.data.username, conf.data.password);
   15 |         await expect(loginPage.baseLoc.dashboardContainer).toBeVisible({ timeout: 15_000 });
   16 |         await inboxPage.open();
   17 |     });
   18 |
   19 |     test("INBOX_003 - Verify feature Search", {
   20 |         tag: ["@INBOX_003", "@inbox", "@function"]
   21 |     }, async ({ conf }) => {
   22 |         await test.step(`Verify search valid data`, async () => {
   23 |             for (const value of Object.values(conf.data.valid)) {
   24 |                 await inboxPage.dashboardLoc.search.inputSearch.fill(String(value));
   25 |                 if (value === conf.data.valid.month_day_slashed || value === conf.data.valid.month_day_numeric || value === conf.data.valid.full_date_numeric) {
   26 |                     await inboxPage.waitForSecond(1);
   27 |                     await expect(inboxPage.dashboardLoc.table.noResult).not.toBeVisible();
   28 |                 } else {
   29 |                     await inboxPage.waitForSecond(1);
   30 |                     await expect(inboxPage.inboxLoc.table.dataInRow(String(value)).first()).toBeVisible();
   31 |                 }
   32 |             }
   33 |         })
   34 |
   35 |         await test.step("Verify when search with invalid data", async () => {
   36 |             await inboxPage.dashboardLoc.search.inputSearch.fill(conf.data.invalid);
   37 |             await expect(inboxPage.dashboardLoc.table.noResult).toBeVisible();
   38 |         })
   39 |     })
   40 |
   41 |     test("INBOX_004 - Verify when change entries per page", {
   42 |         tag: ["@INBOX_004", "@inbox", "@function"]
   43 |     }, async ({ conf }) => {
   44 |         await test.step("Verify with valid entries", async () => {
   45 |             const totalInboxes = await inboxPage.getTotalEntries("api/v1/share-requests/inbox");
   46 |             for (const entrie of Object.values(conf.data.valid)) {
   47 |                 await inboxPage.dashboardLoc.search.perPage.input.fill(String(entrie));
   48 |                 await expect(inboxPage.dashboardLoc.search.perPage.input).toHaveValue(String(entrie));
   49 |                 await inboxPage.page.waitForResponse(/api\/v1\/share-requests\/inbox\?per_page/, { timeout: 15_000 });
   50 |                 const tableRows = await inboxPage.getTableRowCount();
   51 |                 const showingData = parseFloat(String(entrie)) > totalInboxes ? totalInboxes : parseFloat(String(entrie))
   52 |
   53 |                 await expect(inboxPage.dashboardLoc.table.pagingSummary).toContainText(`Showing 1 to ${showingData} of ${totalInboxes} entries`);
   54 |                 expect(tableRows).toBe(parseFloat(showingData));
   55 |             }
   56 |         })
   57 |
   58 |         await test.step("Verify when enter invalid entrie", async () => {
   59 |             for (const entrie of Object.values(conf.data.invalid)) {
   60 |                 await inboxPage.dashboardLoc.search.perPage.input.fill(String(entrie));
   61 |                 await expect(inboxPage.dashboardLoc.search.perPage.input).not.toHaveValue(String(entrie));
   62 |             }
   63 |         })
   64 |     })
   65 |
   66 |     test("INBOX_005 - Verify feature sort inbox", {
   67 |         tag: ["@INBOX_005", "@inbox", "@function"]
   68 |     }, async () => {
   69 |         test.setTimeout(150_000);
   70 |         const displayNames = ['Request #', 'Sender', 'Message', 'Inbox Date'];
   71 |         const sortedFieldName = ['request_id', 'sender_name', 'message', 'created_at'];
   72 |         const propertyNames = ['request.id', 'mails.from.name', 'message', 'created_at'];
   73 |         const sortType = ["asc", "desc"];
   74 |
   75 |         for (let i = 0; i < sortType.length; i++) {
   76 |             for (let j = 0; j < displayNames.length; j++) {
   77 |                 await expect(inboxPage.dashboardLoc.table.headingColumn(displayNames[j])).toBeVisible();
   78 |
   79 |                 if (sortType[i] === "asc") {
   80 |                     await inboxPage.dashboardLoc.table.headingColumn(displayNames[j]).click();
   81 |                 } else {
   82 |                     await inboxPage.dashboardLoc.table.headingColumn(displayNames[j]).click();
   83 |                     await inboxPage.waitForSecond(2);
   84 |                     await inboxPage.dashboardLoc.table.headingColumn(displayNames[j]).click();
   85 |                     await inboxPage.waitForSecond(2);
   86 |                 }
   87 |                 await expect(inboxPage.page).toHaveURL(
   88 |                     new RegExp(`.*sort=${sortedFieldName[j]}&direction=${sortType[i]}`)
   89 |                 );
   90 |
   91 |                 let apiDataUrl = `api/v1/share-requests/inbox?sort=${sortedFieldName[j]}&direction=${sortType[i]}`;
   92 |                 const data = await inboxPage.getDataInTable(displayNames[j], propertyNames[j], apiDataUrl, false);
   93 |                 console.log(`Sort by: ${displayNames[j]}, direction: ${sortType[i]}, property: ${propertyNames[j]}`);
   94 |                 if (sortedFieldName[j] === "sender_email") {
   95 |                     data.dataApi.forEach(name => {
   96 |                         expect(data.dataUI.some(uiVal => uiVal.includes(name))).toBeTruthy();
   97 |                     });
   98 |                 } else {
>  99 |                     expect(data.dataApi).toEqual(data.dataUI);
      |                                          ^ Error: expect(received).toEqual(expected) // deep equality
  100 |                 }
  101 |             }
  102 |         }
  103 |     })
  104 |
  105 |     test("INBOX_006 - Verify feature filter", {
  106 |         tag: ["@INBOX_006", "@inbox", "@function"]
  107 |     }, async ({ conf }) => {
  108 |         for (const [filterType, fields] of Object.entries(conf.data.filter)) {
  109 |             switch (filterType) {
  110 |                 case 'text':
  111 |                     for (const [fieldName, field] of Object.entries(fields as Record<string, any>)) {
  112 |                         // Handle valid case
  113 |                         const validField = field.valid;
  114 |                         await inboxPage.dashboardLoc.search.filter.btn.click();
  115 |                         await inboxPage.dashboardLoc.search.filter.popup.btnReset.click();
  116 |                         await inboxPage.inboxLoc.filter.inputByID(validField.id).fill(validField.value);
  117 |
  118 |                         await expect(inboxPage.inboxLoc.filter.inputByID(validField.id)).toHaveValue(validField.value);
  119 |                         await inboxPage.dashboardLoc.search.filter.popup.btnApply.click();
  120 |                         await expect(inboxPage.inboxLoc.table.dataInRow(validField.value).first()).toBeVisible();
  121 |
  122 |                         // Handle invalid case
  123 |                         const invalidField = field.invalid;
  124 |                         await inboxPage.dashboardLoc.search.filter.btn.click();
  125 |                         await inboxPage.dashboardLoc.search.filter.popup.btnReset.click();
  126 |                         await inboxPage.inboxLoc.filter.inputByID(invalidField.id).fill(invalidField.value);
  127 |
  128 |                         await expect(inboxPage.inboxLoc.filter.inputByID(invalidField.id)).toHaveValue(invalidField.value);
  129 |                         await inboxPage.dashboardLoc.search.filter.popup.btnApply.click();
  130 |                         await expect(inboxPage.dashboardLoc.table.noResult).toBeVisible();
  131 |                     }
  132 |                     break;
  133 |
  134 |                 case 'select':
  135 |                     for (const [fieldName, field] of Object.entries(fields as Record<string, any>)) {
  136 |                         // Handle valid case
  137 |                         const validField = field.valid;
  138 |                         await inboxPage.dashboardLoc.search.filter.btn.click();
  139 |                         await inboxPage.dashboardLoc.search.filter.popup.btnReset.click();
  140 |                         await inboxPage.inboxLoc.filter.inputByID(validField.id).fill(validField.value);
  141 |                         await inboxPage.inboxLoc.filter.dropdownOption(validField.value).waitFor({ state: 'visible' });
  142 |                         await inboxPage.inboxLoc.filter.dropdownOption(validField.value).click();
  143 |                         await expect(inboxPage.inboxLoc.filter.inputByID(validField.id)).toHaveValue(validField.value);
  144 |
  145 |                         await inboxPage.dashboardLoc.search.filter.popup.btnApply.click();
  146 |                         await expect(inboxPage.inboxLoc.table.dataInRow(validField.value).first()).toBeVisible();
  147 |
  148 |                         // Handle invalid case
  149 |                         const invalidField = field.invalid;
  150 |                         await inboxPage.dashboardLoc.search.filter.btn.click();
  151 |                         await inboxPage.dashboardLoc.search.filter.popup.btnReset.click();
  152 |                         await inboxPage.inboxLoc.filter.inputByID(invalidField.id).fill(invalidField.value);
  153 |                         await expect(inboxPage.inboxLoc.filter.noOption).toBeVisible();
  154 |                     }
  155 |                     break;
  156 |
  157 |                 default:
  158 |                     console.warn(`Unknown filter type: ${filterType}`);
  159 |             }
  160 |         }
  161 |     })
  162 | })
```