import { test, expect, Page } from '@playwright/test';
import { strictEqual } from 'assert';

let page: Page;

test.beforeAll(async ({ browser }) => {
  page = await browser.newPage();
});

test.afterAll(async () => {
  if (page !== undefined) {
    await page.close();
  }
});

test('Login', async () => {
  // Login
  await page.goto('http://192.168.1.90:20001/');
  await expect(page).toHaveTitle(/^Sign in to /);
  await page.fill("input[name='username']", 'admin');
  await page.fill("input[name='password']", '1234');
  await page.click('id=kc-login');
  await page.waitForTimeout(2000);
  //   await page.click('id=acceptBtn');
});

test('Edit Naturalperson', async () => {
  // รออัพเดท  PATH
  await page.click('id=menu-icon-customer-management');
  await page.click("//button[@id='btn-dots-PERS000001']");
  await page.click('id=view-detail-btn-undefined-edit');
  await page.click(
    "//div[contains(@class,'q-field__append q-field__marginal')]/following-sibling::div[1]",
  );
  await page.click("//span[text()='บางรัก']");
  await page.fill("(//input[@id='input-employer-id'])[1]", 'หลินปิง');
  await page.fill("(//input[@id='input-customerName'])[1]", 'บางรัก');
  await page.fill("(//input[@id='input-customerEnglishName'])[1]", 'Bangrak');
  await page.click('id=submitBtn');
  await page.waitForTimeout(2000);
});
