# Test info

- Name: Validation my company profile tests >> SETTING_004 - Verify when user update data detail fail
- Location: /root/code/portal-automation-test/tests/settings/my_company/my_company_profile.spec.ts:112:9

# Error details

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

Locator: locator('//div[@id=\'root\' and @class=\'dashboard-index\']')
Expected: visible
Received: <element(s) not found>
Call log:
  - expect.toBeVisible with timeout 10000ms
  - waiting for locator('//div[@id=\'root\' and @class=\'dashboard-index\']')

    at /root/code/portal-automation-test/tests/settings/my_company/my_company_profile.spec.ts:63:60
```

# Page snapshot

```yaml
- text: Email Address
- textbox "your@email.com": portal_auto_lawyer@testmail.loprx.com
- text: These credentials do not match our records. Password
- textbox "Your password"
- img
- checkbox "Remember me for 30 days"
- text: Remember me for 30 days
- button:
  - img
- button "Log in"
- paragraph:
  - text: By continuing, you agree to the
  - link "Terms of Use":
    - /url: https://portalassistant.com/terms-of-service/
  - text: ","
  - link "Privacy Policy":
    - /url: https://portalassistant.com/privacy-policy/
  - text: and
  - link "Business Associate Agreement":
    - /url: https://portalassistant.com/baa/
- link "Forgot Password":
  - /url: https://qa.loprx.com/forgot-password
- link "Login with passcode":
  - /url: https://qa.loprx.com/sign-in-with-passcode
```

# Test source

```ts
   1 | import { expect, test } from '../../../fixtures';
   2 | import { LoginPage } from '../../../pom/login.page';
   3 | import { MyCompanyPage } from '../../../pom/setting/my_company.page';
   4 | import { randomString } from '../../../utils/array';
   5 |
   6 | test.describe('UI my company profile tests', async () => {
   7 |     let loginPage: LoginPage;
   8 |     let myCompanyPage: MyCompanyPage;
   9 |
   10 |     test.beforeEach(async ({ page, conf }) => {
   11 |         loginPage = new LoginPage(page);
   12 |         myCompanyPage = new MyCompanyPage(page);
   13 |
   14 |         await loginPage.open();
   15 |         await loginPage.login(conf.data.username, conf.data.password);
   16 |         await expect(loginPage.baseLoc.dashboardContainer).toBeVisible();
   17 |     });
   18 |
   19 |     test('SETTING_001 - Verify UI my company profile', {
   20 |         tag: ['@SETTING_001', '@my_company', '@ui']
   21 |     }, async ({ conf }) => {
   22 |
   23 |         await test.step('Click menu my company, verify các field', async () => {
   24 |             await myCompanyPage.open();
   25 |             await expect(myCompanyPage.myCompanyLoc.title).toBeVisible();
   26 |
   27 |             // Verify screenshot
   28 |             await expect(myCompanyPage.page.locator('#root')).toMatchAriaSnapshot(`
   29 |               - heading "Detail" [level=2]
   30 |               - img
   31 |               - text: Name *
   32 |               - textbox "Name *": (Portal-Auto-Lawyer)
   33 |               - text: Phone Number
   34 |               - textbox "Phone Number": /\\(\\d+\\) \\d+-\\d+/
   35 |               - text: Email Address
   36 |               - textbox "Email Address"
   37 |               - text: Address
   38 |               - textbox "Address": /\\d+ Autotest-Lawyer/
   39 |               - text: Suite, unit, etc
   40 |               - textbox "Suite, unit, etc"
   41 |               - text: City
   42 |               - textbox "City": Dallas
   43 |               - text: State
   44 |               - textbox "State": Texas
   45 |               - text: Zip/Postal Code
   46 |               - textbox "Zip/Postal Code"
   47 |               - button "Update"
   48 |               `);
   49 |         });
   50 |     });
   51 | });
   52 |
   53 | test.describe('Validation my company profile tests', async () => {
   54 |     let loginPage: LoginPage;
   55 |     let myCompanyPage: MyCompanyPage;
   56 |
   57 |     test.beforeEach(async ({ page, conf }) => {
   58 |         loginPage = new LoginPage(page);
   59 |         myCompanyPage = new MyCompanyPage(page);
   60 |
   61 |         await loginPage.open();
   62 |         await loginPage.login(conf.data.username, conf.data.password);
>  63 |         await expect(loginPage.baseLoc.dashboardContainer).toBeVisible();
      |                                                            ^ Error: Timed out 10000ms waiting for expect(locator).toBeVisible()
   64 |         await myCompanyPage.open();
   65 |     });
   66 |
   67 |     
   68 |     test('SETTING_002 - Verify validation my company profile', {
   69 |         tag: ['@SETTING_002', '@my_company', '@validation']
   70 |     }, async ({ conf }) => {
   71 |         test.slow();
   72 |         await test.step('Clear the "Name" field and click "Update".', async () => {
   73 |             await expect(myCompanyPage.dashboardLoc.modal.inputByID("input_name")).toBeVisible();
   74 |             await myCompanyPage.page.waitForTimeout(2_000); 
   75 |             await myCompanyPage.dashboardLoc.modal.inputByID("input_name").clear({force: true});
   76 |             await myCompanyPage.page.getByRole('button', { name: 'Update' }).click();
   77 |
   78 |             await expect(myCompanyPage.page.getByText('The name field is required.')).toBeVisible();
   79 |             await myCompanyPage.page.locator('input[name="email_address"]').click();
   80 |
   81 |         });
   82 |
   83 |         await test.step('Enter an invalid email in "Email Address" and click "Update".', async () => {
   84 |             await myCompanyPage.page.locator('input[name="email_address"]').fill('abcd');
   85 |             await myCompanyPage.page.waitForTimeout(2_000);
   86 |             await myCompanyPage.page.getByRole('button', { name: 'Update' }).click();
   87 |             await expect(myCompanyPage.page.getByText('The email address field is')).toBeVisible();
   88 |         });
   89 |     });
   90 |
   91 |     
   92 |     test('SETTING_003 - Verify when user update data detail success', {
   93 |         tag: ['@SETTING_003', '@my_company', '@validation']
   94 |     }, async ({ conf }) => {
   95 |         test.slow();
   96 |         let randomPhoneNumber: string;
   97 |         await test.step('Update "Phone Number" to "(435) 453-4533".', async () => {
   98 |             randomPhoneNumber = `(${randomString(3)}) 453-4555`;
   99 |             await myCompanyPage.page.locator("//input[@name='phone_number']").click();
  100 |             await myCompanyPage.page.locator("//input[@name='phone_number']").fill('          ');
  101 |             await myCompanyPage.page.locator("//input[@name='phone_number']").pressSequentially(randomPhoneNumber, { delay: 100 });
  102 |             await myCompanyPage.page.waitForTimeout(2000);
  103 |         });
  104 |
  105 |         await test.step('Click the "Update" button.', async () => {
  106 |             await myCompanyPage.page.getByRole('button', { name: 'Update' }).click();
  107 |             await expect(myCompanyPage.dashboardLoc.msgSuccess).toBeVisible();
  108 |             await expect(myCompanyPage.page.locator("//input[@name='phone_number']")).toHaveValue(randomPhoneNumber);
  109 |         });
  110 |     });
  111 |
  112 |     test('SETTING_004 - Verify when user update data detail fail', {
  113 |         tag: ['@SETTING_004', '@my_company', '@validation']
  114 |     }, async ({ conf }) => {
  115 |         await test.step('Update "Email Address" to "invalid-email".', async () => {
  116 |             await myCompanyPage.page.locator('input[name="email_address"]').fill('abcd');
  117 |             await myCompanyPage.page.waitForTimeout(2000);
  118 |         });
  119 |
  120 |         await test.step('Click the "Update" button.', async () => {
  121 |             await myCompanyPage.page.getByRole('button', { name: 'Update' }).click();
  122 |             await expect(myCompanyPage.myCompanyLoc.msgInvalidEmail).toBeVisible();
  123 |         });
  124 |     });
  125 | });
  126 |
  127 |
```