# Test info

- Name: Feature case for request-listing >> REQ_005 - Verify feature sort
- Location: /root/code/portal-automation-test/tests/request/function.spec.ts:30:9

# Error details

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

Locator: locator(':root')
Expected pattern: /.*sort=created_by_business_id&direction=asc/
Received string:  "https://qa.loprx.com/requests?sort=created_by_business_name&direction=asc"
Call log:
  - expect.toHaveURL with timeout 10000ms
  - waiting for locator(':root')
    13 × locator resolved to <html lang="en" class=" ">…</html>
       - unexpected value "https://qa.loprx.com/requests?sort=created_by_business_name&direction=asc"

    at /root/code/portal-automation-test/tests/request/function.spec.ts:40:44
```

# Page snapshot

```yaml
- complementary:
  - img
  - link:
    - /url: /
  - list:
    - listitem:
      - link:
        - /url: https://qa.loprx.com
        - img
    - listitem:
      - link:
        - /url: https://qa.loprx.com/cases
        - img
    - listitem:
      - link:
        - /url: https://qa.loprx.com/requests
        - img
    - listitem:
      - link:
        - /url: https://qa.loprx.com/clients
        - img
    - listitem:
      - button:
        - img
    - listitem:
      - button:
        - img
    - listitem:
      - button:
        - img
  - list:
    - listitem:
      - button:
        - img
- banner:
  - button:
    - img
  - button [disabled]:
    - img
  - img
  - text: Tri01 Duc shared details regarding Not Accept This Request Medical Bill. See the information now. 11 hours ago
  - img
  - text: "Get the details: Tri01 Duc's response to the Letter of Protection New Patient Test is now available. 11 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 "4 Cart":
    - img
    - text: 4 Cart
  - text: Feedback
  - img
  - link "Open user menu":
    - /url: "#"
    - text: Minh
- img
- text: Requests
- button "New Request":
  - img
  - text: New Request
- text: Tips
- img
- text: Think of the request section as your case file's magnifying glass. Here, you can zoom in on specific details and find exactly what you're looking for. Plus, you get a quick snapshot of each request's status - what's been requested, how it's progressing, and if it's been resolved. Click on
- link "\"New Request\"":
  - /url: /requests/create
- text: to try it out!
- heading "Manage" [level=2]:
  - text: Manage
  - img
- img
- text: Show
- textbox: "10"
- text: entries
- button "4 Quick Submit"
- button "Bulk Edit":
  - img
  - text: Bulk Edit
- button "Filter":
  - img
  - text: Filter
- img
- textbox "Search..."
- table:
  - rowgroup:
    - 'row "Pin Request #  Case #  Request  Client Name  From  Directed To  Status  Status Details  Actions"':
      - cell "Pin"
      - 'cell "Request # "'
      - 'cell "Case # "'
      - cell "Request "
      - cell "Client Name "
      - cell "From "
      - cell "Directed To "
      - cell "Status "
      - cell "Status Details "
      - cell "Actions"
  - rowgroup:
    - row "825928 999033 Medical Bill D D (Portal-Auto-Lawyer) Missing Open Inquiry":
      - cell:
        - img
      - cell "825928":
        - link "825928":
          - /url: /requests/825928
      - cell "999033":
        - link "999033":
          - /url: /cases/999033
      - cell "Medical Bill":
        - link "Medical Bill":
          - /url: /requests/825928
          - img
          - text: Medical Bill
      - cell "D D":
        - link "D D":
          - /url: /requests/825928
      - cell "(Portal-Auto-Lawyer)":
        - link "(Portal-Auto-Lawyer)":
          - /url: /requests/825928
      - cell "Missing":
        - link "Missing":
          - /url: /requests/825928
        - img
      - cell "Open":
        - link "Open":
          - /url: /requests/825928
      - cell "Inquiry":
        - link "Inquiry":
          - /url: /requests/825928
      - cell:
        - img
        - img
    - row "531352 217790 Letter of Protection Case004-08 Autotest (Portal-Auto-Lawyer) A Taylor Law Firm Open Awaiting":
      - cell:
        - img
      - cell "531352":
        - link "531352":
          - /url: /requests/531352
      - cell "217790":
        - link "217790":
          - /url: /cases/217790
      - cell "Letter of Protection":
        - link "Letter of Protection":
          - /url: /requests/531352
          - img
          - text: Letter of Protection
      - cell "Case004-08 Autotest":
        - link "Case004-08 Autotest":
          - /url: /requests/531352
      - cell "(Portal-Auto-Lawyer)":
        - link "(Portal-Auto-Lawyer)":
          - /url: /requests/531352
      - cell "A Taylor Law Firm":
        - link "A Taylor Law Firm":
          - /url: /requests/531352
      - cell "Open":
        - link "Open":
          - /url: /requests/531352
      - cell "Awaiting":
        - link "Awaiting":
          - /url: /requests/531352
      - cell:
        - img
        - img
    - row "506803 455538 Prescription Case004-14 Autotest (Portal-Auto-Lawyer) (Portal-Auto-Lawyer) Open Script Sent":
      - cell:
        - img
      - cell "506803":
        - link "506803":
          - /url: /requests/506803
      - cell "455538":
        - link "455538":
          - /url: /cases/455538
      - cell "Prescription":
        - link "Prescription":
          - /url: /requests/506803
          - img
          - text: Prescription
      - cell "Case004-14 Autotest":
        - link "Case004-14 Autotest":
          - /url: /requests/506803
      - cell "(Portal-Auto-Lawyer)":
        - link "(Portal-Auto-Lawyer)":
          - /url: /requests/506803
      - cell "(Portal-Auto-Lawyer)":
        - link "(Portal-Auto-Lawyer)":
          - /url: /requests/506803
      - cell "Open":
        - link "Open":
          - /url: /requests/506803
      - cell "Script Sent":
        - link "Script Sent":
          - /url: /requests/506803
      - cell:
        - img
        - img
    - row "742830 455538 Letter of Protection Case004-14 Autotest (Portal-Auto-Lawyer) Missing Open Awaiting":
      - cell:
        - img
      - cell "742830":
        - link "742830":
          - /url: /requests/742830
      - cell "455538":
        - link "455538":
          - /url: /cases/455538
      - cell "Letter of Protection":
        - link "Letter of Protection":
          - /url: /requests/742830
          - img
          - text: Letter of Protection
      - cell "Case004-14 Autotest":
        - link "Case004-14 Autotest":
          - /url: /requests/742830
      - cell "(Portal-Auto-Lawyer)":
        - link "(Portal-Auto-Lawyer)":
          - /url: /requests/742830
      - cell "Missing":
        - link "Missing":
          - /url: /requests/742830
        - img
      - cell "Open":
        - link "Open":
          - /url: /requests/742830
      - cell "Awaiting":
        - link "Awaiting":
          - /url: /requests/742830
      - cell:
        - img
        - img
    - row "919163 455538 Letter of Protection Case004-14 Autotest (Portal-Auto-Lawyer) Son35 Pharmacy Open Awaiting":
      - cell:
        - img
      - cell "919163":
        - link "919163":
          - /url: /requests/919163
      - cell "455538":
        - link "455538":
          - /url: /cases/455538
      - cell "Letter of Protection":
        - link "Letter of Protection":
          - /url: /requests/919163
          - img
          - text: Letter of Protection
      - cell "Case004-14 Autotest":
        - link "Case004-14 Autotest":
          - /url: /requests/919163
      - cell "(Portal-Auto-Lawyer)":
        - link "(Portal-Auto-Lawyer)":
          - /url: /requests/919163
      - cell "Son35 Pharmacy":
        - link "Son35 Pharmacy":
          - /url: /requests/919163
      - cell "Open":
        - link "Open":
          - /url: /requests/919163
      - cell "Awaiting":
        - link "Awaiting":
          - /url: /requests/919163
      - cell:
        - img
        - img
    - row "271985 455538 Letter of Protection Case004-14 Autotest (Portal-Auto-Lawyer) Son35 Pharmacy Open Awaiting":
      - cell:
        - img
      - cell "271985":
        - link "271985":
          - /url: /requests/271985
      - cell "455538":
        - link "455538":
          - /url: /cases/455538
      - cell "Letter of Protection":
        - link "Letter of Protection":
          - /url: /requests/271985
          - img
          - text: Letter of Protection
      - cell "Case004-14 Autotest":
        - link "Case004-14 Autotest":
          - /url: /requests/271985
      - cell "(Portal-Auto-Lawyer)":
        - link "(Portal-Auto-Lawyer)":
          - /url: /requests/271985
      - cell "Son35 Pharmacy":
        - link "Son35 Pharmacy":
          - /url: /requests/271985
      - cell "Open":
        - link "Open":
          - /url: /requests/271985
      - cell "Awaiting":
        - link "Awaiting":
          - /url: /requests/271985
      - cell:
        - img
        - img
    - row "878018 455538 Letter of Protection Case004-14 Autotest (Portal-Auto-Lawyer) Son35 Pharmacy Open Awaiting":
      - cell:
        - img
      - cell "878018":
        - link "878018":
          - /url: /requests/878018
      - cell "455538":
        - link "455538":
          - /url: /cases/455538
      - cell "Letter of Protection":
        - link "Letter of Protection":
          - /url: /requests/878018
          - img
          - text: Letter of Protection
      - cell "Case004-14 Autotest":
        - link "Case004-14 Autotest":
          - /url: /requests/878018
      - cell "(Portal-Auto-Lawyer)":
        - link "(Portal-Auto-Lawyer)":
          - /url: /requests/878018
      - cell "Son35 Pharmacy":
        - link "Son35 Pharmacy":
          - /url: /requests/878018
      - cell "Open":
        - link "Open":
          - /url: /requests/878018
      - cell "Awaiting":
        - link "Awaiting":
          - /url: /requests/878018
      - cell:
        - img
        - img
    - row "193103 455538 Letter of Protection Case004-14 Autotest (Portal-Auto-Lawyer) Son35 Pharmacy Open Awaiting":
      - cell:
        - img
      - cell "193103":
        - link "193103":
          - /url: /requests/193103
      - cell "455538":
        - link "455538":
          - /url: /cases/455538
      - cell "Letter of Protection":
        - link "Letter of Protection":
          - /url: /requests/193103
          - img
          - text: Letter of Protection
      - cell "Case004-14 Autotest":
        - link "Case004-14 Autotest":
          - /url: /requests/193103
      - cell "(Portal-Auto-Lawyer)":
        - link "(Portal-Auto-Lawyer)":
          - /url: /requests/193103
      - cell "Son35 Pharmacy":
        - link "Son35 Pharmacy":
          - /url: /requests/193103
      - cell "Open":
        - link "Open":
          - /url: /requests/193103
      - cell "Awaiting":
        - link "Awaiting":
          - /url: /requests/193103
      - cell:
        - img
        - img
    - row "199400 455538 Letter of Protection Case004-14 Autotest (Portal-Auto-Lawyer) Son35 Pharmacy Open Awaiting":
      - cell:
        - img
      - cell "199400":
        - link "199400":
          - /url: /requests/199400
      - cell "455538":
        - link "455538":
          - /url: /cases/455538
      - cell "Letter of Protection":
        - link "Letter of Protection":
          - /url: /requests/199400
          - img
          - text: Letter of Protection
      - cell "Case004-14 Autotest":
        - link "Case004-14 Autotest":
          - /url: /requests/199400
      - cell "(Portal-Auto-Lawyer)":
        - link "(Portal-Auto-Lawyer)":
          - /url: /requests/199400
      - cell "Son35 Pharmacy":
        - link "Son35 Pharmacy":
          - /url: /requests/199400
      - cell "Open":
        - link "Open":
          - /url: /requests/199400
      - cell "Awaiting":
        - link "Awaiting":
          - /url: /requests/199400
      - cell:
        - img
        - img
    - row "179253 455538 Letter of Protection Case004-14 Autotest (Portal-Auto-Lawyer) Son35 Pharmacy Open Awaiting":
      - cell:
        - img
      - cell "179253":
        - link "179253":
          - /url: /requests/179253
      - cell "455538":
        - link "455538":
          - /url: /cases/455538
      - cell "Letter of Protection":
        - link "Letter of Protection":
          - /url: /requests/179253
          - img
          - text: Letter of Protection
      - cell "Case004-14 Autotest":
        - link "Case004-14 Autotest":
          - /url: /requests/179253
      - cell "(Portal-Auto-Lawyer)":
        - link "(Portal-Auto-Lawyer)":
          - /url: /requests/179253
      - cell "Son35 Pharmacy":
        - link "Son35 Pharmacy":
          - /url: /requests/179253
      - cell "Open":
        - link "Open":
          - /url: /requests/179253
      - cell "Awaiting":
        - link "Awaiting":
          - /url: /requests/179253
      - cell:
        - img
        - img
- paragraph: Showing 1 to 10 of 4875 entries
- list:
  - listitem:
    - img
    - text: Prev
  - listitem: "1"
  - listitem: "2"
  - listitem: "3"
  - listitem: ...
  - listitem: "488"
  - listitem:
    - text: Next
    - img
```

# Test source

```ts
   1 | import { test, expect } from '../../fixtures/index';
   2 | import { RequestPage } from '../../pom/request/request.page';
   3 | import { LoginPage } from '../../pom/login.page';
   4 | import path from 'path';
   5 | import { takeScreenshot, verifyScreenshot } from '../../utils/screenshot';
   6 | import { SharedRequestPage } from '../../pom/share-request.page';
   7 | import { getTodayInTimeZone } from '../../pom/utils/utlisFunc';
   8 | import { extractNumber, getRandomNumberInRange, randomString } from '../../utils/array';
   9 | import { Mail } from '../../pom/utils/mail.page';
   10 | import { CasePage } from '../../pom/case/case.page';
   11 | import { authenticator } from 'otplib'
   12 |
   13 | test.describe('Feature case for request-listing', () => {
   14 |     let loginPage: LoginPage;
   15 |     let requestPage: RequestPage;
   16 |     let msgOffNoti: string = "";
   17 |     let msgOnNoti: string = "";
   18 |     let listMailCheck: string[] = [];
   19 |     test.beforeEach(async ({ page, conf }) => {
   20 |         loginPage = new LoginPage(page);
   21 |         requestPage = new RequestPage(page);
   22 |         requestPage.loadBusinessNames(conf.data.business_singular, conf.data.business_plural);
   23 |
   24 |         await loginPage.open();
   25 |         await loginPage.login(conf.data.username, conf.data.password);
   26 |         await expect(loginPage.baseLoc.dashboardContainer).toBeVisible({ timeout: 15_000 });
   27 |         await requestPage.open();
   28 |     });
   29 |
   30 |     test('REQ_005 - Verify feature sort', {
   31 |         tag: ['@REQ_005', '@request', '@feature']
   32 |     }, async () => {
   33 |         const displayNames = ['Request #', 'Client Name', 'From', 'Directed To'];
   34 |         const sortedFieldName = ['id', 'customer_name', 'created_by_business_id', 'provider_name']
   35 |         const propertyNames = ['id', 'customer_name', 'from_business', 'to_business'];
   36 |         const directions = ['asc', 'asc', 'asc', 'asc'];
   37 |         for (let i = 0; i < displayNames.length; i++) {
   38 |             await expect(requestPage.dashboardLoc.table.headingColumn(displayNames[i])).toBeVisible();
   39 |             await requestPage.dashboardLoc.table.headingColumn(displayNames[i]).click();
>  40 |             await expect(requestPage.page).toHaveURL(
      |                                            ^ Error: Timed out 10000ms waiting for expect(locator).toHaveURL(expected)
   41 |                 new RegExp(`.*sort=${sortedFieldName[i]}&direction=${directions[i]}`)
   42 |             );
   43 |
   44 |             let apiDataUrl = `requests?return_type=json&is_archived=false&sort=${sortedFieldName[i]}&direction=${directions[i]}`;
   45 |             const data = await requestPage.getDataInTable(displayNames[i], propertyNames[i], apiDataUrl);
   46 |             console.log(`Sort by: ${displayNames[i]}, direction: ${directions[i]}, property: ${propertyNames[i]}`)
   47 |             expect(data.dataApi).toEqual(data.dataUI);
   48 |         }
   49 |     });
   50 |
   51 |     test('REQ_006 - Verify feature filter', {
   52 |         tag: ['@REQ_006', '@request', '@feature']
   53 |     }, async ({ conf }) => {
   54 |         const filterFields = requestPage.requestProps.filterProperties;
   55 |         for (let i = 0; i < filterFields.length; i++) {
   56 |             // clear filter
   57 |             await requestPage.open();
   58 |             await requestPage.waitForSecond(3);
   59 |
   60 |             // prepare locator
   61 |             let fieldLocator;
   62 |             switch (filterFields[i].type) {
   63 |                 case 'input':
   64 |                     fieldLocator = requestPage.dashboardLoc.search.filter.popup.inputField(filterFields[i].name);
   65 |                     break;
   66 |                 default:
   67 |                     throw new Error(`Unsupported filter type: ${filterFields[i].type}`);
   68 |             }
   69 |
   70 |             // Fill invalid value
   71 |             await requestPage.dashboardLoc.search.filter.btn.click();
   72 |             await expect(requestPage.dashboardLoc.search.filter.popup.container).toBeVisible();
   73 |             await fieldLocator.fill(conf.data.filter_data[filterFields[i].name].invalid_data);
   74 |             await requestPage.dashboardLoc.search.filter.popup.btnApply.click();
   75 |             await expect(requestPage.dashboardLoc.table.noResult).toBeVisible();
   76 |
   77 |             // Fill valid value
   78 |             await requestPage.dashboardLoc.search.filter.btn.click();
   79 |             await expect(requestPage.dashboardLoc.search.filter.popup.container).toBeVisible();
   80 |             await fieldLocator.fill(conf.data.filter_data[filterFields[i].name].valid_data);
   81 |             await requestPage.dashboardLoc.search.filter.popup.btnApply.click();
   82 |             await expect(requestPage.dashboardLoc.table.noResult).not.toBeVisible();
   83 |         }
   84 |     });
   85 |
   86 |     test('REQ_007 - Verify feature Pin', {
   87 |         tag: ['@REQ_007', '@request', '@feature']
   88 |     }, async ({ conf }) => {
   89 |         await test.step('Search and verify icon Pin visible', async () => {
   90 |             //Search
   91 |             await requestPage.requestLoc.inputSearch.fill(conf.data.case_number);
   92 |             await expect(requestPage.requestLoc.tableHeadingColumn('Pin')).toBeVisible();
   93 |
   94 |             //verify icon Pin visible
   95 |             await expect(requestPage.requestLoc.pinIcon(conf.data.case_number)).toBeVisible()
   96 |         });
   97 |         await test.step('Verify Pin and unpin feature', async () => {
   98 |             //Click Pin icon and verify
   99 |             await requestPage.requestLoc.pinIcon(conf.data.case_number).click();
  100 |             await expect(requestPage.requestLoc.pinnedIcon(conf.data.case_number)).toBeVisible();
  101 |             await expect(requestPage.requestLoc.firstCaseNumber(conf.data.case_number)).toBeVisible();
  102 |
  103 |             // Click unpin
  104 |             await requestPage.requestLoc.pinnedIcon(conf.data.case_number).click()
  105 |             await expect(requestPage.requestLoc.pinIcon(conf.data.case_number)).toBeVisible();
  106 |
  107 |         });
  108 |     });
  109 |
  110 |     test('REQ_008 - Verify feature customized columns', {
  111 |         tag: ['@REQ_008', '@request', '@ui']
  112 |     }, async () => {
  113 |         const customThreeDotLocator = requestPage.genLoc("//div[contains(@class, 'card-header')]//span[contains(@class, 'cursor-pointer')]").nth(1);
  114 |         // Verify default columns displayed
  115 |         await test.step("Verify default columns displayed", async () => {
  116 |             const customizedColumns = requestPage.requestProps.customizedColumns;
  117 |             for (let i = 0; i < customizedColumns.length; i++) {
  118 |                 if (customizedColumns[i].default) {
  119 |                     await expect(requestPage.dashboardLoc.listing.heading.headingColumn(customizedColumns[i].tableDisplayName)).toBeVisible();
  120 |                 }
  121 |             }
  122 |         });
  123 |
  124 |         // Verify customized column show disable items and active items
  125 |         await test.step("Verify customized columns popup state", async () => {
  126 |             await requestPage.openThreedotMenu(requestPage.requestProps.threeDotDropdownMenus.customizedColumn, customThreeDotLocator);
  127 |
  128 |             // Verify enabled column and disabled column
  129 |             const customizedColumns = requestPage.requestProps.customizedColumns;
  130 |             for (let i = 0; i < customizedColumns.length; i++) {
  131 |                 if (customizedColumns[i].default) {
  132 |                     await expect(requestPage.dashboardLoc.listing.popup.customizedColumn.columnCheckbox(customizedColumns[i].name)).toBeDisabled();
  133 |                 } else {
  134 |                     await expect(requestPage.dashboardLoc.listing.popup.customizedColumn.columnCheckbox(customizedColumns[i].name)).toBeEnabled();
  135 |                 }
  136 |             }
  137 |         });
  138 |
  139 |         // Pre-condition: disable all enabled column
  140 |         await test.step("Pre-condition: disable all enabled column", async () => {
```