# Test info

- Name: Case already exists >> CASE_017 - Verify when archived/unArchived case has request and transfer to another case
- Location: /root/code/portal-automation-test/tests/case/crud/crud.spec.ts:260:7

# Error details

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

Locator: locator('//div/h3[text()=\'Archive\']')
Expected: visible
Received: hidden
Call log:
  - expect.toBeVisible with timeout 10000ms
  - waiting for locator('//div/h3[text()=\'Archive\']')
    13 × locator resolved to <h3 class="modal-title f-20 d-flex align-items-center ga-8">Archive</h3>
       - unexpected value "hidden"

    at /root/code/portal-automation-test/tests/case/crud/crud.spec.ts:267:74
    at /root/code/portal-automation-test/tests/case/crud/crud.spec.ts:263:5
```

# 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. 10 hours ago
  - img
  - text: Son HaiBon Phan assigned a request to you 10 hours ago
  - img
  - text: Son HaiBon Phan assigned a case to you 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 "0 Cart":
    - img
    - text: 0 Cart
  - text: Feedback
  - img
  - link "Open user menu":
    - /url: "#"
    - text: Minh
- text: "This case has been hidden. You can restore it by unarchiving. #872135 Auto Test Duy Nhat 123"
- img
- img
- text: "DOI: 01/03/2005 - Category: Bus Accidents"
- 'link "DOB: 03/01/1999"':
  - /url: /clients/d1039da4-60db-4c39-bc98-252676268ba5
- text: Tag
- img
- img
- 'button "Status: Open"'
- button:
  - listbox:
    - listitem:
      - text: "Status Details: Open"
      - img
- 'button "Service Date: --"'
- 'button "Assignee: --"':
  - text: "Assignee: --"
  - img
- button "Activity":
  - img
  - text: Activity
- button "Update Case"
- paragraph: Awesome! The Auto Test Duy Nhat 123 case file is ready to go!
- paragraph:
  - text: Click on "Get Started" to submit your request or inquiries for this case now!
  - link "Get Started":
    - /url: /requests/create?patient_id=d1039da4-60db-4c39-bc98-252676268ba5&doi=01/03/2005
- img
- img "Minh Phong (You)"
- img "Team Discussion"
- heading "Discussion" [level=2]
- heading "Minh Phong (You)" [level=4]
- img
- heading "Team Discussion" [level=4]
- img
```

# Test source

```ts
  167 |       await casePage.dashboardLoc.modal.headerModal("Case Detail").click();
  168 |       await casePage.dashboardLoc.buttonByText("Update").first().click({ force: true });
  169 |       await expect(casePage.caseLoc.detail.addLegalModal.msgSuccess.first()).toBeVisible();
  170 |       await expect(casePage.dashboardLoc.modal.headerModal("Case Detail")).not.toBeVisible();
  171 |     })
  172 |
  173 |     await test.step("Teardown data", async () => {
  174 |       await casePage.caseLoc.detail.buttonUpdateCase.click();
  175 |       await expect(casePage.dashboardLoc.modal.headerModal("Case Detail")).toBeVisible();
  176 |
  177 |       // Clear all form fields
  178 |       for (const formField of casePage.caseUpdateForm) {
  179 |         await casePage.caseLoc.detail.update.fieldForm(formField.type, formField.inputName).clear();
  180 |       }
  181 |
  182 |       await casePage.dashboardLoc.buttonByText("Update").first().click();
  183 |       await expect(casePage.caseLoc.detail.addLegalModal.msgSuccess.first()).toBeVisible();
  184 |     });
  185 |   })
  186 |
  187 |   test("CASE_015 - Verify update case when clear Law Firm, Counsel and Case Manager", {
  188 |     tag: ['@CASE_015', '@case', '@function']
  189 |   }, async ({ conf }) => {
  190 |     await test.step("Clear Law Firm, Counsel and Case Manager and submit", async () => {
  191 |       await casePage.caseLoc.detail.update.selectLawFirm("autocomplete_law_firm_id").first().click();
  192 |       await casePage.caseLoc.detail.update.selectLawFirm("autocomplete_lawyer_id").first().click();
  193 |       await casePage.caseLoc.detail.update.selectLawFirm("autocomplete_case_manager_id").first().click();
  194 |       await casePage.dashboardLoc.buttonByText("Update").first().click();
  195 |
  196 |       await expect(casePage.caseLoc.detail.addLegalModal.msgSuccess.first()).toBeVisible();
  197 |       await expect(casePage.dashboardLoc.modal.headerModal("Case Detail")).not.toBeVisible();
  198 |       await expect(casePage.caseLoc.detail.noLegal).toBeVisible();
  199 |     })
  200 |
  201 |     await test.step("Teardown data", async () => {
  202 |       await casePage.fillLegalContact(conf.data.business, conf.data.user_recive_case);
  203 |       await casePage.dashboardLoc.buttonByText("Submit").nth(2).click();
  204 |       await expect(casePage.caseLoc.detail.addLegalModal.msgSuccess.first()).toBeVisible();
  205 |       await expect(casePage.caseLoc.detail.noLegal).not.toBeVisible();
  206 |     })
  207 |   })
  208 |
  209 |   test("CASE_016 - Verify when archived/unArchived case has no request yet", {
  210 |     tag: ['@CASE_016', '@case', '@function']
  211 |   }, async ({ conf, casePage16 }) => {
  212 |     test.setTimeout(150_000);
  213 |     await test.step("Verify when archive case", async () => {
  214 |       await expect(casePage16.caseLoc.detail.buttonUpdateCase).toBeVisible();
  215 |       await casePage16.caseLoc.detail.buttonUpdateCase.click({ force: true });
  216 |       await casePage16.dashboardLoc.buttonByText("Archive").first().click();
  217 |       await expect(casePage16.caseLoc.detail.update.msgArchive).toBeVisible();
  218 |       await casePage.dashboardLoc.btnClosePopupNotification.click();
  219 |
  220 |       await expect(casePage16.dashboardLoc.modal.headerModalh2("Case Detail")).not.toBeVisible();
  221 |       await expect(casePage16.caseLoc.detail.update.boxHeaderArchive).toBeVisible();
  222 |       await casePage16.page.reload();// Sau khi client update tự reload cần bỏ
  223 |
  224 |       // Verify activity
  225 |       const newestActivity = await casePage16.getNewestActivity();
  226 |       expect(newestActivity).toContain(`archive case ${await getTodayInTimeZone()}`);
  227 |
  228 |       //Verify not show in table
  229 |       await casePage16.open();
  230 |       await casePage16.dashboardLoc.search.inputSearch.fill(conf.data.case);
  231 |       await expect(casePage16.caseLoc.msgNoResultFound).toBeVisible();
  232 |     })
  233 |
  234 |     await test.step("Verify when unArchive case", async () => {
  235 |       //Verify data show in archived table
  236 |       await casePage16.dashboardLoc.search.filter.btn.click();
  237 |       await casePage16.caseLoc.inputArchive.fill("Yes");
  238 |       await casePage16.caseLoc.boxSelectArchive.click();
  239 |       await casePage16.dashboardLoc.search.filter.popup.btnApply.click();
  240 |       await expect(casePage16.dashboardLoc.table.itemInRow(conf.data.case)).toBeVisible();
  241 |
  242 |       //Verify when unArchive case
  243 |       await casePage16.dashboardLoc.table.itemInRow(conf.data.case).click();
  244 |       await casePage16.caseLoc.detail.update.btnUnArchive.click();
  245 |       await expect(casePage16.caseLoc.detail.update.msgUnArchive.first()).toBeVisible();
  246 |       await expect(casePage16.caseLoc.detail.update.boxHeaderArchive).not.toBeVisible();
  247 |       await casePage16.page.reload(); // Sau khi client update tự reload cần bỏ
  248 |
  249 |       // Verify change activity
  250 |       const newestActivity = await casePage16.getNewestActivity();
  251 |       expect(newestActivity).toContain(`unarchive case ${await getTodayInTimeZone()}`);
  252 |
  253 |       //Verify case exist in table
  254 |       await casePage16.open();
  255 |       await casePage16.dashboardLoc.search.inputSearch.fill(conf.data.case);
  256 |       await expect(casePage16.dashboardLoc.table.itemInRow(conf.data.case)).toBeVisible();
  257 |     })
  258 |   })
  259 |
  260 |   test("CASE_017 - Verify when archived/unArchived case has request and transfer to another case", {
  261 |     tag: ['@CASE_017', '@case', '@function']
  262 |   }, async ({ conf, casePage17 }) => {
  263 |     await test.step("Verify when archive case and transfer case", async () => {
  264 |       await expect(casePage17.dashboardLoc.buttonByText("Archive").first()).toBeVisible();
  265 |       await casePage17.dashboardLoc.buttonByText("Archive").first().click();
  266 |
> 267 |       await expect(casePage17.dashboardLoc.modal.headerModal("Archive")).toBeVisible();
      |                                                                          ^ Error: Timed out 10000ms waiting for expect(locator).toBeVisible()
  268 |       await casePage17.caseLoc.detail.transfer.inputTransfer.click();
  269 |       await casePage17.caseLoc.detail.transfer.inputTransfer.type(conf.data.case_transfer_to, { delay: 100 });
  270 |       await casePage17.caseLoc.detail.transfer.boxOption(conf.data.case_transfer_to).click();
  271 |       await casePage17.dashboardLoc.buttonByText("Archive").nth(1).click();
  272 |
  273 |       await expect(casePage17.caseLoc.detail.update.btnUnArchive).toBeVisible();
  274 |
  275 |       // Verify activity 
  276 |       await casePage17.waitForSecond(3); // Load for update new activity
  277 |       const newestActivity = await casePage17.getNewestActivity();
  278 |       expect(newestActivity).toContain(`archive case and moved request Case: #${conf.data.case_transfer} #${conf.data.case_transfer_to}`);
  279 |     });
  280 |
  281 |     await test.step("Verify when unarchive case", async () => {
  282 |       await casePage17.caseLoc.detail.update.btnUnArchive.click();
  283 |       await expect(casePage17.caseLoc.detail.update.msgUnArchive.first()).toBeVisible();
  284 |       await expect(casePage17.caseLoc.detail.update.boxHeaderArchive).not.toBeVisible();
  285 |     })
  286 |
  287 |     await test.step("Verify case have request had transfered", async () => {
  288 |       await casePage17.open();
  289 |       await casePage17.getDetailCase(conf.data.case_transfer_to);
  290 |       await casePage17.waitForSecond(2);
  291 |       const requests = (await casePage17.caseLoc.detail.requestExist(conf.data.request_id_exist).all()).length;
  292 |       expect(requests).toBe(2);
  293 |     })
  294 |
  295 |     await test.step("Transfer teardown data", async () => {
  296 |       //Transfer again to old case
  297 |       await casePage17.clickButtonDropdownSelect("BTN_SHOW_MOVE_REQUEST_OF_BUSINESS_MODAL");
  298 |       await expect(casePage17.dashboardLoc.modal.headerModal("Move Requests")).toBeVisible();
  299 |       await casePage17.caseLoc.detail.inputMoveRequest.click();
  300 |       await casePage17.caseLoc.detail.inputMoveRequest.type(conf.data.case_transfer, { delay: 100 });
  301 |       await casePage17.caseLoc.detail.transfer.boxOption(conf.data.case_transfer).click();
  302 |       await casePage17.caseLoc.buttonByText("Move").click();
  303 |     })
  304 |   })
  305 |
  306 |   test("CASE_018 - Verify when archived/unArchived case has been requested and not transferred to another case", {
  307 |     tag: ['@CASE_018', '@case', '@function']
  308 |   }, async ({ conf, casePage18 }) => {
  309 |     test.setTimeout(180_000);
  310 |     let numberRequest: number;
  311 |
  312 |     await test.step("Go to get number requests in dashboard", async () => {
  313 |       await casePage18.page.goto("")
  314 |       await expect(casePage18.dashboardLoc.common.pText("My Requests")).toBeVisible();
  315 |       await casePage18.dashboardLoc.common.pText("My Requests").click();
  316 |
  317 |       await expect(casePage18.dashboardLoc.filterMonitor.requestTypeNumber.first()).toBeVisible();
  318 |       await casePage18.waitForSecond(2);
  319 |       const textRequest = await casePage18.dashboardLoc.filterMonitor.requestTypeNumber.first().innerText();
  320 |       numberRequest = parseInt(textRequest);
  321 |     });
  322 |
  323 |     await test.step("Verify archive and not transferred to another case", async () => {
  324 |       // Get detail case
  325 |       await casePage18.open();
  326 |       await casePage18.getDetailCase(conf.data.case);
  327 |       await expect(casePage18.caseLoc.detail.buttonUpdateCase).toBeVisible();
  328 |
  329 |       // Archive case
  330 |       await casePage18.caseLoc.detail.buttonUpdateCase.click({ force: true });
  331 |       await casePage.dashboardLoc.buttonByText("Archive").first().click();
  332 |       await expect(casePage18.dashboardLoc.modal.headerModal("Archive")).toBeVisible();
  333 |
  334 |       await casePage18.caseLoc.detail.transfer.radioCheckArchive.click();
  335 |       await casePage.dashboardLoc.buttonByText("Archive").nth(1).click();
  336 |       await expect(casePage18.caseLoc.detail.transfer.msgArchive).toBeVisible();
  337 |       await casePage18.dashboardLoc.btnClosePopupNotification.click();
  338 |     });
  339 |
  340 |     await test.step("Verify requests archive in table", async () => {
  341 |       await casePage18.page.reload();
  342 |       await expect(casePage18.caseLoc.detail.dataIntable("Archived Request", conf.data.request_id_exist)).toBeVisible();
  343 |       await expect(casePage18.caseLoc.detail.requestTableNoResult).toBeVisible();
  344 |
  345 |       // unArchive case
  346 |       await casePage18.caseLoc.detail.update.btnUnArchive.click();
  347 |       await expect(casePage18.caseLoc.detail.update.msgUnArchive.first()).toBeVisible();
  348 |       await casePage18.dashboardLoc.btnClosePopupNotification.click();
  349 |     });
  350 |
  351 |     await test.step("Verify requests change number in dashboard", async () => {
  352 |       await casePage18.page.goto("")
  353 |       await expect(casePage18.dashboardLoc.common.pText("My Requests")).toBeVisible();
  354 |       await casePage18.dashboardLoc.common.pText("My Requests").click();
  355 |       await casePage18.waitForSecond(2);
  356 |       const textRequestAfter = await casePage18.dashboardLoc.filterMonitor.requestTypeNumber.first().innerText();
  357 |       const numberRequestAfter = parseInt(textRequestAfter);
  358 |       expect(numberRequestAfter).toBe(numberRequest - 1);
  359 |     });
  360 |
  361 |     await test.step("Verify requests back to request table", async () => {
  362 |       await casePage18.open();
  363 |       await casePage18.getDetailCase(conf.data.case);
  364 |       await expect(casePage18.caseLoc.detail.requestExist(conf.data.request_id_exist).first()).toBeVisible();
  365 |       await casePage18.waitForSecond(1);
  366 |       await casePage18.caseLoc.detail.requestExist(conf.data.request_id_exist).first().click({ force: true });
  367 |       await casePage18.caseLoc.detail.update.btnUnArchive.click();
```