From c4bdd18deb716d53290110d647f3dcdc7c8a5779 Mon Sep 17 00:00:00 2001 From: Linpiing Date: Tue, 3 Dec 2024 17:59:46 +0700 Subject: [PATCH] update test --- .../JWS_BM_002_CreateHeadquarterFail.spec.ts | 146 -- .../JWS_BM_004_CreateSub-branchFail.spec.ts | 116 -- .../JWS_BM_006_CreateServicePointFail.spec.ts | 112 -- .../JWS_BM_008_ViewDetail.spec.ts | 91 -- .../JWS_BM_013_DeleteBranch.spec.ts | 219 --- .../JWS_RP_001_CorporateCustomer.spec.ts | 0 .../JWS_RP_002_HeadOfAdmin.spec.ts | 0 .../JWS_RP_003_Sale.spec.ts | 0 .../JWS_RP_004_DocumentChecker.spec.ts | 0 .../JWS_RP_005_SaleAgent.spec.ts | 0 .../JWS_RP_006_Messenger.spec.ts | 0 .../JWS_RP_007_Account.spec.ts | 0 .../JWS_RP_008_Admin.spec.ts | 0 .../JWS_RP_009_Executive.spec.ts | 0 .../JWS_RP_010_DataEntry.spec.ts | 0 .../JWS_RP_011_HeadOfAccount.spec.ts | 0 .../JWS_RP_012_HeadOfSale.spec.ts | 0 .../JWS_RP_013_PersonalCustomer.spec.ts | 0 .../JWS_RP_014_BranchManager.spec.ts | 0 .../JWS_BM_001_CreateHeadquarters.spec.ts | 55 +- ...S_BM_002-1_CreateHeadquarterFailEn.spec.ts | 206 +++ .../JWS_BM_002_CreateHeadquarterFail.spec.ts | 210 +++ .../JWS_BM_003_CreateSub-branch.spec.ts | 40 +- ...WS_BM_004-1_CreateSub-branchFailEn.spec.ts | 207 +++ .../JWS_BM_004_CreateSub-branchFail.spec.ts | 194 +++ .../JWS_BM_005_CreateServicePoint.spec.ts | 40 +- ...WS_BM_006-1_CreateServicePointFail.spec.ts | 176 +++ .../JWS_BM_006_CreateServicePointFail.spec.ts | 167 +++ .../JWS_BM_007_SelectTypeBranch.spec.ts | 62 +- .../JWS_BM_008_ViewDetail.spec.ts | 235 ++++ .../JWS_BM_009_EditBranch.spec.ts | 49 +- .../JWS_BM_010_StatusBranchandSubType.spec.ts | 42 +- .../JWS_BM_011_SearchBranchmanagement.spec.ts | 41 +- .../JWS_BM_012_CloseStatusBranch.spec.ts | 46 +- .../JWS_BM_013_DeleteBranch.spec.ts | 247 ++++ .../JWS_PM_001_CreatePersonnel.spec.ts | 961 +++++++++++++ ...JWS_PM_002-1_CreatePersonnelFailEn.spec.ts | 220 +++ .../JWS_PM_002_CreatePersonnelFail.spec.ts | 217 +++ .../JWS_PM_003_ViewDetail.spec.ts | 248 ++++ .../JWS_PM_004_EditPersonnel.spec.ts | 58 +- .../JWS_PM_005_StatusPersonnel.spec.ts | 44 +- .../JWS_PM_006_SearchPersonnel.spec.ts | 104 ++ .../JWS_PM_007_StatusPersonnelType.spec.ts | 61 +- .../JWS_PM_008_TypePersonnelFields.spec.ts | 203 ++- .../Createemployeeinlegal.spec.ts | 145 ++ .../JWS_MC_001_CreateNaturalperoson.spec.ts | 112 +- ..._002-1_CreateNaturalperosonfailEn.spec.ts} | 382 +++-- ...WS_MC_002_CreateNaturalperosonfail.spec.ts | 545 ++++++++ .../JWS_MC_003_DetailNaturalperson.spec.ts | 118 ++ .../JWS_MC_004_EditNaturalperson.spec.ts | 78 ++ .../JWS_MC_005_DeleteNaturalperson.spec.ts | 72 + .../JWS_MC_006_StatusNaturalperson.spec.ts | 125 ++ .../JWS_MC_007_CreateLegalentitly.spec.ts | 265 ++++ ..._MC_008-1_CreateLegalentitlyfailEn.spec.ts | 557 ++++++++ .../JWS_MC_008_CreateLegalentitlyfail.spec.ts | 550 ++++++++ .../JWS_MC_009_DetailLegalentitly.spec.ts | 120 ++ .../JWS_MC_010_EditLegalentitly.spec.ts | 113 ++ .../JWS_MC_011_DeleteLegalentitly.spec.ts | 72 + .../JWS_MC_012_StatusLegalentitly.spec.ts | 122 ++ .../JWS_MC_013_DropdownEmployertype.spec.ts | 477 +++++++ .../JWS_MC_014_SearchManageCustomer.spec.ts | 102 ++ ...WS_MC_015_ManageStatusCustomerType.spec.ts | 113 ++ .../JWS_MC_016_CreateEmployee.spec.ts | 331 +++++ .../JWS_MC_017-1_CreateEmployeeFailEn.spec.ts | 273 ++++ .../JWS_MC_017_CreateEmployeeFail.spec.ts | 271 ++++ .../JWS_MC_018_SeachEmployee.spec.ts | 105 ++ .../JWS_MC_019_StatusEmployeeType.spec.ts | 115 ++ .../JWS_MC_020_DetailEmployee.spec.ts | 112 ++ .../JWS_MC_021_EditEmployee.spec.ts | 93 ++ .../JWS_MC_022_DeleteEmployee.spec.ts | 125 ++ .../JWS_MC_023_StatusEmployee.spec.ts | 124 ++ .../JWS_MC_024_DropdownEmployeetype.spec.ts | 612 ++++++++ .../JWS_MC_025_CreateInNaturalperson.spec.ts | 454 ++++++ ...S_MC_026_CreateInNaturalpersonFail.spec.ts | 292 ++++ .../JWS_MC_027_CreateInLegalentitly.spec.ts | 470 +++++++ ...S_MC_028_CreateInLegalentitlyFail.spec.ts} | 0 ...D_001_CreateProductandServiceGroup.spec.ts | 44 +- ...CreateProductandServiceGroupFailEn.spec.ts | 75 + ...2_CreateProductandServiceGroupFail.spec.ts | 69 + ...JWS_PD_003_CreateProductandService.spec.ts | 96 ++ ...04-1_CreateProductandServiceFailEn.spec.ts | 87 ++ ...PD_004_CreateProductandServiceFail.spec.ts | 82 ++ .../JWS_PD_005_CreatePackage.spec.ts | 108 ++ .../JWS_PD_006_CreatePackageFail.spec.ts} | 51 +- ...JWS_PD_007_DetailProductandService.spec.ts | 58 +- .../JWS_PD_008_EditProductandService.spec.ts | 46 +- ...PD_009_StatusProductandServiceType.spec.ts | 43 +- .../JWS_PD_010_SelectTypeFields.spec.ts | 57 +- ...JWS_PD_011_StatusProductandService.spec.ts | 64 +- ...JWS_PD_012_SearchProductandService.spec.ts | 0 ...JWS_PD_013_DeleteProductandService.spec.ts | 40 +- .../JWS_WF_001_CreateWorkflow.spec.ts} | 16 +- .../JWS_PM_001_CreatePersonnel.spec.ts | 793 ----------- .../JWS_PM_002_CreatePersonnelFail.spec.ts | 128 -- .../JWS_PM_003_ViewDetail.spec.ts | 109 -- ...06_SearchPersonnel(ยังไม่เสร็จทำทีหลัง).spec.ts | 41 - .../JWS_MC_003_DetailNaturalperson.spec.ts | 34 - .../JWS_MC_004_EditNaturalperson.spec.ts | 41 - .../JWS_MC_005_DeleteNaturalperson.spec.ts | 34 - .../JWS_MC_006_StatusNaturalperson.spec.ts | 38 - .../JWS_MC_007_CreateLegalentitly.spec.ts | 132 -- .../JWS_MC_008_CreateLegalentitlyfail.spec.ts | 1226 ----------------- .../JWS_MC_010_EditLegalentitly.spec.ts | 37 - .../JWS_MC_011_DeleteLegalentitly.spec.ts | 35 - .../JWS_MC_012_StatusLegalentitly.spec.ts | 39 - .../JWS_MC_013_DropdownEmployertype.spec.ts | 57 - .../JWS_MC_014_SearchManageCustomer.spec.ts | 43 - ..._MC_015_FilterManageStatusCustomer.spec.ts | 44 - .../JWS_MC_016_CreateEmployee.spec.ts | 98 -- .../JWS_MC_017_CreateEmployeeFail.spec.ts | 297 ---- .../JWS_MC_018_SeachEmployee.spec.ts | 44 - .../JWS_MC_019_FliterStatusEmployee.spec.ts | 45 - .../JWS_MC_020_DetailEmployee.spec.ts | 33 - .../JWS_MC_021_EditEmployee.spec.ts | 33 - .../JWS_MC_022_DeleteEmployee.spec.ts | 33 - .../JWS_MC_023_StatusEmployee.spec.ts | 40 - .../JWS_MC_024_DropdownEmployeetype.spec.ts | 72 - ...C_025_CreateSubBranchNaturalperson.spec.ts | 71 - ...MC_026_CreateSubBranchLegalentitly.spec.ts | 31 - ...2_CreateProductandServiceGroupFail.spec.ts | 53 - ...JWS_PD_003_CreateProductandService.spec.ts | 75 - ...PD_004_CreateProductandServiceFail.spec.ts | 59 - .../JWS_PD_005_CreateType.spec.ts | 124 -- 123 files changed, 12136 insertions(+), 5001 deletions(-) delete mode 100644 tests/01-Admin-BranchManagement/JWS_BM_002_CreateHeadquarterFail.spec.ts delete mode 100644 tests/01-Admin-BranchManagement/JWS_BM_004_CreateSub-branchFail.spec.ts delete mode 100644 tests/01-Admin-BranchManagement/JWS_BM_006_CreateServicePointFail.spec.ts delete mode 100644 tests/01-Admin-BranchManagement/JWS_BM_008_ViewDetail.spec.ts delete mode 100644 tests/01-Admin-BranchManagement/JWS_BM_013_DeleteBranch.spec.ts rename tests/{ => 01-Manage}/00-Role&Permission/JWS_RP_001_CorporateCustomer.spec.ts (100%) rename tests/{ => 01-Manage}/00-Role&Permission/JWS_RP_002_HeadOfAdmin.spec.ts (100%) rename tests/{ => 01-Manage}/00-Role&Permission/JWS_RP_003_Sale.spec.ts (100%) rename tests/{ => 01-Manage}/00-Role&Permission/JWS_RP_004_DocumentChecker.spec.ts (100%) rename tests/{ => 01-Manage}/00-Role&Permission/JWS_RP_005_SaleAgent.spec.ts (100%) rename tests/{ => 01-Manage}/00-Role&Permission/JWS_RP_006_Messenger.spec.ts (100%) rename tests/{ => 01-Manage}/00-Role&Permission/JWS_RP_007_Account.spec.ts (100%) rename tests/{ => 01-Manage}/00-Role&Permission/JWS_RP_008_Admin.spec.ts (100%) rename tests/{ => 01-Manage}/00-Role&Permission/JWS_RP_009_Executive.spec.ts (100%) rename tests/{ => 01-Manage}/00-Role&Permission/JWS_RP_010_DataEntry.spec.ts (100%) rename tests/{ => 01-Manage}/00-Role&Permission/JWS_RP_011_HeadOfAccount.spec.ts (100%) rename tests/{ => 01-Manage}/00-Role&Permission/JWS_RP_012_HeadOfSale.spec.ts (100%) rename tests/{ => 01-Manage}/00-Role&Permission/JWS_RP_013_PersonalCustomer.spec.ts (100%) rename tests/{ => 01-Manage}/00-Role&Permission/JWS_RP_014_BranchManager.spec.ts (100%) rename tests/{ => 01-Manage}/01-Admin-BranchManagement/JWS_BM_001_CreateHeadquarters.spec.ts (84%) create mode 100644 tests/01-Manage/01-Admin-BranchManagement/JWS_BM_002-1_CreateHeadquarterFailEn.spec.ts create mode 100644 tests/01-Manage/01-Admin-BranchManagement/JWS_BM_002_CreateHeadquarterFail.spec.ts rename tests/{ => 01-Manage}/01-Admin-BranchManagement/JWS_BM_003_CreateSub-branch.spec.ts (78%) create mode 100644 tests/01-Manage/01-Admin-BranchManagement/JWS_BM_004-1_CreateSub-branchFailEn.spec.ts create mode 100644 tests/01-Manage/01-Admin-BranchManagement/JWS_BM_004_CreateSub-branchFail.spec.ts rename tests/{ => 01-Manage}/01-Admin-BranchManagement/JWS_BM_005_CreateServicePoint.spec.ts (78%) create mode 100644 tests/01-Manage/01-Admin-BranchManagement/JWS_BM_006-1_CreateServicePointFail.spec.ts create mode 100644 tests/01-Manage/01-Admin-BranchManagement/JWS_BM_006_CreateServicePointFail.spec.ts rename tests/{ => 01-Manage}/01-Admin-BranchManagement/JWS_BM_007_SelectTypeBranch.spec.ts (92%) create mode 100644 tests/01-Manage/01-Admin-BranchManagement/JWS_BM_008_ViewDetail.spec.ts rename tests/{ => 01-Manage}/01-Admin-BranchManagement/JWS_BM_009_EditBranch.spec.ts (81%) rename tests/{ => 01-Manage}/01-Admin-BranchManagement/JWS_BM_010_StatusBranchandSubType.spec.ts (91%) rename tests/{ => 01-Manage}/01-Admin-BranchManagement/JWS_BM_011_SearchBranchmanagement.spec.ts (75%) rename tests/{ => 01-Manage}/01-Admin-BranchManagement/JWS_BM_012_CloseStatusBranch.spec.ts (76%) create mode 100644 tests/01-Manage/01-Admin-BranchManagement/JWS_BM_013_DeleteBranch.spec.ts create mode 100644 tests/01-Manage/02-Admin-PersonnelManagement/JWS_PM_001_CreatePersonnel.spec.ts create mode 100644 tests/01-Manage/02-Admin-PersonnelManagement/JWS_PM_002-1_CreatePersonnelFailEn.spec.ts create mode 100644 tests/01-Manage/02-Admin-PersonnelManagement/JWS_PM_002_CreatePersonnelFail.spec.ts create mode 100644 tests/01-Manage/02-Admin-PersonnelManagement/JWS_PM_003_ViewDetail.spec.ts rename tests/{ => 01-Manage}/02-Admin-PersonnelManagement/JWS_PM_004_EditPersonnel.spec.ts (87%) rename tests/{ => 01-Manage}/02-Admin-PersonnelManagement/JWS_PM_005_StatusPersonnel.spec.ts (75%) create mode 100644 tests/01-Manage/02-Admin-PersonnelManagement/JWS_PM_006_SearchPersonnel.spec.ts rename tests/{ => 01-Manage}/02-Admin-PersonnelManagement/JWS_PM_007_StatusPersonnelType.spec.ts (92%) rename tests/{ => 01-Manage}/02-Admin-PersonnelManagement/JWS_PM_008_TypePersonnelFields.spec.ts (96%) create mode 100644 tests/01-Manage/03-Admin-ManageCustomer/Createemployeeinlegal.spec.ts rename tests/{ => 01-Manage}/03-Admin-ManageCustomer/JWS_MC_001_CreateNaturalperoson.spec.ts (64%) rename tests/{03-Admin-ManageCustomer/JWS_MC_002_CreateNaturalperosonfail.spec.ts => 01-Manage/03-Admin-ManageCustomer/JWS_MC_002-1_CreateNaturalperosonfailEn.spec.ts} (58%) create mode 100644 tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_002_CreateNaturalperosonfail.spec.ts create mode 100644 tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_003_DetailNaturalperson.spec.ts create mode 100644 tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_004_EditNaturalperson.spec.ts create mode 100644 tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_005_DeleteNaturalperson.spec.ts create mode 100644 tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_006_StatusNaturalperson.spec.ts create mode 100644 tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_007_CreateLegalentitly.spec.ts create mode 100644 tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_008-1_CreateLegalentitlyfailEn.spec.ts create mode 100644 tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_008_CreateLegalentitlyfail.spec.ts create mode 100644 tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_009_DetailLegalentitly.spec.ts create mode 100644 tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_010_EditLegalentitly.spec.ts create mode 100644 tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_011_DeleteLegalentitly.spec.ts create mode 100644 tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_012_StatusLegalentitly.spec.ts create mode 100644 tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_013_DropdownEmployertype.spec.ts create mode 100644 tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_014_SearchManageCustomer.spec.ts create mode 100644 tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_015_ManageStatusCustomerType.spec.ts create mode 100644 tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_016_CreateEmployee.spec.ts create mode 100644 tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_017-1_CreateEmployeeFailEn.spec.ts create mode 100644 tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_017_CreateEmployeeFail.spec.ts create mode 100644 tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_018_SeachEmployee.spec.ts create mode 100644 tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_019_StatusEmployeeType.spec.ts create mode 100644 tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_020_DetailEmployee.spec.ts create mode 100644 tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_021_EditEmployee.spec.ts create mode 100644 tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_022_DeleteEmployee.spec.ts create mode 100644 tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_023_StatusEmployee.spec.ts create mode 100644 tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_024_DropdownEmployeetype.spec.ts create mode 100644 tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_025_CreateInNaturalperson.spec.ts create mode 100644 tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_026_CreateInNaturalpersonFail.spec.ts create mode 100644 tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_027_CreateInLegalentitly.spec.ts rename tests/{04-ProductandService/JWS_PD_012_SearchProductandService.spec.ts => 01-Manage/03-Admin-ManageCustomer/JWS_MC_028_CreateInLegalentitlyFail.spec.ts} (100%) rename tests/{ => 01-Manage}/04-ProductandService/JWS_PD_001_CreateProductandServiceGroup.spec.ts (71%) create mode 100644 tests/01-Manage/04-ProductandService/JWS_PD_002-1_CreateProductandServiceGroupFailEn.spec.ts create mode 100644 tests/01-Manage/04-ProductandService/JWS_PD_002_CreateProductandServiceGroupFail.spec.ts create mode 100644 tests/01-Manage/04-ProductandService/JWS_PD_003_CreateProductandService.spec.ts create mode 100644 tests/01-Manage/04-ProductandService/JWS_PD_004-1_CreateProductandServiceFailEn.spec.ts create mode 100644 tests/01-Manage/04-ProductandService/JWS_PD_004_CreateProductandServiceFail.spec.ts create mode 100644 tests/01-Manage/04-ProductandService/JWS_PD_005_CreatePackage.spec.ts rename tests/{04-ProductandService/JWS_PD_006_CreateTypeFail.spec.ts => 01-Manage/04-ProductandService/JWS_PD_006_CreatePackageFail.spec.ts} (54%) rename tests/{ => 01-Manage}/04-ProductandService/JWS_PD_007_DetailProductandService.spec.ts (86%) rename tests/{ => 01-Manage}/04-ProductandService/JWS_PD_008_EditProductandService.spec.ts (82%) rename tests/{ => 01-Manage}/04-ProductandService/JWS_PD_009_StatusProductandServiceType.spec.ts (82%) rename tests/{ => 01-Manage}/04-ProductandService/JWS_PD_010_SelectTypeFields.spec.ts (93%) rename tests/{ => 01-Manage}/04-ProductandService/JWS_PD_011_StatusProductandService.spec.ts (85%) create mode 100644 tests/01-Manage/04-ProductandService/JWS_PD_012_SearchProductandService.spec.ts rename tests/{ => 01-Manage}/04-ProductandService/JWS_PD_013_DeleteProductandService.spec.ts (91%) rename tests/{03-Admin-ManageCustomer/JWS_MC_009_DetailLegalentitly.spec.ts => 01-Manage/05-Workflow/JWS_WF_001_CreateWorkflow.spec.ts} (58%) delete mode 100644 tests/02-Admin-PersonnelManagement/JWS_PM_001_CreatePersonnel.spec.ts delete mode 100644 tests/02-Admin-PersonnelManagement/JWS_PM_002_CreatePersonnelFail.spec.ts delete mode 100644 tests/02-Admin-PersonnelManagement/JWS_PM_003_ViewDetail.spec.ts delete mode 100644 tests/02-Admin-PersonnelManagement/JWS_PM_006_SearchPersonnel(ยังไม่เสร็จทำทีหลัง).spec.ts delete mode 100644 tests/03-Admin-ManageCustomer/JWS_MC_003_DetailNaturalperson.spec.ts delete mode 100644 tests/03-Admin-ManageCustomer/JWS_MC_004_EditNaturalperson.spec.ts delete mode 100644 tests/03-Admin-ManageCustomer/JWS_MC_005_DeleteNaturalperson.spec.ts delete mode 100644 tests/03-Admin-ManageCustomer/JWS_MC_006_StatusNaturalperson.spec.ts delete mode 100644 tests/03-Admin-ManageCustomer/JWS_MC_007_CreateLegalentitly.spec.ts delete mode 100644 tests/03-Admin-ManageCustomer/JWS_MC_008_CreateLegalentitlyfail.spec.ts delete mode 100644 tests/03-Admin-ManageCustomer/JWS_MC_010_EditLegalentitly.spec.ts delete mode 100644 tests/03-Admin-ManageCustomer/JWS_MC_011_DeleteLegalentitly.spec.ts delete mode 100644 tests/03-Admin-ManageCustomer/JWS_MC_012_StatusLegalentitly.spec.ts delete mode 100644 tests/03-Admin-ManageCustomer/JWS_MC_013_DropdownEmployertype.spec.ts delete mode 100644 tests/03-Admin-ManageCustomer/JWS_MC_014_SearchManageCustomer.spec.ts delete mode 100644 tests/03-Admin-ManageCustomer/JWS_MC_015_FilterManageStatusCustomer.spec.ts delete mode 100644 tests/03-Admin-ManageCustomer/JWS_MC_016_CreateEmployee.spec.ts delete mode 100644 tests/03-Admin-ManageCustomer/JWS_MC_017_CreateEmployeeFail.spec.ts delete mode 100644 tests/03-Admin-ManageCustomer/JWS_MC_018_SeachEmployee.spec.ts delete mode 100644 tests/03-Admin-ManageCustomer/JWS_MC_019_FliterStatusEmployee.spec.ts delete mode 100644 tests/03-Admin-ManageCustomer/JWS_MC_020_DetailEmployee.spec.ts delete mode 100644 tests/03-Admin-ManageCustomer/JWS_MC_021_EditEmployee.spec.ts delete mode 100644 tests/03-Admin-ManageCustomer/JWS_MC_022_DeleteEmployee.spec.ts delete mode 100644 tests/03-Admin-ManageCustomer/JWS_MC_023_StatusEmployee.spec.ts delete mode 100644 tests/03-Admin-ManageCustomer/JWS_MC_024_DropdownEmployeetype.spec.ts delete mode 100644 tests/03-Admin-ManageCustomer/JWS_MC_025_CreateSubBranchNaturalperson.spec.ts delete mode 100644 tests/03-Admin-ManageCustomer/JWS_MC_026_CreateSubBranchLegalentitly.spec.ts delete mode 100644 tests/04-ProductandService/JWS_PD_002_CreateProductandServiceGroupFail.spec.ts delete mode 100644 tests/04-ProductandService/JWS_PD_003_CreateProductandService.spec.ts delete mode 100644 tests/04-ProductandService/JWS_PD_004_CreateProductandServiceFail.spec.ts delete mode 100644 tests/04-ProductandService/JWS_PD_005_CreateType.spec.ts diff --git a/tests/01-Admin-BranchManagement/JWS_BM_002_CreateHeadquarterFail.spec.ts b/tests/01-Admin-BranchManagement/JWS_BM_002_CreateHeadquarterFail.spec.ts deleted file mode 100644 index 7495a823..00000000 --- a/tests/01-Admin-BranchManagement/JWS_BM_002_CreateHeadquarterFail.spec.ts +++ /dev/null @@ -1,146 +0,0 @@ -import { test, expect, Page } from '@playwright/test'; -import { strictEqual } from 'assert'; -import exp from 'constants'; - -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.62:20101/'); - 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('Create Branch Management - ไม่มีการกรอกข้อมูล', async () => { - await page.click('id=menu-icon-branch-management'); - await page.click('id=hq-add-btn'); - await page.click('id=btn-form-submit'); - - const abbreviationError = page.locator( - "(//div[@class='q-field__messages col'])[1]", - ); - const taxNoError = page.locator( - "(//div[@class='q-field__messages col']//div)[2]", - ); - const nameError = page.locator( - "(//div[@class='q-field__messages col']//div)[3]", - ); - const nameEnError = page.locator( - "(//div[@class='q-field__messages col']//div)[4]", - ); - const LicenseNumberError = page.locator( - "(//div[@class='q-field__messages col']//div)[5]", - ); - const addressError = page.locator( - "(//div[@class='q-field__messages col']//div)[6]", - ); - const provinceError = page.locator( - "(//div[@class='q-field__messages col']//div)[7]", - ); - const districtError = page.locator( - "(//div[@class='q-field__messages col']//div)[8]", - ); - const subDistrictError = page.locator( - "(//div[@class='q-field__messages col']//div)[9]", - ); - const addressEnError = page.locator( - "(//div[@class='q-field__messages col']//div)[10]", - ); - - await expect(abbreviationError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้', { - timeout: 2000, - }); - await expect(taxNoError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้'); - await expect(nameError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้'); - await expect(nameEnError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้'); - await expect(LicenseNumberError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้'); - await expect(addressError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้'); - await expect(provinceError).toHaveText('โปรดเลือกจังหวัด'); - await expect(districtError).toHaveText('โปรดเลือกอำเภอ'); - await expect(subDistrictError).toHaveText('โปรดเลือกตำบล'); - await expect(addressEnError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้'); - - await page.waitForTimeout(4000); - await page.click('id=btn-form-cancel'); - console.log('การตรวจสอบ Validation ถูกต้อง'); -}); - -test('Create Branch Managenment - กรณีที่กรอกชื่อย่อที่ไม่ใช่ภาษาอังกฤษ', async () => { - await page.reload(); - await page.click('id=hq-add-btn'); - await page.fill("(//input[@id='input-abbreviation'])[2]", 'ภาษาไทย'); - const invalidDataabbreviationError = page.locator( - // ตรวจสอบการแสดง Validation แจ้งเตือนชื่อย่อในกรณีที่ไม่ใช้ภาษาอังกฤษ - "(//div[contains(@class,'q-field__bottom row')])[1]", - ); - - await expect(invalidDataabbreviationError).toHaveText( - 'ข้อมูลไม่ถูกต้อง โปรดใช้เฉพาะตัวอักษรภาษาอังกฤษและตัวเลขเท่านั้น', - { - timeout: 2000, - }, - ); - console.log( - 'ตรวจสอบการแสดง Vidation แจ้งเตือนในกรณีที่ไม่ใช่ภาษาอังกฤษถูกต้อง', - ); - - await page.waitForTimeout(4000); - await page.click('id=btn-form-cancel'); -}); - -test('Create Branch Management - กรอกเลขนิติบุคคลในกรณีที่กรอกไม่ครบจำนวน 13 หลัก', async () => { - await page.reload(); - await page.click('id=hq-add-btn'); - await page.fill("(//input[@id='input-tax-no'])[2]", '123'); - const taxNoError = page.locator( - // ตรวจสอบการแสดง Validation แจ้งเตือนชื่อย่อในกรณีที่ไม่ใช้ภาษาอังกฤษ - "(//div[@class='q-field__messages col']//div)[2]", - ); - - await expect(taxNoError).toHaveText( - 'ข้อมูลไม่ถูกต้อง กรุณากรอกให้ครบ 13 หลัก', - { - timeout: 2000, - }, - ); - console.log( - 'ตรวจสอบการแสดง Vidation แจ้งเตือนในกรณีที่กรอกทะเบียนนิติบุคคลเลขที่ไม่ครบ 13 หลัก', - ); - - await page.waitForTimeout(4000); - await page.click('id=btn-form-cancel'); -}); - -test('Create Branch Management - กรอกอีเมลในกรณีที่ไม่ตรงรูปแบบอีเมล', async () => { - await page.reload(); - await page.click('id=hq-add-btn'); - await page.fill("(//input[@id='input-email'])[2]", '123'); - const emailError = page.locator( - // ตรวจสอบการแสดง Validation แจ้งเตือนในกรณีที่กรอกอีเมลไม่ถูกรูปแบบ - "(//div[@class='q-field__messages col']//div)[2]", - ); - - await expect(emailError).toHaveText('ข้อมูลไม่ถูกต้อง', { - timeout: 2000, - }); - console.log( - 'ตรวจสอบการแสดง Vidation แจ้งเตือนในกรณีที่กรอกอีเมลไม่ถูกรูปแบบ', - ); - - await page.waitForTimeout(4000); - await page.click('id=btn-form-cancel'); -}); diff --git a/tests/01-Admin-BranchManagement/JWS_BM_004_CreateSub-branchFail.spec.ts b/tests/01-Admin-BranchManagement/JWS_BM_004_CreateSub-branchFail.spec.ts deleted file mode 100644 index 7dadaeac..00000000 --- a/tests/01-Admin-BranchManagement/JWS_BM_004_CreateSub-branchFail.spec.ts +++ /dev/null @@ -1,116 +0,0 @@ -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.62:20101/'); - 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('Create Sub-Branch Managenment - ในกรณีที่ไม่กรอกข้อมูล', async () => { - await page.click('id=menu-icon-branch-management'); - await page.click('id=create-sub-branch-btn-บริษัท โคโม่ จำกัด'); - await page.click("(//button[@type='submit'])[1]"); - await page.click('id=btn-form-submit'); - - const taxNoError = page.locator( - "(//div[@class='q-field__messages col']//div)[1]", - ); - const nameError = page.locator( - "(//div[@class='q-field__messages col']//div)[2]", - ); - const nameEnError = page.locator( - "(//div[@class='q-field__messages col']//div)[3]", - ); - const lincenseNumberError = page.locator( - "(//div[@class='q-field__messages col']//div)[4]", - ); - const addressError = page.locator( - "(//div[@class='q-field__messages col']//div)[5]", - ); - const provinceError = page.locator( - "(//div[@class='q-field__messages col']//div)[6]", - ); - const districtError = page.locator( - "(//div[@class='q-field__messages col']//div)[7]", - ); - const subDistrictError = page.locator( - "(//div[@class='q-field__messages col']//div)[8]", - ); - const addressEnError = page.locator( - "(//div[@class='q-field__messages col']//div)[9]", - ); - - await expect(taxNoError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้'); - await expect(nameError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้'); - await expect(nameEnError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้'); - await expect(lincenseNumberError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้'); - await expect(addressError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้'); - await expect(provinceError).toHaveText('โปรดเลือกจังหวัด'); - await expect(districtError).toHaveText('โปรดเลือกอำเภอ'); - await expect(subDistrictError).toHaveText('โปรดเลือกตำบล'); - await expect(addressEnError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้'); - - await page.waitForTimeout(4000); - await page.click('id=btn-form-cancel'); - console.log('การตรวจสอบ Validation ถูกต้อง'); -}); - -test('Create Sub-Branch Managenment - ในกรณีที่กรอกทะเบียนนิติบุคคลเลขที่ไม่ครบ 13 หลัก', async () => { - await page.reload(); - await page.click('id=create-sub-branch-btn-บริษัท โคโม่ จำกัด'); - await page.click("(//button[@type='submit'])[1]"); - await page.fill("(//input[@id='input-tax-no'])[2]", '123'); - - // ตรวจสอบการแจ้งเตือนของทะเบียนนิติบุคคลเลขที่ในกรณีที่กรอกข้อมูลไม่ครบ 13 หลัก - const taxNoError = page.locator( - "(//div[@class='q-field__messages col']//div)[1]", - ); - - await expect(taxNoError).toHaveText( - 'ข้อมูลไม่ถูกต้อง กรุณากรอกให้ครบ 13 หลัก', - ); - - await page.waitForTimeout(4000); - await page.click('id=btn-form-cancel'); - console.log( - 'ตรวจสอบการแสดง Vidation แจ้งเตือนในกรณีที่กรอกทะเบียนนิติบุคคลเลขที่ไม่ครบ 13 หลักถูกต้อง', - ); -}); - -test('Create Sub-Branch Managenment - กรอกอีเมลในกรณีที่ไม่ตรงรูปแบบอีเมล', async () => { - await page.reload(); - await page.click('id=create-sub-branch-btn-บริษัท โคโม่ จำกัด'); - await page.click("(//button[@type='submit'])[1]"); - await page.fill("(//input[@id='input-email'])[2]", 'email'); - - // ตรวจสอบการแจ้งเตือนของทะเบียนนิติบุคคลเลขที่ในกรณีที่กรอกข้อมูลไม่ครบ 13 หลัก - const emailError = page.locator( - "(//div[@class='q-field__messages col']//div)[2]", - ); - - await expect(emailError).toHaveText('ข้อมูลไม่ถูกต้อง'); - - await page.waitForTimeout(4000); - await page.click('id=btn-form-cancel'); - console.log( - 'ตรวจสอบการแสดง Vidation แจ้งเตือนในกรณีที่กรอกอีเมลไม่ตรงรูปแบบถูกต้อง', - ); -}); diff --git a/tests/01-Admin-BranchManagement/JWS_BM_006_CreateServicePointFail.spec.ts b/tests/01-Admin-BranchManagement/JWS_BM_006_CreateServicePointFail.spec.ts deleted file mode 100644 index 189d0502..00000000 --- a/tests/01-Admin-BranchManagement/JWS_BM_006_CreateServicePointFail.spec.ts +++ /dev/null @@ -1,112 +0,0 @@ -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.62:20101/'); - 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('Create Service Point - ในกรณีที่ไม่กรอกข้อมูล', async () => { - await page.click('id=menu-icon-branch-management'); - await page.click('id=create-sub-branch-btn-บริษัท คาโมมายด์ จำกัด'); - await page.click("(//button[@type='submit'])[2]"); - await page.click('id=btn-form-submit'); - - const taxNoError = page.locator( - "(//div[@class='q-field__messages col']//div)[1]", - ); - const nameError = page.locator( - "(//div[@class='q-field__messages col']//div)[2]", - ); - const nameEnError = page.locator( - "(//div[@class='q-field__messages col']//div)[3]", - ); - const addressError = page.locator( - "(//div[@class='q-field__messages col']//div)[4]", - ); - const provinceError = page.locator( - "(//div[@class='q-field__messages col']//div)[5]", - ); - const districtError = page.locator( - "(//div[@class='q-field__messages col']//div)[6]", - ); - const subDistrictError = page.locator( - "(//div[@class='q-field__messages col']//div)[7]", - ); - const addressEnError = page.locator( - "(//div[@class='q-field__messages col']//div)[8]", - ); - - await expect(taxNoError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้'); - await expect(nameError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้'); - await expect(nameEnError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้'); - await expect(addressError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้'); - await expect(provinceError).toHaveText('โปรดเลือกจังหวัด'); - await expect(districtError).toHaveText('โปรดเลือกอำเภอ'); - await expect(subDistrictError).toHaveText('โปรดเลือกตำบล'); - await expect(addressEnError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้'); - - await page.waitForTimeout(4000); - await page.click('id=btn-form-cancel'); - console.log('การตรวจสอบ Validation ถูกต้อง'); -}); - -test('Create Service Point - ในกรณีที่กรอกทะเบียนนิติบุคคลเลขที่ไม่ครบ 13 หลัก', async () => { - await page.reload(); - await page.click('id=create-sub-branch-btn-บริษัท คาโมมายด์ จำกัด'); - await page.click("(//button[@type='submit'])[2]"); - await page.fill("(//input[@id='input-tax-no'])[2]", '123'); - - // ตรวจสอบการแจ้งเตือนของทะเบียนนิติบุคคลเลขที่ในกรณีที่กรอกข้อมูลไม่ครบ 13 หลัก - const taxNoError = page.locator( - "(//div[@class='q-field__messages col']//div)[1]", - ); - - await expect(taxNoError).toHaveText( - 'ข้อมูลไม่ถูกต้อง กรุณากรอกให้ครบ 13 หลัก', - ); - - await page.waitForTimeout(4000); - await page.click('id=btn-form-cancel'); - console.log( - 'ตรวจสอบการแสดง Vidation แจ้งเตือนในกรณีที่กรอกทะเบียนนิติบุคคลเลขที่ไม่ครบ 13 หลักถูกต้อง', - ); -}); - -test('Create Service Point - กรอกอีเมลในกรณีที่ไม่ตรงรูปแบบอีเมล', async () => { - await page.reload(); - await page.click('id=create-sub-branch-btn-บริษัท คาโมมายด์ จำกัด'); - await page.click("(//button[@type='submit'])[2]"); - await page.fill("(//input[@id='input-email'])[2]", 'email'); - - // ตรวจสอบการแจ้งเตือนของทะเบียนนิติบุคคลเลขที่ในกรณีที่กรอกข้อมูลไม่ครบ 13 หลัก - const emailError = page.locator( - "(//div[@class='q-field__messages col']//div)[2]", - ); - - await expect(emailError).toHaveText('ข้อมูลไม่ถูกต้อง'); - - await page.waitForTimeout(4000); - await page.click('id=btn-form-cancel'); - console.log( - 'ตรวจสอบการแสดง Vidation แจ้งเตือนในกรณีที่กรอกอีเมลไม่ตรงรูปแบบถูกต้อง', - ); -}); diff --git a/tests/01-Admin-BranchManagement/JWS_BM_008_ViewDetail.spec.ts b/tests/01-Admin-BranchManagement/JWS_BM_008_ViewDetail.spec.ts deleted file mode 100644 index 7c1fe507..00000000 --- a/tests/01-Admin-BranchManagement/JWS_BM_008_ViewDetail.spec.ts +++ /dev/null @@ -1,91 +0,0 @@ -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.62:20101/'); - 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('View Detail Headquter Branch', async () => { - try { - await page.click('id=menu-icon-branch-management'); - await page.click('id=btn-kebab-action-บริษัท โคโม่ จำกัด'); - await page.click('id=btn-kebab-view-detail-บริษัท โคโม่ จำกัด'); - - const detailTitle = page.locator( - "//span[text()='บริษัท โคโม่ จำกัด ']/following-sibling::span", - ); - - await expect(detailTitle).toHaveText('CMO00000'); // เลขรหัสสำนักงานใหญ่ - - console.log('ตรวจสอบข้อมูลถูกต้อง'); - } catch (error) { - console.error('เกิดข้อผิดพลาดในการทดสอบ', error); - throw error; - } - - await page.waitForTimeout(4000); - await page.click('id=btn-info-close'); -}); - -test('View Detail Sub Branch', async () => { - try { - await page.click("(//div[@id='tree-enter-บริษัท โคโม่ จำกัด']//div)[1]"); - await page.click('id=btn-kebab-action-สีลม1'); - await page.click('id=btn-kebab-view-detail-สีลม1'); - - const detailTitle = page.locator("//span[text()='สีลม1 ']"); - - await detailTitle.waitFor({ state: 'visible' }); - - await expect(detailTitle).toHaveText('สีลม1'); // เลขรหัสสำนักงานใหญ่ - - console.log('ตรวจสอบข้อมูลถูกต้อง'); - } catch (error) { - console.error('เกิดข้อผิดพลาดในการทดสอบ', error); - throw error; - } - - await page.waitForTimeout(4000); - await page.click('id=btn-info-close'); -}); - -test('View Detail Service Point', async () => { - try { - await page.click("//div[@id='tree-enter-บริษัท คาโมมายด์ จำกัด']/div[1]"); - await page.click('id=btn-kebab-action-บางรัก1'); - await page.click('id=btn-kebab-view-detail-บางรัก1'); - - const detailTitle = page.locator("//span[text()='บางรัก1 ']"); - - await detailTitle.waitFor({ state: 'visible' }); - - await expect(detailTitle).toHaveText('บางรัก1'); // เลขรหัสสำนักงานใหญ่ - - console.log('ตรวจสอบข้อมูลถูกต้อง'); - } catch (error) { - console.error('เกิดข้อผิดพลาดในการทดสอบ', error); - throw error; - } - - await page.waitForTimeout(4000); - await page.click('id=btn-info-close'); -}); diff --git a/tests/01-Admin-BranchManagement/JWS_BM_013_DeleteBranch.spec.ts b/tests/01-Admin-BranchManagement/JWS_BM_013_DeleteBranch.spec.ts deleted file mode 100644 index b8651a4d..00000000 --- a/tests/01-Admin-BranchManagement/JWS_BM_013_DeleteBranch.spec.ts +++ /dev/null @@ -1,219 +0,0 @@ -import { test, expect, Page } from '@playwright/test'; -import { strictEqual } from 'assert'; -import { Console, error, log } from 'console'; -import exp from 'constants'; -import { it } from 'node:test'; - -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.62:20101/'); - 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('ทดสอบการลบจัดการสาขา', async () => { - await page.click('id=menu-icon-branch-management'); - - // จำลองการสร้างสำนักงานใหญ่ - - await page.click('id=hq-add-btn'); - await page.fill("(//input[@id='input-abbreviation'])[2]", 'TES'); - await page.fill("(//input[@id='input-tax-no'])[2]", '1260846220284'); - await page.fill("(//input[@id='input-name'])[2]", 'บริษัท จำลอง จำกัด'); - await page.fill("(//input[@id='input-name-en'])[2]", 'JOMLONG'); - await page.fill("(//input[@id='input-email'])[2]", 'JOM@support.com'); - await page.fill("(//input[@id='input-telephone-no'])[2]", '022010100'); - await page.fill("(//input[@id='input-contact-name'])[2]", 'คุณอาท'); - await page.fill("(//input[@id='input-contact'])[2]", '0866224228'); - await page.fill("(//input[@id='input-line-id'])[2]", 'como20'); - await page.fill("(//input[@id='default-input-address'])[2]", '40/04'); - await page.click("(//input[@id='default-select-province'])[2]"); - await page.click("//div[@role='option']"); - await page.click("(//input[@id='default-select-district'])[2]"); - await page.waitForTimeout(1000); - await page.click("//div[@role='option']"); - await page.click("(//input[@id='default-select-sub-district'])[2]"); - await page.waitForTimeout(1000); - await page.click("//div[@role='option']"); - await page.fill("(//input[@id='default-input-address-en'])[2]", '40/04'); - await page.click("(//input[@id='select-bankbook'])[3]"); - await page.click('id=select-bankbook_4'); - await page.fill("(//input[@aria-label='เลขบัญชี'])[2]", '2022822624262'); - await page.fill("(//input[@aria-label='สาขาธนาคาร'])[2]", 'ลำพูน'); - await page.fill("(//input[@aria-label='ชื่อบัญชี'])[2]", 'Pongpon Kuntana'); - await page.click("(//input[@aria-label='ประเภทบัญชี'])[2]"); - await page.waitForTimeout(2000); - await page.click('id=select-bankbook_0'); - await page.click('id=btn-form-submit'); - - await page.waitForSelector('id=btn-ok-dialog'); - await page.click('id=btn-ok-dialog'); - - // จำลองการสร้างสาขา - - await page.click('id=create-sub-branch-btn-บริษัท จำลอง จำกัด'); - await page.click("(//button[@type='submit'])[1]"); - - await page.fill("(//input[@id='input-tax-no'])[2]", '1260846220281'); - await page.fill("(//input[@id='input-name'])[3]", 'สาขาจำลอง'); - await page.fill("(//input[@id='input-name-en'])[2]", 'SAKAJOMLONG'); - await page.fill( - "(//input[@aria-label='เลขที่ใบอนุญาต'])[2]", - '1228222822822', - ); - await page.fill("(//input[@id='input-email'])[2]", 'test@support.com'); - await page.fill("(//input[@id='input-telephone-no'])[2]", '022222002'); - await page.fill("(//input[@id='input-contact-name'])[2]", 'คุณอาท'); - await page.fill("(//input[@id='input-contact'])[2]", '0822262228'); - await page.fill("(//input[@id='input-line-id'])[2]", 'company'); - - await page.fill("(//input[@id='default-input-address-no'])[2]", '20/02'); - await page.click("(//input[@id='default-select-province'])[2]"); - await page.click("//div[@role='option']"); - await page.click("(//input[@id='default-select-district'])[2]"); - await page.waitForTimeout(400); - await page.click("//div[@role='option']"); - await page.click("(//input[@id='default-select-sub-district'])[2]"); - await page.waitForTimeout(400); - await page.click("//div[@role='option']"); - await page.fill("(//input[@id='default-input-address-en'])[2]", '20/02'); - - await page.click("(//input[@id='select-bankbook'])[3]"); - await page.click('id=select-bankbook_1'); - await page.fill("(//input[@aria-label='เลขบัญชี'])[2]", '2282020021'); - await page.fill("(//input[@aria-label='สาขาธนาคาร'])[2]", 'เชียงใหม่'); - await page.fill("(//input[@aria-label='ชื่อบัญชี'])[2]", 'Pongpon Kuntana'); - await page.click("(//input[@aria-label='ประเภทบัญชี'])[2]"); - await page.waitForTimeout(2000); - await page.click('id=select-bankbook_0'); - - await page.click('id=btn-info-basic-save'); - await page.click('id=btn-form-close'); - - // จำลองการสร้างสาขาเสมือน - - await page.click('id=create-sub-branch-btn-บริษัท จำลอง จำกัด'); - await page.click("(//button[@type='submit'])[2]"); - - await page.fill("(//input[@id='input-tax-no'])[2]", '2022826282642'); - await page.fill("(//input[@id='input-name'])[2]", 'สาขาเสมือน'); - await page.fill("(//input[@id='input-name-en'])[2]", 'VISUALBRANCH'); - await page.fill("(//input[@id='input-email'])[2]", 'visual@local.co.th'); - await page.fill("(//input[@id='input-telephone-no'])[2]", '022222002'); - await page.fill("(//input[@id='input-contact-name'])[2]", 'คุณอุล'); - await page.fill("(//input[@id='input-contact'])[2]", '0822622862'); - await page.fill("(//input[@id='input-line-id'])[2]", 'cmmsupport'); - - await page.fill("(//input[@id='default-input-address'])[2]", '40/04'); - await page.click("(//input[@id='default-select-province'])[2]"); - await page.click("//div[@role='option']"); - await page.click("(//input[@id='default-select-district'])[2]"); - await page.waitForTimeout(400); - await page.click("//div[@role='option']"); - await page.click("(//input[@id='default-select-sub-district'])[2]"); - await page.waitForTimeout(400); - await page.click("//div[@role='option']"); - await page.fill("(//input[@id='default-input-address-en'])[2]", '40/04'); - - await page.click("(//input[@id='select-bankbook'])[3]"); - await page.click('id=select-bankbook_2'); - await page.fill("(//input[@aria-label='เลขบัญชี'])[2]", '2822642201'); - await page.fill("(//input[@aria-label='สาขาธนาคาร'])[2]", 'ลำพูน'); - await page.fill("(//input[@aria-label='ชื่อบัญชี'])[2]", 'Pongpon Kuntana'); - await page.click("(//input[@aria-label='ประเภทบัญชี'])[2]"); - await page.waitForTimeout(2000); - await page.click('id=select-bankbook_0'); - - await page.click('id=btn-info-basic-save'); - await page.click('id=btn-form-close'); - - // ลบสาขาและตรวจสอบการลบสาขา - try { - await page.click('id=btn-kebab-action-สาขาจำลอง'); - await page.click('id=btn-kebab-delete-สาขาจำลอง'); - - // ยืนยันการลบ - await page.click('id=btn-ok-dialog'); - await page.waitForTimeout(1000); - - // ตรวจสอบการลบสาขา - const itemLocator = page.locator( - "//tr[contains(.,'1 สาขาจำลองTES0000112608462202810822262228คุณอาท20/02')]", - ); - - // ตรวจสอบว่าถูกลบออกจากระบบหรือไม่ - await expect(itemLocator).toBeHidden(); - - console.log('ตรวจสอบข้อมูลการลบสาขาสำเร็จ'); - } catch (error) { - console.error('เกิดข้อผิดพลาดในการลบสาขา', error); - throw error; - } - - // ลบสาขาเสมือนและตรวจสอบการลบสาขาเสมือน - - try { - await page.click('id=btn-kebab-action-สาขาเสมือน'); - await page.click('id=btn-kebab-delete-สาขาเสมือน'); - - // ยืนยันการลบ - await page.click('id=btn-ok-dialog'); - await page.waitForTimeout(1000); - - // ตรวจสอบการลบสาขาเสมือน - const itemLocator = page.locator( - "//tr[contains(.,'2 สาขาเสมือนTES0000220228262826420822622862คุณอุล40/04')]", - ); - - // ตรวจสอบว่าถูกลบออกจากระบบหรือไม่ - await expect(itemLocator).toBeHidden(); - - console.log('ตรวจสอบข้อมูลการลบสาขาเสมือนสำเร็จ'); - } catch (error) { - console.error('เกิดข้อผิดพลาดในการลบสาขาเสมือน', error); - throw error; - } - - // // ลบสำนักงานใหญ่และตรวจสอบการลบสำนักงานใหญ่ - - // await page.click("//div[@id='tree-enter-บริษัท จำลอง จำกัด']/div[1]"); - // try { - // await page.click('id=btn-kebab-action-บริษัท จำลอง จำกัด'); - // await page.click('id=btn-kebab-delete-บริษัท จำลอง จำกัด'); - - // // ยืนยันการลบ - // await page.click('id=btn-ok-dialog'); - // await page.waitForTimeout(1000); - - // // ตรวจสอบการลบสำนักงานใหญ่ - // const itemLocator = page.locator( - // "//tr[contains(.,'9 บริษัท จำลอง จำกัดTES0000012608462202840866224228คุณอาท40/04')]", - // ); - - // // ตรวจสอบว่าถูกลบออกจากระบบหรือไม่ - // await expect(itemLocator).toBeHidden(); - - // console.log('ตรวจสอบข้อมูลการลบสำนักงานใหญ่สำเร็จ'); - // } catch (error) { - // console.error('เกิดข้อผิดพลาดในการลบสำนักงานใหญ่', error); - // throw error; - // } - - await page.waitForTimeout(2000); -}); diff --git a/tests/00-Role&Permission/JWS_RP_001_CorporateCustomer.spec.ts b/tests/01-Manage/00-Role&Permission/JWS_RP_001_CorporateCustomer.spec.ts similarity index 100% rename from tests/00-Role&Permission/JWS_RP_001_CorporateCustomer.spec.ts rename to tests/01-Manage/00-Role&Permission/JWS_RP_001_CorporateCustomer.spec.ts diff --git a/tests/00-Role&Permission/JWS_RP_002_HeadOfAdmin.spec.ts b/tests/01-Manage/00-Role&Permission/JWS_RP_002_HeadOfAdmin.spec.ts similarity index 100% rename from tests/00-Role&Permission/JWS_RP_002_HeadOfAdmin.spec.ts rename to tests/01-Manage/00-Role&Permission/JWS_RP_002_HeadOfAdmin.spec.ts diff --git a/tests/00-Role&Permission/JWS_RP_003_Sale.spec.ts b/tests/01-Manage/00-Role&Permission/JWS_RP_003_Sale.spec.ts similarity index 100% rename from tests/00-Role&Permission/JWS_RP_003_Sale.spec.ts rename to tests/01-Manage/00-Role&Permission/JWS_RP_003_Sale.spec.ts diff --git a/tests/00-Role&Permission/JWS_RP_004_DocumentChecker.spec.ts b/tests/01-Manage/00-Role&Permission/JWS_RP_004_DocumentChecker.spec.ts similarity index 100% rename from tests/00-Role&Permission/JWS_RP_004_DocumentChecker.spec.ts rename to tests/01-Manage/00-Role&Permission/JWS_RP_004_DocumentChecker.spec.ts diff --git a/tests/00-Role&Permission/JWS_RP_005_SaleAgent.spec.ts b/tests/01-Manage/00-Role&Permission/JWS_RP_005_SaleAgent.spec.ts similarity index 100% rename from tests/00-Role&Permission/JWS_RP_005_SaleAgent.spec.ts rename to tests/01-Manage/00-Role&Permission/JWS_RP_005_SaleAgent.spec.ts diff --git a/tests/00-Role&Permission/JWS_RP_006_Messenger.spec.ts b/tests/01-Manage/00-Role&Permission/JWS_RP_006_Messenger.spec.ts similarity index 100% rename from tests/00-Role&Permission/JWS_RP_006_Messenger.spec.ts rename to tests/01-Manage/00-Role&Permission/JWS_RP_006_Messenger.spec.ts diff --git a/tests/00-Role&Permission/JWS_RP_007_Account.spec.ts b/tests/01-Manage/00-Role&Permission/JWS_RP_007_Account.spec.ts similarity index 100% rename from tests/00-Role&Permission/JWS_RP_007_Account.spec.ts rename to tests/01-Manage/00-Role&Permission/JWS_RP_007_Account.spec.ts diff --git a/tests/00-Role&Permission/JWS_RP_008_Admin.spec.ts b/tests/01-Manage/00-Role&Permission/JWS_RP_008_Admin.spec.ts similarity index 100% rename from tests/00-Role&Permission/JWS_RP_008_Admin.spec.ts rename to tests/01-Manage/00-Role&Permission/JWS_RP_008_Admin.spec.ts diff --git a/tests/00-Role&Permission/JWS_RP_009_Executive.spec.ts b/tests/01-Manage/00-Role&Permission/JWS_RP_009_Executive.spec.ts similarity index 100% rename from tests/00-Role&Permission/JWS_RP_009_Executive.spec.ts rename to tests/01-Manage/00-Role&Permission/JWS_RP_009_Executive.spec.ts diff --git a/tests/00-Role&Permission/JWS_RP_010_DataEntry.spec.ts b/tests/01-Manage/00-Role&Permission/JWS_RP_010_DataEntry.spec.ts similarity index 100% rename from tests/00-Role&Permission/JWS_RP_010_DataEntry.spec.ts rename to tests/01-Manage/00-Role&Permission/JWS_RP_010_DataEntry.spec.ts diff --git a/tests/00-Role&Permission/JWS_RP_011_HeadOfAccount.spec.ts b/tests/01-Manage/00-Role&Permission/JWS_RP_011_HeadOfAccount.spec.ts similarity index 100% rename from tests/00-Role&Permission/JWS_RP_011_HeadOfAccount.spec.ts rename to tests/01-Manage/00-Role&Permission/JWS_RP_011_HeadOfAccount.spec.ts diff --git a/tests/00-Role&Permission/JWS_RP_012_HeadOfSale.spec.ts b/tests/01-Manage/00-Role&Permission/JWS_RP_012_HeadOfSale.spec.ts similarity index 100% rename from tests/00-Role&Permission/JWS_RP_012_HeadOfSale.spec.ts rename to tests/01-Manage/00-Role&Permission/JWS_RP_012_HeadOfSale.spec.ts diff --git a/tests/00-Role&Permission/JWS_RP_013_PersonalCustomer.spec.ts b/tests/01-Manage/00-Role&Permission/JWS_RP_013_PersonalCustomer.spec.ts similarity index 100% rename from tests/00-Role&Permission/JWS_RP_013_PersonalCustomer.spec.ts rename to tests/01-Manage/00-Role&Permission/JWS_RP_013_PersonalCustomer.spec.ts diff --git a/tests/00-Role&Permission/JWS_RP_014_BranchManager.spec.ts b/tests/01-Manage/00-Role&Permission/JWS_RP_014_BranchManager.spec.ts similarity index 100% rename from tests/00-Role&Permission/JWS_RP_014_BranchManager.spec.ts rename to tests/01-Manage/00-Role&Permission/JWS_RP_014_BranchManager.spec.ts diff --git a/tests/01-Admin-BranchManagement/JWS_BM_001_CreateHeadquarters.spec.ts b/tests/01-Manage/01-Admin-BranchManagement/JWS_BM_001_CreateHeadquarters.spec.ts similarity index 84% rename from tests/01-Admin-BranchManagement/JWS_BM_001_CreateHeadquarters.spec.ts rename to tests/01-Manage/01-Admin-BranchManagement/JWS_BM_001_CreateHeadquarters.spec.ts index d541760d..75d97120 100644 --- a/tests/01-Admin-BranchManagement/JWS_BM_001_CreateHeadquarters.spec.ts +++ b/tests/01-Manage/01-Admin-BranchManagement/JWS_BM_001_CreateHeadquarters.spec.ts @@ -3,6 +3,7 @@ import path from 'path'; import { off } from 'process'; let page: Page; +let isLoginSuccessful = false; test.beforeAll(async ({ browser }) => { page = await browser.newPage(); @@ -13,21 +14,46 @@ test.afterAll(async () => { await page.close(); } }); +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + // เข้าสู่เมนูสาขา + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-branch'); + await page.click('id=sub-menu-branch'); + + // ถ้าทั้งหมดสำเร็จ + isLoginSuccessful = true; + console.log('ระบบทำการ Login สำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการ Login'); + isLoginSuccessful = false; + } +} test('Login', async () => { - // Login - await page.goto('http://192.168.1.62:20101/'); - 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'); + await login(page); }); test('Create Branch Managenment', async () => { + // ถ้ายังไม่ได้ Login ให้ทำการ Login + if (!isLoginSuccessful) { + await login(page); + } + try { - await page.click('id=menu-icon-branch-management'); + // เข้าสู่เมนูสาขา + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-branch'); + await page.click('id=sub-menu-branch'); + // await page.click('id=hq-add-btn'); await page.click('id=btn-Add'); // await page.click("(//div[@class='q-avatar relative-position'])[2]"); @@ -51,7 +77,7 @@ test('Create Branch Managenment', async () => { // ส่วนข้อมูลพื้นฐาน await page.fill("(//input[@id='input-abbreviation'])[2]", 'CMM'); await page.fill("(//input[@id='input-tax-no'])[2]", '1260846220284'); - await page.fill("(//input[@id='input-name'])[3]", 'บริษัท คาโมมายด์ จำกัด'); + await page.fill("(//input[@id='input-name'])[2]", 'บริษัท คาโมมายด์ จำกัด'); await page.fill("(//input[@id='input-name-en'])[2]", 'CHAMOMIND'); await page.fill( "(//input[@aria-label='เลขที่ใบอนุญาต'])[2]", @@ -113,6 +139,7 @@ test('Create Branch Managenment', async () => { } } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; throw error; } @@ -120,12 +147,17 @@ test('Create Branch Managenment', async () => { }); test('Create Branch Managenment Second', async () => { + // ถ้ายังไม่ได้ Login ให้ทำการ Login + if (!isLoginSuccessful) { + await login(page); + } + try { // ส่วนข้อมูลพื้นฐาน await page.click('id=hq-add-btn'); await page.fill("(//input[@id='input-abbreviation'])[2]", 'CMO'); await page.fill("(//input[@id='input-tax-no'])[2]", '1260846220284'); - await page.fill("(//input[@id='input-name'])[3]", 'บริษัท โคโม่ จำกัด'); + await page.fill("(//input[@id='input-name'])[2]", 'บริษัท โคโม่ จำกัด'); await page.fill("(//input[@id='input-name-en'])[2]", 'COMO'); await page.fill( "(//input[@aria-label='เลขที่ใบอนุญาต'])[2]", @@ -187,6 +219,7 @@ test('Create Branch Managenment Second', async () => { } } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; throw error; } diff --git a/tests/01-Manage/01-Admin-BranchManagement/JWS_BM_002-1_CreateHeadquarterFailEn.spec.ts b/tests/01-Manage/01-Admin-BranchManagement/JWS_BM_002-1_CreateHeadquarterFailEn.spec.ts new file mode 100644 index 00000000..04fcb20b --- /dev/null +++ b/tests/01-Manage/01-Admin-BranchManagement/JWS_BM_002-1_CreateHeadquarterFailEn.spec.ts @@ -0,0 +1,206 @@ +import { test, expect, Page } from '@playwright/test'; +import { strictEqual } from 'assert'; +import { log } from 'console'; +import exp from 'constants'; + +let page: Page; +let isLoginSuccessful = false; + +test.beforeAll(async ({ browser }) => { + page = await browser.newPage(); +}); + +test.afterAll(async () => { + if (page !== undefined) { + await page.close(); + } +}); +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + // เข้าสู่เมนูสาขา + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-branch'); + await page.click('id=sub-menu-branch'); + await page.waitForTimeout(2000); + + isLoginSuccessful = true; + console.log('ระบบ Login สำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการ Login', error); + isLoginSuccessful = false; + } +} +test('Login', async () => { + await login(page); +}); + +test('Create Branch Management - ไม่มีการกรอกข้อมูล', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + // เปลี่ยนภาษา + await page.click('id=btn-change-language'); + await page.waitForSelector('id=btn-change-language-eng'); + await page.click('id=btn-change-language-eng'); + + await page.click('id=hq-add-btn'); + await page.click('id=btn-info-basic-save'); + + const expectedErrors = [ + { + locator: "(//div[@class='q-field__messages col']//div)[1]", + message: 'This field is required.', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[2]", + message: 'This field is required.', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[3]", + message: 'This field is required.', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[4]", + message: 'This field is required.', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[5]", + message: 'This field is required.', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[6]", + message: 'This field is required.', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[7]", + message: 'Please select Province.', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[8]", + message: 'Please select District.', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[9]", + message: 'Please select Sub-district.', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[10]", + message: 'This field is required.', + }, + ]; + + for (const error of expectedErrors) { + const locator = page.locator(error.locator); + await expect(locator).toHaveText(error.message); + } + console.log('ระบบตรวจสอบการแจ้งเตือนแล้ว'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForTimeout(4000); + await page.click('id=btn-form-close'); + console.log('การตรวจสอบ Validation ถูกต้อง'); +}); + +test('Create Branch Managenment - กรณีที่กรอกชื่อย่อที่ไม่ใช่ภาษาอังกฤษ', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + await page.reload(); + await page.click('id=hq-add-btn'); + await page.fill("(//input[@id='input-abbreviation'])[2]", 'ภาษาไทย'); + const invalidDataabbreviationError = page.locator( + // ตรวจสอบการแสดง Validation แจ้งเตือนชื่อย่อในกรณีที่ไม่ใช้ภาษาอังกฤษ + "(//div[contains(@class,'q-field__bottom row')])[1]", + ); + + await expect(invalidDataabbreviationError).toHaveText( + 'Invalid value. Only _ letters and number are allowed', + { + timeout: 2000, + }, + ); + console.log( + 'ตรวจสอบการแสดง Vidation แจ้งเตือนในกรณีที่ไม่ใช่ภาษาอังกฤษถูกต้อง', + ); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForTimeout(4000); + await page.click('id=btn-form-close'); +}); + +test('Create Branch Management - กรอกเลขนิติบุคคลในกรณีที่กรอกไม่ครบจำนวน 13 หลัก', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + await page.reload(); + await page.click('id=hq-add-btn'); + await page.fill("(//input[@id='input-tax-no'])[2]", '123'); + const taxNoError = page.locator( + // ตรวจสอบการแสดง Validation แจ้งเตือนชื่อย่อในกรณีที่ไม่ใช้ภาษาอังกฤษ + "(//div[@class='q-field__messages col']//div)[2]", + ); + + await expect(taxNoError).toHaveText( + 'Invalid value. Please enter 13 character', + { + timeout: 2000, + }, + ); + console.log( + 'ตรวจสอบการแสดง Vidation แจ้งเตือนในกรณีที่กรอกทะเบียนนิติบุคคลเลขที่ไม่ครบ 13 หลัก', + ); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForTimeout(4000); + await page.click('id=btn-form-close'); +}); + +test('Create Branch Management - กรอกอีเมลในกรณีที่ไม่ตรงรูปแบบอีเมล', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + await page.reload(); + await page.click('id=hq-add-btn'); + await page.fill("(//input[@id='input-email'])[2]", '123'); + const emailError = page.locator( + // ตรวจสอบการแสดง Validation แจ้งเตือนในกรณีที่กรอกอีเมลไม่ถูกรูปแบบ + "(//div[@class='q-field__messages col']//div)[2]", + ); + + await expect(emailError).toHaveText('Invalid value.', { + timeout: 2000, + }); + console.log( + 'ตรวจสอบการแสดง Vidation แจ้งเตือนในกรณีที่กรอกอีเมลไม่ถูกรูปแบบ', + ); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForTimeout(4000); + await page.click('id=btn-form-close'); +}); diff --git a/tests/01-Manage/01-Admin-BranchManagement/JWS_BM_002_CreateHeadquarterFail.spec.ts b/tests/01-Manage/01-Admin-BranchManagement/JWS_BM_002_CreateHeadquarterFail.spec.ts new file mode 100644 index 00000000..2e52e181 --- /dev/null +++ b/tests/01-Manage/01-Admin-BranchManagement/JWS_BM_002_CreateHeadquarterFail.spec.ts @@ -0,0 +1,210 @@ +import { test, expect, Page, errors } from '@playwright/test'; +import { strictEqual } from 'assert'; +import { log } from 'console'; +import exp from 'constants'; +import { errorMonitor } from 'stream'; + +let page: Page; +let isLoginSuccessful = false; + +test.beforeAll(async ({ browser }) => { + page = await browser.newPage(); +}); + +test.afterAll(async () => { + if (page !== undefined) { + await page.close(); + } +}); + +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + // เข้าสู่เมนูสาขา + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-branch'); + await page.click('id=sub-menu-branch'); + + // ถ้าขั้นตอนสำเร็จ + isLoginSuccessful = true; + } catch (error) { + console.error('เกิดข้อผิดพลาดในการ Login', error); + isLoginSuccessful = false; + } +} +test('Login', async () => { + await login(page); +}); + +test('Create Branch Management - ไม่มีการกรอกข้อมูล', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + // เข้าสู่เมนูสาขา + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-branch'); + await page.click('id=sub-menu-branch'); + + await page.click('id=hq-add-btn'); + await page.click('id=btn-info-basic-save'); + + const exceptError = [ + { + locator: "(//div[@class='q-field__messages col']//div)[1]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[2]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[3]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[4]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[5]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[6]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[7]", + message: 'โปรดเลือกจังหวัด', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[8]", + message: 'โปรดเลือกเขต/อำเภอ', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[9]", + message: 'โปรดเลือกแขวง/ตำบล', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[10]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + ]; + + for (const error of exceptError) { + const locator = page.locator(error.locator); + await expect(locator).toHaveText(error.message); + } + console.log('ระบบตรวจสอบการแจ้งเตือนแล้ว'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการ Login', error); + isLoginSuccessful = false; + throw error; + } + + await page.waitForTimeout(4000); + await page.click('id=btn-form-close'); + console.log('การตรวจสอบ Validation ถูกต้อง'); +}); + +test('Create Branch Managenment - กรณีที่กรอกชื่อย่อที่ไม่ใช่ภาษาอังกฤษ', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + await page.reload(); + await page.click('id=hq-add-btn'); + await page.fill("(//input[@id='input-abbreviation'])[2]", 'ภาษาไทย'); + const invalidDataabbreviationError = page.locator( + // ตรวจสอบการแสดง Validation แจ้งเตือนชื่อย่อในกรณีที่ไม่ใช้ภาษาอังกฤษ + "(//div[contains(@class,'q-field__bottom row')])[1]", + ); + + await expect(invalidDataabbreviationError).toHaveText( + 'ข้อมูลไม่ถูกต้อง โปรดใช้เฉพาะ _ ตัวอักษรภาษาอังกฤษและตัวเลขเท่านั้น', + { + timeout: 2000, + }, + ); + console.log( + 'ตรวจสอบการแสดง Vidation แจ้งเตือนในกรณีที่ไม่ใช่ภาษาอังกฤษถูกต้อง', + ); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + + await page.waitForTimeout(4000); + await page.click('id=btn-form-close'); +}); + +test('Create Branch Management - กรอกเลขนิติบุคคลในกรณีที่กรอกไม่ครบจำนวน 13 หลัก', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + await page.reload(); + await page.click('id=hq-add-btn'); + await page.fill("(//input[@id='input-tax-no'])[2]", '123'); + const taxNoError = page.locator( + // ตรวจสอบการแสดง Validation แจ้งเตือนชื่อย่อในกรณีที่ไม่ใช้ภาษาอังกฤษ + "(//div[@class='q-field__messages col']//div)[2]", + ); + + await expect(taxNoError).toHaveText( + 'ข้อมูลไม่ถูกต้อง กรุณากรอกให้ครบ 13 หลัก', + { + timeout: 2000, + }, + ); + console.log( + 'ตรวจสอบการแสดง Vidation แจ้งเตือนในกรณีที่กรอกทะเบียนนิติบุคคลเลขที่ไม่ครบ 13 หลัก', + ); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + + await page.waitForTimeout(4000); + await page.click('id=btn-form-close'); +}); + +test('Create Branch Management - กรอกอีเมลในกรณีที่ไม่ตรงรูปแบบอีเมล', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + await page.reload(); + await page.click('id=hq-add-btn'); + await page.fill("(//input[@id='input-email'])[2]", '123'); + const emailError = page.locator( + // ตรวจสอบการแสดง Validation แจ้งเตือนในกรณีที่กรอกอีเมลไม่ถูกรูปแบบ + "(//div[@class='q-field__messages col']//div)[2]", + ); + + await expect(emailError).toHaveText('ข้อมูลไม่ถูกต้อง', { + timeout: 2000, + }); + console.log( + 'ตรวจสอบการแสดง Vidation แจ้งเตือนในกรณีที่กรอกอีเมลไม่ถูกรูปแบบ', + ); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + + await page.waitForTimeout(4000); + await page.click('id=btn-form-close'); +}); diff --git a/tests/01-Admin-BranchManagement/JWS_BM_003_CreateSub-branch.spec.ts b/tests/01-Manage/01-Admin-BranchManagement/JWS_BM_003_CreateSub-branch.spec.ts similarity index 78% rename from tests/01-Admin-BranchManagement/JWS_BM_003_CreateSub-branch.spec.ts rename to tests/01-Manage/01-Admin-BranchManagement/JWS_BM_003_CreateSub-branch.spec.ts index cd5b2aff..af610b82 100644 --- a/tests/01-Admin-BranchManagement/JWS_BM_003_CreateSub-branch.spec.ts +++ b/tests/01-Manage/01-Admin-BranchManagement/JWS_BM_003_CreateSub-branch.spec.ts @@ -2,6 +2,7 @@ import { test, expect, Page } from '@playwright/test'; import { strictEqual } from 'assert'; let page: Page; +let isLoginSuccessful = false; test.beforeAll(async ({ browser }) => { page = await browser.newPage(); @@ -12,21 +13,39 @@ test.afterAll(async () => { await page.close(); } }); +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + // เข้าสู่เมนูสาขา + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-branch'); + await page.click('id=sub-menu-branch'); + + isLoginSuccessful = true; + console.log('ระบบทำการ Login สำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } +} test('Login', async () => { - // Login - await page.goto('http://192.168.1.62:20101/'); - 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'); + await login(page); }); test('Create Sub Branch Managenment', async () => { + if (!isLoginSuccessful) { + await login(page); + } try { - await page.click('id=menu-icon-branch-management'); for (let i = 0; i < 5; i++) { await page.click('id=create-sub-branch-btn-บริษัท โคโม่ จำกัด'); await page.click("(//button[@type='submit'])[1]"); @@ -36,7 +55,7 @@ test('Create Sub Branch Managenment', async () => { "(//input[@id='input-tax-no'])[2]", `126084622028${i + 1}`, ); - await page.fill("(//input[@id='input-name'])[3]", `สีลม${i + 1}`); + await page.fill("(//input[@id='input-name'])[2]", `สีลม${i + 1}`); await page.fill("(//input[@id='input-name-en'])[2]", `Silom${i + 1}`); await page.fill( "(//input[@aria-label='เลขที่ใบอนุญาต'])[2]", @@ -106,6 +125,7 @@ test('Create Sub Branch Managenment', async () => { console.log('การตรวจสอบสำเร็จ : ข้อมูลถูกต้อง'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; throw error; } diff --git a/tests/01-Manage/01-Admin-BranchManagement/JWS_BM_004-1_CreateSub-branchFailEn.spec.ts b/tests/01-Manage/01-Admin-BranchManagement/JWS_BM_004-1_CreateSub-branchFailEn.spec.ts new file mode 100644 index 00000000..f6d4ac2d --- /dev/null +++ b/tests/01-Manage/01-Admin-BranchManagement/JWS_BM_004-1_CreateSub-branchFailEn.spec.ts @@ -0,0 +1,207 @@ +import { test, expect, Page } from '@playwright/test'; +import { strictEqual } from 'assert'; +import { log } from 'console'; +import { fstat } from 'fs'; + +let page: Page; +let isLoginSuccessful = false; + +test.beforeAll(async ({ browser }) => { + page = await browser.newPage(); +}); + +test.afterAll(async () => { + if (page !== undefined) { + await page.close(); + } +}); +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + // เข้าสู่เมนูสาขา + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-branch'); + await page.click('id=sub-menu-branch'); + await page.waitForTimeout(2000); + + //ถ้าขั้นตอนสำเร็จ + isLoginSuccessful = true; + console.log('ระบบทำการ Login สำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการ Login', error); + isLoginSuccessful = false; + throw error; + } +} + +test('Login', async () => { + await login(page); +}); + +test('Create Sub-Branch Managenment - ในกรณีที่ไม่กรอกข้อมูล', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + // เปลี่ยนภาษา + await page.click('id=btn-change-language'); + await page.waitForSelector('id=btn-change-language-eng'); + await page.click('id=btn-change-language-eng'); + + await page.click('id=create-sub-branch-btn-COMO'); + await page.click("(//button[@type='submit'])[1]"); + await page.click('id=btn-info-basic-save'); + + const expectedErrors = [ + { + locator: "(//div[@class='q-field__messages col']//div)[1]", + message: 'This field is required.', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[2]", + message: 'This field is required.', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[3]", + message: 'This field is required.', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[4]", + message: 'This field is required.', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[5]", + message: 'This field is required.', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[6]", + message: 'Please select Province.', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[7]", + message: 'Please select District.', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[8]", + message: 'Please select District.', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[9]", + message: 'This field is required.', + }, + ]; + + for (const error of expectedErrors) { + const locator = page.locator(error.locator); + await expect(locator).toHaveText(error.message); + } + + console.log('การตรวจสอบ Validation ถูกต้อง'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForTimeout(4000); + await page.click('id=btn-form-close'); +}); + +test('Create Sub-Branch Managenment - ในกรณีที่กรอกทะเบียนนิติบุคคลเลขที่ไม่ครบ 13 หลัก', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.reload(); + await page.click('id=create-sub-branch-btn-COMO'); + + await page.click("(//button[@type='submit'])[1]"); + await page.fill("(//input[@id='input-tax-no'])[2]", '123'); + + // ตรวจสอบการแจ้งเตือนของทะเบียนนิติบุคคลเลขที่ในกรณีที่กรอกข้อมูลไม่ครบ 13 หลัก + const taxNoError = page.locator( + "(//div[@class='q-field__messages col']//div)[1]", + ); + + await expect(taxNoError).toHaveText( + 'Invalid value. Please enter 13 character', + ); + console.log( + 'ตรวจสอบการแสดง Vidation แจ้งเตือนในกรณีที่กรอกทะเบียนนิติบุคคลเลขที่ไม่ครบ 13 หลักถูกต้อง', + ); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForTimeout(4000); + await page.click('id=btn-form-close'); +}); + +test('Create Sub-Branch Managenment - กรอกอีเมลในกรณีที่ไม่ตรงรูปแบบอีเมล', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.reload(); + await page.click('id=create-sub-branch-btn-COMO'); + + await page.click("(//button[@type='submit'])[1]"); + await page.fill("(//input[@id='input-email'])[2]", 'email'); + + // ตรวจสอบการแจ้งเตือนของทะเบียนนิติบุคคลเลขที่ในกรณีที่กรอกข้อมูลไม่ครบ 13 หลัก + const emailError = page.locator( + "(//div[@class='q-field__messages col']//div)[2]", + ); + + await expect(emailError).toHaveText('Invalid value.'); + console.log( + 'ตรวจสอบการแสดง Vidation แจ้งเตือนในกรณีที่กรอกอีเมลไม่ตรงรูปแบบถูกต้อง', + ); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForTimeout(4000); + await page.click('id=btn-form-close'); +}); + +test('Create Sub-Branch Managenment - กรอกชื่อสาขาในกรณีที่ไม่ใช่ภาษาอังกฤษ', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.reload(); + await page.click('id=create-sub-branch-btn-COMO'); + + await page.click("(//button[@type='submit'])[1]"); + await page.fill("(//input[@id='input-name-en'])[2]", 'ทดสอบ'); + + // ตรวจสอบการแจ้งเตือนของทะเบียนนิติบุคคลเลขที่ในกรณีที่กรอกข้อมูลไม่ครบ 13 หลัก + const emailError = page.locator( + "(//div[@class='q-field__messages col']//div)[2]", + ); + + await expect(emailError).toHaveText('Only letters are allowed'); + console.log( + 'ตรวจสอบการแสดง Vidation แจ้งเตือนในกรณีที่กรอกอีเมลไม่ตรงรูปแบบถูกต้อง', + ); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForTimeout(4000); + await page.click('id=btn-form-close'); +}); diff --git a/tests/01-Manage/01-Admin-BranchManagement/JWS_BM_004_CreateSub-branchFail.spec.ts b/tests/01-Manage/01-Admin-BranchManagement/JWS_BM_004_CreateSub-branchFail.spec.ts new file mode 100644 index 00000000..534512a1 --- /dev/null +++ b/tests/01-Manage/01-Admin-BranchManagement/JWS_BM_004_CreateSub-branchFail.spec.ts @@ -0,0 +1,194 @@ +import { test, expect, Page } from '@playwright/test'; +import { strictEqual } from 'assert'; + +let page: Page; +let isLoginSuccessful = false; + +test.beforeAll(async ({ browser }) => { + page = await browser.newPage(); +}); + +test.afterAll(async () => { + if (page !== undefined) { + await page.close(); + } +}); +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + // เข้าสู่เมนูสาขา + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-branch'); + await page.click('id=sub-menu-branch'); + + isLoginSuccessful = true; + console.log('ระบบทำการ Login สำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + } +} +test('Login', async () => { + await login(page); +}); + +test('Create Sub-Branch Managenment - ในกรณีที่ไม่กรอกข้อมูล', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click('id=create-sub-branch-btn-บริษัท โคโม่ จำกัด'); + await page.click("(//button[@type='submit'])[1]"); + await page.click('id=btn-info-basic-save'); + + const expectedErrors = [ + { + locator: "(//div[@class='q-field__messages col']//div)[1]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[2]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[3]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[4]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[5]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[6]", + message: 'โปรดเลือกจังหวัด', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[7]", + message: 'โปรดเลือกเขต/อำเภอ', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[8]", + message: 'โปรดเลือกแขวง/ตำบล', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[9]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + ]; + + for (const error of expectedErrors) { + const locator = page.locator(error.locator); + await expect(locator).toHaveText(error.message); + } + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + + await page.waitForTimeout(4000); + await page.click('id=btn-form-close'); + console.log('การตรวจสอบ Validation ถูกต้อง'); +}); + +test('Create Sub-Branch Managenment - ในกรณีที่กรอกทะเบียนนิติบุคคลเลขที่ไม่ครบ 13 หลัก', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + await page.reload(); + await page.click('id=create-sub-branch-btn-บริษัท โคโม่ จำกัด'); + await page.click("(//button[@type='submit'])[1]"); + await page.fill("(//input[@id='input-tax-no'])[2]", '123'); + + // ตรวจสอบการแจ้งเตือนของทะเบียนนิติบุคคลเลขที่ในกรณีที่กรอกข้อมูลไม่ครบ 13 หลัก + const taxNoError = page.locator( + "(//div[@class='q-field__messages col']//div)[1]", + ); + + await expect(taxNoError).toHaveText( + 'ข้อมูลไม่ถูกต้อง กรุณากรอกให้ครบ 13 หลัก', + ); + console.log( + 'ตรวจสอบการแสดง Vidation แจ้งเตือนในกรณีที่กรอกทะเบียนนิติบุคคลเลขที่ไม่ครบ 13 หลักถูกต้อง', + ); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + + await page.waitForTimeout(4000); + await page.click('id=btn-form-close'); +}); + +test('Create Sub-Branch Managenment - กรอกอีเมลในกรณีที่ไม่ตรงรูปแบบอีเมล', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + await page.reload(); + await page.click('id=create-sub-branch-btn-บริษัท โคโม่ จำกัด'); + await page.click("(//button[@type='submit'])[1]"); + await page.fill("(//input[@id='input-email'])[2]", 'email'); + + // ตรวจสอบการแจ้งเตือนของทะเบียนนิติบุคคลเลขที่ในกรณีที่กรอกข้อมูลไม่ครบ 13 หลัก + const emailError = page.locator( + "(//div[@class='q-field__messages col']//div)[2]", + ); + + await expect(emailError).toHaveText('ข้อมูลไม่ถูกต้อง'); + console.log( + 'ตรวจสอบการแสดง Vidation แจ้งเตือนในกรณีที่กรอกอีเมลไม่ตรงรูปแบบถูกต้อง', + ); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForTimeout(4000); + await page.click('id=btn-form-close'); +}); + +test('Create Sub-Branch Managenment - กรอกชื่อสาขาในกรณีที่ไม่ใช่ภาษาอังกฤษ', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + await page.reload(); + await page.click('id=create-sub-branch-btn-บริษัท โคโม่ จำกัด'); + await page.click("(//button[@type='submit'])[1]"); + await page.fill("(//input[@id='input-name-en'])[2]", 'ทดสอบ'); + + // ตรวจสอบการแจ้งเตือนของทะเบียนนิติบุคคลเลขที่ในกรณีที่กรอกข้อมูลไม่ครบ 13 หลัก + const emailError = page.locator( + "(//div[@class='q-field__messages col']//div)[2]", + ); + + await expect(emailError).toHaveText( + 'โปรดใช้เฉพาะตัวอักษรภาษาอังกฤษเท่านั้น', + ); + console.log( + 'ตรวจสอบการแสดง Vidation แจ้งเตือนในกรณีที่กรอกอีเมลไม่ตรงรูปแบบถูกต้อง', + ); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForTimeout(4000); + await page.click('id=btn-form-close'); +}); diff --git a/tests/01-Admin-BranchManagement/JWS_BM_005_CreateServicePoint.spec.ts b/tests/01-Manage/01-Admin-BranchManagement/JWS_BM_005_CreateServicePoint.spec.ts similarity index 78% rename from tests/01-Admin-BranchManagement/JWS_BM_005_CreateServicePoint.spec.ts rename to tests/01-Manage/01-Admin-BranchManagement/JWS_BM_005_CreateServicePoint.spec.ts index 81691e0f..4ffdee8b 100644 --- a/tests/01-Admin-BranchManagement/JWS_BM_005_CreateServicePoint.spec.ts +++ b/tests/01-Manage/01-Admin-BranchManagement/JWS_BM_005_CreateServicePoint.spec.ts @@ -2,6 +2,7 @@ import { test, expect, Page } from '@playwright/test'; import { strictEqual } from 'assert'; let page: Page; +let isLoginSuccessful = false; test.beforeAll(async ({ browser }) => { page = await browser.newPage(); @@ -12,21 +13,39 @@ test.afterAll(async () => { await page.close(); } }); +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + // เข้าสู่เมนูสาขา + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-branch'); + await page.click('id=sub-menu-branch'); + await page.waitForTimeout(2000); + + isLoginSuccessful = true; + console.log('ระบบทำการ Login สำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการ Login'); + isLoginSuccessful = false; + } +} test('Login', async () => { - // Login - await page.goto('http://192.168.1.62:20101/'); - 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'); + await login(page); }); test('Create Service Point Managenment', async () => { + if (!isLoginSuccessful) { + await login(page); + } try { - await page.click('id=menu-icon-branch-management'); for (let i = 0; i < 5; i++) { await page.click('id=create-sub-branch-btn-บริษัท คาโมมายด์ จำกัด'); await page.click("(//button[@type='submit'])[2]"); @@ -36,7 +55,7 @@ test('Create Service Point Managenment', async () => { "(//input[@id='input-tax-no'])[2]", `202282628264${i + 1}`, ); - await page.fill("(//input[@id='input-name'])[3]", `บางรัก${i + 1}`); + await page.fill("(//input[@id='input-name'])[2]", `บางรัก${i + 1}`); await page.fill("(//input[@id='input-name-en'])[2]", `Bangrak${i + 1}`); await page.fill( "(//input[@aria-label='เลขที่ใบอนุญาต'])[2]", @@ -112,6 +131,7 @@ test('Create Service Point Managenment', async () => { console.log('การตรวจสอบสำเร็จ : ข้อมูลถูกต้อง'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; throw error; } diff --git a/tests/01-Manage/01-Admin-BranchManagement/JWS_BM_006-1_CreateServicePointFail.spec.ts b/tests/01-Manage/01-Admin-BranchManagement/JWS_BM_006-1_CreateServicePointFail.spec.ts new file mode 100644 index 00000000..f356069c --- /dev/null +++ b/tests/01-Manage/01-Admin-BranchManagement/JWS_BM_006-1_CreateServicePointFail.spec.ts @@ -0,0 +1,176 @@ +import { test, expect, Page } from '@playwright/test'; +import { strictEqual } from 'assert'; +import { exec } from 'child_process'; +import { error } from 'console'; +import exp from 'constants'; + +let page: Page; +let isLoginSuccessful = false; + +test.beforeAll(async ({ browser }) => { + page = await browser.newPage(); +}); + +test.afterAll(async () => { + if (page !== undefined) { + await page.close(); + } +}); +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + // เข้าสู่เมนูสาขา + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-branch'); + await page.click('id=sub-menu-branch'); + await page.waitForTimeout(2000); + + isLoginSuccessful = true; + console.log('ระบบทำการ Login สำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + } +} +test('Login', async () => { + await login(page); +}); + +test('Create Service Point - ในกรณีที่ไม่กรอกข้อมูล', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + // เปลี่ยนภาษา + await page.click('id=btn-change-language'); + await page.waitForSelector('id=btn-change-language-eng'); + await page.click('id=btn-change-language-eng'); + + await page.click('id=create-sub-branch-btn-CHAMOMIND'); + await page.click("(//button[@type='submit'])[2]"); + await page.click('id=btn-info-basic-save'); + + const expectedErrors = [ + { + locator: "(//div[@class='q-field__messages col']//div)[1]", + message: 'This field is required.', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[2]", + message: 'This field is required.', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[3]", + message: 'This field is required.', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[4]", + message: 'This field is required.', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[5]", + message: 'This field is required.', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[6]", + message: 'Please select Province.', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[7]", + message: 'Please select District.', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[8]", + message: 'Please select Sub-district.', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[9]", + message: 'This field is required.', + }, + ]; + + for (const error of expectedErrors) { + const locator = page.locator(error.locator); + await expect(locator).toHaveText(error.message); + } + + console.log('การตรวจสอบ Validation ถูกต้อง'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForTimeout(4000); + await page.click('id=btn-form-close'); +}); + +test('Create Service Point - ในกรณีที่กรอกทะเบียนนิติบุคคลเลขที่ไม่ครบ 13 หลัก', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.reload(); + await page.click('id=create-sub-branch-btn-CHAMOMIND'); + await page.click("(//button[@type='submit'])[2]"); + await page.fill("(//input[@id='input-tax-no'])[2]", '123'); + + // ตรวจสอบการแจ้งเตือนของทะเบียนนิติบุคคลเลขที่ในกรณีที่กรอกข้อมูลไม่ครบ 13 หลัก + const taxNoError = page.locator( + "(//div[@class='q-field__messages col']//div)[1]", + ); + + await expect(taxNoError).toHaveText( + 'Invalid value. Please enter 13 character', + ); + + console.log( + 'ตรวจสอบการแสดง Vidation แจ้งเตือนในกรณีที่กรอกทะเบียนนิติบุคคลเลขที่ไม่ครบ 13 หลักถูกต้อง', + ); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForTimeout(4000); + await page.click('id=btn-form-close'); +}); + +test('Create Service Point - กรอกอีเมลในกรณีที่ไม่ตรงรูปแบบอีเมล', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.reload(); + await page.click('id=create-sub-branch-btn-CHAMOMIND'); + await page.click("(//button[@type='submit'])[2]"); + await page.fill("(//input[@id='input-email'])[2]", 'email'); + + // ตรวจสอบการแจ้งเตือนของทะเบียนนิติบุคคลเลขที่ในกรณีที่กรอกข้อมูลไม่ครบ 13 หลัก + const emailError = page.locator( + "(//div[@class='q-field__messages col']//div)[2]", + ); + + await expect(emailError).toHaveText('Invalid value.'); + + console.log( + 'ตรวจสอบการแสดง Vidation แจ้งเตือนในกรณีที่กรอกอีเมลไม่ตรงรูปแบบถูกต้อง', + ); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForTimeout(4000); + await page.click('id=btn-form-close'); +}); diff --git a/tests/01-Manage/01-Admin-BranchManagement/JWS_BM_006_CreateServicePointFail.spec.ts b/tests/01-Manage/01-Admin-BranchManagement/JWS_BM_006_CreateServicePointFail.spec.ts new file mode 100644 index 00000000..987f6f4a --- /dev/null +++ b/tests/01-Manage/01-Admin-BranchManagement/JWS_BM_006_CreateServicePointFail.spec.ts @@ -0,0 +1,167 @@ +import { test, expect, Page } from '@playwright/test'; +import { strictEqual } from 'assert'; +import { exec } from 'child_process'; + +let page: Page; +let isLoginSuccessful = false; + +test.beforeAll(async ({ browser }) => { + page = await browser.newPage(); +}); + +test.afterAll(async () => { + if (page !== undefined) { + await page.close(); + } +}); + +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + // เข้าสู่เมนูสาขา + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-branch'); + await page.click('id=sub-menu-branch'); + await page.waitForTimeout(2000); + + isLoginSuccessful = true; + console.log('ระบบทำการ Login สำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + } +} +test('Login', async () => { + await login(page); +}); + +test('Create Service Point - ในกรณีที่ไม่กรอกข้อมูล', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click('id=create-sub-branch-btn-บริษัท คาโมมายด์ จำกัด'); + await page.click("(//button[@type='submit'])[2]"); + await page.click('id=btn-info-basic-save'); + + const expectedErrors = [ + { + locator: "(//div[@class='q-field__messages col']//div)[1]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[2]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[3]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[4]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[5]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[6]", + message: 'โปรดเลือกจังหวัด', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[7]", + message: 'โปรดเลือกเขต/อำเภอ', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[8]", + message: 'โปรดเลือกแขวง/ตำบล', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[9]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + ]; + + for (const error of expectedErrors) { + const locator = page.locator(error.locator); + await expect(locator).toHaveText(error.message); + } + + console.log('การตรวจสอบ Validation ถูกต้อง'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForTimeout(4000); + await page.click('id=btn-form-close'); +}); + +test('Create Service Point - ในกรณีที่กรอกทะเบียนนิติบุคคลเลขที่ไม่ครบ 13 หลัก', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + await page.reload(); + await page.click('id=create-sub-branch-btn-บริษัท คาโมมายด์ จำกัด'); + await page.click("(//button[@type='submit'])[2]"); + await page.fill("(//input[@id='input-tax-no'])[2]", '123'); + + // ตรวจสอบการแจ้งเตือนของทะเบียนนิติบุคคลเลขที่ในกรณีที่กรอกข้อมูลไม่ครบ 13 หลัก + const taxNoError = page.locator( + "(//div[@class='q-field__messages col']//div)[1]", + ); + + await expect(taxNoError).toHaveText( + 'ข้อมูลไม่ถูกต้อง กรุณากรอกให้ครบ 13 หลัก', + ); + console.log( + 'ตรวจสอบการแสดง Vidation แจ้งเตือนในกรณีที่กรอกทะเบียนนิติบุคคลเลขที่ไม่ครบ 13 หลักถูกต้อง', + ); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForTimeout(4000); + await page.click('id=btn-form-close'); +}); + +test('Create Service Point - กรอกอีเมลในกรณีที่ไม่ตรงรูปแบบอีเมล', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.reload(); + await page.click('id=create-sub-branch-btn-บริษัท คาโมมายด์ จำกัด'); + await page.click("(//button[@type='submit'])[2]"); + await page.fill("(//input[@id='input-email'])[2]", 'email'); + + // ตรวจสอบการแจ้งเตือนของทะเบียนนิติบุคคลเลขที่ในกรณีที่กรอกข้อมูลไม่ครบ 13 หลัก + const emailError = page.locator( + "(//div[@class='q-field__messages col']//div)[2]", + ); + + await expect(emailError).toHaveText('ข้อมูลไม่ถูกต้อง'); + console.log( + 'ตรวจสอบการแสดง Vidation แจ้งเตือนในกรณีที่กรอกอีเมลไม่ตรงรูปแบบถูกต้อง', + ); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForTimeout(4000); + await page.click('id=btn-form-close'); +}); diff --git a/tests/01-Admin-BranchManagement/JWS_BM_007_SelectTypeBranch.spec.ts b/tests/01-Manage/01-Admin-BranchManagement/JWS_BM_007_SelectTypeBranch.spec.ts similarity index 92% rename from tests/01-Admin-BranchManagement/JWS_BM_007_SelectTypeBranch.spec.ts rename to tests/01-Manage/01-Admin-BranchManagement/JWS_BM_007_SelectTypeBranch.spec.ts index e8736281..54559d43 100644 --- a/tests/01-Admin-BranchManagement/JWS_BM_007_SelectTypeBranch.spec.ts +++ b/tests/01-Manage/01-Admin-BranchManagement/JWS_BM_007_SelectTypeBranch.spec.ts @@ -1,9 +1,12 @@ import { test, expect, Page } from '@playwright/test'; import { strictEqual } from 'assert'; +import { log } from 'console'; +import { sign } from 'crypto'; import { watchFile } from 'fs'; import { waitForDebugger } from 'inspector'; let page: Page; +let isLoginSuccessful = false; test.beforeAll(async ({ browser }) => { page = await browser.newPage(); @@ -14,23 +17,39 @@ test.afterAll(async () => { await page.close(); } }); +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + // เข้าสู่เมนูสาขา + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-branch'); + await page.click('id=sub-menu-branch'); + await page.waitForTimeout(2000); + + isLoginSuccessful = true; + console.log('ระบบทำการ Login สำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + } +} test('Login', async () => { - // Login - await page.goto('http://192.168.1.62:20101/'); - 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'); + await login(page); }); test('ตรวจสอบการแสดงผลฟิลด์แสดงผลลำดับที่', async () => { + if (!isLoginSuccessful) { + await login(page); + } try { - // คลิกเมนูเพื่อจัดการสาขา - await page.click('id=menu-icon-branch-management'); - // คลิกเพื่อเปิด dropdown await page.click("(//input[@id='select-field'])[1]"); await page.waitForTimeout(1000); // รอให้ dropdown เปิด @@ -82,6 +101,7 @@ test('ตรวจสอบการแสดงผลฟิลด์แสด console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; throw error; } @@ -89,6 +109,9 @@ test('ตรวจสอบการแสดงผลฟิลด์แสด }); test('ตรวจสอบการแสดงผลฟิลด์แสดงผลชื่อ', async () => { + if (!isLoginSuccessful) { + await login(page); + } try { // คลิกเพื่อเปิด dropdown await page.keyboard.press('Escape'); @@ -142,6 +165,7 @@ test('ตรวจสอบการแสดงผลฟิลด์แสด console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; throw error; } @@ -149,6 +173,9 @@ test('ตรวจสอบการแสดงผลฟิลด์แสด }); test('ตรวจสอบการแสดงผลฟิลด์แสดงผลทะเบียนนิติบุคคล', async () => { + if (!isLoginSuccessful) { + await login(page); + } try { // คลิกเพื่อเปิด dropdown await page.keyboard.press('Escape'); @@ -202,6 +229,7 @@ test('ตรวจสอบการแสดงผลฟิลด์แสด console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; throw error; } @@ -209,6 +237,9 @@ test('ตรวจสอบการแสดงผลฟิลด์แสด }); test('ตรวจสอบการแสดงผลฟิลด์แสดงผลเบอร์โทรสำนักงาน', async () => { + if (!isLoginSuccessful) { + await login(page); + } try { // คลิกเพื่อเปิด dropdown await page.keyboard.press('Escape'); @@ -262,6 +293,7 @@ test('ตรวจสอบการแสดงผลฟิลด์แสด console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; throw error; } @@ -269,6 +301,9 @@ test('ตรวจสอบการแสดงผลฟิลด์แสด }); test('ตรวจสอบการแสดงผลฟิลด์แสดงผลติดต่อ', async () => { + if (!isLoginSuccessful) { + await login(page); + } try { // คลิกเพื่อเปิด dropdown await page.keyboard.press('Escape'); @@ -320,6 +355,7 @@ test('ตรวจสอบการแสดงผลฟิลด์แสด console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; throw error; } @@ -327,6 +363,9 @@ test('ตรวจสอบการแสดงผลฟิลด์แสด }); test('ตรวจสอบการแสดงผลฟิลด์แสดงผลที่อยู่', async () => { + if (!isLoginSuccessful) { + await login(page); + } try { // คลิกเพื่อเปิด dropdown await page.keyboard.press('Escape'); @@ -380,6 +419,7 @@ test('ตรวจสอบการแสดงผลฟิลด์แสด console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; throw error; } diff --git a/tests/01-Manage/01-Admin-BranchManagement/JWS_BM_008_ViewDetail.spec.ts b/tests/01-Manage/01-Admin-BranchManagement/JWS_BM_008_ViewDetail.spec.ts new file mode 100644 index 00000000..b627cdd1 --- /dev/null +++ b/tests/01-Manage/01-Admin-BranchManagement/JWS_BM_008_ViewDetail.spec.ts @@ -0,0 +1,235 @@ +import { test, expect, Page } from '@playwright/test'; +import { strictEqual } from 'assert'; +import { log } from 'console'; + +let page: Page; +let isLoginSuccessful = false; + +test.beforeAll(async ({ browser }) => { + page = await browser.newPage(); +}); + +test.afterAll(async () => { + if (page !== undefined) { + await page.close(); + } +}); + +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + // เข้าสู่เมนูสาขา + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-branch'); + await page.click('id=sub-menu-branch'); + await page.waitForTimeout(2000); + + isLoginSuccessful = true; + console.log('ระบบทำการ Login สำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการ Login', error); + isLoginSuccessful = false; + } +} + +test('Login', async () => { + await login(page); +}); + +test('ทดสอบการดูรายละเอียดสำนักงานใหญ่', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + await page.click('id=btn-kebab-action-บริษัท โคโม่ จำกัด'); + await page.click('id=btn-kebab-view-detail-บริษัท โคโม่ จำกัด'); + + const detailTitle = page.locator( + "//span[text()='บริษัท โคโม่ จำกัด ']/following-sibling::span", + ); + + await expect(detailTitle).toHaveText('CMO00000'); // เลขรหัสสำนักงานใหญ่ + + console.log('ตรวจสอบข้อมูลถูกต้อง'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + + await page.waitForTimeout(4000); + await page.click('id=btn-info-close'); +}); + +test('ทดสอบการดูรายละเอียดสาขา', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + await page.click("(//div[@id='tree-enter-บริษัท โคโม่ จำกัด']//div)[1]"); + await page.click('id=btn-kebab-action-สีลม1'); + await page.click('id=btn-kebab-view-detail-สีลม1'); + + const detailTitle = page.locator("//span[text()='สีลม1 ']"); + + await detailTitle.waitFor({ state: 'visible' }); + + await expect(detailTitle).toHaveText('สีลม1'); // เลขรหัสสำนักงานใหญ่ + + console.log('ตรวจสอบข้อมูลถูกต้อง'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + + await page.waitForTimeout(4000); + await page.click('id=btn-info-close'); +}); + +test('ทดสอบการดูรายละเอียดจุดรับบริการ', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + await page.click("//div[@id='tree-enter-บริษัท คาโมมายด์ จำกัด']/div[1]"); + await page.click('id=btn-kebab-action-บางรัก1'); + await page.click('id=btn-kebab-view-detail-บางรัก1'); + + const detailTitle = page.locator("//span[text()='บางรัก1 ']"); + + await detailTitle.waitFor({ state: 'visible' }); + + await expect(detailTitle).toHaveText('บางรัก1'); // เลขรหัสสำนักงานใหญ่ + + console.log('ตรวจสอบข้อมูลถูกต้อง'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + + await page.waitForTimeout(4000); + await page.click('id=btn-info-close'); +}); + +test('ทดสอบการดูรายละเอียดสำนักงานใหญ่ในรูปแบบการ์ด', async () => { + if (!isLoginSuccessful) { + await login(page); + } + await page.reload(); + + await page.click("//button[@aria-pressed='false']"); + await page.waitForTimeout(2000); + try { + const nameBrnach = page.locator( + "//b[normalize-space(text())='บริษัท คาโมมายด์ จำกัด']", + ); + const legalPerson = page.locator( + "(//div[text()='ทะเบียนนิติบุคคล']/following-sibling::div)[1]", + ); + const cellPhone = page.locator( + "(//div[text()='เบอร์โทรสำนักงาน']/following-sibling::div)[1]", + ); + const contactName = page.locator("//div[normalize-space(text())='คุณต่อ']"); + const address = page.locator( + "//div[normalize-space(text())='20/02 หมู่ 1, พระบรมมหาราชวัง, พระนคร, กรุงเทพมหานคร 10200']", + ); + + await expect(nameBrnach).toHaveText('บริษัท คาโมมายด์ จำกัด'); + await expect(legalPerson).toHaveText('1260846220284'); + await expect(cellPhone).toHaveText('0866224228'); + await expect(contactName).toHaveText('คุณต่อ'); + await expect(address).toHaveText( + '20/02 หมู่ 1, พระบรมมหาราชวัง, พระนคร, กรุงเทพมหานคร 10200', + ); + + console.log('ตรวจสอบข้อมูลถูกต้อง'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + + await page.waitForTimeout(4000); +}); + +test('ทดสอบการดูรายละเอียดสาขาในรูปแบบการ์ด', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click("//div[@id='tree-enter-บริษัท คาโมมายด์ จำกัด']/div[1]"); + + await page.waitForTimeout(2000); + + const legalPerson = page.locator( + "(//div[text()='ทะเบียนนิติบุคคล']/following-sibling::div)[1]", + ); + const contactName = page.locator( + "(//div[text()='ติดต่อ']/following-sibling::div)[1]", + ); + const address = page.locator( + "//div[normalize-space(text())='40/01 พระบรมมหาราชวัง, พระนคร, กรุงเทพมหานคร 10200']", + ); + + await expect(legalPerson).toHaveText('2022826282641'); + await expect(contactName).toHaveText('คุณอุล'); + await expect(address).toHaveText( + '40/01 พระบรมมหาราชวัง, พระนคร, กรุงเทพมหานคร 10200', + ); + + console.log('ตรวจสอบข้อมูลถูกต้อง'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + + await page.waitForTimeout(4000); +}); + +test('ทดสอบการดูรายละเอียดจุดรับบริการในรูปแบบการ์ด', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click("(//div[@id='tree-enter-บริษัท โคโม่ จำกัด']//div)[1]"); + + await page.waitForTimeout(2000); + + const legalPerson = page.locator( + "(//div[text()='ทะเบียนนิติบุคคล']/following-sibling::div)[1]", + ); + const contactName = page.locator( + "(//div[text()='ติดต่อ']/following-sibling::div)[1]", + ); + const address = page.locator( + "//div[normalize-space(text())='20/01 พระบรมมหาราชวัง, พระนคร, กรุงเทพมหานคร 10200']", + ); + + await expect(legalPerson).toHaveText('1260846220281'); + await expect(contactName).toHaveText('คุณอาท'); + await expect(address).toHaveText( + '20/01 พระบรมมหาราชวัง, พระนคร, กรุงเทพมหานคร 10200', + ); + + console.log('ตรวจสอบข้อมูลถูกต้อง'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + + await page.waitForTimeout(4000); +}); diff --git a/tests/01-Admin-BranchManagement/JWS_BM_009_EditBranch.spec.ts b/tests/01-Manage/01-Admin-BranchManagement/JWS_BM_009_EditBranch.spec.ts similarity index 81% rename from tests/01-Admin-BranchManagement/JWS_BM_009_EditBranch.spec.ts rename to tests/01-Manage/01-Admin-BranchManagement/JWS_BM_009_EditBranch.spec.ts index 7d79dfa3..a5adee1e 100644 --- a/tests/01-Admin-BranchManagement/JWS_BM_009_EditBranch.spec.ts +++ b/tests/01-Manage/01-Admin-BranchManagement/JWS_BM_009_EditBranch.spec.ts @@ -1,8 +1,10 @@ import { test, expect, Page } from '@playwright/test'; import { strictEqual } from 'assert'; import exp from 'constants'; +import { sign } from 'crypto'; let page: Page; +let isLoginSuccessful = false; test.beforeAll(async ({ browser }) => { page = await browser.newPage(); @@ -14,21 +16,41 @@ test.afterAll(async () => { } }); +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + // เข้าสู่เมนูสาขา + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-branch'); + await page.click('id=sub-menu-branch'); + await page.waitForTimeout(2000); + + isLoginSuccessful = true; + console.log('ระบบทำการ Login สำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการ Login', error); + isLoginSuccessful = false; + } +} test('Login', async () => { - // Login - await page.goto('http://192.168.1.62:20101/'); - 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'); + await login(page); }); test('Edit Headquter Branch', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { // แก้ไขสำนักงานใหญ่ - await page.click('id=menu-icon-branch-management'); await page.click('id=btn-kebab-action-บริษัท โคโม่ จำกัด'); await page.click('id=btn-kebab-edit-บริษัท โคโม่ จำกัด'); await page.fill('id=input-name', 'บริษัท โคโมโดะ จำกัด'); @@ -53,6 +75,7 @@ test('Edit Headquter Branch', async () => { console.log('ตรวจสอบการแก้ไขข้อมูลสำนักงานใหญ่ถูกต้อง'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; throw error; } @@ -61,6 +84,9 @@ test('Edit Headquter Branch', async () => { }); test('Edit Sub Branch', async () => { + if (!isLoginSuccessful) { + await login(page); + } try { // แก้ไขสำนักงานใหญ่ await page.click("//div[@id='tree-enter-บริษัท โคโมโดะ จำกัด']/div[1]"); @@ -90,6 +116,7 @@ test('Edit Sub Branch', async () => { console.log('ตรวจสอบการแก้ไขข้อมูลสาขาถูกต้อง'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; throw error; } @@ -98,6 +125,9 @@ test('Edit Sub Branch', async () => { }); test('Edit Visual Branch', async () => { + if (!isLoginSuccessful) { + await login(page); + } try { // แก้ไขสำนักงานใหญ่ await page.click("//div[@id='tree-enter-บริษัท คาโมมายด์ จำกัด']/div[1]"); @@ -121,6 +151,7 @@ test('Edit Visual Branch', async () => { console.log('ตรวจสอบการแก้ไขข้อมูลสาขาเสมือนถูกต้อง'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; throw error; } diff --git a/tests/01-Admin-BranchManagement/JWS_BM_010_StatusBranchandSubType.spec.ts b/tests/01-Manage/01-Admin-BranchManagement/JWS_BM_010_StatusBranchandSubType.spec.ts similarity index 91% rename from tests/01-Admin-BranchManagement/JWS_BM_010_StatusBranchandSubType.spec.ts rename to tests/01-Manage/01-Admin-BranchManagement/JWS_BM_010_StatusBranchandSubType.spec.ts index aa031da4..a7c24a49 100644 --- a/tests/01-Admin-BranchManagement/JWS_BM_010_StatusBranchandSubType.spec.ts +++ b/tests/01-Manage/01-Admin-BranchManagement/JWS_BM_010_StatusBranchandSubType.spec.ts @@ -2,6 +2,7 @@ import { test, expect, Page } from '@playwright/test'; import { strictEqual } from 'assert'; let page: Page; +let isLoginSuccessful = false; test.beforeAll(async ({ browser }) => { page = await browser.newPage(); @@ -13,22 +14,40 @@ test.afterAll(async () => { } }); +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + // เข้าสู่เมนูสาขา + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-branch'); + await page.click('id=sub-menu-branch'); + await page.waitForTimeout(2000); + + isLoginSuccessful = true; + console.log('ระบบทำการ Login'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการ Login'); + isLoginSuccessful = false; + } +} + test('Login', async () => { - // Login - await page.goto('http://192.168.1.62:20101/'); - 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'); + await login(page); }); test('ตรวจสอบการแสดงผลสถานะการใช้งาน เปิด/ปิด สำนักงานใหญ่', async () => { + if (!isLoginSuccessful) { + await login(page); + } try { - // คลิกเมนูเพื่อจัดการสาขา - await page.click('id=menu-icon-branch-management'); - // แสดงสถานะที่ใช้งาน // คลิกเพื่อเปิด dropdown await page.click('id=field-select-status'); @@ -86,6 +105,7 @@ test('ตรวจสอบการแสดงผลสถานะการ console.log('ตรวจสอบสถานะทั้งหมด'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; throw error; } diff --git a/tests/01-Admin-BranchManagement/JWS_BM_011_SearchBranchmanagement.spec.ts b/tests/01-Manage/01-Admin-BranchManagement/JWS_BM_011_SearchBranchmanagement.spec.ts similarity index 75% rename from tests/01-Admin-BranchManagement/JWS_BM_011_SearchBranchmanagement.spec.ts rename to tests/01-Manage/01-Admin-BranchManagement/JWS_BM_011_SearchBranchmanagement.spec.ts index 4a5be902..beee34bd 100644 --- a/tests/01-Admin-BranchManagement/JWS_BM_011_SearchBranchmanagement.spec.ts +++ b/tests/01-Manage/01-Admin-BranchManagement/JWS_BM_011_SearchBranchmanagement.spec.ts @@ -3,6 +3,7 @@ import { strictEqual } from 'assert'; import { Console, error, log } from 'console'; let page: Page; +let isLoginSuccessful = false; test.beforeAll(async ({ browser }) => { page = await browser.newPage(); @@ -14,20 +15,39 @@ test.afterAll(async () => { } }); +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + // เข้าสู่เมนูสาขา + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-branch'); + await page.click('id=sub-menu-branch'); + await page.waitForTimeout(2000); + + isLoginSuccessful = true; + console.log('ระบบทำการ Login'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการ Login', error); + isLoginSuccessful = false; + } +} + 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'); + await login(page); }); test('Search Data Branch Management', async () => { - await page.click('id=menu-icon-branch-management'); - + if (!isLoginSuccessful) { + await login(page); + } try { // กำหนดคำที่จะค้นหา const searchDatas = [ @@ -79,6 +99,7 @@ test('Search Data Branch Management', async () => { } } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบการค้นหาหลายคำค้นหา', error); + isLoginSuccessful = false; throw error; } await page.waitForTimeout(2000); diff --git a/tests/01-Admin-BranchManagement/JWS_BM_012_CloseStatusBranch.spec.ts b/tests/01-Manage/01-Admin-BranchManagement/JWS_BM_012_CloseStatusBranch.spec.ts similarity index 76% rename from tests/01-Admin-BranchManagement/JWS_BM_012_CloseStatusBranch.spec.ts rename to tests/01-Manage/01-Admin-BranchManagement/JWS_BM_012_CloseStatusBranch.spec.ts index 03decd4d..a3f80bd1 100644 --- a/tests/01-Admin-BranchManagement/JWS_BM_012_CloseStatusBranch.spec.ts +++ b/tests/01-Manage/01-Admin-BranchManagement/JWS_BM_012_CloseStatusBranch.spec.ts @@ -3,6 +3,7 @@ import { strictEqual } from 'assert'; import { Console, error, log } from 'console'; let page: Page; +let isLoginSuccessful = false; test.beforeAll(async ({ browser }) => { page = await browser.newPage(); @@ -14,20 +15,41 @@ test.afterAll(async () => { } }); +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + // เข้าสู่เมนูสาขา + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-branch'); + await page.click('id=sub-menu-branch'); + await page.waitForTimeout(2000); + + isLoginSuccessful = true; + console.log('ระบบทำการ Login'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการ Login', error); + isLoginSuccessful = false; + } +} + test('Login', async () => { - // Login - await page.goto('http://192.168.1.62:20101/'); - 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'); + await login(page); }); test('ปิดการใช้งานสำนักงานใหญ่', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { - await page.click('id=menu-icon-branch-management'); await page.click('id=btn-kebab-action-บริษัท คาโมมายด์ จำกัด'); await page.click('id=btn-kebab-status-บริษัท คาโมมายด์ จำกัด', { @@ -57,12 +79,17 @@ test('ปิดการใช้งานสำนักงานใหญ่', console.log('สีของแถวถูกเปลี่ยนเป็นสีเทาอ่อน'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ'); + isLoginSuccessful = false; throw error; } await page.waitForTimeout(2000); }); test('เปิดการใช้งานสำนักงานใหญ่', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { await page.click('id=btn-kebab-action-บริษัท คาโมมายด์ จำกัด'); @@ -93,6 +120,7 @@ test('เปิดการใช้งานสำนักงานใหญ console.log('สีของแถวถูกเปลี่ยนเป็นของสถานะการใช้งาน'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ'); + isLoginSuccessful = false; throw error; } await page.waitForTimeout(2000); diff --git a/tests/01-Manage/01-Admin-BranchManagement/JWS_BM_013_DeleteBranch.spec.ts b/tests/01-Manage/01-Admin-BranchManagement/JWS_BM_013_DeleteBranch.spec.ts new file mode 100644 index 00000000..6fc7d113 --- /dev/null +++ b/tests/01-Manage/01-Admin-BranchManagement/JWS_BM_013_DeleteBranch.spec.ts @@ -0,0 +1,247 @@ +import { test, expect, Page } from '@playwright/test'; +import { strictEqual } from 'assert'; +import { Console, error, log } from 'console'; +import exp from 'constants'; +import { it } from 'node:test'; +import { prependOnceListener } from 'process'; + +let page: Page; +let isLoginSuccessful = false; + +test.beforeAll(async ({ browser }) => { + page = await browser.newPage(); +}); + +test.afterAll(async () => { + if (page !== undefined) { + await page.close(); + } +}); + +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + // เข้าสู่เมนูสาขา + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-branch'); + await page.click('id=sub-menu-branch'); + await page.waitForTimeout(2000); + + isLoginSuccessful = true; + console.log('ระบบทำการ Login'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการ Login', error); + isLoginSuccessful = false; + } +} + +test('Login', async () => { + await login(page); +}); + +test('ทดสอบการลบจัดการสาขา', async () => { + // จำลองการสร้างสำนักงานใหญ่ + + // await page.click('id=hq-add-btn'); + // await page.fill("(//input[@id='input-abbreviation'])[2]", 'TES'); + // await page.fill("(//input[@id='input-tax-no'])[2]", '1260846220284'); + // await page.fill("(//input[@id='input-name'])[2]", 'บริษัท จำลอง จำกัด'); + // await page.fill("(//input[@id='input-name-en'])[2]", 'JOMLONG'); + // await page.fill("(//input[@id='input-license-number'])[2]", '2938227328292'); + // await page.fill("(//input[@id='input-email'])[2]", 'JOM@support.com'); + // await page.fill("(//input[@id='input-telephone-no'])[2]", '022010100'); + // await page.fill("(//input[@id='input-contact-name'])[2]", 'คุณอาท'); + // await page.fill("(//input[@id='input-contact'])[2]", '0866224228'); + // await page.fill("(//input[@id='input-line-id'])[2]", 'como20'); + // await page.fill("(//input[@id='default-input-address-no'])[2]", '40/04'); + // await page.click("(//input[@id='default-select-province'])[2]"); + // await page.click("//div[@role='option']"); + // await page.click("(//input[@id='default-select-district'])[2]"); + // await page.waitForTimeout(1000); + // await page.click("//div[@role='option']"); + // await page.click("(//input[@id='default-select-sub-district'])[2]"); + // await page.waitForTimeout(1000); + // await page.click("//div[@role='option']"); + // await page.fill("(//input[@id='default-input-address-en'])[2]", '40/04'); + // await page.click("(//input[@id='select-bankbook'])[3]"); + // await page.click('id=select-bankbook_4'); + // await page.fill("(//input[@aria-label='เลขบัญชี'])[2]", '2022822624262'); + // await page.fill("(//input[@aria-label='สาขาธนาคาร'])[2]", 'ลำพูน'); + // await page.fill("(//input[@aria-label='ชื่อบัญชี'])[2]", 'Pongpon Kuntana'); + // await page.click("(//input[@aria-label='ประเภทบัญชี'])[2]"); + // await page.waitForTimeout(2000); + // await page.click('id=select-bankbook_0'); + // await page.click('id=btn-info-basic-save'); + + // await page.waitForSelector('id=btn-ok-dialog'); + // await page.click('id=btn-ok-dialog'); + // await page.click('id=btn-form-close'); + + if (!isLoginSuccessful) { + await login(page); + } + // จำลองการสร้างสาขา + try { + await page.click('id=create-sub-branch-btn-บริษัท จำลอง จำกัด'); + await page.click("(//button[@type='submit'])[1]"); + + await page.fill("(//input[@id='input-tax-no'])[2]", '1260846220281'); + await page.fill("(//input[@id='input-name'])[2]", 'สาขาจำลอง'); + await page.fill("(//input[@id='input-name-en'])[2]", 'SAKAJOMLONG'); + await page.fill( + "(//input[@aria-label='เลขที่ใบอนุญาต'])[2]", + '1228222822822', + ); + await page.fill("(//input[@id='input-email'])[2]", 'test@support.com'); + await page.fill("(//input[@id='input-telephone-no'])[2]", '022222002'); + await page.fill("(//input[@id='input-contact-name'])[2]", 'คุณอาท'); + await page.fill("(//input[@id='input-contact'])[2]", '0822262228'); + await page.fill("(//input[@id='input-line-id'])[2]", 'company'); + + await page.fill("(//input[@id='default-input-address-no'])[2]", '20/02'); + await page.click("(//input[@id='default-select-province'])[2]"); + await page.click("//div[@role='option']"); + await page.click("(//input[@id='default-select-district'])[2]"); + await page.waitForTimeout(400); + await page.click("//div[@role='option']"); + await page.click("(//input[@id='default-select-sub-district'])[2]"); + await page.waitForTimeout(400); + await page.click("//div[@role='option']"); + await page.fill("(//input[@id='default-input-address-en'])[2]", '20/02'); + + await page.click("(//input[@id='select-bankbook'])[3]"); + await page.click('id=select-bankbook_1'); + await page.fill("(//input[@aria-label='เลขบัญชี'])[2]", '2282020021'); + await page.fill("(//input[@aria-label='สาขาธนาคาร'])[2]", 'เชียงใหม่'); + await page.fill("(//input[@aria-label='ชื่อบัญชี'])[2]", 'Pongpon Kuntana'); + await page.click("(//input[@aria-label='ประเภทบัญชี'])[2]"); + await page.waitForTimeout(2000); + await page.click('id=select-bankbook_0'); + + await page.click('id=btn-info-basic-save'); + await page.click('id=btn-form-close'); + + // จำลองการสร้างสาขาเสมือน + + await page.click('id=create-sub-branch-btn-บริษัท จำลอง จำกัด'); + await page.click("(//button[@type='submit'])[2]"); + + await page.fill("(//input[@id='input-tax-no'])[2]", '2022826282642'); + await page.fill("(//input[@id='input-name'])[2]", 'สาขาเสมือน'); + await page.fill("(//input[@id='input-name-en'])[2]", 'VISUALBRANCH'); + await page.fill( + "(//input[@aria-label='เลขที่ใบอนุญาต'])[2]", + '1228222822822', + ); + await page.fill("(//input[@id='input-email'])[2]", 'visual@local.co.th'); + await page.fill("(//input[@id='input-telephone-no'])[2]", '022222002'); + await page.fill("(//input[@id='input-contact-name'])[2]", 'คุณอุล'); + await page.fill("(//input[@id='input-contact'])[2]", '0822622862'); + await page.fill("(//input[@id='input-line-id'])[2]", 'cmmsupport'); + + await page.fill("(//input[@id='default-input-address-no'])[2]", '40/04'); + await page.click("(//input[@id='default-select-province'])[2]"); + await page.click("//div[@role='option']"); + await page.click("(//input[@id='default-select-district'])[2]"); + await page.waitForTimeout(400); + await page.click("//div[@role='option']"); + await page.click("(//input[@id='default-select-sub-district'])[2]"); + await page.waitForTimeout(400); + await page.click("//div[@role='option']"); + await page.fill("(//input[@id='default-input-address-en'])[2]", '40/04'); + + await page.click("(//input[@id='select-bankbook'])[3]"); + await page.click('id=select-bankbook_2'); + await page.fill("(//input[@aria-label='เลขบัญชี'])[2]", '2822642201'); + await page.fill("(//input[@aria-label='สาขาธนาคาร'])[2]", 'ลำพูน'); + await page.fill("(//input[@aria-label='ชื่อบัญชี'])[2]", 'Pongpon Kuntana'); + await page.click("(//input[@aria-label='ประเภทบัญชี'])[2]"); + await page.waitForTimeout(2000); + await page.click('id=select-bankbook_0'); + + await page.click('id=btn-info-basic-save'); + await page.click('id=btn-form-close'); + await page.waitForTimeout(1000); + + // ลบสาขาและตรวจสอบการลบสาขา + await page.click('id=btn-kebab-action-สาขาจำลอง'); + await page.click('id=btn-kebab-delete-สาขาจำลอง'); + + // ยืนยันการลบ + await page.click('id=btn-ok-dialog'); + await page.waitForTimeout(1000); + + // ตรวจสอบการลบสาขา + const itemLocator = page.locator( + "//tr[contains(.,'1 สาขาจำลองTES0000112608462202810822262228คุณอาท20/02')]", + ); + + // ตรวจสอบว่าถูกลบออกจากระบบหรือไม่ + await expect(itemLocator).toBeHidden(); + + console.log('ตรวจสอบข้อมูลการลบสาขาสำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการลบสาขา', error); + throw error; + } + + // ลบสาขาเสมือนและตรวจสอบการลบสาขาเสมือน + + try { + await page.click('id=btn-kebab-action-สาขาเสมือน'); + await page.click('id=btn-kebab-delete-สาขาเสมือน'); + + // ยืนยันการลบ + await page.click('id=btn-ok-dialog'); + await page.waitForTimeout(1000); + + // ตรวจสอบการลบสาขาเสมือน + const itemLocator = page.locator( + "//tr[contains(.,'2 สาขาเสมือนTES0000220228262826420822622862คุณอุล40/04')]", + ); + + // ตรวจสอบว่าถูกลบออกจากระบบหรือไม่ + await expect(itemLocator).toBeHidden(); + + console.log('ตรวจสอบข้อมูลการลบสาขาเสมือนสำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการลบสาขาเสมือน', error); + isLoginSuccessful = false; + throw error; + } + + // // ลบสำนักงานใหญ่และตรวจสอบการลบสำนักงานใหญ่ + + // await page.click("//div[@id='tree-enter-บริษัท จำลอง จำกัด']/div[1]"); + // try { + // await page.click('id=btn-kebab-action-บริษัท จำลอง จำกัด'); + // await page.click('id=btn-kebab-delete-บริษัท จำลอง จำกัด'); + + // // ยืนยันการลบ + // await page.click('id=btn-ok-dialog'); + // await page.waitForTimeout(1000); + + // // ตรวจสอบการลบสำนักงานใหญ่ + // const itemLocator = page.locator( + // "//tr[contains(.,'9 บริษัท จำลอง จำกัดTES0000012608462202840866224228คุณอาท40/04')]", + // ); + + // // ตรวจสอบว่าถูกลบออกจากระบบหรือไม่ + // await expect(itemLocator).toBeHidden(); + + // console.log('ตรวจสอบข้อมูลการลบสำนักงานใหญ่สำเร็จ'); + // } catch (error) { + // console.error('เกิดข้อผิดพลาดในการลบสำนักงานใหญ่', error); + // throw error; + // } + + await page.waitForTimeout(2000); +}); diff --git a/tests/01-Manage/02-Admin-PersonnelManagement/JWS_PM_001_CreatePersonnel.spec.ts b/tests/01-Manage/02-Admin-PersonnelManagement/JWS_PM_001_CreatePersonnel.spec.ts new file mode 100644 index 00000000..0026f767 --- /dev/null +++ b/tests/01-Manage/02-Admin-PersonnelManagement/JWS_PM_001_CreatePersonnel.spec.ts @@ -0,0 +1,961 @@ +import { test, expect, Page } from '@playwright/test'; +import { strictEqual } from 'assert'; +import exp from 'constants'; +import { prependOnceListener } from 'process'; + +let page: Page; +let isLoginSuccessful = false; + +test.beforeAll(async ({ browser }) => { + page = await browser.newPage(); +}); + +test.afterAll(async () => { + if (page !== undefined) { + await page.close(); + } +}); + +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + // เข้าสู่หน้าบุคลากร + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-personnel'); + await page.click('id=sub-menu-personnel'); + + isLoginSuccessful = true; + console.log('ระบบทำการ Login'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการ Login', error); + isLoginSuccessful = false; + } +} + +test('Login', async () => { + await login(page); +}); + +test('Create Personnel พนักงาน ชาย', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click('id=btn-Add'); + + // กรอกข้อมูลพื้นฐานของบุคคลากร + await page.click("//i[@aria-hidden='false']"); + await page.waitForSelector('id=select-hq-id', { + state: 'visible', + }); + await page.click('id=select-hq-id'); + await page.click("//span[normalize-space(text())='CMO00000']"); + + await page.waitForSelector('id=select-br-id', { state: 'visible' }); + await page.click('id=select-br-id'); + await page.click('id=select-br-id_4'); + await page.fill('id=input-username', 'employeem'); + await page.click('id=select-user-type'); + await page.click('id=select-user-type_0'); + await page.click('id=select-user-role'); + await page.click('id=select-user-role_2'); + // await page.click("//div[@role='option']"); + + // กรอกชื่อข้อมูลพื้นฐาน + await page.fill('id=input-citizen-id', '1282262422820'); + await page.click( + "//label[@for='form-dialog-personnel-select-prefix-name']", + ); + await page.click('id=form-dialog-personnel-select-prefix-name_0'); + await page.fill('id=form-dialog-personnel-input-first-name', 'ธรรมรงด์'); + await page.fill('id=form-dialog-personnel-input-last-name', 'ดำรงธรรม'); + await page.fill('id=form-dialog-personnel-input-first-name-en', 'Thamrong'); + await page.fill( + 'id=form-dialog-personnel-input-last-name-en', + 'Dumrongtum', + ); + await page.fill('id=form-dialog-personnel-input-telephone', '08422622282'); + await page.fill( + 'id=form-dialog-personnel-input-email', + 'employeem@mail.com', + ); + + // เลือกเพศ + await page.click('id=form-dialog-personnel-select-gender'); + await page.click("//span[text()='ชาย']"); + + // เลือกวันเกิด + await page.click('id=form-dialog-personnel-input-birth-date'); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); + await page.click("//div[text()='2000']"); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[1]"); + await page.click("//div[text()='ม.ค.']"); + await page.click("//div[@id='2000-01-02']/div[1]"); + + // วันออกบัตร + await page.click( + "(//input[@id='form-dialog-personnel-input-citizen-issue'])[1]", + ); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); + await page.click("//div[text()='2010']"); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[1]"); + await page.click("//div[text()='ม.ค.']"); + await page.click("//div[@id='2010-01-02']/div[1]"); + + // กรอกที่อยู่ + await page.fill('id=drawer-info-personnel-input-address-no', '20/1'); + await page.click('id=drawer-info-personnel-select-province'); + await page.waitForSelector('id=drawer-info-personnel-select-province_6', { + state: 'visible', + }); + await page.click('id=drawer-info-personnel-select-province_6'); + await page.click('id=drawer-info-personnel-select-district'); + await page.waitForSelector('id=drawer-info-personnel-select-district_2', { + state: 'visible', + }); + await page.click('id=drawer-info-personnel-select-district_2'); + await page.click('id=drawer-info-personnel-select-sub-district'); + await page.waitForSelector( + 'id=drawer-info-personnel-select-sub-district_1', + { + state: 'visible', + }, + ); + await page.click('id=drawer-info-personnel-select-sub-district_1'); + + // กรอกที่อยู่ภาษาอังกฤษ + await page.fill('id=drawer-info-personnel-input-address-en', '20/01'); + + // กรอกข้อมูลการทำงาน + await page.fill('id=input-regis-no', '2822282222421'); + await page.click('id=input-start-date'); + await page.click("//div[text()='11']"); + await page.click('id=input-retire-date'); + await page.click("//div[text()='21']"); + + // กดปุ่มเพื่อสร้างบุคคลากร + await page.click('id=btn-info-basic-save'); + await page.waitForTimeout(2000); + + // ดึงข้อมูลจาก Locator และนำ .textContent() เพื่อดึงมาแต่ข้อความจริง ๆ + await page.waitForSelector; + const displayNameLocator = page.locator( + "//div[normalize-space(text())='ธรรมรงด์ ดำรงธรรม']", + ); + + const displayName = (await displayNameLocator.textContent())?.trim() || ''; + + // ตรวจสอบข้อมูลที่ดึงออกมา + expect(displayName).toBe('ธรรมรงด์ ดำรงธรรม'); + console.log(displayName); + + console.log('ตรวจสอบการสร้างพนักงานชายถูกต้อง'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForTimeout(2000); +}); + +test('Create Personnel พนักงาน หญิง', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click('id=btn-add'); + + // กรอกข้อมูลพื้นฐานของบุคคลากร + await page.click("//i[@aria-hidden='false']"); + await page.waitForSelector('id=select-hq-id', { + state: 'visible', + }); + await page.click('id=select-hq-id'); + await page.click("//span[normalize-space(text())='CMO00000']"); + + await page.waitForSelector('id=select-br-id', { state: 'visible' }); + await page.click('id=select-br-id'); + await page.click('id=select-br-id_4'); + await page.fill('id=input-username', 'employeew'); + await page.click('id=select-user-role'); + await page.click('id=select-user-role_6'); + // await page.click("//div[@role='option']"); + + // กรอกชื่อข้อมูลพื้นฐาน + await page.fill('id=input-citizen-id', '1282262422820'); + await page.click( + "//label[@for='form-dialog-personnel-select-prefix-name']", + ); + await page.click('id=form-dialog-personnel-select-prefix-name_0'); + await page.fill('id=form-dialog-personnel-input-first-name', 'อารยา'); + await page.fill('id=form-dialog-personnel-input-last-name', 'มาลา'); + await page.fill('id=form-dialog-personnel-input-first-name-en', 'Araya'); + await page.fill('id=form-dialog-personnel-input-last-name-en', 'Mala'); + await page.fill('id=form-dialog-personnel-input-telephone', '08422622282'); + await page.fill( + 'id=form-dialog-personnel-input-email', + 'employeew@mail.com', + ); + + // เลือกเพศ + await page.click('id=form-dialog-personnel-select-gender'); + await page.click("//span[text()='หญิง']"); + + // เลือกวันเกิด + await page.click('id=form-dialog-personnel-input-birth-date'); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); + await page.click("//div[text()='2001']"); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[1]"); + await page.click("//div[text()='ม.ค.']"); + await page.click("//div[@id='2001-01-02']/div[1]"); + + // วันออกบัตร + await page.click( + "(//input[@id='form-dialog-personnel-input-citizen-issue'])[1]", + ); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); + await page.click("//div[text()='2011']"); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[1]"); + await page.click("//div[text()='ม.ค.']"); + await page.click("//div[@id='2011-01-02']/div[1]"); + + // กรอกที่อยู่ + await page.fill('id=drawer-info-personnel-input-address-no', '20/1'); + await page.click('id=drawer-info-personnel-select-province'); + await page.waitForSelector('id=drawer-info-personnel-select-province_6', { + state: 'visible', + }); + await page.click('id=drawer-info-personnel-select-province_6'); + await page.click('id=drawer-info-personnel-select-district'); + await page.waitForSelector('id=drawer-info-personnel-select-district_2', { + state: 'visible', + }); + await page.click('id=drawer-info-personnel-select-district_2'); + await page.click('id=drawer-info-personnel-select-sub-district'); + await page.waitForSelector( + 'id=drawer-info-personnel-select-sub-district_1', + { + state: 'visible', + }, + ); + await page.click('id=drawer-info-personnel-select-sub-district_1'); + + // กรอกที่อยู่ภาษาอังกฤษ + await page.fill('id=drawer-info-personnel-input-address-en', '20/01'); + + // กรอกข้อมูลการทำงาน + await page.fill('id=input-regis-no', '2822282222421'); + await page.click('id=input-start-date'); + await page.click("//div[text()='11']"); + await page.click('id=input-retire-date'); + await page.click("//div[text()='21']"); + + // กดปุ่มเพื่อสร้างบุคคลากร + await page.click('id=btn-info-basic-save'); + await page.waitForTimeout(2000); + + // ดึงข้อมูลจาก Locator และนำ .textContent() เพื่อดึงมาแต่ข้อความจริง ๆ + const displayNameLocator = page.locator( + "//div[normalize-space(text())='อารยา มาลา']", + ); + const displayName = (await displayNameLocator.textContent())?.trim(); + + // ตรวจสอบข้อมูลที่ดึงออกมา + expect(displayName).toBe('อารยา มาลา'); + + console.log('ตรวจสอบการสร้างพนักงานหญิงถูกต้อง'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } +}); + +test('Create Personnel พนักงานส่งเอกสาร หญิง', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click("(//div[@role='tab'])[3]"); + await page.click('id=btn-add'); + + // กรอกข้อมูลพื้นฐานของบุคคลากร + await page.click("//i[@aria-hidden='false']"); + await page.waitForSelector('id=select-hq-id', { + state: 'visible', + }); + await page.click('id=select-hq-id'); + await page.click("//span[normalize-space(text())='CMO00000']"); + + await page.waitForSelector('id=select-br-id', { state: 'visible' }); + await page.click('id=select-br-id'); + await page.click('id=select-br-id_4'); + await page.fill('id=input-username', 'courierw'); + await page.click('id=select-user-role'); + await page.click('id=select-user-role_6'); + // await page.click("//div[@role='option']"); + + // กรอกชื่อข้อมูลพื้นฐาน + await page.fill('id=input-citizen-id', '1282262422820'); + await page.click( + "//label[@for='form-dialog-personnel-select-prefix-name']", + ); + await page.click('id=form-dialog-personnel-select-prefix-name_0'); + await page.fill('id=form-dialog-personnel-input-first-name', 'มาตา'); + await page.fill('id=form-dialog-personnel-input-last-name', 'ลดา'); + await page.fill('id=form-dialog-personnel-input-first-name-en', 'Mata'); + await page.fill('id=form-dialog-personnel-input-last-name-en', 'Lada'); + await page.fill('id=form-dialog-personnel-input-telephone', '08422622282'); + await page.fill( + 'id=form-dialog-personnel-input-email', + 'courierw@mail.com', + ); + + // เลือกเพศ + await page.click('id=form-dialog-personnel-select-gender'); + await page.click("//span[text()='หญิง']"); + + // เลือกวันเกิด + await page.click('id=form-dialog-personnel-input-birth-date'); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); + await page.click("//div[text()='2002']"); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[1]"); + await page.click("//div[text()='ม.ค.']"); + await page.click("//div[@id='2002-01-02']/div[1]"); + + // วันออกบัตร + await page.click( + "(//input[@id='form-dialog-personnel-input-citizen-issue'])[1]", + ); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); + await page.click("//div[text()='2012']"); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[1]"); + await page.click("//div[text()='ม.ค.']"); + await page.click("//div[@id='2012-01-02']/div[1]"); + + // กรอกที่อยู่ + await page.fill('id=drawer-info-personnel-input-address-no', '20/1'); + await page.click('id=drawer-info-personnel-select-province'); + await page.waitForSelector('id=drawer-info-personnel-select-province_6', { + state: 'visible', + }); + await page.click('id=drawer-info-personnel-select-province_6'); + await page.click('id=drawer-info-personnel-select-district'); + await page.waitForSelector('id=drawer-info-personnel-select-district_2', { + state: 'visible', + }); + await page.click('id=drawer-info-personnel-select-district_2'); + await page.click('id=drawer-info-personnel-select-sub-district'); + await page.waitForSelector( + 'id=drawer-info-personnel-select-sub-district_1', + { + state: 'visible', + }, + ); + await page.click('id=drawer-info-personnel-select-sub-district_1'); + + // กรอกที่อยู่ภาษาอังกฤษ + await page.fill('id=drawer-info-personnel-input-address-en', '20/01'); + + // กรอกข้อมูลการทำงาน + await page.fill('id=input-regis-no', '2822282222421'); + await page.click('id=input-start-date'); + await page.click("//div[text()='11']"); + await page.click('id=input-retire-date'); + await page.click("//div[text()='21']"); + + // กดปุ่มเพื่อสร้างบุคคลากร + await page.click('id=btn-info-basic-save'); + await page.waitForTimeout(2000); + + // ดึงข้อมูลจาก Locator และนำ .textContent() เพื่อดึงมาแต่ข้อความจริง ๆ + const displayNameLocator = page.locator( + "//div[normalize-space(text())='มาตา ลดา']", + ); + const displayName = (await displayNameLocator.textContent())?.trim(); + + // ตรวจสอบข้อมูลที่ดึงออกมา + expect(displayName).toBe('มาตา ลดา'); + + console.log('ตรวจสอบการสร้างพนักงานส่งเอกสารหญิงถูกต้อง'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } +}); + +test('Create Personnel พนักงานส่งเอกสาร ชาย', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click('id=btn-add'); + + // กรอกข้อมูลพื้นฐานของบุคคลากร + await page.click("//i[@aria-hidden='false']"); + await page.waitForSelector('id=select-hq-id', { + state: 'visible', + }); + await page.click('id=select-hq-id'); + await page.click("//span[normalize-space(text())='CMO00000']"); + + await page.waitForSelector('id=select-br-id', { state: 'visible' }); + await page.click('id=select-br-id'); + await page.click('id=select-br-id_4'); + await page.fill('id=input-username', 'courierm'); + await page.click('id=select-user-role'); + await page.click('id=select-user-role_6'); + // await page.click("//div[@role='option']"); + + // กรอกชื่อข้อมูลพื้นฐาน + await page.fill('id=input-citizen-id', '1282262422820'); + await page.click( + "//label[@for='form-dialog-personnel-select-prefix-name']", + ); + await page.click('id=form-dialog-personnel-select-prefix-name_0'); + await page.fill('id=form-dialog-personnel-input-first-name', 'ธันวา'); + await page.fill('id=form-dialog-personnel-input-last-name', 'มานา'); + await page.fill('id=form-dialog-personnel-input-first-name-en', 'Thanwa'); + await page.fill('id=form-dialog-personnel-input-last-name-en', 'Mana'); + await page.fill('id=form-dialog-personnel-input-telephone', '08422622282'); + await page.fill( + 'id=form-dialog-personnel-input-email', + 'courierm@mail.com', + ); + + // เลือกเพศ + await page.click('id=form-dialog-personnel-select-gender'); + await page.click("//span[text()='ชาย']"); + + // เลือกวันเกิด + await page.click('id=form-dialog-personnel-input-birth-date'); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); + await page.click("//div[text()='2003']"); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[1]"); + await page.click("//div[text()='ม.ค.']"); + await page.click("//div[@id='2003-01-02']/div[1]"); + + // วันออกบัตร + await page.click( + "(//input[@id='form-dialog-personnel-input-citizen-issue'])[1]", + ); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); + await page.click("//div[text()='2013']"); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[1]"); + await page.click("//div[text()='ม.ค.']"); + await page.click("//div[@id='2013-01-02']/div[1]"); + + // กรอกที่อยู่ + await page.fill('id=drawer-info-personnel-input-address-no', '20/1'); + await page.click('id=drawer-info-personnel-select-province'); + await page.waitForSelector('id=drawer-info-personnel-select-province_6', { + state: 'visible', + }); + await page.click('id=drawer-info-personnel-select-province_6'); + await page.click('id=drawer-info-personnel-select-district'); + await page.waitForSelector('id=drawer-info-personnel-select-district_2', { + state: 'visible', + }); + await page.click('id=drawer-info-personnel-select-district_2'); + await page.click('id=drawer-info-personnel-select-sub-district'); + await page.waitForSelector( + 'id=drawer-info-personnel-select-sub-district_1', + { + state: 'visible', + }, + ); + await page.click('id=drawer-info-personnel-select-sub-district_1'); + + // กรอกที่อยู่ภาษาอังกฤษ + await page.fill('id=drawer-info-personnel-input-address-en', '20/01'); + + // กรอกข้อมูลการทำงาน + await page.fill('id=input-regis-no', '2822282222421'); + await page.click('id=input-start-date'); + await page.click("//div[text()='11']"); + await page.click('id=input-retire-date'); + await page.click("//div[text()='21']"); + + // กดปุ่มเพื่อสร้างบุคคลากร + await page.click('id=btn-info-basic-save'); + await page.waitForTimeout(2000); + + // ดึงข้อมูลจาก Locator และนำ .textContent() เพื่อดึงมาแต่ข้อความจริง ๆ + const displayNameLocator = page.locator( + "//div[normalize-space(text())='ธันวา มานา']", + ); + const displayName = (await displayNameLocator.textContent())?.trim(); + + // ตรวจสอบข้อมูลที่ดึงออกมา + expect(displayName).toBe('ธันวา มานา'); + + console.log('ตรวจสอบการสร้างพนักงานส่งเอกสารชายถูกต้อง'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } +}); + +test('Create Personnel ตัวแทน ชาย', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click("(//div[@role='tab'])[4]"); + await page.click('id=btn-add'); + + // กรอกข้อมูลพื้นฐานของบุคคลากร + await page.click("//i[@aria-hidden='false']"); + await page.waitForSelector('id=select-hq-id', { + state: 'visible', + }); + await page.click('id=select-hq-id'); + await page.click("//span[normalize-space(text())='CMO00000']"); + + await page.waitForSelector('id=select-br-id', { state: 'visible' }); + await page.click('id=select-br-id'); + await page.click('id=select-br-id_4'); + await page.fill('id=input-username', 'delegatem'); + await page.click('id=select-user-role'); + await page.click('id=select-user-role_8'); + // await page.click("//div[@role='option']"); + + // กรอกชื่อข้อมูลพื้นฐาน + await page.fill('id=input-citizen-id', '1282262422820'); + await page.click( + "//label[@for='form-dialog-personnel-select-prefix-name']", + ); + await page.click('id=form-dialog-personnel-select-prefix-name_0'); + await page.fill('id=form-dialog-personnel-input-first-name', 'อาคม'); + await page.fill('id=form-dialog-personnel-input-last-name', 'พลัง'); + await page.fill('id=form-dialog-personnel-input-first-name-en', 'Akom'); + await page.fill('id=form-dialog-personnel-input-last-name-en', 'Palang'); + await page.fill('id=form-dialog-personnel-input-telephone', '08422622282'); + await page.fill( + 'id=form-dialog-personnel-input-email', + 'delegatem@mail.com', + ); + + // เลือกเพศ + await page.click('id=form-dialog-personnel-select-gender'); + await page.click("//span[text()='ชาย']"); + + // เลือกวันเกิด + await page.click('id=form-dialog-personnel-input-birth-date'); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); + await page.click("//div[text()='2004']"); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[1]"); + await page.click("//div[text()='ม.ค.']"); + await page.click("//div[@id='2004-01-02']/div[1]"); + + // วันออกบัตร + await page.click( + "(//input[@id='form-dialog-personnel-input-citizen-issue'])[1]", + ); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); + await page.click("//div[text()='2014']"); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[1]"); + await page.click("//div[text()='ม.ค.']"); + await page.click("//div[@id='2014-01-02']/div[1]"); + + // กรอกที่อยู่ + await page.fill('id=drawer-info-personnel-input-address-no', '20/1'); + await page.click('id=drawer-info-personnel-select-province'); + await page.waitForSelector('id=drawer-info-personnel-select-province_6', { + state: 'visible', + }); + await page.click('id=drawer-info-personnel-select-province_6'); + await page.click('id=drawer-info-personnel-select-district'); + await page.waitForSelector('id=drawer-info-personnel-select-district_2', { + state: 'visible', + }); + await page.click('id=drawer-info-personnel-select-district_2'); + await page.click('id=drawer-info-personnel-select-sub-district'); + await page.waitForSelector( + 'id=drawer-info-personnel-select-sub-district_1', + { + state: 'visible', + }, + ); + await page.click('id=drawer-info-personnel-select-sub-district_1'); + + // กรอกที่อยู่ภาษาอังกฤษ + await page.fill('id=drawer-info-personnel-input-address-en', '20/01'); + + // กรอกข้อมูลการทำงาน + await page.fill('id=input-discount-condition', 'ทดสอบข้อมูลการทำงาน'); + + // กดปุ่มเพื่อสร้างบุคคลากร + await page.click('id=btn-info-basic-save'); + await page.waitForTimeout(2000); + + // ดึงข้อมูลจาก Locator และนำ .textContent() เพื่อดึงมาแต่ข้อความจริง ๆ + const displayNameLocator = page.locator( + "//div[normalize-space(text())='อาคม พลัง']", + ); + const displayName = (await displayNameLocator.textContent())?.trim(); + + // ตรวจสอบข้อมูลที่ดึงออกมา + expect(displayName).toBe('อาคม พลัง'); + + console.log('ตรวจสอบการสร้างตัวแทนชายถูกต้อง'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } +}); + +test('Create Personnel ตัวแทน หญิง', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click('id=btn-add'); + + // กรอกข้อมูลพื้นฐานของบุคคลากร + await page.click("//i[@aria-hidden='false']"); + await page.waitForSelector('id=select-hq-id', { + state: 'visible', + }); + await page.click('id=select-hq-id'); + await page.click("//span[normalize-space(text())='CMO00000']"); + + await page.waitForSelector('id=select-br-id', { state: 'visible' }); + await page.click('id=select-br-id'); + await page.click('id=select-br-id_4'); + await page.fill('id=input-username', 'delegatew'); + await page.click('id=select-user-role'); + await page.click('id=select-user-role_10'); + // await page.click("//div[@role='option']"); + + // กรอกชื่อข้อมูลพื้นฐาน + await page.fill('id=input-citizen-id', '1282262422820'); + await page.click( + "//label[@for='form-dialog-personnel-select-prefix-name']", + ); + await page.click('id=form-dialog-personnel-select-prefix-name_0'); + await page.fill('id=form-dialog-personnel-input-first-name', 'สโรชา'); + await page.fill('id=form-dialog-personnel-input-last-name', 'มีนา'); + await page.fill('id=form-dialog-personnel-input-first-name-en', 'Sarocha'); + await page.fill('id=form-dialog-personnel-input-last-name-en', 'Mena'); + await page.fill('id=form-dialog-personnel-input-telephone', '08422622282'); + await page.fill( + 'id=form-dialog-personnel-input-email', + 'delegatew@mail.com', + ); + + // เลือกเพศ + await page.click('id=form-dialog-personnel-select-gender'); + await page.click("//span[text()='หญิง']"); + + // เลือกวันเกิด + await page.click('id=form-dialog-personnel-input-birth-date'); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); + await page.click("//div[text()='2005']"); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[1]"); + await page.click("//div[text()='ม.ค.']"); + await page.click("//div[@id='2005-01-02']/div[1]"); + + // วันออกบัตร + await page.click( + "(//input[@id='form-dialog-personnel-input-citizen-issue'])[1]", + ); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); + await page.click("//div[text()='2015']"); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[1]"); + await page.click("//div[text()='ม.ค.']"); + await page.click("//div[@id='2015-01-02']/div[1]"); + + // กรอกที่อยู่ + await page.fill('id=drawer-info-personnel-input-address-no', '20/1'); + await page.click('id=drawer-info-personnel-select-province'); + await page.waitForSelector('id=drawer-info-personnel-select-province_6', { + state: 'visible', + }); + await page.click('id=drawer-info-personnel-select-province_6'); + await page.click('id=drawer-info-personnel-select-district'); + await page.waitForSelector('id=drawer-info-personnel-select-district_2', { + state: 'visible', + }); + await page.click('id=drawer-info-personnel-select-district_2'); + await page.click('id=drawer-info-personnel-select-sub-district'); + await page.waitForSelector( + 'id=drawer-info-personnel-select-sub-district_1', + { + state: 'visible', + }, + ); + await page.click('id=drawer-info-personnel-select-sub-district_1'); + + // กรอกที่อยู่ภาษาอังกฤษ + await page.fill('id=drawer-info-personnel-input-address-en', '20/01'); + + // กรอกข้อมูลการทำงาน + await page.fill('id=input-discount-condition', 'ทดสอบข้อมูลการทำงาน'); + + // กดปุ่มเพื่อสร้างบุคคลากร + await page.click('id=btn-info-basic-save'); + await page.waitForTimeout(2000); + + // ดึงข้อมูลจาก Locator และนำ .textContent() เพื่อดึงมาแต่ข้อความจริง ๆ + const displayNameLocator = page.locator( + "//div[normalize-space(text())='สโรชา มีนา']", + ); + const displayName = (await displayNameLocator.textContent())?.trim(); + + // ตรวจสอบข้อมูลที่ดึงออกมา + expect(displayName).toBe('สโรชา มีนา'); + + console.log('ตรวจสอบการสร้างตัวแทนหญิงถูกต้อง'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } +}); + +test('Create Personnel เอเจนซี่ หญิง', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click("(//div[@role='tab'])[5]"); + await page.click('id=btn-add'); + + // กรอกข้อมูลพื้นฐานของบุคคลากร + await page.click("//i[@aria-hidden='false']"); + await page.waitForSelector('id=select-hq-id', { + state: 'visible', + }); + await page.click('id=select-hq-id'); + await page.click("//span[normalize-space(text())='CMO00000']"); + + await page.waitForSelector('id=select-br-id', { state: 'visible' }); + await page.click('id=select-br-id'); + await page.click('id=select-br-id_4'); + await page.fill('id=input-username', 'agencyw'); + await page.click('id=select-user-role'); + await page.click('id=select-user-role_2'); + // await page.click("//div[@role='option']"); + + // กรอกชื่อข้อมูลพื้นฐาน + await page.fill('id=input-citizen-id', '1282262422820'); + await page.click( + "//label[@for='form-dialog-personnel-select-prefix-name']", + ); + await page.click('id=form-dialog-personnel-select-prefix-name_0'); + await page.fill('id=form-dialog-personnel-input-first-name', 'ธิดา'); + await page.fill('id=form-dialog-personnel-input-last-name', 'งามตา'); + await page.fill('id=form-dialog-personnel-input-first-name-en', 'Thida'); + await page.fill('id=form-dialog-personnel-input-last-name-en', 'Yamta'); + await page.fill('id=form-dialog-personnel-input-telephone', '08422622282'); + await page.fill('id=form-dialog-personnel-input-email', 'agencyw@mail.com'); + + // เลือกเพศ + await page.click('id=form-dialog-personnel-select-gender'); + await page.click("//span[text()='หญิง']"); + + // เลือกวันเกิด + await page.click('id=form-dialog-personnel-input-birth-date'); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); + await page.click("//div[text()='2006']"); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[1]"); + await page.click("//div[text()='ม.ค.']"); + await page.click("//div[@id='2006-01-02']/div[1]"); + + // วันออกบัตร + await page.click( + "(//input[@id='form-dialog-personnel-input-citizen-issue'])[1]", + ); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); + await page.click("//div[text()='2016']"); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[1]"); + await page.click("//div[text()='ม.ค.']"); + await page.click("//div[@id='2016-01-02']/div[1]"); + + // กรอกที่อยู่ + await page.fill('id=drawer-info-personnel-input-address-no', '20/1'); + await page.click('id=drawer-info-personnel-select-province'); + await page.waitForSelector('id=drawer-info-personnel-select-province_6', { + state: 'visible', + }); + await page.click('id=drawer-info-personnel-select-province_6'); + await page.click('id=drawer-info-personnel-select-district'); + await page.waitForSelector('id=drawer-info-personnel-select-district_2', { + state: 'visible', + }); + await page.click('id=drawer-info-personnel-select-district_2'); + await page.click('id=drawer-info-personnel-select-sub-district'); + await page.waitForSelector( + 'id=drawer-info-personnel-select-sub-district_1', + { + state: 'visible', + }, + ); + await page.click('id=drawer-info-personnel-select-sub-district_1'); + + // กรอกที่อยู่ภาษาอังกฤษ + await page.fill('id=drawer-info-personnel-input-address-en', '20/01'); + + // กรอกข้อมูลการทำงาน + await page.click('id=input-source-nationality'); + await page.click("(//div[@role='option'])[1]"); + await page.click('id=input-import-nationality'); + await page.click("(//div[@role='option'])[1]"); + await page.click('id=select-trainig-place'); + await page.click("//span[text()='สถานที่อบรมแรงงานเมียนมา-แม่สอด จ.ตาก']"); + await page.fill('id=input-checkpoint', 'แม่สอด'); + await page.fill('id=input-checkpoint-en', 'Maesod'); + + // กดปุ่มเพื่อสร้างบุคคลากร + await page.click('id=btn-info-basic-save'); + await page.waitForTimeout(2000); + + // ดึงข้อมูลจาก Locator และนำ .textContent() เพื่อดึงมาแต่ข้อความจริง ๆ + const displayNameLocator = page.locator( + "//div[normalize-space(text())='ธิดา งามตา']", + ); + const displayName = (await displayNameLocator.textContent())?.trim(); + + // ตรวจสอบข้อมูลที่ดึงออกมา + expect(displayName).toBe('ธิดา งามตา'); + + console.log('ตรวจสอบการสร้างเอเจนซี่หญิงถูกต้อง'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } +}); + +test('Create Personnel เอเจนซี่ ชาย', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click('id=btn-add'); + + // กรอกข้อมูลพื้นฐานของบุคคลากร + await page.click("//i[@aria-hidden='false']"); + await page.waitForSelector('id=select-hq-id', { + state: 'visible', + }); + await page.click('id=select-hq-id'); + await page.click("//span[normalize-space(text())='CMO00000']"); + + await page.waitForSelector('id=select-br-id', { state: 'visible' }); + await page.click('id=select-br-id'); + await page.click('id=select-br-id_4'); + await page.fill('id=input-username', 'agencym'); + await page.click('id=select-user-role'); + await page.click('id=select-user-role_8'); + // await page.click("//div[@role='option']"); + + // กรอกชื่อข้อมูลพื้นฐาน + await page.fill('id=input-citizen-id', '1282262422820'); + await page.click( + "//label[@for='form-dialog-personnel-select-prefix-name']", + ); + await page.click('id=form-dialog-personnel-select-prefix-name_0'); + await page.fill('id=form-dialog-personnel-input-first-name', 'อันดา'); + await page.fill('id=form-dialog-personnel-input-last-name', 'ธรรมา'); + await page.fill('id=form-dialog-personnel-input-first-name-en', 'Aunda'); + await page.fill('id=form-dialog-personnel-input-last-name-en', 'Thamma'); + await page.fill('id=form-dialog-personnel-input-telephone', '08422622282'); + await page.fill('id=form-dialog-personnel-input-email', 'agencym@mail.com'); + + // เลือกเพศ + await page.click('id=form-dialog-personnel-select-gender'); + await page.click("//span[text()='ชาย']"); + + // เลือกวันเกิด + await page.click('id=form-dialog-personnel-input-birth-date'); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); + await page.click("//div[text()='2007']"); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[1]"); + await page.click("//div[text()='ม.ค.']"); + await page.click("//div[@id='2007-01-02']/div[1]"); + + // วันออกบัตร + await page.click( + "(//input[@id='form-dialog-personnel-input-citizen-issue'])[1]", + ); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); + await page.click("//div[text()='2017']"); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[1]"); + await page.click("//div[text()='ม.ค.']"); + await page.click("//div[@id='2017-01-02']/div[1]"); + + // กรอกที่อยู่ + await page.fill('id=drawer-info-personnel-input-address-no', '20/1'); + await page.click('id=drawer-info-personnel-select-province'); + await page.waitForSelector('id=drawer-info-personnel-select-province_6', { + state: 'visible', + }); + await page.click('id=drawer-info-personnel-select-province_6'); + await page.click('id=drawer-info-personnel-select-district'); + await page.waitForSelector('id=drawer-info-personnel-select-district_2', { + state: 'visible', + }); + await page.click('id=drawer-info-personnel-select-district_2'); + await page.click('id=drawer-info-personnel-select-sub-district'); + await page.waitForSelector( + 'id=drawer-info-personnel-select-sub-district_1', + { + state: 'visible', + }, + ); + await page.click('id=drawer-info-personnel-select-sub-district_1'); + + // กรอกที่อยู่ภาษาอังกฤษ + await page.fill('id=drawer-info-personnel-input-address-en', '20/01'); + + // กรอกข้อมูลการทำงาน + await page.click('id=input-source-nationality'); + await page.click("(//div[@role='option'])[1]"); + await page.click('id=input-import-nationality'); + await page.click("(//div[@role='option'])[1]"); + await page.click('id=select-trainig-place'); + await page.click("//span[text()='สถานที่อบรมแรงงานเมียนมา-แม่สอด จ.ตาก']"); + await page.fill('id=input-checkpoint', 'แม่สอด'); + await page.fill('id=input-checkpoint-en', 'Maesod'); + + // กดปุ่มเพื่อสร้างบุคคลากร + await page.click('id=btn-info-basic-save'); + await page.waitForTimeout(2000); + + // ดึงข้อมูลจาก Locator และนำ .textContent() เพื่อดึงมาแต่ข้อความจริง ๆ + const displayNameLocator = page.locator( + "//div[normalize-space(text())='อันดา ธรรมา']", + ); + const displayName = (await displayNameLocator.textContent())?.trim(); + + // ตรวจสอบข้อมูลที่ดึงออกมา + expect(displayName).toBe('อันดา ธรรมา'); + + console.log('ตรวจสอบการสร้างเอเจนซี่ชายถูกต้อง'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } +}); diff --git a/tests/01-Manage/02-Admin-PersonnelManagement/JWS_PM_002-1_CreatePersonnelFailEn.spec.ts b/tests/01-Manage/02-Admin-PersonnelManagement/JWS_PM_002-1_CreatePersonnelFailEn.spec.ts new file mode 100644 index 00000000..c2115fcd --- /dev/null +++ b/tests/01-Manage/02-Admin-PersonnelManagement/JWS_PM_002-1_CreatePersonnelFailEn.spec.ts @@ -0,0 +1,220 @@ +import { test, expect, Page } from '@playwright/test'; +import { strictEqual } from 'assert'; +import exp from 'constants'; +import { getSystemErrorMap } from 'util'; + +let page: Page; +let isLoginSuccessful = false; + +test.beforeAll(async ({ browser }) => { + page = await browser.newPage(); +}); + +test.afterAll(async () => { + if (page !== undefined) { + await page.close(); + } +}); + +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + // เข้าสู่หน้าบุคลากร + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-personnel'); + await page.click('id=sub-menu-personnel'); + await page.waitForTimeout(2000); + + isLoginSuccessful = true; + console.log('ระบบทำการ Login'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการ Login', error); + isLoginSuccessful = false; + } +} + +test('Login', async () => { + await login(page); +}); + +test('Create Personnel - ในกรณีที่ไม่กรอกข้อมูล', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + // เปลี่ยนภาษา + await page.click('id=btn-change-language'); + await page.waitForSelector('id=btn-change-language-eng'); + await page.click('id=btn-change-language-eng'); + + await page.click('id=btn-add'); + + await page.click('id=btn-info-basic-save'); + await page.waitForTimeout(2000); + + const expectedErrors = [ + { + locator: "(//div[@role='alert'])[1]", + message: 'This field is required.', + }, + { + locator: "(//div[@role='alert'])[1]", + message: 'Please select User Type.', + }, + { + locator: "(//div[@role='alert'])[1]", + message: 'Please select User Role.', + }, + { + locator: "(//div[@role='alert'])[1]", + message: 'This field is required.', + }, + { + locator: "(//div[@role='alert'])[1]", + message: 'This field is required.', + }, + { + locator: "(//div[@role='alert'])[1]", + message: 'This field is required.', + }, + { + locator: "(//div[@role='alert'])[1]", + message: 'This field is required.', + }, + { + locator: "(//div[@role='alert'])[1]", + message: 'This field is required.', + }, + { + locator: "(//div[@role='alert'])[1]", + message: 'Please select Birth Date.', + }, + { + locator: "(//div[@role='alert'])[1]", + message: 'Please select Citizen Issue.', + }, + { + locator: "(//div[@role='alert'])[1]", + message: 'This field is required.', + }, + { + locator: "(//div[@role='alert'])[1]", + message: 'Please select Province.', + }, + { + locator: "(//div[@role='alert'])[1]", + message: 'Please select District.', + }, + { + locator: "(//div[@role='alert'])[1]", + message: 'Please select Sub-district.', + }, + { + locator: "(//div[@role='alert'])[1]", + message: 'This field is required.', + }, + ]; + + for (const error of expectedErrors) { + const locator = page.locator(error.locator); + await expect(locator).toHaveText(error.message); + } + + await page.waitForTimeout(2000); + await page.click('id=btn-form-close'); + console.log('การตรวจสอบการทำงานถูกต้อง'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } +}); + +test('Create Personnel - ในกรณีที่กรอกชื่อผู้ใช้งานที่ไม่ตรงกับตัวอักษรที่กำหนด', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click('id=btn-add'); + + // กรอกชื่อผู้ใช้งาน + await page.fill('id=input-username', 'ทดสอบ'); + + const usernameError = page.locator("(//div[@role='alert'])[1]"); + + await expect(usernameError).toHaveText( + 'Only _ letters and number are allowed', + ); + + await page.waitForTimeout(2000); + await page.click('id=btn-form-close'); + console.log('การตรวจสอบการทำงานถูกต้อง'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } +}); + +test('Create Personnel - ในกรณีที่กรอกชื่อและนามสกุลภาษาอังกฤษไม่ตรงตามรูปแบบ', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click('id=btn-add'); + + // กรอกชื่อผู้ใช้งาน + await page.fill('id=form-dialog-personnel-input-first-name-en', 'ทดสอบ'); + await page.fill('id=form-dialog-personnel-input-last-name-en', 'ทดสอบ'); + + const firstNameEnError = page.locator("(//div[@role='alert'])[1]"); + const lastNameEnError = page.locator("(//div[@role='alert'])[2]"); + + await expect(firstNameEnError).toHaveText('Only letters are allowed'); + await expect(lastNameEnError).toHaveText('Only letters are allowed'); + + await page.waitForTimeout(2000); + await page.click('id=btn-form-close'); + console.log('การตรวจสอบการทำงานถูกต้อง'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } +}); + +test('Create Personnel - ในกรณีที่กรอกอีเมลไม่ตรงรูปแบบ', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click('id=btn-add'); + + // กรอกชื่อผู้ใช้งาน + await page.fill('id=form-dialog-personnel-input-email', 'ทดสอบ'); + + const firstNameEnError = page.locator("(//div[@role='alert'])[1]"); + + await expect(firstNameEnError).toHaveText('Invalid value.'); + + await page.waitForTimeout(2000); + await page.click('id=btn-form-close'); + console.log('การตรวจสอบการทำงานถูกต้อง'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } +}); diff --git a/tests/01-Manage/02-Admin-PersonnelManagement/JWS_PM_002_CreatePersonnelFail.spec.ts b/tests/01-Manage/02-Admin-PersonnelManagement/JWS_PM_002_CreatePersonnelFail.spec.ts new file mode 100644 index 00000000..32911f93 --- /dev/null +++ b/tests/01-Manage/02-Admin-PersonnelManagement/JWS_PM_002_CreatePersonnelFail.spec.ts @@ -0,0 +1,217 @@ +import { test, expect, Page } from '@playwright/test'; +import { strictEqual } from 'assert'; +import exp from 'constants'; + +let page: Page; +let isLoginSuccessful = false; + +test.beforeAll(async ({ browser }) => { + page = await browser.newPage(); +}); + +test.afterAll(async () => { + if (page !== undefined) { + await page.close(); + } +}); + +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + // เข้าสู่หน้าบุคลากร + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-personnel'); + await page.click('id=sub-menu-personnel'); + + isLoginSuccessful = true; + console.log('ระบบทำการ Login'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการ Login'); + isLoginSuccessful = false; + } +} + +test('Login', async () => { + await login(page); +}); + +test('Create Personnel - ในกรณีที่ไม่กรอกข้อมูล', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click('id=btn-add'); + + await page.click('id=btn-info-basic-save'); + await page.waitForTimeout(2000); + + const expectedErrors = [ + { + locator: "(//div[@role='alert'])[1]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + { + locator: "(//div[@role='alert'])[2]", + message: 'โปรดเลือกประเภทผู้ใช้งาน', + }, + { + locator: "(//div[@role='alert'])[3]", + message: 'โปรดเลือกสิทธิ์ผู้ใช้งาน', + }, + { + locator: "(//div[@role='alert'])[4]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + { + locator: "(//div[@role='alert'])[5]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + { + locator: "(//div[@role='alert'])[6]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + { + locator: "(//div[@role='alert'])[7]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + { + locator: "(//div[@role='alert'])[8]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + { + locator: "(//div[@role='alert'])[9]", + message: 'โปรดเลือกวันเดือนปีเกิด', + }, + { + locator: "(//div[@role='alert'])[10]", + message: 'โปรดเลือกวันที่ออกบัตร', + }, + { + locator: "(//div[@role='alert'])[11]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + { + locator: "(//div[@role='alert'])[12]", + message: 'โปรดเลือกจังหวัด', + }, + { + locator: "(//div[@role='alert'])[13]", + message: 'โปรดเลือกเขต/อำเภอ', + }, + { + locator: "(//div[@role='alert'])[14]", + message: 'โปรดเลือกแขวง/ตำบล', + }, + { + locator: "(//div[@role='alert'])[15]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + ]; + + for (const error of expectedErrors) { + const locator = page.locator(error.locator); + await expect(locator).toHaveText(error.message); + } + + await page.waitForTimeout(2000); + await page.click('id=btn-form-close'); + console.log('การตรวจสอบการทำงานถูกต้อง'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } +}); + +test('Create Personnel - ในกรณีที่กรอกชื่อผู้ใช้งานที่ไม่ตรงกับตัวอักษรที่กำหนด', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click('id=btn-add'); + + // กรอกชื่อผู้ใช้งาน + await page.fill('id=input-username', 'ทดสอบ'); + + const usernameError = page.locator("(//div[@role='alert'])[1]"); + + await expect(usernameError).toHaveText( + 'โปรดใช้เฉพาะ _ ตัวอักษรภาษาอังกฤษและตัวเลขเท่านั้น', + ); + + await page.waitForTimeout(2000); + await page.click('id=btn-form-close'); + console.log('การตรวจสอบการทำงานถูกต้อง'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } +}); + +test('Create Personnel - ในกรณีที่กรอกชื่อและนามสกุลภาษาอังกฤษไม่ตรงตามรูปแบบ', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click('id=btn-add'); + + // กรอกชื่อผู้ใช้งาน + await page.fill('id=form-dialog-personnel-input-first-name-en', 'ทดสอบ'); + await page.fill('id=form-dialog-personnel-input-last-name-en', 'ทดสอบ'); + + const firstNameEnError = page.locator("(//div[@role='alert'])[1]"); + const lastNameEnError = page.locator("(//div[@role='alert'])[2]"); + + await expect(firstNameEnError).toHaveText( + 'โปรดใช้เฉพาะตัวอักษรภาษาอังกฤษเท่านั้น', + ); + await expect(lastNameEnError).toHaveText( + 'โปรดใช้เฉพาะตัวอักษรภาษาอังกฤษเท่านั้น', + ); + + await page.waitForTimeout(2000); + await page.click('id=btn-form-close'); + console.log('การตรวจสอบการทำงานถูกต้อง'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } +}); + +test('Create Personnel - ในกรณีที่กรอกอีเมลไม่ตรงรูปแบบ', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click('id=btn-add'); + + // กรอกชื่อผู้ใช้งาน + await page.fill('id=form-dialog-personnel-input-email', 'ทดสอบ'); + + const firstNameEnError = page.locator("(//div[@role='alert'])[1]"); + + await expect(firstNameEnError).toHaveText('ข้อมูลไม่ถูกต้อง'); + + await page.waitForTimeout(2000); + await page.click('id=btn-form-close'); + console.log('การตรวจสอบการทำงานถูกต้อง'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } +}); diff --git a/tests/01-Manage/02-Admin-PersonnelManagement/JWS_PM_003_ViewDetail.spec.ts b/tests/01-Manage/02-Admin-PersonnelManagement/JWS_PM_003_ViewDetail.spec.ts new file mode 100644 index 00000000..b6d24b12 --- /dev/null +++ b/tests/01-Manage/02-Admin-PersonnelManagement/JWS_PM_003_ViewDetail.spec.ts @@ -0,0 +1,248 @@ +import { test, expect, Page } from '@playwright/test'; +import { strictEqual } from 'assert'; +import { exec } from 'child_process'; + +let page: Page; +let isLoginSuccessful = false; + +test.beforeAll(async ({ browser }) => { + page = await browser.newPage(); +}); + +test.afterAll(async () => { + if (page !== undefined) { + await page.close(); + } +}); + +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + // เข้าสู่หน้าบุคลากร + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-personnel'); + await page.click('id=sub-menu-personnel'); + + isLoginSuccessful = true; + console.log('ระบบทำการ Login'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการ Login', error); + isLoginSuccessful = false; + } +} + +test('Login', async () => { + await login(page); +}); + +test('ดูรายละเอียดพนักงาน', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click("(//div[@role='tab'])[2]"); + + try { + await page.waitForSelector('id=btn-kebab-action-employeem', { + state: 'visible', + }); + await page.click('id=btn-kebab-action-employeem'); + await page.click('id=btn-kebab-view-detail-employeem'); + + const detailTitle = page.locator("//span[text()='ธรรมรงด์ ดำรงธรรม']"); + + await expect(detailTitle).toHaveText('ธรรมรงด์ ดำรงธรรม'); + console.log('ตรวจสอบรายละเอียดพนักงานถูกต้อง'); + } catch (error) { + console.log('เกิดข้อผิดพลาดในการทดสอบ'); + throw error; + } + + await page.waitForTimeout(2000); + await page.click('id=btn-info-close'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } +}); + +test('ดูรายละเอียดพนักงานส่งเอกสาร', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click("(//div[@role='tab'])[3]"); + await page.click('id=btn-kebab-action-courierw'); + await page.click('id=btn-kebab-view-detail-courierw'); + + const detailTitle = page.locator("//span[text()='มาตา ลดา']"); + + await expect(detailTitle).toHaveText('มาตา ลดา'); + console.log('ตรวจสอบรายละเอียดพนักงานส่งเอกสารถูกต้อง'); + } catch (error) { + console.log('เกิดข้อผิดพลาดในการทดสอบ'); + isLoginSuccessful = false; + throw error; + } + + await page.waitForTimeout(2000); + await page.click('id=btn-info-close'); +}); + +test('ดูรายละเอียดตัวแทน', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click("(//div[@role='tab'])[4]"); + await page.click('id=btn-kebab-action-delegatem'); + await page.click('id=btn-kebab-view-detail-delegatem'); + + const detailTitle = page.locator("//span[text()='อาคม พลัง']"); + + await expect(detailTitle).toHaveText('อาคม พลัง'); + console.log('ตรวจสอบรายละเอียดตัวแทนถูกต้อง'); + } catch (error) { + console.log('เกิดข้อผิดพลาดในการทดสอบ'); + isLoginSuccessful = false; + throw error; + } + + await page.waitForTimeout(2000); + await page.click('id=btn-info-close'); +}); + +test('ดูรายละเอียดเอเจนซี่', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click("(//div[@role='tab'])[5]"); + await page.click('id=btn-kebab-action-agencyw'); + await page.waitForSelector('id=btn-kebab-view-detail-agencyw', { + state: 'visible', + }); + await page.click('id=btn-kebab-view-detail-agencyw'); + + const detailTitle = await page.locator("//span[text()='ธิดา งามตา']"); + + await expect(detailTitle).toHaveText('ธิดา งามตา'); + console.log('ตรวจสอบรายละเอียดเอเจนซี่ถูกต้อง'); + } catch (error) { + console.log('เกิดข้อผิดพลาดในการทดสอบ'); + isLoginSuccessful = false; + throw error; + } + + await page.waitForTimeout(2000); + await page.click('id=btn-info-close'); +}); + +// ---------------------------------- รูปแบบการ์ด ----------------------------// +test('ดูรายละเอียดพนักงานในรูปแบบการ์ด', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + await page.reload(); + await page.click("//button[@aria-pressed='false']"); + + await page.click("(//div[@role='tab'])[2]"); + + const namePersonal = page.locator( + "//div[normalize-space(text())='ธรรมรงด์ ดำรงธรรม']", + ); + + await expect(namePersonal).toHaveText('ธรรมรงด์ ดำรงธรรม'); + console.log('ตรวจสอบรายละเอียดพนักงานถูกต้อง'); + } catch (error) { + console.log('เกิดข้อผิดพลาดในการทดสอบ'); + isLoginSuccessful = false; + throw error; + } + + await page.waitForTimeout(2000); +}); + +test('ดูรายละเอียดพนักงานส่งเอกสารในรูปแบบการ์ด', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click("(//div[@role='tab'])[3]"); + + const namePersonal = page.locator( + "//div[normalize-space(text())='มาตา ลดา']", + ); + + await expect(namePersonal).toHaveText('มาตา ลดา'); + + console.log('ตรวจสอบรายละเอียดพนักงานถูกต้อง'); + } catch (error) { + console.log('เกิดข้อผิดพลาดในการทดสอบ'); + isLoginSuccessful = false; + throw error; + } + + await page.waitForTimeout(2000); +}); + +test('ดูรายละเอียดตัวแทนในรูปแบบการ์ด', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click("(//div[@role='tab'])[4]"); + + const namePersonal = page.locator( + "//div[normalize-space(text())='อาคม พลัง']", + ); + + await expect(namePersonal).toHaveText('อาคม พลัง'); + console.log('ตรวจสอบรายละเอียดตัวแทนถูกต้อง'); + } catch (error) { + console.log('เกิดข้อผิดพลาดในการทดสอบ'); + isLoginSuccessful = false; + throw error; + } + + await page.waitForTimeout(2000); +}); + +test('ดูรายละเอียดเอเจนซี่ในรูปแบบการ์ด', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click("(//div[@role='tab'])[5]"); + + const namePersonal = page.locator( + "//div[normalize-space(text())='ธิดา งามตา']", + ); + + await expect(namePersonal).toHaveText('ธิดา งามตา'); + console.log('ตรวจสอบรายละเอียดเอเจนซี่ถูกต้อง'); + } catch (error) { + console.log('เกิดข้อผิดพลาดในการทดสอบ'); + isLoginSuccessful = false; + throw error; + } + + await page.waitForTimeout(2000); +}); diff --git a/tests/02-Admin-PersonnelManagement/JWS_PM_004_EditPersonnel.spec.ts b/tests/01-Manage/02-Admin-PersonnelManagement/JWS_PM_004_EditPersonnel.spec.ts similarity index 87% rename from tests/02-Admin-PersonnelManagement/JWS_PM_004_EditPersonnel.spec.ts rename to tests/01-Manage/02-Admin-PersonnelManagement/JWS_PM_004_EditPersonnel.spec.ts index 490ccdad..9f8e2bfc 100644 --- a/tests/02-Admin-PersonnelManagement/JWS_PM_004_EditPersonnel.spec.ts +++ b/tests/01-Manage/02-Admin-PersonnelManagement/JWS_PM_004_EditPersonnel.spec.ts @@ -5,6 +5,7 @@ import { log } from 'console'; import { writeFileSync } from 'fs'; let page: Page; +let isLoginSuccessful = false; test.beforeAll(async ({ browser }) => { page = await browser.newPage(); @@ -16,19 +17,38 @@ test.afterAll(async () => { } }); +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + // เข้าสู่หน้าบุคลากร + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-personnel'); + await page.click('id=sub-menu-personnel'); + + isLoginSuccessful = true; + console.log('ระบบทำการ Login'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + } +} + test('Login', async () => { - // Login - await page.goto('http://192.168.1.62:20101/'); - 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'); + await login(page); }); test('Edit Personnel - พนักงาน', async () => { - await page.click('id=menu-icon-personnel-management'); + if (!isLoginSuccessful) { + await login(page); + } try { // เข้าสู่หน้าแก้ไขพนักงาน @@ -83,6 +103,7 @@ test('Edit Personnel - พนักงาน', async () => { console.log('ตรวจสอบการแก้ไขข้อมูลพนักงานถูกต้อง'); } catch (error) { console.log('เกิดข้อผิดพลาดในการทดสอบแก้ไขบุคลากร'); + isLoginSuccessful = false; throw error; } await page.waitForTimeout(4000); @@ -90,10 +111,15 @@ test('Edit Personnel - พนักงาน', async () => { }); test('Edit Personnel - พนักงานส่งเอกสาร', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { // เข้าสู่หน้าแก้ไขพนักงาน await page.click("(//div[@role='tab'])[3]"); await page.click('id=btn-kebab-action-courierw'); + await page.waitForSelector('id=btn-kebab-edit-courierw'); await page.click('id=btn-kebab-edit-courierw'); // แก้ไขข้อมูล @@ -131,6 +157,7 @@ test('Edit Personnel - พนักงานส่งเอกสาร', async console.log('ตรวจสอบการแก้ไขข้อมูลพนักงานส่งเอกสารถูกต้อง'); } catch (error) { console.log('เกิดข้อผิดพลาดในการทดสอบแก้ไขบุคลากร'); + isLoginSuccessful = false; throw error; } await page.waitForTimeout(4000); @@ -138,10 +165,16 @@ test('Edit Personnel - พนักงานส่งเอกสาร', async }); test('Edit Personnel - ตัวแทน', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { // เข้าสู่หน้าแก้ไขพนักงาน await page.click("(//div[@role='tab'])[4]"); + await page.waitForTimeout(1000); await page.click('id=btn-kebab-action-delegatem'); + await page.waitForSelector('id=btn-kebab-edit-delegatem'); await page.click('id=btn-kebab-edit-delegatem'); // แก้ไขข้อมูล @@ -184,6 +217,7 @@ test('Edit Personnel - ตัวแทน', async () => { console.log('ตรวจสอบการแก้ไขข้อมูลตัวแทนถูกต้อง'); } catch (error) { console.log('เกิดข้อผิดพลาดในการทดสอบแก้ไขบุคลากร'); + isLoginSuccessful = false; throw error; } await page.waitForTimeout(4000); @@ -191,6 +225,10 @@ test('Edit Personnel - ตัวแทน', async () => { }); test('Edit Personnel - เอเจนซี่', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { // เข้าสู่หน้าแก้ไขพนักงาน await page.click("(//div[@role='tab'])[5]"); @@ -199,6 +237,7 @@ test('Edit Personnel - เอเจนซี่', async () => { state: 'visible', }); await page.click('id=btn-kebab-action-agencyw'); + await page.waitForSelector('id=btn-kebab-edit-agencyw'); await page.click('id=btn-kebab-edit-agencyw'); // แก้ไขข้อมูล @@ -236,6 +275,7 @@ test('Edit Personnel - เอเจนซี่', async () => { console.log('ตรวจสอบการแก้ไขข้อมูลเอเจนซี่ถูกต้อง'); } catch (error) { console.log('เกิดข้อผิดพลาดในการทดสอบแก้ไขบุคลากร'); + isLoginSuccessful = false; throw error; } await page.waitForTimeout(4000); diff --git a/tests/02-Admin-PersonnelManagement/JWS_PM_005_StatusPersonnel.spec.ts b/tests/01-Manage/02-Admin-PersonnelManagement/JWS_PM_005_StatusPersonnel.spec.ts similarity index 75% rename from tests/02-Admin-PersonnelManagement/JWS_PM_005_StatusPersonnel.spec.ts rename to tests/01-Manage/02-Admin-PersonnelManagement/JWS_PM_005_StatusPersonnel.spec.ts index 2922f605..d4cecacb 100644 --- a/tests/02-Admin-PersonnelManagement/JWS_PM_005_StatusPersonnel.spec.ts +++ b/tests/01-Manage/02-Admin-PersonnelManagement/JWS_PM_005_StatusPersonnel.spec.ts @@ -1,7 +1,9 @@ import { test, expect, Page } from '@playwright/test'; import { strictEqual } from 'assert'; +import { log } from 'console'; let page: Page; +let isLoginSuccessful = false; test.beforeAll(async ({ browser }) => { page = await browser.newPage(); @@ -13,19 +15,38 @@ test.afterAll(async () => { } }); +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + // เข้าสู่หน้าบุคลากร + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-personnel'); + await page.click('id=sub-menu-personnel'); + + isLoginSuccessful = true; + console.log('Login สำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการ Login', error); + isLoginSuccessful = false; + } +} + test('Login', async () => { - // Login - await page.goto('http://192.168.1.62:20101/'); - 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'); + await login(page); }); test('ปิดสถานะการใช้งานบุคลากร', async () => { - await page.click('id=menu-icon-personnel-management'); + if (!isLoginSuccessful) { + await login(page); + } try { await page.click('id=btn-kebab-action-employeem'); @@ -56,12 +77,16 @@ test('ปิดสถานะการใช้งานบุคลากร', console.log('สีของแถวถูกเปลี่ยนเป็นสีเทาอ่อน'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ'); + isLoginSuccessful = false; throw error; } await page.waitForTimeout(2000); }); test('เปิดสถานะการใช้งานบุคลากร', async () => { + if (!isLoginSuccessful) { + await login(page); + } try { await page.click('id=btn-kebab-action-employeem'); @@ -92,6 +117,7 @@ test('เปิดสถานะการใช้งานบุคลาก console.log('สีของแถวถูกเปลี่ยนเป็นของสถานะการใช้งาน'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ'); + isLoginSuccessful = false; throw error; } await page.waitForTimeout(2000); diff --git a/tests/01-Manage/02-Admin-PersonnelManagement/JWS_PM_006_SearchPersonnel.spec.ts b/tests/01-Manage/02-Admin-PersonnelManagement/JWS_PM_006_SearchPersonnel.spec.ts new file mode 100644 index 00000000..e2e55385 --- /dev/null +++ b/tests/01-Manage/02-Admin-PersonnelManagement/JWS_PM_006_SearchPersonnel.spec.ts @@ -0,0 +1,104 @@ +import { test, expect, Page } from '@playwright/test'; +import { strictEqual } from 'assert'; +import { log } from 'console'; +import { errorMonitor } from 'events'; + +let page: Page; +let isLoginSuccessful = false; + +test.beforeAll(async ({ browser }) => { + page = await browser.newPage(); +}); + +test.afterAll(async () => { + if (page !== undefined) { + await page.close(); + } +}); +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + // เข้าสู่หน้าบุคลากร + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-personnel'); + await page.click('id=sub-menu-personnel'); + + isLoginSuccessful = true; + console.log('Login สำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการ Login'); + isLoginSuccessful = false; + } +} + +test('Login', async () => { + await login(page); +}); + +test('Search Personnel', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + // กำหนดคำที่จะค้นหา + const searchDatas = [ + 'อานน', + '0842262228', + '1000001', + '10', + '20', + '30', + '40', + ]; + + for (const searchData of searchDatas) { + // พิมพ์คำที่ต้องการค้นหา + await page.fill('id=input-search', searchData); // ดึงคำมาจาก searchDatas + await page.waitForTimeout(2000); + + // ดึงผลลัพฑ์การค้นหาทั้งหมด + const searchResults = page.locator("//table[@class='q-table']//tbody[1]"); + const resultCount = await searchResults.count(); + + // ถ้าไม่มีผลลัพธ์ให้ข้ามคำถัดไป + if (resultCount === 0) { + console.error(`ไม่พบการค้นหา: '${searchData}', ข้ามไปคำถัดไป`); + continue; // ข้ามคำค้นหาคำถัดไป + } + + // ดึงข้อความทั้งหมดของผลลัพธ์การค้นหา + const searchResultTexts = await searchResults.allTextContents(); + console.log(`ผลลัพธ์ของการค้นหา '${searchData}'`, searchDatas); + + // ตรวจสอบว่าผลลัพธ์ทั้งหมดมีคำที่ค้นหาหรือไม่ + const allResultContainSearchData = searchResultTexts.every((result) => + result.includes(searchData), + ); + + // ถ้าไม่พบคำค้นหา ให้แค่แจ้งเตือนและข้ามไปคำถัดไป + if (!allResultContainSearchData) { + console.error( + `\x1b[31mผลลัพธ์บางรายการไม่ตรงกับคำค้นหา: '${searchData}', ข้ามไปคำถัดไป\x1b[0m`, + ); + continue; // ข้ามไปคำค้นหาถัดไป + } + + expect(allResultContainSearchData).toBe(true); + + console.log(`การค้นหา '${searchData}' และการแสดงผลสำเร็จ`); + } + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบการค้นหาหลายคำค้นหา', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForTimeout(2000); +}); diff --git a/tests/02-Admin-PersonnelManagement/JWS_PM_007_StatusPersonnelType.spec.ts b/tests/01-Manage/02-Admin-PersonnelManagement/JWS_PM_007_StatusPersonnelType.spec.ts similarity index 92% rename from tests/02-Admin-PersonnelManagement/JWS_PM_007_StatusPersonnelType.spec.ts rename to tests/01-Manage/02-Admin-PersonnelManagement/JWS_PM_007_StatusPersonnelType.spec.ts index 111acde6..36a87f41 100644 --- a/tests/02-Admin-PersonnelManagement/JWS_PM_007_StatusPersonnelType.spec.ts +++ b/tests/01-Manage/02-Admin-PersonnelManagement/JWS_PM_007_StatusPersonnelType.spec.ts @@ -2,6 +2,7 @@ import { test, expect, Page } from '@playwright/test'; import { strictEqual } from 'assert'; let page: Page; +let isLoginSuccessful = false; test.beforeAll(async ({ browser }) => { page = await browser.newPage(); @@ -13,26 +14,45 @@ test.afterAll(async () => { } }); +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + // เข้าสู่หน้าบุคลากร + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-personnel'); + await page.click('id=sub-menu-personnel'); + + isLoginSuccessful = true; + console.log('Login สำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการ Login', error); + isLoginSuccessful = false; + } +} + test('Login', async () => { - // Login - await page.goto('http://192.168.1.62:20101/'); - 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'); + await login(page); }); test('ตรวจสอบการแสดงสถานะใช้งาน เปิด/ปิด บุคลากรทั้งหมด', async () => { + if (!isLoginSuccessful) { + await login(page); + } try { - // คลิกเมนูจัดการบุคลากร - await page.click('id=menu-icon-personnel-management'); - // แสดงสถานะที่ใช้งาน // คลิกเพื่อเปิด dropdown + await page.waitForTimeout(1000); await page.click('id=field-select-status'); - await page.waitForTimeout(1000); // รอให้ dropdown เปิด + //รอให้ dropdown เปิด + await page.waitForSelector('id=field-select-status_1'); // คลิกเพื่อแสดงสถานะกำลังใช้งานอยู่ await page.click('id=field-select-status_1'); @@ -86,11 +106,15 @@ test('ตรวจสอบการแสดงสถานะใช้งา console.log('ตรวจสอบสถานะทั้งหมด'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; throw error; } }); test('ตรวจสอบการแสดงสถานะใช้งาน เปิด/ปิด พนักงาน', async () => { + if (!isLoginSuccessful) { + await login(page); + } try { // คลิก Tab พนักงาน await page.click("(//div[@role='tab'])[2]"); @@ -152,11 +176,15 @@ test('ตรวจสอบการแสดงสถานะใช้งา console.log('ตรวจสอบสถานะทั้งหมด'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; throw error; } }); test('ตรวจสอบการแสดงสถานะใช้งาน เปิด/ปิด พนักงานส่งเอกสาร', async () => { + if (!isLoginSuccessful) { + await login(page); + } try { // คลิก Tab พนักงานส่งเอกสาร await page.click("(//div[@role='tab'])[3]"); @@ -218,11 +246,15 @@ test('ตรวจสอบการแสดงสถานะใช้งา console.log('ตรวจสอบสถานะทั้งหมด'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; throw error; } }); test('ตรวจสอบการแสดงสถานะใช้งาน เปิด/ปิด ตัวแทน', async () => { + if (!isLoginSuccessful) { + await login(page); + } try { // คลิก Tab ตัวแทน await page.click("(//div[@role='tab'])[4]"); @@ -284,11 +316,15 @@ test('ตรวจสอบการแสดงสถานะใช้งา console.log('ตรวจสอบสถานะทั้งหมด'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; throw error; } }); test('ตรวจสอบการแสดงสถานะใช้งาน เปิด/ปิด เอเจนซี่', async () => { + if (!isLoginSuccessful) { + await login(page); + } try { // คลิก Tab เอเจนซี่ await page.click("(//div[@role='tab'])[5]"); @@ -350,6 +386,7 @@ test('ตรวจสอบการแสดงสถานะใช้งา console.log('ตรวจสอบสถานะทั้งหมด'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; throw error; } }); diff --git a/tests/02-Admin-PersonnelManagement/JWS_PM_008_TypePersonnelFields.spec.ts b/tests/01-Manage/02-Admin-PersonnelManagement/JWS_PM_008_TypePersonnelFields.spec.ts similarity index 96% rename from tests/02-Admin-PersonnelManagement/JWS_PM_008_TypePersonnelFields.spec.ts rename to tests/01-Manage/02-Admin-PersonnelManagement/JWS_PM_008_TypePersonnelFields.spec.ts index ebd33853..6c9318ae 100644 --- a/tests/02-Admin-PersonnelManagement/JWS_PM_008_TypePersonnelFields.spec.ts +++ b/tests/01-Manage/02-Admin-PersonnelManagement/JWS_PM_008_TypePersonnelFields.spec.ts @@ -2,6 +2,7 @@ import { test, expect, Page } from '@playwright/test'; import { strictEqual } from 'assert'; let page: Page; +let isLoginSuccessful = false; test.beforeAll(async ({ browser }) => { page = await browser.newPage(); @@ -12,24 +13,42 @@ test.afterAll(async () => { await page.close(); } }); + +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + // เข้าสู่หน้าบุคลากร + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-personnel'); + await page.click('id=sub-menu-personnel'); + + isLoginSuccessful = true; + console.log('Login สำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการ Login', error); + isLoginSuccessful = false; + } +} + test('Login', async () => { - // Login - await page.goto('http://192.168.1.62:20101/'); - 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'); + await login(page); }); //---------------------------------Tab ทั้งหมด---------------------------------------- test('ตรวจสอบการแสดงผลฟิลด์แสดงผลลำดับ', async () => { + if (!isLoginSuccessful) { + await login(page); + } try { - // คลิกเมนูเพื่อเข้าหน้าจัดการบุคลากร - await page.click('id=menu-icon-personnel-management'); - // คลิกเพื่อเปิด dropdown await page.click("(//input[@id='select-field'])[1]"); await page.waitForTimeout(1000); // รอให้ dropdown เปิด @@ -81,12 +100,16 @@ test('ตรวจสอบการแสดงผลฟิลด์แสด console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; throw error; } await page.keyboard.press('Escape'); }); test('ตรวจสอบการแสดงผลฟิลด์แสดงผลชื่อ-สกุล', async () => { + if (!isLoginSuccessful) { + await login(page); + } try { // คลิกเพื่อเปิด dropdown await page.click("(//input[@id='select-field'])[1]"); @@ -139,12 +162,16 @@ test('ตรวจสอบการแสดงผลฟิลด์แสด console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; throw error; } await page.keyboard.press('Escape'); }); test('ตรวจสอบการแสดงผลฟิลด์แสดงผลประเภท', async () => { + if (!isLoginSuccessful) { + await login(page); + } try { // คลิกเพื่อเปิด dropdown await page.click("(//input[@id='select-field'])[1]"); @@ -197,12 +224,16 @@ test('ตรวจสอบการแสดงผลฟิลด์แสด console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; throw error; } await page.keyboard.press('Escape'); }); test('ตรวจสอบการแสดงผลฟิลด์แสดงผลเบอร์โทรศัพท์', async () => { + if (!isLoginSuccessful) { + await login(page); + } try { // คลิกเพื่อเปิด dropdown await page.click("(//input[@id='select-field'])[1]"); @@ -255,12 +286,16 @@ test('ตรวจสอบการแสดงผลฟิลด์แสด console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; throw error; } await page.keyboard.press('Escape'); }); test('ตรวจสอบการแสดงผลฟิลด์แสดงผลอายุ', async () => { + if (!isLoginSuccessful) { + await login(page); + } try { // คลิกเพื่อเปิด dropdown await page.click("(//input[@id='select-field'])[1]"); @@ -313,12 +348,16 @@ test('ตรวจสอบการแสดงผลฟิลด์แสด console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; throw error; } await page.keyboard.press('Escape'); }); test('ตรวจสอบการแสดงผลฟิลด์แสดงผลอีเมล', async () => { + if (!isLoginSuccessful) { + await login(page); + } try { // คลิกเพื่อเปิด dropdown await page.click("(//input[@id='select-field'])[1]"); @@ -371,12 +410,16 @@ test('ตรวจสอบการแสดงผลฟิลด์แสด console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; throw error; } await page.keyboard.press('Escape'); }); test('ตรวจสอบการแสดงผลฟิลด์แสดงผลสิทธิ์ผู้ใช้งาน', async () => { + if (!isLoginSuccessful) { + await login(page); + } try { // คลิกเพื่อเปิด dropdown await page.click("(//input[@id='select-field'])[1]"); @@ -429,6 +472,7 @@ test('ตรวจสอบการแสดงผลฟิลด์แสด console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; throw error; } await page.keyboard.press('Escape'); @@ -438,6 +482,9 @@ test('ตรวจสอบการแสดงผลฟิลด์แสด //---------------------------------Tab พนักงาน---------------------------------------- test('ตรวจสอบการแสดงผลฟิลด์แสดงผลลำดับ - พนักงาน', async () => { + if (!isLoginSuccessful) { + await login(page); + } try { // คลิก Tab พนักงาน await page.click("(//div[@role='tab'])[2]"); @@ -493,12 +540,16 @@ test('ตรวจสอบการแสดงผลฟิลด์แสด console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; throw error; } await page.keyboard.press('Escape'); }); test('ตรวจสอบการแสดงผลฟิลด์แสดงผลชื่อ-สกุล - พนักงาน', async () => { + if (!isLoginSuccessful) { + await login(page); + } try { // คลิกเพื่อเปิด dropdown await page.click("(//input[@id='select-field'])[1]"); @@ -551,12 +602,17 @@ test('ตรวจสอบการแสดงผลฟิลด์แสด console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; throw error; } await page.keyboard.press('Escape'); }); test('ตรวจสอบการแสดงผลฟิลด์แสดงผลประเภท - พนักงาน', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { // คลิกเพื่อเปิด dropdown await page.click("(//input[@id='select-field'])[1]"); @@ -609,12 +665,16 @@ test('ตรวจสอบการแสดงผลฟิลด์แสด console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; throw error; } await page.keyboard.press('Escape'); }); test('ตรวจสอบการแสดงผลฟิลด์แสดงผลเบอร์โทรศัพท์ - พนักงาน', async () => { + if (!isLoginSuccessful) { + await login(page); + } try { // คลิกเพื่อเปิด dropdown await page.click("(//input[@id='select-field'])[1]"); @@ -667,12 +727,17 @@ test('ตรวจสอบการแสดงผลฟิลด์แสด console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; throw error; } await page.keyboard.press('Escape'); }); test('ตรวจสอบการแสดงผลฟิลด์แสดงผลอายุ - พนักงาน', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { // คลิกเพื่อเปิด dropdown await page.click("(//input[@id='select-field'])[1]"); @@ -725,12 +790,17 @@ test('ตรวจสอบการแสดงผลฟิลด์แสด console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; throw error; } await page.keyboard.press('Escape'); }); test('ตรวจสอบการแสดงผลฟิลด์แสดงผลอีเมล - พนักงาน', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { // คลิกเพื่อเปิด dropdown await page.click("(//input[@id='select-field'])[1]"); @@ -783,12 +853,17 @@ test('ตรวจสอบการแสดงผลฟิลด์แสด console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; throw error; } await page.keyboard.press('Escape'); }); test('ตรวจสอบการแสดงผลฟิลด์แสดงผลสิทธิ์ผู้ใช้งาน - พนักงาน', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { // คลิกเพื่อเปิด dropdown await page.click("(//input[@id='select-field'])[1]"); @@ -841,6 +916,7 @@ test('ตรวจสอบการแสดงผลฟิลด์แสด console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; throw error; } await page.keyboard.press('Escape'); @@ -850,6 +926,10 @@ test('ตรวจสอบการแสดงผลฟิลด์แสด //---------------------------------Tab พนักงานส่งเอกสาร---------------------------------------- test('ตรวจสอบการแสดงผลฟิลด์แสดงผลลำดับ - พนักงานส่งเอกสาร', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { // คลิก Tab พนักงาน await page.click("(//div[@role='tab'])[3]"); @@ -905,12 +985,17 @@ test('ตรวจสอบการแสดงผลฟิลด์แสด console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; throw error; } await page.keyboard.press('Escape'); }); test('ตรวจสอบการแสดงผลฟิลด์แสดงผลชื่อ-สกุล - พนักงานส่งเอกสาร', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { // คลิกเพื่อเปิด dropdown await page.click("(//input[@id='select-field'])[1]"); @@ -963,12 +1048,17 @@ test('ตรวจสอบการแสดงผลฟิลด์แสด console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; throw error; } await page.keyboard.press('Escape'); }); test('ตรวจสอบการแสดงผลฟิลด์แสดงผลประเภท - พนักงานส่งเอกสาร', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { // คลิกเพื่อเปิด dropdown await page.click("(//input[@id='select-field'])[1]"); @@ -1021,12 +1111,17 @@ test('ตรวจสอบการแสดงผลฟิลด์แสด console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; throw error; } await page.keyboard.press('Escape'); }); test('ตรวจสอบการแสดงผลฟิลด์แสดงผลเบอร์โทรศัพท์ - พนักงานส่งเอกสาร', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { // คลิกเพื่อเปิด dropdown await page.click("(//input[@id='select-field'])[1]"); @@ -1079,12 +1174,17 @@ test('ตรวจสอบการแสดงผลฟิลด์แสด console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; throw error; } await page.keyboard.press('Escape'); }); test('ตรวจสอบการแสดงผลฟิลด์แสดงผลอายุ - พนักงานส่งเอกสาร', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { // คลิกเพื่อเปิด dropdown await page.click("(//input[@id='select-field'])[1]"); @@ -1137,12 +1237,17 @@ test('ตรวจสอบการแสดงผลฟิลด์แสด console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; throw error; } await page.keyboard.press('Escape'); }); test('ตรวจสอบการแสดงผลฟิลด์แสดงผลอีเมล - พนักงานส่งเอกสาร', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { // คลิกเพื่อเปิด dropdown await page.click("(//input[@id='select-field'])[1]"); @@ -1195,12 +1300,17 @@ test('ตรวจสอบการแสดงผลฟิลด์แสด console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; throw error; } await page.keyboard.press('Escape'); }); test('ตรวจสอบการแสดงผลฟิลด์แสดงผลสิทธิ์ผู้ใช้งาน - พนักงานส่งเอกสาร', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { // คลิกเพื่อเปิด dropdown await page.click("(//input[@id='select-field'])[1]"); @@ -1253,6 +1363,7 @@ test('ตรวจสอบการแสดงผลฟิลด์แสด console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; throw error; } await page.keyboard.press('Escape'); @@ -1262,6 +1373,10 @@ test('ตรวจสอบการแสดงผลฟิลด์แสด //---------------------------------Tab ตัวแทน---------------------------------------- test('ตรวจสอบการแสดงผลฟิลด์แสดงผลลำดับ - ตัวแทน', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { // คลิก Tab พนักงาน await page.click("(//div[@role='tab'])[4]"); @@ -1317,12 +1432,17 @@ test('ตรวจสอบการแสดงผลฟิลด์แสด console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; throw error; } await page.keyboard.press('Escape'); }); test('ตรวจสอบการแสดงผลฟิลด์แสดงผลชื่อ-สกุล - ตัวแทน', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { // คลิกเพื่อเปิด dropdown await page.click("(//input[@id='select-field'])[1]"); @@ -1375,12 +1495,17 @@ test('ตรวจสอบการแสดงผลฟิลด์แสด console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; throw error; } await page.keyboard.press('Escape'); }); test('ตรวจสอบการแสดงผลฟิลด์แสดงผลประเภท - ตัวแทน', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { // คลิกเพื่อเปิด dropdown await page.click("(//input[@id='select-field'])[1]"); @@ -1433,12 +1558,17 @@ test('ตรวจสอบการแสดงผลฟิลด์แสด console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; throw error; } await page.keyboard.press('Escape'); }); test('ตรวจสอบการแสดงผลฟิลด์แสดงผลเบอร์โทรศัพท์ - ตัวแทน', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { // คลิกเพื่อเปิด dropdown await page.click("(//input[@id='select-field'])[1]"); @@ -1491,12 +1621,17 @@ test('ตรวจสอบการแสดงผลฟิลด์แสด console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; throw error; } await page.keyboard.press('Escape'); }); test('ตรวจสอบการแสดงผลฟิลด์แสดงผลอายุ - ตัวแทน', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { // คลิกเพื่อเปิด dropdown await page.click("(//input[@id='select-field'])[1]"); @@ -1549,12 +1684,17 @@ test('ตรวจสอบการแสดงผลฟิลด์แสด console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; throw error; } await page.keyboard.press('Escape'); }); test('ตรวจสอบการแสดงผลฟิลด์แสดงผลอีเมล - ตัวแทน', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { // คลิกเพื่อเปิด dropdown await page.click("(//input[@id='select-field'])[1]"); @@ -1607,12 +1747,17 @@ test('ตรวจสอบการแสดงผลฟิลด์แสด console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; throw error; } await page.keyboard.press('Escape'); }); test('ตรวจสอบการแสดงผลฟิลด์แสดงผลสิทธิ์ผู้ใช้งาน - ตัวแทน', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { // คลิกเพื่อเปิด dropdown await page.click("(//input[@id='select-field'])[1]"); @@ -1665,6 +1810,7 @@ test('ตรวจสอบการแสดงผลฟิลด์แสด console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; throw error; } await page.keyboard.press('Escape'); @@ -1674,6 +1820,10 @@ test('ตรวจสอบการแสดงผลฟิลด์แสด //---------------------------------Tab เอเจนซี่---------------------------------------- test('ตรวจสอบการแสดงผลฟิลด์แสดงผลลำดับ - เอเจนซี่', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { // คลิก Tab พนักงาน await page.click("(//div[@role='tab'])[5]"); @@ -1729,12 +1879,17 @@ test('ตรวจสอบการแสดงผลฟิลด์แสด console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; throw error; } await page.keyboard.press('Escape'); }); test('ตรวจสอบการแสดงผลฟิลด์แสดงผลชื่อ-สกุล - เอเจนซี่', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { // คลิกเพื่อเปิด dropdown await page.click("(//input[@id='select-field'])[1]"); @@ -1787,12 +1942,17 @@ test('ตรวจสอบการแสดงผลฟิลด์แสด console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; throw error; } await page.keyboard.press('Escape'); }); test('ตรวจสอบการแสดงผลฟิลด์แสดงผลประเภท - เอเจนซี่', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { // คลิกเพื่อเปิด dropdown await page.click("(//input[@id='select-field'])[1]"); @@ -1845,12 +2005,17 @@ test('ตรวจสอบการแสดงผลฟิลด์แสด console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; throw error; } await page.keyboard.press('Escape'); }); test('ตรวจสอบการแสดงผลฟิลด์แสดงผลเบอร์โทรศัพท์ - เอเจนซี่', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { // คลิกเพื่อเปิด dropdown await page.click("(//input[@id='select-field'])[1]"); @@ -1903,12 +2068,17 @@ test('ตรวจสอบการแสดงผลฟิลด์แสด console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; throw error; } await page.keyboard.press('Escape'); }); test('ตรวจสอบการแสดงผลฟิลด์แสดงผลอายุ - เอเจนซี่', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { // คลิกเพื่อเปิด dropdown await page.click("(//input[@id='select-field'])[1]"); @@ -1961,12 +2131,17 @@ test('ตรวจสอบการแสดงผลฟิลด์แสด console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; throw error; } await page.keyboard.press('Escape'); }); test('ตรวจสอบการแสดงผลฟิลด์แสดงผลอีเมล - เอเจนซี่', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { // คลิกเพื่อเปิด dropdown await page.click("(//input[@id='select-field'])[1]"); @@ -2019,12 +2194,17 @@ test('ตรวจสอบการแสดงผลฟิลด์แสด console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; throw error; } await page.keyboard.press('Escape'); }); test('ตรวจสอบการแสดงผลฟิลด์แสดงผลสิทธิ์ผู้ใช้งาน - เอเจนซี่', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { // คลิกเพื่อเปิด dropdown await page.click("(//input[@id='select-field'])[1]"); @@ -2077,6 +2257,7 @@ test('ตรวจสอบการแสดงผลฟิลด์แสด console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; throw error; } await page.keyboard.press('Escape'); diff --git a/tests/01-Manage/03-Admin-ManageCustomer/Createemployeeinlegal.spec.ts b/tests/01-Manage/03-Admin-ManageCustomer/Createemployeeinlegal.spec.ts new file mode 100644 index 00000000..bea51866 --- /dev/null +++ b/tests/01-Manage/03-Admin-ManageCustomer/Createemployeeinlegal.spec.ts @@ -0,0 +1,145 @@ +import { test, expect, Page } from '@playwright/test'; +import { strictEqual } from 'assert'; +import fs from 'fs'; +import path from 'path'; + +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://chamomind.ddns.net: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('สร้างลูกจ้างในสาขา', async () => { + const names = [ + { + firstName: 'อริญา', + lastName: 'จิตรเกียรติ', + firstNameEn: 'Arinya', + lastNameEn: 'Jitkiat', + }, + { + firstName: 'เกียรติศักดิ์', + lastName: 'อำนวย', + firstNameEn: 'Kiatsakd', + lastNameEn: 'Amnuy', + }, + { + firstName: 'ภัทรพล', + lastName: 'รุ่งโรจน์', + firstNameEn: 'Phatthapon', + lastNameEn: 'Rungroj', + }, + { + firstName: 'ศิริพร', + lastName: 'พงษ์รัตน์', + firstNameEn: 'Siriporn', + lastNameEn: 'Phongrat', + }, + { + firstName: 'กรกมล', + lastName: 'กิตติสมบัติ', + firstNameEn: 'Karakamon', + lastNameEn: 'Kittisombat', + }, + ]; + + // เข้าสู่เมนูลูกค้า + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-customer'); + await page.click('id=sub-menu-customer'); + + await page.click( + "//td[contains(.,'บริษัท เทคโนโลยีอินโนเวต จำกัดInnovative Technology Co., Ltd.')]", + ); + await page.click("//table[@class='q-table']/tbody[1]/tr[3]/td[6]/button[1]"); + try { + for (const user of names) { + await page.click("(//th[@class='text-right']//button)[2]"); + await page.click('id=form-employee-select-prefix-name'); + await page.click('id=form-employee-select-prefix-name_0'); + await page.fill('id=form-employee-input-first-name', user.firstName); + await page.fill('id=form-employee-input-last-name', user.lastName); + await page.fill('id=form-employee-input-first-name-en', user.firstNameEn); + await page.fill('id=form-employee-input-last-name-en', user.lastNameEn); + + // วันเกิด + await page.click('id=form-employee-input-birth-date'); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); + await page.click("//div[text()='2000']"); + await page.click("//div[@id='2000-11-02']/div[1]"); + + // สัญชาติ + await page.click('id=form-employee-select-nationality'); + await page.click('id=form-employee-select-nationality_3'); + await page.click('id=btn-info-basic-save'); + await page.waitForTimeout(2000); + await page.click('id=btn-form-close'); + } + } catch (error) { + console.error('error'); + } +}); + +test('สร้างลูกจ้างในสาขา 2', async () => { + const namestwo = [ + { + firstName: 'สุทิน', + lastName: 'ภาณุวงศ์', + firstNameEn: 'Suthin', + lastNameEn: 'Phanuwong', + }, + ]; + + // เข้าสู่เมนูลูกค้า + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-customer'); + await page.click('id=sub-menu-customer'); + + await page.click( + "//td[contains(.,'บริษัท เทคโนโลยีอินโนเวต จำกัดInnovative Technology Co., Ltd.')]", + ); + await page.click("//table[@class='q-table']/tbody[1]/tr[5]/td[6]/button[1]"); + try { + for (const user of namestwo) { + await page.click("(//th[@class='text-right']//button)[3]"); + await page.click('id=form-employee-select-prefix-name'); + await page.click('id=form-employee-select-prefix-name_0'); + await page.fill('id=form-employee-input-first-name', user.firstName); + await page.fill('id=form-employee-input-last-name', user.lastName); + await page.fill('id=form-employee-input-first-name-en', user.firstNameEn); + await page.fill('id=form-employee-input-last-name-en', user.lastNameEn); + + // วันเกิด + await page.click('id=form-employee-input-birth-date'); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); + await page.click("//div[text()='2000']"); + await page.click("//div[@id='2000-11-02']/div[1]"); + + // สัญชาติ + await page.click('id=form-employee-select-nationality'); + await page.click('id=form-employee-select-nationality_3'); + await page.click('id=btn-info-basic-save'); + await page.waitForTimeout(2000); + await page.click('id=btn-form-close'); + } + } catch (error) { + console.error('error'); + } +}); diff --git a/tests/03-Admin-ManageCustomer/JWS_MC_001_CreateNaturalperoson.spec.ts b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_001_CreateNaturalperoson.spec.ts similarity index 64% rename from tests/03-Admin-ManageCustomer/JWS_MC_001_CreateNaturalperoson.spec.ts rename to tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_001_CreateNaturalperoson.spec.ts index 68fcd590..a1eb3c84 100644 --- a/tests/03-Admin-ManageCustomer/JWS_MC_001_CreateNaturalperoson.spec.ts +++ b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_001_CreateNaturalperoson.spec.ts @@ -2,6 +2,7 @@ import { test, expect, Page } from '@playwright/test'; import { strictEqual } from 'assert'; let page: Page; +let isLoginSuccessful = false; test.beforeAll(async ({ browser }) => { page = await browser.newPage(); @@ -13,32 +14,53 @@ test.afterAll(async () => { } }); +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + // เข้าสู่เมนูลูกค้า + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-customer'); + await page.click('id=sub-menu-customer'); + + isLoginSuccessful = true; + console.log('Login สำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการ Login', error); + isLoginSuccessful = false; + } +} + test('Login', async () => { - // Login - await page.goto('http://192.168.1.62:20101/'); - 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'); + await login(page); }); test('ทดสอบการสร้างนายจ้างบุคคลธรรมดา', async () => { - await page.click('id=menu-icon-customer-management'); + if (!isLoginSuccessful) { + await login(page); + } + try { - await page.click('id=btn-Add'); - await page.click("(//button[@type='submit'])[2]"); + await page.waitForTimeout(2000); + await page.click('id=btn-add'); + await page.click('id=add-customer-natural-person'); // ส่วนเกี่ยวกับ - await page.fill('id=input-legal-person-no', '1524428220420'); + await page.fill('id=input-card-number', '1524428220420'); await page.waitForSelector('id=form-select-prefix-name'); await page.click('id=form-select-prefix-name'); await page.waitForSelector('id=form-select-prefix-name_0'); await page.click('id=form-select-prefix-name_0'); - await page.fill("(//input[@id='form-input-first-name'])[1]", 'ยศพัฒน์'); - await page.fill("(//input[@id='form-input-last-name'])[1]", 'ธนากานต์'); - await page.fill("(//input[@id='form-input-first-name'])[3]", 'Yossapat'); - await page.fill("(//input[@id='form-input-last-name'])[2]", 'Tanakarn'); + await page.fill('id=form-input-first-name', 'ยศพัฒน์'); + await page.fill('id=form-input-last-name', 'ธนากานต์'); + await page.fill('id=form-input-first-name-en', 'Yossapat'); + await page.fill('id=form-input-last-name-en', 'Tanakarn'); await page.fill('id=form-input-telephone', '0842262228'); await page.waitForSelector('id=form-input-birth-date'); await page.click('id=form-input-birth-date'); @@ -46,8 +68,10 @@ test('ทดสอบการสร้างนายจ้างบุคค "(//button[@class='dp__btn dp__month_year_select'])[2]", ); await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2542']"); - await page.click("//div[@id='1999-09-02']/div[1]"); + await page.click("//div[text()='1999']"); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[1]"); + await page.click("//div[text()='ต.ค.']"); + await page.click("//div[@id='1999-10-02']/div[1]"); // ส่วนข้อมูลธุรกิจ await page.waitForSelector("(//div[@aria-selected='false'])[2]"); @@ -77,45 +101,50 @@ test('ทดสอบการสร้างนายจ้างบุคค await page.click('id=btn-form-close'); // กำหนดค่าเพื่อตรวจสอบความถูกต้องหลังสร้าง + const nameTitleNatrualPerson = await page.locator( - "//div[normalize-space(text())='ยศพัฒน์ ธนากานต์']", + "//tr[contains(.,'นาย ยศพัฒน์ ธนากานต์') and contains (.,'--')]", ); - expect(nameTitleNatrualPerson).toHaveText('ยศพัฒน์ ธนากานต์'); + expect(nameTitleNatrualPerson).toContainText('ยศพัฒน์ ธนากานต์'); + expect(nameTitleNatrualPerson).toContainText('--'); + console.log('ระบบสามารถสร้างนายจ้างบุคคลธรรมดาได้'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; throw error; } await page.waitForTimeout(2000); }); test('ทดสอบการสร้างนายจ้างบุคคลธรรมดาครั้งที่ 2', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + await page.waitForTimeout(2000); await page.click('id=btn-add'); await page.click('id=add-customer-natural-person'); // ส่วนเกี่ยวกับ - await page.fill('id=input-legal-person-no', '1886222422008'); + await page.fill('id=input-card-number', '1886222422008'); await page.waitForSelector('id=form-select-prefix-name'); await page.click('id=form-select-prefix-name'); await page.waitForSelector('id=form-select-prefix-name_0'); await page.click('id=form-select-prefix-name_0'); - await page.fill("(//input[@id='form-input-first-name'])[1]", 'สุรวัฒน์'); - await page.fill("(//input[@id='form-input-last-name'])[1]", 'จันทรสมบัติ '); - await page.fill("(//input[@id='form-input-first-name'])[3]", 'Surawat'); - await page.fill( - "(//input[@id='form-input-last-name'])[2]", - 'Jantarasombat', - ); + await page.fill('id=form-input-first-name', 'สุรวัฒน์'); + await page.fill('id=form-input-last-name', 'จันทรสมบัติ '); + await page.fill('id=form-input-first-name-en', 'Surawat'); + await page.fill('id=form-input-last-name-en', 'Jantarasombat'); await page.fill('id=form-input-telephone', '0864240842'); await page.waitForSelector('id=form-input-birth-date'); await page.click('id=form-input-birth-date'); - await page.waitForSelector( - "(//button[@class='dp__btn dp__month_year_select'])[2]", - ); await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2542']"); - await page.click("//div[@id='1999-09-02']/div[1]"); + await page.click("//div[text()='1999']"); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[1]"); + await page.click("//div[text()='ต.ค.']"); + await page.click("//div[@id='1999-10-02']/div[1]"); // ส่วนข้อมูลธุรกิจ await page.waitForSelector("(//div[@aria-selected='false'])[2]"); @@ -129,32 +158,33 @@ test('ทดสอบการสร้างนายจ้างบุคค // ส่วนที่อยู่นายจ้าง await page.click("(//div[@aria-selected='false'])[3]"); - await page.fill("(//input[@id='form-input-address'])[1]", '22282206402'); - await page.fill('id=form-input-address-no', '400'); + await page.fill("(//input[@id='form-input-address'])[1]", '22282205202'); + await page.fill('id=form-input-address-no', '200'); await page.click('id=form-select-province'); await page.waitForSelector('id=form-select-province_4'); await page.click('id=form-select-province_4'); await page.click('id=form-select-district'); + await page.waitForTimeout(1000); await page.waitForSelector('id=form-select-district_8'); await page.click('id=form-select-district_8'); await page.click('id=form-select-sub-district'); await page.waitForSelector('id=form-select-sub-district_7'); await page.click('id=form-select-sub-district_7'); - await page.fill('id=form-input-address-en', '400'); + await page.fill('id=form-input-address-en', '200'); await page.click("//button[@type='submit']"); await page.click('id=btn-form-close'); - await page.waitForSelector( - "//div[normalize-space(text())='สุรวัฒน์ จันทรสมบัติ']", - ); // กำหนดค่าเพื่อตรวจสอบความถูกต้องหลังสร้าง const nameTitleNatrualPerson = await page.locator( - "//div[normalize-space(text())='สุรวัฒน์ จันทรสมบัติ']", + "//tr[contains(.,'นาย สุรวัฒน์ จันทรสมบัติ') and contains (.,'--')]", ); - expect(nameTitleNatrualPerson).toHaveText('สุรวัฒน์ จันทรสมบัติ'); + expect(nameTitleNatrualPerson).toContainText('สุรวัฒน์ จันทรสมบัติ'); + expect(nameTitleNatrualPerson).toContainText('--'); + console.log('ระบบสามารถสร้างนายจ้างบุคคลธรรมดาได้'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; throw error; } await page.waitForTimeout(2000); diff --git a/tests/03-Admin-ManageCustomer/JWS_MC_002_CreateNaturalperosonfail.spec.ts b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_002-1_CreateNaturalperosonfailEn.spec.ts similarity index 58% rename from tests/03-Admin-ManageCustomer/JWS_MC_002_CreateNaturalperosonfail.spec.ts rename to tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_002-1_CreateNaturalperosonfailEn.spec.ts index c8c14863..81452209 100644 --- a/tests/03-Admin-ManageCustomer/JWS_MC_002_CreateNaturalperosonfail.spec.ts +++ b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_002-1_CreateNaturalperosonfailEn.spec.ts @@ -6,6 +6,7 @@ import { ToastHeader } from 'react-bootstrap'; import { toHandlerKey } from 'vue'; let page: Page; +let isLoginSuccessful = false; test.beforeAll(async ({ browser }) => { page = await browser.newPage(); @@ -17,55 +18,87 @@ test.afterAll(async () => { } }); +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + // เข้าสู่เมนูลูกค้า + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-customer'); + await page.click('id=sub-menu-customer'); + await page.waitForTimeout(2000); + + // เปลี่ยนภาษา + await page.click('id=btn-change-language'); + await page.waitForSelector('id=btn-change-language-eng'); + await page.click('id=btn-change-language-eng'); + + isLoginSuccessful = true; + console.log('Login สำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการ Login', error); + isLoginSuccessful = false; + } +} + test('Login', async () => { - // Login - await page.goto('http://192.168.1.62:20101/'); - 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'); + await login(page); }); -test('ทดสอบการสร้างนายจ้างบุคคลธรรมดาในกรณีที่ไม่กรอกช้อมูล', async () => { - await page.click('id=menu-icon-customer-management'); +test('ทดสอบการสร้างนายจ้างบุคคลธรรมดาในกรณีที่ไม่กรอกข้อมูล', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + await page.waitForTimeout(1000); await page.click('id=btn-add'); await page.click('id=add-customer-natural-person'); await page.click("//button[@type='submit']"); - // กำหนดค่าเพื่อตรวจสอบหลังเกิดการ Validation - const citizenNoError = await page.locator( - "(//div[@class='q-field__messages col'])[1]", - ); - const firstNameThError = await page.locator( - "(//div[@class='q-field__messages col'])[2]", - ); - const lastNameThError = await page.locator( - "(//div[@class='q-field__messages col'])[3]", - ); - const firstNameEngError = await page.locator( - "(//div[@class='q-field__messages col'])[4]", - ); - const lastNameEngError = await page.locator( - "(//div[@class='q-field__messages col'])[5]", - ); - const brithDateError = await page.locator( - "(//div[@class='q-field__messages col'])[6]", - ); + const expectedErrors = [ + { + locator: "(//div[@class='q-field__messages col'])[1]", + message: 'This field is required.', + }, + { + locator: "(//div[@class='q-field__messages col'])[1]", + message: 'This field is required.', + }, + { + locator: "(//div[@class='q-field__messages col'])[1]", + message: 'This field is required.', + }, + { + locator: "(//div[@class='q-field__messages col'])[1]", + message: 'This field is required.', + }, + { + locator: "(//div[@class='q-field__messages col'])[1]", + message: 'This field is required.', + }, + { + locator: "(//div[@class='q-field__messages col'])[1]", + message: 'Please select Birth Date.', + }, + ]; - // ตรวจสอบการเกิด Validation - expect(citizenNoError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้'); - expect(firstNameThError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้'); - expect(lastNameThError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้'); - expect(firstNameEngError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้'); - expect(lastNameEngError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้'); - expect(brithDateError).toHaveText('โปรดเลือกวันเดือนปีเกิด'); + for (const error of expectedErrors) { + const locator = page.locator(error.locator); + await expect(locator).toHaveText(error.message); + } console.log('ตรวจสอบการแจ้งเตือนทั้งหมดถูกต้อง'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; throw error; } await page.waitForTimeout(2000); @@ -73,6 +106,10 @@ test('ทดสอบการสร้างนายจ้างบุคค }); test('ทดสอบการสร้างนายจ้างบุคคลธรรมดาในกรณีที่กรอกข้อมูลเฉพาะส่วนเกี่ยวกับ', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { await page.click('id=btn-add'); await page.click('id=add-customer-natural-person'); @@ -85,19 +122,31 @@ test('ทดสอบการสร้างนายจ้างบุคค await page.fill("(//input[@id='form-input-first-name'])[3]", 'Mana'); await page.fill("(//input[@id='form-input-last-name'])[2]", 'Man'); await page.click('id=form-input-birth-date'); - await page.waitForSelector("//div[@id='2024-09-18']/div[1]"); - await page.click("//div[@id='2024-09-18']/div[1]"); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); + await page.waitForSelector("//div[text()='2002']"); + await page.click("//div[text()='2002']"); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[1]"); + await page.click("//div[text()='May']"); + await page.click("//div[@id='2002-05-02']/div[1]"); await page.click("//button[@type='submit']"); // รอการเกิด Dialog const textPopupError = await page.locator( - "//span[normalize-space(text())='กรอกข้อมูลไม่ครบ']", + "//span[normalize-space(text())='Incomplete Data Entry']", + ); + const detailPopupError = await page.locator( + "//span[normalize-space(text())='Incomplete data entry on Business, Address page']", + ); + + await expect(textPopupError).toHaveText('Incomplete Data Entry'); + await expect(detailPopupError).toHaveText( + 'Incomplete data entry on Business, Address page', ); - await expect(textPopupError).toHaveText('กรอกข้อมูลไม่ครบ'); console.log('ตรวจสอบการแจ้งเตือน Pop-up สำเร็จ'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; throw error; } await page.waitForSelector('id=btn-ok-dialog'); @@ -108,40 +157,54 @@ test('ทดสอบการสร้างนายจ้างบุคค }); test('ทดสอบการสร้างนายจ้างบุคคลธรรมดาในกรณีที่ไม่ได้กรอกข้อมูลส่วนข้อมูลธุรกิจ', async () => { + if (!isLoginSuccessful) { + await login(page); + } try { await page.click('id=btn-add'); await page.click('id=add-customer-natural-person'); await page.click("(//div[@aria-selected='false'])[2]"); await page.click("//button[@type='submit']"); - // กำหนดค่าเพื่อตรวจสอบการแจ้งเตือน - const businessTypeError = await page.locator( - "(//div[@class='q-field__messages col']//div)[1]", - ); - const businessTypeEngError = await page.locator( - "(//div[@class='q-field__messages col']//div)[2]", - ); - const jobPositionError = await page.locator( - "(//div[@class='q-field__messages col']//div)[3]", - ); - const jobPositionEnError = await page.locator( - "(//div[@class='q-field__messages col']//div)[4]", - ); + const expectedErrors = [ + { + locator: "//div[@class='q-field__messages col']//div)[1]", + message: 'This field is required.', + }, + { + locator: "//div[@class='q-field__messages col']//div)[2]", + message: 'This field is required.', + }, + { + locator: "//div[@class='q-field__messages col']//div)[3]", + message: 'This field is required.', + }, + { + locator: "//div[@class='q-field__messages col']//div)[4]", + message: 'This field is required.', + }, + ]; + + for (const error of expectedErrors) { + const locator = page.locator(error.locator); + await expect(locator).toHaveText(error.message); + } - // ตรวจสอบการแจ้งเตือน - expect(businessTypeError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้'); - expect(businessTypeEngError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้'); - expect(jobPositionError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้'); - expect(jobPositionEnError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้'); console.log('ตรวจสอบการแจ้งเตือนสำเร็จ'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; } await page.waitForTimeout(2000); await page.click('id=btn-form-close'); }); test('ทดสอบการสร้างนายจ้างบุคคลธรรมดาในกรณีที่กรอกข้อมูลเฉพาะส่วนข้อมูลธุรกิจ', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { await page.click('id=btn-add'); await page.click('id=add-customer-natural-person'); @@ -156,18 +219,26 @@ test('ทดสอบการสร้างนายจ้างบุคค await page.fill("(//input[@id='form-input-pay-rate'])[1]", 'วันจ่ายเงิน'); await page.fill("(//input[@id='form-input-pay-rate'])[2]", 'Pay Day'); await page.fill("(//input[@id='form-input-pay-rate'])[3]", '2000'); - await page.fill("//input[@aria-label='อัตราค่าจ้าง/วัน (Text)']", '2000'); + await page.fill("//input[@aria-label='Pay Rate (Text)']", '2000'); await page.click("//button[@type='submit']"); - // กำหนดค่าการแจ้งเตือน - const titleError = await page.locator( - "//span[normalize-space(text())='กรอกข้อมูลไม่ครบ']", + // รอการเกิด Dialog + const textPopupError = await page.locator( + "//span[normalize-space(text())='Incomplete Data Entry']", + ); + const detailPopupError = await page.locator( + "//span[normalize-space(text())='Incomplete data entry on About, Address page']", ); - expect(titleError).toHaveText('กรอกข้อมูลไม่ครบ'); + await expect(textPopupError).toHaveText('Incomplete Data Entry'); + await expect(detailPopupError).toHaveText( + 'Incomplete data entry on About, Address page', + ); console.log('การแจ้งเตือนถูกต้อง'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; } await page.waitForSelector('id=btn-ok-dialog'); await page.click('id=btn-ok-dialog'); @@ -177,43 +248,78 @@ test('ทดสอบการสร้างนายจ้างบุคค }); test('ทดสอบการสร้างนายจ้างบุคคลธรรมดาในกรณีที่ไม่กรอกข้อมูลส่วนที่อยู่นายจ้าง', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { await page.click('id=btn-add'); await page.click('id=add-customer-natural-person'); await page.click("(//div[@aria-selected='false'])[3]"); await page.click("//button[@type='submit']"); - // กำหนดค่าการแจ้งเตือน - const addressIdentificationError = await page.locator( - "(//div[@class='q-field__messages col']//div)[1]", - ); - const addressNoError = await page.locator( - "(//div[@class='q-field__messages col']//div)[2]", - ); - const provinceError = await page.locator( - "(//div[@class='q-field__messages col']//div)[3]", - ); - const districtError = await page.locator( - "(//div[@class='q-field__messages col']//div)[4]", - ); - const subdistrictError = await page.locator( - "(//div[@class='q-field__messages col']//div)[5]", - ); - const addressNoEngError = await page.locator( - "(//div[@class='q-field__messages col']//div)[6]", - ); + const expectedErrors = [ + { + locator: "(//div[@class='q-field__messages col']//div)[1]", + message: 'This field is required.', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[2]", + message: 'Please select Province.', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[3]", + message: 'Please select District.', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[4]", + message: 'Please select Sub-district.', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[5]", + message: 'This field is required.', + }, + ]; - // ตรวจสอบการแจ้งเตือน - expect(addressIdentificationError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้'); - expect(addressNoError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้'); - expect(provinceError).toHaveText('โปรดเลือกจังหวัด'); - expect(districtError).toHaveText('โปรดเลือกอำเภอ'); - expect(subdistrictError).toHaveText('โปรดเลือกตำบล'); - expect(addressNoEngError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้'); + for (const error of expectedErrors) { + const locator = page.locator(error.locator); + await expect(locator).toHaveText(error.message); + } console.log('ตรวจสอบการแจ้งเตือนสำเร็จ'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForTimeout(2000); + await page.click('id=btn-form-close'); +}); + +test('ทดสอบการสร้างนายจ้างบุคคลธรรมดาในกรณีที่กรอกข้อมูลรหัสประจำบ้านไม่ครบ 11 หลัก', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click('id=btn-add'); + await page.click('id=add-customer-natural-person'); + await page.click("(//div[@aria-selected='false'])[3]"); + + await page.fill("(//input[@id='form-input-address'])[1]", '111'); + await page.click("//button[@type='submit']"); + + // กำหนดค่าการแจ้งเตือน + const codeAddress = await page.locator( + "(//div[@class='q-field__messages col']//div)[1]", + ); + // ตรวจสอบการแจ้งเตือน + expect(codeAddress).toHaveText('Invalid value. Please enter 11 character'); + + console.log('ตรวจสอบการแจ้งเตือนสำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; throw error; } await page.waitForTimeout(2000); @@ -221,7 +327,12 @@ test('ทดสอบการสร้างนายจ้างบุคค }); test('ทดสอบการสร้างนายจ้างบุคคลธรรมดาในกรณีที่กรอกข้อมูลเฉพาะส่วนที่อยู่นายจ้าง', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + await page.waitForTimeout(1000); await page.click('id=btn-add'); await page.click('id=add-customer-natural-person'); await page.click("(//div[@aria-selected='false'])[3]"); @@ -239,16 +350,22 @@ test('ทดสอบการสร้างนายจ้างบุคค await page.fill('id=form-input-address-en', '800'); await page.click("//button[@type='submit']"); - // กำหนดค่าการแจ้งเตือน - const popupError = await page.locator( - "//span[normalize-space(text())='กรอกข้อมูลไม่ครบ']", + // รอการเกิด Dialog + const textPopupError = await page.locator( + "//span[normalize-space(text())='Incomplete Data Entry']", + ); + const detailPopupError = await page.locator( + "//span[normalize-space(text())='Incomplete data entry on About, Business page']", ); - // ตรวจสอบการแจ้งเตือน - expect(popupError).toHaveText('กรอกข้อมูลไม่ครบ'); + await expect(textPopupError).toHaveText('Incomplete Data Entry'); + await expect(detailPopupError).toHaveText( + 'Incomplete data entry on About, Business page', + ); console.log('ตรวจสอบการแจ้งเตือนถูกต้อง'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; throw error; } await page.waitForSelector('id=btn-ok-dialog'); @@ -259,21 +376,32 @@ test('ทดสอบการสร้างนายจ้างบุคค }); test('ทดสอบการสร้างนายจ้างบุคคลธรรมดาในกรณีที่ไม่กรอกข้อมูลส่วนข้อมูลติดต่อ', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { await page.click('id=btn-add'); await page.click('id=add-customer-natural-person'); await page.click("(//div[@aria-selected='false'])[4]"); await page.click("//button[@type='submit']"); - // กำหนดค่าการแจ้งเตือน - const popupError = await page.locator( - "//span[normalize-space(text())='กรอกข้อมูลไม่ครบ']", + + // รอการเกิด Dialog + const textPopupError = await page.locator( + "//span[normalize-space(text())='Incomplete Data Entry']", + ); + const detailPopupError = await page.locator( + "//span[normalize-space(text())='Incomplete data entry on About, Business, Address page']", ); - // ตรวจสอบการแจ้งเตือน - expect(popupError).toHaveText('กรอกข้อมูลไม่ครบ'); + await expect(textPopupError).toHaveText('Incomplete Data Entry'); + await expect(detailPopupError).toHaveText( + 'Incomplete data entry on About, Business, Address page', + ); console.log('ตรวจสอบการแจ้งเตือนถูกต้อง'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; throw error; } await page.waitForSelector('id=btn-ok-dialog'); @@ -284,6 +412,10 @@ test('ทดสอบการสร้างนายจ้างบุคค }); test('ทดสอบการสร้างนายจ้างบุคคลธรรมดาในกรณีที่กรอกข้อมูลเฉพาะส่วนข้อมูลติดต่อ', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { await page.click('id=btn-add'); await page.click('id=add-customer-natural-person'); @@ -293,16 +425,22 @@ test('ทดสอบการสร้างนายจ้างบุคค await page.fill("(//input[@id='form-input-telephone'])[1]", '0882622426'); await page.fill("(//input[@id='form-input-telephone'])[2]", '022222002'); await page.click("//button[@type='submit']"); - // กำหนดค่าการแจ้งเตือน - const popupError = await page.locator( - "//span[normalize-space(text())='กรอกข้อมูลไม่ครบ']", + // รอการเกิด Dialog + const textPopupError = await page.locator( + "//span[normalize-space(text())='Incomplete Data Entry']", + ); + const detailPopupError = await page.locator( + "//span[normalize-space(text())='Incomplete data entry on About, Business, Address page']", ); - // ตรวจสอบการแจ้งเตือน - expect(popupError).toHaveText('กรอกข้อมูลไม่ครบ'); + await expect(textPopupError).toHaveText('Incomplete Data Entry'); + await expect(detailPopupError).toHaveText( + 'Incomplete data entry on About, Business, Address page', + ); console.log('ตรวจสอบการแจ้งเตือนถูกต้อง'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; throw error; } await page.waitForSelector('id=btn-ok-dialog'); @@ -313,22 +451,27 @@ test('ทดสอบการสร้างนายจ้างบุคค }); test('ทดสอบการสร้างนายจ้างบุคคลธรรมดาในกรณีที่กรอกรูปแบบอีเมลส่วนข้อมูลติดต่อไม่ถูกต้อง', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { await page.click('id=btn-add'); await page.click('id=add-customer-natural-person'); await page.click("(//div[@aria-selected='false'])[4]"); await page.fill('id=form-input-mail', 'art'); await page.click("//button[@type='submit']"); - // กำหนดค่าการแจ้งเตือน - const emailFomatError = await page.locator( - "//div[normalize-space(text())='ข้อมูลไม่ถูกต้อง']", + // รอการเกิด Dialog + const emailError = await page.locator( + "//div[@class='q-field__messages col']//div[1]", ); - // ตรวจสอบการแจ้งเตือน - expect(emailFomatError).toHaveText('ข้อมูลไม่ถูกต้อง'); + await expect(emailError).toHaveText('Invalid value.'); + console.log('ตรวจสอบการแจ้งเตือนรูปแบบอีเมลไม่ถูกต้อง : Success '); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; throw error; } await page.waitForTimeout(2000); @@ -336,22 +479,31 @@ test('ทดสอบการสร้างนายจ้างบุคค }); test('ทดสอบการสร้างนายจ้างบุคคลธรรมดาในกรณีที่ไม่อัปโหลดข้อมูลส่วนเอกสาร', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { await page.click('id=btn-add'); await page.click('id=add-customer-natural-person'); await page.click("(//div[@aria-selected='false'])[5]"); await page.click("//button[@type='submit']"); - - // กำหนดค่าแจ้งเตือน - const popupError = await page.locator( - "//span[normalize-space(text())='กรอกข้อมูลไม่ครบ']", + // รอการเกิด Dialog + const textPopupError = await page.locator( + "//span[normalize-space(text())='Incomplete Data Entry']", + ); + const detailPopupError = await page.locator( + "//span[normalize-space(text())='Incomplete data entry on About, Business, Address page']", ); - // ตรวจสอบการแจ้งเตือน - expect(popupError).toHaveText('กรอกข้อมูลไม่ครบ'); + await expect(textPopupError).toHaveText('Incomplete Data Entry'); + await expect(detailPopupError).toHaveText( + 'Incomplete data entry on About, Business, Address page', + ); console.log('ตรวจสอบการแจ้งเตือนถูกต้อง'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; throw error; } await page.waitForSelector('id=btn-ok-dialog'); diff --git a/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_002_CreateNaturalperosonfail.spec.ts b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_002_CreateNaturalperosonfail.spec.ts new file mode 100644 index 00000000..3bc43835 --- /dev/null +++ b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_002_CreateNaturalperosonfail.spec.ts @@ -0,0 +1,545 @@ +import { test, expect, Page } from '@playwright/test'; +import { strictEqual } from 'assert'; +import { formToJSON } from 'axios'; +import { exec } from 'child_process'; +import e from 'express'; +import { ToastHeader } from 'react-bootstrap'; +import { toHandlerKey } from 'vue'; + +let page: Page; +let isLoginSuccessful = false; + +test.beforeAll(async ({ browser }) => { + page = await browser.newPage(); +}); + +test.afterAll(async () => { + if (page !== undefined) { + await page.close(); + } +}); + +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + // เข้าสู่เมนูลูกค้า + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-customer'); + await page.click('id=sub-menu-customer'); + + isLoginSuccessful = true; + console.log('Login สำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการ Login', error); + isLoginSuccessful = false; + } +} + +test('Login', async () => { + await login(page); +}); + +test('ทดสอบการสร้างนายจ้างบุคคลธรรมดาในกรณีที่ไม่กรอกข้อมูล', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.waitForTimeout(1000); + await page.click('id=btn-add'); + await page.click('id=add-customer-natural-person'); + await page.click("//button[@type='submit']"); + + const expectedErrors = [ + { + locator: "(//div[@class='q-field__messages col'])[1]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + { + locator: "(//div[@class='q-field__messages col'])[2]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + { + locator: "(//div[@class='q-field__messages col'])[3]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + { + locator: "(//div[@class='q-field__messages col'])[4]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + { + locator: "(//div[@class='q-field__messages col'])[5]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + { + locator: "(//div[@class='q-field__messages col'])[6]", + message: 'โปรดเลือกวันเดือนปีเกิด', + }, + ]; + + for (const error of expectedErrors) { + const locator = page.locator(error.locator); + await expect(locator).toHaveText(error.message); + } + + console.log('ตรวจสอบการแจ้งเตือนทั้งหมดถูกต้อง'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForTimeout(2000); + await page.click('id=btn-form-close'); +}); + +test('ทดสอบการสร้างนายจ้างบุคคลธรรมดาในกรณีที่กรอกข้อมูลเฉพาะส่วนเกี่ยวกับ', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click('id=btn-add'); + await page.click('id=add-customer-natural-person'); + await page.fill('id=input-legal-person-no', '1222202282262'); + await page.click('id=form-select-prefix-name'); + await page.waitForSelector('id=form-select-prefix-name_0'); + await page.click('id=form-select-prefix-name_0'); + await page.fill("(//input[@id='form-input-first-name'])[1]", 'มานะ'); + await page.fill("(//input[@id='form-input-last-name'])[1]", 'แมน'); + await page.fill("(//input[@id='form-input-first-name'])[3]", 'Mana'); + await page.fill("(//input[@id='form-input-last-name'])[2]", 'Man'); + await page.click('id=form-input-birth-date'); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); + await page.waitForSelector("//div[text()='2002']"); + await page.click("//div[text()='2002']"); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[1]"); + await page.click("//div[text()='พ.ค.']"); + await page.click("//div[@id='2002-05-02']/div[1]"); + await page.click("//button[@type='submit']"); + + // รอการเกิด Dialog + const textPopupError = await page.locator( + "//span[normalize-space(text())='กรอกข้อมูลไม่ครบ']", + ); + const detailPopupError = await page.locator( + "//span[normalize-space(text())='กรอกข้อมูลไม่ครบในหน้า ข้อมูลธุรกิจ, ที่อยู่นายจ้าง']", + ); + + await expect(textPopupError).toHaveText('กรอกข้อมูลไม่ครบ'); + await expect(detailPopupError).toHaveText( + 'กรอกข้อมูลไม่ครบในหน้า ข้อมูลธุรกิจ, ที่อยู่นายจ้าง', + ); + + console.log('ตรวจสอบการแจ้งเตือน Pop-up สำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForSelector('id=btn-ok-dialog'); + await page.click('id=btn-ok-dialog'); + + await page.waitForTimeout(2000); + await page.click('id=btn-form-close'); +}); + +test('ทดสอบการสร้างนายจ้างบุคคลธรรมดาในกรณีที่ไม่ได้กรอกข้อมูลส่วนข้อมูลธุรกิจ', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + await page.click('id=btn-add'); + await page.click('id=add-customer-natural-person'); + await page.click("(//div[@aria-selected='false'])[2]"); + await page.click("//button[@type='submit']"); + + const expectedErrors = [ + { + locator: "(//div[@class='q-field__messages col']//div)[1]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[2]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[3]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[4]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + ]; + + for (const error of expectedErrors) { + const locator = page.locator(error.locator); + await expect(locator).toHaveText(error.message); + } + + console.log('ตรวจสอบการแจ้งเตือนสำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForTimeout(2000); + await page.click('id=btn-form-close'); +}); + +test('ทดสอบการสร้างนายจ้างบุคคลธรรมดาในกรณีที่กรอกข้อมูลเฉพาะส่วนข้อมูลธุรกิจ', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click('id=btn-add'); + await page.click('id=add-customer-natural-person'); + await page.click("(//div[@aria-selected='false'])[2]"); + await page.click('id=form-select-business-type'); + await page.waitForSelector('id=form-select-business-type_1'); + await page.click('id=form-select-business-type_1'); + await page.click('id=form-select-job-position'); + await page.waitForSelector('id=form-select-job-position_1'); + await page.click('id=form-select-job-position_1'); + await page.fill('id=form-input-job-description', 'รายละเอียด'); + await page.fill("(//input[@id='form-input-pay-rate'])[1]", 'วันจ่ายเงิน'); + await page.fill("(//input[@id='form-input-pay-rate'])[2]", 'Pay Day'); + await page.fill("(//input[@id='form-input-pay-rate'])[3]", '2000'); + await page.fill("//input[@aria-label='อัตราค่าจ้าง/วัน (Text)']", '2000'); + await page.click("//button[@type='submit']"); + + // รอการเกิด Dialog + const textPopupError = await page.locator( + "//span[normalize-space(text())='กรอกข้อมูลไม่ครบ']", + ); + + const detailPopupError = await page.locator( + "//span[normalize-space(text())='กรอกข้อมูลไม่ครบในหน้า เกี่ยวกับ, ที่อยู่นายจ้าง']", + ); + + await expect(textPopupError).toHaveText('กรอกข้อมูลไม่ครบ'); + await expect(detailPopupError).toHaveText( + 'กรอกข้อมูลไม่ครบในหน้า เกี่ยวกับ, ที่อยู่นายจ้าง', + ); + console.log('การแจ้งเตือนถูกต้อง'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForSelector('id=btn-ok-dialog'); + await page.click('id=btn-ok-dialog'); + + await page.waitForTimeout(2000); + await page.click('id=btn-form-close'); +}); + +test('ทดสอบการสร้างนายจ้างบุคคลธรรมดาในกรณีที่ไม่กรอกข้อมูลส่วนที่อยู่นายจ้าง', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click('id=btn-add'); + await page.click('id=add-customer-natural-person'); + await page.click("(//div[@aria-selected='false'])[3]"); + await page.click("//button[@type='submit']"); + + const expectedErrors = [ + { + locator: "(//div[@class='q-field__messages col']//div)[1]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[2]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[3]", + message: 'โปรดเลือกจังหวัด', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[4]", + message: 'โปรดเลือกเขต/อำเภอ', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[5]", + message: 'โปรดเลือกแขวง/ตำบล', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[6]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + ]; + + for (const error of expectedErrors) { + const locator = page.locator(error.locator); + await expect(locator).toHaveText(error.message); + } + + console.log('ตรวจสอบการแจ้งเตือนสำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForTimeout(2000); + await page.click('id=btn-form-close'); +}); + +test('ทดสอบการสร้างนายจ้างบุคคลธรรมดาในกรณีที่กรอกข้อมูลรหัสประจำบ้านไม่ครบ 11 หลัก', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click('id=btn-add'); + await page.click('id=add-customer-natural-person'); + await page.click("(//div[@aria-selected='false'])[3]"); + + await page.fill("(//input[@id='form-input-address'])[1]", '111'); + await page.click("//button[@type='submit']"); + + // กำหนดค่าการแจ้งเตือน + const codeAddress = await page.locator( + "(//div[@class='q-field__messages col']//div)[1]", + ); + // ตรวจสอบการแจ้งเตือน + expect(codeAddress).toHaveText('ข้อมูลไม่ถูกต้อง กรุณากรอกให้ครบ 11 หลัก'); + + console.log('ตรวจสอบการแจ้งเตือนสำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForTimeout(2000); + await page.click('id=btn-form-close'); +}); + +test('ทดสอบการสร้างนายจ้างบุคคลธรรมดาในกรณีที่กรอกข้อมูลเฉพาะส่วนที่อยู่นายจ้าง', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.waitForTimeout(1000); + await page.click('id=btn-add'); + await page.click('id=add-customer-natural-person'); + await page.click("(//div[@aria-selected='false'])[3]"); + await page.fill("(//input[@id='form-input-address'])[1]", '22282202202'); + await page.fill('id=form-input-address-no', '800'); + await page.click('id=form-select-province'); + await page.waitForSelector('id=form-select-province_4'); + await page.click('id=form-select-province_4'); + await page.click('id=form-select-district'); + await page.waitForSelector('id=form-select-district_8'); + await page.click('id=form-select-district_8'); + await page.click('id=form-select-sub-district'); + await page.waitForSelector('id=form-select-sub-district_7'); + await page.click('id=form-select-sub-district_7'); + await page.fill('id=form-input-address-en', '800'); + await page.click("//button[@type='submit']"); + + // รอการเกิด Dialog + const textPopupError = await page.locator( + "//span[normalize-space(text())='กรอกข้อมูลไม่ครบ']", + ); + + const detailPopupError = await page.locator( + "//span[normalize-space(text())='กรอกข้อมูลไม่ครบในหน้า เกี่ยวกับ, ข้อมูลธุรกิจ']", + ); + + await expect(textPopupError).toHaveText('กรอกข้อมูลไม่ครบ'); + await expect(detailPopupError).toHaveText( + 'กรอกข้อมูลไม่ครบในหน้า เกี่ยวกับ, ข้อมูลธุรกิจ', + ); + console.log('ตรวจสอบการแจ้งเตือนถูกต้อง'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForSelector('id=btn-ok-dialog'); + await page.click('id=btn-ok-dialog'); + + await page.waitForTimeout(2000); + await page.click('id=btn-form-close'); +}); + +test('ทดสอบการสร้างนายจ้างบุคคลธรรมดาในกรณีที่ไม่กรอกข้อมูลส่วนข้อมูลติดต่อ', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click('id=btn-add'); + await page.click('id=add-customer-natural-person'); + await page.click("(//div[@aria-selected='false'])[4]"); + await page.click("//button[@type='submit']"); + // รอการเกิด Dialog + const textPopupError = await page.locator( + "//span[normalize-space(text())='กรอกข้อมูลไม่ครบ']", + ); + + const detailPopupError = await page.locator( + "//span[normalize-space(text())='กรอกข้อมูลไม่ครบในหน้า เกี่ยวกับ, ข้อมูลธุรกิจ, ที่อยู่นายจ้าง']", + ); + + await expect(textPopupError).toHaveText('กรอกข้อมูลไม่ครบ'); + await expect(detailPopupError).toHaveText( + 'กรอกข้อมูลไม่ครบในหน้า เกี่ยวกับ, ข้อมูลธุรกิจ, ที่อยู่นายจ้าง', + ); + console.log('ตรวจสอบการแจ้งเตือนถูกต้อง'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForSelector('id=btn-ok-dialog'); + await page.click('id=btn-ok-dialog'); + + await page.waitForTimeout(2000); + await page.click('id=btn-form-close'); +}); + +test('ทดสอบการสร้างนายจ้างบุคคลธรรมดาในกรณีที่กรอกข้อมูลเฉพาะส่วนข้อมูลติดต่อ', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click('id=btn-add'); + await page.click('id=add-customer-natural-person'); + await page.click("(//div[@aria-selected='false'])[4]"); + await page.fill('id=form-input-contact-name', 'คุณอาท'); + await page.fill('id=form-input-mail', 'art@mail.com'); + await page.fill("(//input[@id='form-input-telephone'])[1]", '0882622426'); + await page.fill("(//input[@id='form-input-telephone'])[2]", '022222002'); + await page.click("//button[@type='submit']"); + // รอการเกิด Dialog + const textPopupError = await page.locator( + "//span[normalize-space(text())='กรอกข้อมูลไม่ครบ']", + ); + + const detailPopupError = await page.locator( + "//span[normalize-space(text())='กรอกข้อมูลไม่ครบในหน้า เกี่ยวกับ, ข้อมูลธุรกิจ, ที่อยู่นายจ้าง']", + ); + + await expect(textPopupError).toHaveText('กรอกข้อมูลไม่ครบ'); + await expect(detailPopupError).toHaveText( + 'กรอกข้อมูลไม่ครบในหน้า เกี่ยวกับ, ข้อมูลธุรกิจ, ที่อยู่นายจ้าง', + ); + console.log('ตรวจสอบการแจ้งเตือนถูกต้อง'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForSelector('id=btn-ok-dialog'); + await page.click('id=btn-ok-dialog'); + + await page.waitForTimeout(2000); + await page.click('id=btn-form-close'); +}); + +test('ทดสอบการสร้างนายจ้างบุคคลธรรมดาในกรณีที่กรอกรูปแบบอีเมลส่วนข้อมูลติดต่อไม่ถูกต้อง', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click('id=btn-add'); + await page.click('id=add-customer-natural-person'); + await page.click("(//div[@aria-selected='false'])[4]"); + await page.fill('id=form-input-mail', 'art'); + await page.click("//button[@type='submit']"); + // กำหนดค่าการแจ้งเตือน + const emailFomatError = await page.locator( + "//div[normalize-space(text())='ข้อมูลไม่ถูกต้อง']", + ); + + // ตรวจสอบการแจ้งเตือน + expect(emailFomatError).toHaveText('ข้อมูลไม่ถูกต้อง'); + console.log('ตรวจสอบการแจ้งเตือนรูปแบบอีเมลไม่ถูกต้อง : Success '); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForTimeout(2000); + await page.click('id=btn-form-close'); +}); + +test('ทดสอบการสร้างนายจ้างบุคคลธรรมดาในกรณีที่ไม่อัปโหลดข้อมูลส่วนเอกสาร', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click('id=btn-add'); + await page.click('id=add-customer-natural-person'); + await page.click("(//div[@aria-selected='false'])[5]"); + await page.click("//button[@type='submit']"); + + // รอการเกิด Dialog + const textPopupError = await page.locator( + "//span[normalize-space(text())='กรอกข้อมูลไม่ครบ']", + ); + + const detailPopupError = await page.locator( + "//span[normalize-space(text())='กรอกข้อมูลไม่ครบในหน้า เกี่ยวกับ, ข้อมูลธุรกิจ, ที่อยู่นายจ้าง']", + ); + + await expect(textPopupError).toHaveText('กรอกข้อมูลไม่ครบ'); + await expect(detailPopupError).toHaveText( + 'กรอกข้อมูลไม่ครบในหน้า เกี่ยวกับ, ข้อมูลธุรกิจ, ที่อยู่นายจ้าง', + ); + console.log('ตรวจสอบการแจ้งเตือนถูกต้อง'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForSelector('id=btn-ok-dialog'); + await page.click('id=btn-ok-dialog'); + + await page.waitForTimeout(2000); + await page.click('id=btn-form-close'); +}); + +// test('ทดสอบการสร้างนายจ้างบุคคลธรรมดาในกรณีที่อัปโหลดเอกสารเฉพาะส่วนเอกสาร', async () => { +// await page.click('id=menu-icon-customer-management'); +// try { +// await page.click('id=btn-add'); +// await page.click('id=add-customer-natural-person'); +// await page.click("(//div[@aria-selected='false'])[5]"); +// await page.click("//button[@type='submit']"); + +// // กำหนดค่าแจ้งเตือน +// const popupError = await page.locator( +// "//span[normalize-space(text())='กรอกข้อมูลไม่ครบ']", +// ); + +// // ตรวจสอบการแจ้งเตือน +// expect(popupError).toHaveText('กรอกข้อมูลไม่ครบ'); +// console.log('ตรวจสอบการแจ้งเตือนถูกต้อง'); +// } catch (error) { +// console.error('เกิดข้อผิดพลาดในการทดสอบ', error); +// throw error; +// } +// await page.waitForSelector('id=btn-ok-dialog'); +// await page.click('id=btn-ok-dialog'); + +// await page.waitForTimeout(2000); +// await page.click('id=btn-form-close'); +// }); diff --git a/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_003_DetailNaturalperson.spec.ts b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_003_DetailNaturalperson.spec.ts new file mode 100644 index 00000000..e7a8d53a --- /dev/null +++ b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_003_DetailNaturalperson.spec.ts @@ -0,0 +1,118 @@ +import { test, expect, Page } from '@playwright/test'; +import { strictEqual } from 'assert'; + +let page: Page; +let isLoginSuccessful = false; + +test.beforeAll(async ({ browser }) => { + page = await browser.newPage(); +}); + +test.afterAll(async () => { + if (page !== undefined) { + await page.close(); + } +}); + +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + // เข้าสู่เมนูลูกค้า + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-customer'); + await page.click('id=sub-menu-customer'); + await page.waitForTimeout(2000); + + isLoginSuccessful = true; + console.log('Login สำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการ Login', error); + isLoginSuccessful = false; + } +} + +test('Login', async () => { + await login(page); +}); + +test('ตรวจสอบดูรายละเอียดบุคคลธรรมดาโดยการคลิกไอคอนดวงตา', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click("(//button[@id='btn-eye-ยศพัฒน์'])[2]"); + await page.waitForTimeout(2000); + + const fullName = page.locator("//span[text()='ยศพัฒน์ ธนากานต์']"); + + await expect(fullName).toHaveText('ยศพัฒน์ ธนากานต์'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForSelector('id=btn-info-close'); + await page.click('id=btn-info-close'); +}); + +test('ตรวจสอบดูรายละเอียดบุคคลธรรมดาผ่านเมนูย่อยจุดสามจุด', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click('id=btn-kebab-action-ยศพัฒน์'); + await page.waitForSelector('id=btn-kebab-view-detail-ยศพัฒน์'); + await page.click('id=btn-kebab-view-detail-ยศพัฒน์'); + await page.waitForTimeout(2000); + + const fullName = page.locator("//span[text()='ยศพัฒน์ ธนากานต์']"); + + await expect(fullName).toHaveText('ยศพัฒน์ ธนากานต์'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForSelector('id=btn-info-close'); + await page.click('id=btn-info-close'); +}); + +test('ตรวจสอบดูรายละเอียดบุคคลธรรมดาในรูปแบบการ์ด', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.waitForSelector("//button[@aria-pressed='false']"); + await page.click("//button[@aria-pressed='false']"); + + const fullName = await page.locator( + "//b[normalize-space(text())='ยศพัฒน์ ธนากานต์']", + ); + + const citizenId = await page.locator( + "//span[normalize-space(text())='1524428220420']", + ); + const typeBussiness = await page.locator( + "(//span[text()='ประเภทกิจการ']/following-sibling::span)[1]", + ); + + await expect(fullName).toHaveText('ยศพัฒน์ ธนากานต์'); + await expect(citizenId).toHaveText('1524428220420'); + await expect(typeBussiness).toHaveText('กรรมกร'); + } catch (error) { + console.log('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } +}); diff --git a/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_004_EditNaturalperson.spec.ts b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_004_EditNaturalperson.spec.ts new file mode 100644 index 00000000..8426bc3b --- /dev/null +++ b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_004_EditNaturalperson.spec.ts @@ -0,0 +1,78 @@ +import { test, expect, Page } from '@playwright/test'; +import { strictEqual } from 'assert'; + +let page: Page; +let isLoginSuccessful = false; + +test.beforeAll(async ({ browser }) => { + page = await browser.newPage(); +}); + +test.afterAll(async () => { + if (page !== undefined) { + await page.close(); + } +}); + +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + // เข้าสู่เมนูลูกค้า + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-customer'); + await page.click('id=sub-menu-customer'); + await page.waitForTimeout(2000); + + isLoginSuccessful = true; + console.log('Login สำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการ Login', error); + isLoginSuccessful = false; + } +} + +test('Login', async () => { + await login(page); +}); + +test('Edit Naturalperson', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click('id=btn-kebab-action-สุรวัฒน์'); + await page.waitForSelector('id=btn-kebab-edit-สุรวัฒน์'); + await page.click('id=btn-kebab-edit-สุรวัฒน์'); + + // แก้ไขนายจ้างบุคคลธรรมดา + await page.fill("(//input[@id='info-input-first-name'])[1]", 'ธนพล'); + await page.fill("(//input[@id='info-input-last-name'])[1]", 'รุ่งเรือง'); + await page.fill("(//input[@id='info-input-first-name'])[3]", 'Thanapol'); + await page.fill("(//input[@id='info-input-last-name'])[2]", 'Rungreung'); + await page.waitForSelector("//button[@type='submit']"); + await page.click("//button[@type='submit']"); + await page.waitForTimeout(1000); + await page.waitForSelector('id=btn-info-close'); + await page.click('id=btn-info-close'); + const nameEditCheck = await page.locator( + "//tr[contains(.,'นาย ธนพล รุ่งเรือง') and contains(.,'--')]", + ); + + await expect(nameEditCheck).toContainText('ธนพล รุ่งเรือง'); + await expect(nameEditCheck).toContainText('--'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForTimeout(2000); +}); diff --git a/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_005_DeleteNaturalperson.spec.ts b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_005_DeleteNaturalperson.spec.ts new file mode 100644 index 00000000..fea39e5e --- /dev/null +++ b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_005_DeleteNaturalperson.spec.ts @@ -0,0 +1,72 @@ +import { test, expect, Page } from '@playwright/test'; +import { strictEqual } from 'assert'; +import { log } from 'console'; +import { it } from 'node:test'; + +let page: Page; +let isLoginSuccessful = false; + +test.beforeAll(async ({ browser }) => { + page = await browser.newPage(); +}); + +test.afterAll(async () => { + if (page !== undefined) { + await page.close(); + } +}); + +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + // เข้าสู่เมนูลูกค้า + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-customer'); + await page.click('id=sub-menu-customer'); + await page.waitForTimeout(2000); + + isLoginSuccessful = true; + console.log('Login สำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการ Login', error); + isLoginSuccessful = false; + } +} + +test('Login', async () => { + await login(page); +}); + +test('Delete Naturalperson', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click('id=btn-kebab-action-ธนพล'); + await page.waitForSelector('id=btn-kebab-delete-ธนพล'); + await page.click('id=btn-kebab-delete-ธนพล'); + await page.waitForSelector('id=btn-ok-dialog'); + await page.click('id=btn-ok-dialog'); + await page.waitForTimeout(2000); + const itemLocator = await page.locator( + "//tr[contains(.,'นาย สุรวัฒน์ รุ่งเรือง') and contains (.,'--')]", + ); + + await expect(itemLocator).toBeHidden(); + console.log('ระบบทำการลบนายจ้างบุคคลธรรมดาแล้ว '); + } catch (error) { + console.log('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForTimeout(2000); +}); diff --git a/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_006_StatusNaturalperson.spec.ts b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_006_StatusNaturalperson.spec.ts new file mode 100644 index 00000000..cb28ee2c --- /dev/null +++ b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_006_StatusNaturalperson.spec.ts @@ -0,0 +1,125 @@ +import { test, expect, Page } from '@playwright/test'; +import { strictEqual } from 'assert'; + +let page: Page; +let isLoginSuccessful = false; + +test.beforeAll(async ({ browser }) => { + page = await browser.newPage(); +}); + +test.afterAll(async () => { + if (page !== undefined) { + await page.close(); + } +}); + +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + // เข้าสู่เมนูลูกค้า + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-customer'); + await page.click('id=sub-menu-customer'); + + await page.waitForTimeout(2000); + + isLoginSuccessful = true; + console.log('Login สำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการ Login', error); + isLoginSuccessful = false; + } +} + +test('Login', async () => { + await login(page); +}); + +test('ปิดสถานะนายจ้างบุคคลธรรมดา', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click('id=btn-kebab-action-ยศพัฒน์'); + + await page.click('id=btn-kebab-status-ยศพัฒน์', { + force: true, + }); + await page.click('id=btn-ok-dialog'); + console.log('เปลี่ยนสถานะสำเร็จ'); + + // รอ Update + await page.waitForTimeout(2000); + console.log('สถานะถูกเปลี่ยนแล้ว'); + + // ตรวจสอบสีของแถวหลังจากทำการเปลี่ยนสถานะ + const rowLocator = page.locator( + "//tr[contains(.,'นาย ยศพัฒน์ ธนากานต์')and contains (.,'--')]", + ); + const backgroundColor = await rowLocator.evaluate( + (el) => window.getComputedStyle(el).backgroundColor, + ); + + // กำหนดสีหลัเปลี่ยนสถานะการใช้งาน + const expectedColor = 'rgba(0, 0, 0, 0)'; + + // ตรวจสอบสีที่เปลี่ยนไป + expect(backgroundColor.trim()).toBe(expectedColor); + console.log('สีของแถวถูกเปลี่ยนเป็นสีเทาอ่อน'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForTimeout(2000); +}); + +test('เปิดสถานะนายจ้างบุคคลธรรมดา', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click('id=btn-kebab-action-ยศพัฒน์'); + + await page.click('id=btn-kebab-status-ยศพัฒน์', { + force: true, + }); + await page.click('id=btn-ok-dialog'); + console.log('เปลี่ยนสถานะสำเร็จ'); + + // รอ Update + await page.waitForTimeout(2000); + console.log('สถานะถูกเปลี่ยนแล้ว'); + + // ตรวจสอบสีของแถวหลังจากทำการเปลี่ยนสถานะ + const rowLocator = page.locator( + "//tr[contains(.,'นาย ยศพัฒน์ ธนากานต์')and contains (.,'--')]", + ); + const backgroundColor = await rowLocator.evaluate( + (el) => window.getComputedStyle(el).backgroundColor, + ); + + // กำหนดสีหลัเปลี่ยนสถานะการใช้งาน + const expectedColor = 'rgba(0, 0, 0, 0)'; + + // ตรวจสอบสีที่เปลี่ยนไป + expect(backgroundColor.trim()).toBe(expectedColor); + console.log('สีของแถวถูกเปลี่ยนเป็นของสถานะการใช้งาน'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForTimeout(2000); +}); diff --git a/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_007_CreateLegalentitly.spec.ts b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_007_CreateLegalentitly.spec.ts new file mode 100644 index 00000000..914ffdca --- /dev/null +++ b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_007_CreateLegalentitly.spec.ts @@ -0,0 +1,265 @@ +import { test, expect, Page } from '@playwright/test'; +import { strictEqual } from 'assert'; + +let page: Page; +let isLoginSuccessful = false; + +test.beforeAll(async ({ browser }) => { + page = await browser.newPage(); +}); + +test.afterAll(async () => { + if (page !== undefined) { + await page.close(); + } +}); + +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + // เข้าสู่เมนูลูกค้า + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-customer'); + await page.click('id=sub-menu-customer'); + + isLoginSuccessful = true; + console.log('Login สำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการ Login', error); + isLoginSuccessful = false; + } +} + +test('Login', async () => { + await login(page); +}); + +test('Create Legalentitly Person', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.waitForTimeout(2000); + await page.click('id=btn-add'); + await page.waitForSelector('id=add-customer-legal-entity'); + await page.click('id=add-customer-legal-entity'); + + // ส่วนเกี่ยวกับ + await page.fill( + 'id=input-register-name', + 'บริษัท เอเชียเทค ซิสเต็มส์ จำกัด ', + ); + await page.fill('id=input-register-name-en', 'AsiaTech Systems Co., Ltd.'); + await page.fill('id=input-legal-person-no', 'อนุชา ศรีสวัสดิ์'); + await page.fill('id=input-legal-person-code', '2022822642228'); + + // จดทะเบียนเมื่อ + await page.click("(//input[@id='form-input-register-date'])[1]"); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); + await page.click("//div[text()='2020']"); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[1]"); + await page.click("//div[text()='ก.ย.']"); + await page.click("//div[@id='2020-09-18']/div[1]"); + + await page.fill('id=input-authorized-capital', '10000000'); + await page.fill('id=input-telephone-no', '022202002'); + + // ส่วนข้อมูลธุรกิจ + await page.click("(//div[@class='q-tab__label'])[2]"); + await page.click('id=form-select-business-type'); + await page.waitForSelector('id=form-select-business-type_3'); + await page.click('id=form-select-business-type_3'); + await page.click('id=form-select-job-position'); + await page.waitForSelector('id=form-select-job-position_0'); + await page.click('id=form-select-job-position_0'); + await page.fill('id=form-input-job-description', 'รายละเอียดงาน'); + await page.fill( + "(//input[@id='form-input-pay-rate'])[1]", + 'วันจ่ายเงินเดือน', + ); + await page.fill("(//input[@id='form-input-pay-rate'])[2]", 'Pay day'); + await page.fill("(//input[@id='form-input-pay-rate'])[3]", '2000'); + + // ส่วนผู้มีอำนาจลงนาม + await page.click("(//div[@class='q-tab__label'])[3]"); + await page.fill( + "(//input[@id='form-input-contact-name'])[1]", + 'อนุชา ศรีสวัสดิ์', + ); + await page.fill( + "(//input[@id='form-input-contact-name'])[2]", + 'Anucha Srisawat', + ); + + // ส่วนที่อยู่นายจ้าง + await page.click("(//div[@class='q-tab__label'])[4]"); + await page.fill("(//input[@id='form-input-address'])[1]", '20228226242'); + await page.fill( + 'id=form-input-address-no', + '1234 อาคารซิตี้ทาวเวอร์ ชั้น 12', + ); + await page.fill("(//input[@id='form-input-street'])[1]", 'สาทรใต้'); + await page.click('id=form-select-province'); + await page.waitForSelector('id=form-select-province_0'); + await page.click('id=form-select-province_0'); + await page.click('id=form-select-district'); + await page.waitForSelector('id=form-select-district_11'); + await page.click('id=form-select-district_11'); + await page.click('id=form-select-sub-district'); + await page.waitForSelector('id=form-select-sub-district_1'); + await page.click('id=form-select-sub-district_1'); + await page.fill( + 'id=form-input-address-en', + '1234 City Tower Building, 12th Floor', + ); + await page.fill("(//input[@id='form-input-street'])[2]", 'South Sathorn'); + + // ส่วนข้อมูลผู้ติดต่อ + await page.click("(//div[@class='q-tab__label'])[5]"); + await page.fill('id=form-input-contact-name', 'วราภรณ์ ศรีสวัสดิ์'); + await page.fill('id=form-input-mail', 'asiatech@support.com'); + await page.fill("(//input[@id='form-input-telephone'])[1]", '0866522622'); + await page.fill("(//input[@id='form-input-telephone'])[2]", '022022002'); + await page.click('id=quotation-branch'); + await page.waitForSelector('id=quotation-branch_1'); + await page.click('id=quotation-branch_1'); + await page.waitForSelector("//button[@type='submit']"); + await page.click("//button[@type='submit']"); + await page.click('id=btn-form-close'); + await page.waitForTimeout(2000); + + const legalentitlyNameCheck = await page.locator( + "//tr[contains(.,'บริษัท เอเชียเทค ซิสเต็มส์ จำกัด') and contains (.,'022022002')]", + ); + + await expect(legalentitlyNameCheck).toContainText( + 'บริษัท เอเชียเทค ซิสเต็มส์ จำกัด', + ); + await expect(legalentitlyNameCheck).toContainText('022022002'); + } catch (error) { + console.log('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } +}); + +test('Create Legalentitly Person Second', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click('id=btn-add'); + await page.waitForSelector('id=add-customer-legal-entity'); + await page.click('id=add-customer-legal-entity'); + + // ส่วนเกี่ยวกับ + await page.fill( + 'id=input-register-name', + 'บริษัท กรีนโกลบอล โซลูชั่นส์ จำกัด', + ); + await page.fill( + 'id=input-register-name-en', + 'Green Global Solutions Co., Ltd.', + ); + await page.fill('id=input-legal-person-no', 'ณัฐวุฒิ เกียรติกุล'); + await page.fill('id=input-legal-person-code', '2022822642229'); + + // จดทะเบียนเมื่อ + await page.click("(//input[@id='form-input-register-date'])[1]"); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); + await page.click("//div[text()='2021']"); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[1]"); + await page.click("//div[text()='ก.ย.']"); + await page.click("//div[@id='2021-09-18']/div[1]"); + + await page.fill('id=input-authorized-capital', '10000000'); + await page.fill('id=input-telephone-no', '022202002'); + + // ส่วนข้อมูลธุรกิจ + await page.click("(//div[@class='q-tab__label'])[2]"); + await page.click('id=form-select-business-type'); + await page.waitForSelector('id=form-select-business-type_2'); + await page.click('id=form-select-business-type_2'); + await page.click('id=form-select-job-position'); + await page.waitForSelector('id=form-select-job-position_0'); + await page.click('id=form-select-job-position_0'); + await page.fill('id=form-input-job-description', 'รายละเอียดงาน'); + await page.fill( + "(//input[@id='form-input-pay-rate'])[1]", + 'วันจ่ายเงินเดือน', + ); + await page.fill("(//input[@id='form-input-pay-rate'])[2]", 'Pay day'); + await page.fill("(//input[@id='form-input-pay-rate'])[3]", '2000'); + + // ส่วนผู้มีอำนาจลงนาม + await page.click("(//div[@class='q-tab__label'])[3]"); + await page.fill( + "(//input[@id='form-input-contact-name'])[1]", + 'ณัฐวุฒิ เกียรติกุล', + ); + await page.fill( + "(//input[@id='form-input-contact-name'])[2]", + 'Nattawut Kiatkul', + ); + + // ส่วนที่อยู่นายจ้าง + await page.click("(//div[@class='q-tab__label'])[4]"); + await page.fill("(//input[@id='form-input-address'])[1]", '20228226244'); + await page.fill( + 'id=form-input-address-no', + '5678 อาคารอินฟินิท พลาซ่า ชั้น 8', + ); + await page.fill("(//input[@id='form-input-street'])[1]", 'เพลินจิต'); + await page.click('id=form-select-province'); + await page.waitForSelector('id=form-select-province_0'); + await page.click('id=form-select-province_0'); + await page.click('id=form-select-district'); + await page.waitForSelector('id=form-select-district_6'); + await page.click('id=form-select-district_6'); + await page.click('id=form-select-sub-district'); + await page.waitForSelector('id=form-select-sub-district_3'); + await page.click('id=form-select-sub-district_3'); + await page.fill( + 'id=form-input-address-en', + '5678 Infinite Plaza Building, 8th Floor', + ); + await page.fill("(//input[@id='form-input-street'])[2]", 'Ploenchit'); + + // ส่วนข้อมูลผู้ติดต่อ + await page.click("(//div[@class='q-tab__label'])[5]"); + await page.fill('id=form-input-contact-name', 'ณัฐวุฒิ เกียรติกุล'); + await page.fill('id=form-input-mail', 'asiatech@support.com'); + await page.fill("(//input[@id='form-input-telephone'])[1]", '0866522624'); + await page.fill("(//input[@id='form-input-telephone'])[2]", '022022000'); + await page.click('id=quotation-branch'); + await page.waitForSelector('id=quotation-branch_0'); + await page.click('id=quotation-branch_0'); + await page.waitForSelector("//button[@type='submit']"); + await page.click("//button[@type='submit']"); + await page.click('id=btn-form-close'); + await page.waitForTimeout(2000); + + const legalentitlyNameCheck = await page.locator( + "//tr[contains(.,'บริษัท กรีนโกลบอล โซลูชั่นส์ จำกัด') and contains (.,'022022000')]", + ); + + await expect(legalentitlyNameCheck).toContainText( + 'บริษัท กรีนโกลบอล โซลูชั่นส์ จำกัด', + ); + await expect(legalentitlyNameCheck).toContainText('022022000'); + } catch (error) { + console.log('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } +}); diff --git a/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_008-1_CreateLegalentitlyfailEn.spec.ts b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_008-1_CreateLegalentitlyfailEn.spec.ts new file mode 100644 index 00000000..772748eb --- /dev/null +++ b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_008-1_CreateLegalentitlyfailEn.spec.ts @@ -0,0 +1,557 @@ +import { test, expect, Page } from '@playwright/test'; +import { strictEqual } from 'assert'; +import { exec } from 'child_process'; +import exp from 'constants'; +import e from 'express'; +import { execPath } from 'process'; + +let page: Page; +let isLoginSuccessful = false; + +test.beforeAll(async ({ browser }) => { + page = await browser.newPage(); +}); + +test.afterAll(async () => { + if (page !== undefined) { + await page.close(); + } +}); + +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + // เข้าสู่เมนูลูกค้า + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-customer'); + await page.click('id=sub-menu-customer'); + await page.waitForTimeout(2000); + + // เปลี่ยนภาษา + await page.click('id=btn-change-language'); + await page.waitForSelector('id=btn-change-language-eng'); + await page.click('id=btn-change-language-eng'); + + isLoginSuccessful = true; + console.log('Login สำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการ Login', error); + isLoginSuccessful = false; + } +} + +test('Login', async () => { + await login(page); +}); + +test('ทดสอบการเพิ่มนิติบุคคลในกรณีที่ไม่กรอกข้อมูลส่วนเกี่ยวกับ', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.waitForTimeout(2000); + await page.click('id=btn-add'); + await page.waitForSelector('id=add-customer-legal-entity'); + await page.click('id=add-customer-legal-entity'); + await page.click("//button[@type='submit']"); + const companyNameError = await page.locator( + "(//div[@class='q-field__messages col']//div)[1]", + ); + const legalCodeError = await page.locator( + "(//div[@class='q-field__messages col']//div)[2]", + ); + + await expect(companyNameError).toHaveText('This field is required.'); + await expect(legalCodeError).toHaveText('This field is required.'); + } catch (error) { + console.log('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForSelector('id=btn-form-close'); + await page.click('id=btn-form-close'); + await page.waitForTimeout(2000); +}); + +test('ทดสอบการเพิ่มนิติบุคคลในกรณีที่กรอกเฉพาะส่วนเกี่ยวกับ', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click('id=btn-add'); + await page.waitForSelector('id=add-customer-legal-entity'); + await page.click('id=add-customer-legal-entity'); + + // ส่วนเกี่ยวกับ + await page.fill( + 'id=input-register-name', + 'บริษัท เอเชียเทค ซิสเต็มส์ จำกัด ', + ); + await page.fill('id=input-register-name-en', 'AsiaTech Systems Co., Ltd.'); + await page.fill('id=input-legal-person-no', 'อนุชา ศรีสวัสดิ์'); + await page.fill('id=input-legal-person-code', '2022822642228'); + + // จดทะเบียนเมื่อ + await page.click("(//input[@id='form-input-register-date'])[1]"); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); + await page.click("//div[text()='2020']"); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[1]"); + await page.click("//div[text()='Sep']"); + await page.click("//div[@id='2020-09-18']/div[1]"); + + await page.fill('id=input-authorized-capital', '10000000'); + await page.fill('id=input-telephone-no', '022202002'); + await page.click("//button[@type='submit']"); + const headPopupError = await page.locator( + "//span[normalize-space(text())='Incomplete Data Entry']", + ); + const detailPopupError = await page.locator( + "//span[normalize-space(text())='Incomplete data entry on Business, Address page']", + ); + + await expect(headPopupError).toHaveText('Incomplete Data Entry'); + await expect(detailPopupError).toHaveText( + 'Incomplete data entry on Business, Address page', + ); + } catch (error) { + console.log('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForSelector('id=btn-ok-dialog'); + await page.click('id=btn-ok-dialog'); + await page.waitForSelector('id=btn-form-close'); + await page.click('id=btn-form-close'); + await page.waitForTimeout(2000); +}); + +test('ทดสอบการเพิ่มนิติบุคคลในกรณีที่ไม่กรอกข้อมูลส่วนข้อมูลธุรกิจ', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click('id=btn-add'); + await page.waitForSelector('id=add-customer-legal-entity'); + await page.click('id=add-customer-legal-entity'); + + await page.waitForSelector("(//div[@class='q-tab__label'])[2]"); + await page.click("(//div[@class='q-tab__label'])[2]"); + await page.click("//button[@type='submit']"); + + const expectedErrors = [ + { + locator: "(//div[@class='q-field__messages col']//div)[1]", + message: 'This field is required.', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[2]", + message: 'This field is required.', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[3]", + message: 'This field is required.', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[4]", + message: 'This field is required.', + }, + ]; + + for (const error of expectedErrors) { + const locator = page.locator(error.locator); + await expect(locator).toHaveText(error.message); + } + } catch (error) { + console.log('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForSelector('id=btn-form-close'); + await page.click('id=btn-form-close'); + await page.waitForTimeout(2000); +}); + +test('ทดสอบการเพิ่มนิติบุคคลในกรณีที่กรอกข้อมูลเฉพาะส่วนข้อมูลธุรกิจ', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click('id=btn-add'); + await page.waitForSelector('id=add-customer-legal-entity'); + await page.click('id=add-customer-legal-entity'); + + await page.waitForSelector("(//div[@class='q-tab__label'])[2]"); + await page.click("(//div[@class='q-tab__label'])[2]"); + await page.click('id=form-select-business-type'); + await page.waitForSelector('id=form-select-business-type_5'); + await page.click('id=form-select-business-type_5'); + await page.click('id=form-select-job-position'); + await page.waitForSelector('id=form-select-job-position_2'); + await page.click('id=form-select-job-position_2'); + + await page.fill('id=form-input-job-description', 'รายละเอียดงาน'); + await page.fill( + "(//input[@id='form-input-pay-rate'])[1]", + 'วันที่จ่ายเงินเดือน', + ); + await page.fill("(//input[@id='form-input-pay-rate'])[2]", 'Pay Day'); + await page.fill("(//input[@id='form-input-pay-rate'])[3]", '500'); + + await page.click("//button[@type='submit']"); + + const headPopupError = page.locator( + "//span[normalize-space(text())='Incomplete Data Entry']", + ); + const detailPopupError = page.locator( + "//span[normalize-space(text())='Incomplete data entry on About, Address page']", + ); + + await expect(headPopupError).toHaveText('Incomplete Data Entry'); + await expect(detailPopupError).toHaveText( + 'Incomplete data entry on About, Address page', + ); + } catch (error) { + console.log('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForSelector('id=btn-ok-dialog'); + await page.click('id=btn-ok-dialog'); + await page.waitForSelector('id=btn-form-close'); + await page.click('id=btn-form-close'); + await page.waitForTimeout(2000); +}); + +test('ทดสอบการเพิ่มนิติบุคคลในกรณีที่ไม่กรอกข้อมูลส่วนผู้มีอำนาจลงนาม', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click('id=btn-add'); + await page.waitForSelector('id=add-customer-legal-entity'); + await page.click('id=add-customer-legal-entity'); + + await page.waitForSelector("(//div[@class='q-tab__label'])[3]"); + await page.click("(//div[@class='q-tab__label'])[3]"); + await page.click("//button[@type='submit']"); + + const headPopupError = page.locator( + "//span[normalize-space(text())='Incomplete Data Entry']", + ); + const detailPopupError = page.locator( + "//span[normalize-space(text())='Incomplete data entry on About, Business, Address page']", + ); + + await expect(headPopupError).toHaveText('Incomplete Data Entry'); + await expect(detailPopupError).toHaveText( + 'Incomplete data entry on About, Business, Address page', + ); + } catch (error) { + console.log('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForSelector('id=btn-ok-dialog'); + await page.click('id=btn-ok-dialog'); + await page.waitForSelector('id=btn-form-close'); + await page.click('id=btn-form-close'); + await page.waitForTimeout(2000); +}); + +test('ทดสอบการเพิ่มนิติบุคคลในกรณีที่กรอกข้อมูลเฉพาะส่วนผู้มีอำนาจลงนาม', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click('id=btn-add'); + await page.waitForSelector('id=add-customer-legal-entity'); + await page.click('id=add-customer-legal-entity'); + + await page.waitForSelector("(//div[@class='q-tab__label'])[3]"); + await page.click("(//div[@class='q-tab__label'])[3]"); + await page.fill( + "(//input[@id='form-input-contact-name'])[1]", + 'ผู้มีอำนาจลงนาม', + ); + await page.fill( + "(//input[@id='form-input-contact-name'])[2]", + 'ผู้มีอำนาจลงนาม EN', + ); + await page.click("//button[@type='submit']"); + + const headPopupError = page.locator( + "//span[normalize-space(text())='Incomplete Data Entry']", + ); + const detailPopupError = page.locator( + "//span[normalize-space(text())='Incomplete data entry on About, Business, Address page']", + ); + + await expect(headPopupError).toHaveText('Incomplete Data Entry'); + await expect(detailPopupError).toHaveText( + 'Incomplete data entry on About, Business, Address page', + ); + } catch (error) { + console.log('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForSelector('id=btn-ok-dialog'); + await page.click('id=btn-ok-dialog'); + await page.waitForSelector('id=btn-form-close'); + await page.click('id=btn-form-close'); + await page.waitForTimeout(2000); +}); + +test('ทดสอบการเพิ่มนิติบุคคลในกรณีที่ไม่กรอกข้อมูลส่วนที่อยู๋นายจ้าง', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click('id=btn-add'); + await page.waitForSelector('id=add-customer-legal-entity'); + await page.click('id=add-customer-legal-entity'); + + await page.waitForSelector("(//div[@class='q-tab__label'])[4]"); + await page.click("(//div[@class='q-tab__label'])[4]"); + await page.click("//button[@type='submit']"); + + const expectedErrors = [ + { + locator: "(//div[@class='q-field__messages col']//div)[1]", + message: 'This field is required.', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[2]", + message: 'Please select Province.', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[3]", + message: 'Please select District.', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[4]", + message: 'Please select Sub-district.', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[5]", + message: 'This field is required.', + }, + ]; + + for (const error of expectedErrors) { + const locator = page.locator(error.locator); + await expect(locator).toHaveText(error.message); + } + } catch (error) { + console.log('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForSelector('id=btn-form-close'); + await page.click('id=btn-form-close'); + await page.waitForTimeout(2000); +}); + +test('ทดสอบการเพิ่มนิติบุคคลในกรณีที่กรอกเฉพาะข้อมูลส่วนที่อยู๋นายจ้าง', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click('id=btn-add'); + await page.waitForSelector('id=add-customer-legal-entity'); + await page.click('id=add-customer-legal-entity'); + + await page.waitForSelector("(//div[@class='q-tab__label'])[4]"); + await page.click("(//div[@class='q-tab__label'])[4]"); + await page.fill("(//input[@id='form-input-address'])[1]", '22082202202'); + await page.fill('id=form-input-address-no', '20/02'); + await page.click('id=form-select-province'); + await page.waitForSelector('id=form-select-province_3'); + await page.click('id=form-select-province_3'); + await page.click('id=form-select-district'); + await page.waitForSelector('id=form-select-district_5'); + await page.click('id=form-select-district_5'); + await page.click('id=form-select-sub-district'); + await page.waitForSelector('id=form-select-sub-district_2'); + await page.click('id=form-select-sub-district_2'); + await page.fill('id=form-input-address-en', '20/02'); + await page.click("//button[@type='submit']"); + + const headPopupError = await page.locator( + "//span[normalize-space(text())='Incomplete Data Entry']", + ); + const detailPopupError = await page.locator( + "//span[normalize-space(text())='Incomplete data entry on About, Business page']", + ); + + await expect(headPopupError).toHaveText('Incomplete Data Entry'); + await expect(detailPopupError).toHaveText( + 'Incomplete data entry on About, Business page', + ); + } catch (error) { + console.log('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForSelector('id=btn-ok-dialog'); + await page.click('id=btn-ok-dialog'); + await page.waitForSelector('id=btn-form-close'); + await page.click('id=btn-form-close'); + await page.waitForTimeout(2000); +}); + +test('ทดสอบการเพิ่มนิติบุคคลในกรณีที่กรอกช่องรหัสประจำบ้านไม่ครบ 11 หลัก', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click('id=btn-add'); + await page.waitForSelector('id=add-customer-legal-entity'); + await page.click('id=add-customer-legal-entity'); + + await page.waitForSelector("(//div[@class='q-tab__label'])[4]"); + await page.click("(//div[@class='q-tab__label'])[4]"); + await page.fill("(//input[@id='form-input-address'])[1]", '123'); + + const addressNumberError = await page.locator( + "//div[@class='q-field__messages col']//div[1]", + ); + await expect(addressNumberError).toHaveText( + 'Invalid value. Please enter 11 character', + ); + } catch (error) { + console.log('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForSelector('id=btn-form-close'); + await page.click('id=btn-form-close'); + await page.waitForTimeout(2000); +}); + +test('ทดสอบการเพิ่มนิติบุคคลในกรณีที่ไม่กรอกข้อมูลส่วนข้อมูลติดต่อ', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click('id=btn-add'); + await page.waitForSelector('id=add-customer-legal-entity'); + await page.click('id=add-customer-legal-entity'); + + await page.waitForSelector("(//div[@class='q-tab__label'])[5]"); + await page.click("(//div[@class='q-tab__label'])[5]"); + await page.click("//button[@type='submit']"); + + const headPopupError = await page.locator( + "//span[normalize-space(text())='Incomplete Data Entry']", + ); + const detailPopupError = await page.locator( + "//span[normalize-space(text())='Incomplete data entry on About, Business, Address page']", + ); + + await expect(headPopupError).toHaveText('Incomplete Data Entry'); + await expect(detailPopupError).toHaveText( + 'Incomplete data entry on About, Business, Address page', + ); + } catch (error) { + console.log('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForSelector('id=btn-ok-dialog'); + await page.click('id=btn-ok-dialog'); + await page.waitForSelector('id=btn-form-close'); + await page.click('id=btn-form-close'); + await page.waitForTimeout(2000); +}); + +test('ทดสอบการเพิ่มนิติบุคคลในกรณีที่กรอกข้อมูลเฉพาะส่วนข้อมูลติดต่อ', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click('id=btn-add'); + await page.waitForSelector('id=add-customer-legal-entity'); + await page.click('id=add-customer-legal-entity'); + + await page.waitForSelector("(//div[@class='q-tab__label'])[5]"); + await page.click("(//div[@class='q-tab__label'])[5]"); + await page.fill('id=form-input-contact-name', 'ชื่อผู้ติดต่อ'); + await page.fill('id=form-input-mail', 'mail@mail.com'); + await page.fill("(//input[@id='form-input-telephone'])[1]", '0886224228'); + await page.fill("(//input[@id='form-input-telephone'])[2]", '022002800'); + await page.click('id=quotation-branch'); + await page.waitForSelector('id=quotation-branch_0'); + await page.click('id=quotation-branch_0'); + await page.click("//button[@type='submit']"); + + const headPopupError = await page.locator( + "//span[normalize-space(text())='Incomplete Data Entry']", + ); + const detailPopupError = await page.locator( + "//span[normalize-space(text())='Incomplete data entry on About, Business, Address page']", + ); + + await expect(headPopupError).toHaveText('Incomplete Data Entry'); + await expect(detailPopupError).toHaveText( + 'Incomplete data entry on About, Business, Address page', + ); + } catch (error) { + console.log('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForSelector('id=btn-ok-dialog'); + await page.click('id=btn-ok-dialog'); + await page.waitForSelector('id=btn-form-close'); + await page.click('id=btn-form-close'); + await page.waitForTimeout(2000); +}); + +test('ทดสอบการเพิ่มนิติบุคคลในกรณีที่กรอกอีเมลไม่ตรงรูปแบบของส่วนข้อมูลติดต่อ', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click('id=btn-add'); + await page.waitForSelector('id=add-customer-legal-entity'); + await page.click('id=add-customer-legal-entity'); + + await page.waitForSelector("(//div[@class='q-tab__label'])[5]"); + await page.click("(//div[@class='q-tab__label'])[5]"); + await page.fill('id=form-input-mail', 'mail'); + + const emailError = await page.locator( + "//div[@class='q-field__messages col']//div[1]", + ); + + await expect(emailError).toHaveText('Invalid value.'); + } catch (error) { + console.log('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForSelector('id=btn-form-close'); + await page.click('id=btn-form-close'); + await page.waitForTimeout(2000); +}); diff --git a/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_008_CreateLegalentitlyfail.spec.ts b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_008_CreateLegalentitlyfail.spec.ts new file mode 100644 index 00000000..d9a9564b --- /dev/null +++ b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_008_CreateLegalentitlyfail.spec.ts @@ -0,0 +1,550 @@ +import { test, expect, Page } from '@playwright/test'; +import { strictEqual } from 'assert'; +import { exec } from 'child_process'; +import exp from 'constants'; +import e from 'express'; +import { execPath } from 'process'; +import { urlToHttpOptions } from 'url'; + +let page: Page; +let isLoginSuccessful = false; + +test.beforeAll(async ({ browser }) => { + page = await browser.newPage(); +}); + +test.afterAll(async () => { + if (page !== undefined) { + await page.close(); + } +}); + +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + // เข้าสู่เมนูลูกค้า + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-customer'); + await page.click('id=sub-menu-customer'); + + isLoginSuccessful = true; + console.log('Login สำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการ Login', error); + isLoginSuccessful = false; + } +} + +test('Login', async () => { + await login(page); +}); + +test('ทดสอบการเพิ่มนิติบุคคลในกรณีที่ไม่กรอกข้อมูลส่วนเกี่ยวกับ', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.waitForTimeout(2000); + await page.click('id=btn-add'); + await page.waitForSelector('id=add-customer-legal-entity'); + await page.click('id=add-customer-legal-entity'); + await page.click("//button[@type='submit']"); + const companyNameError = await page.locator( + "(//div[@class='q-field__messages col']//div)[1]", + ); + const legalCodeError = await page.locator( + "(//div[@class='q-field__messages col']//div)[2]", + ); + + await expect(companyNameError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้'); + await expect(legalCodeError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้'); + } catch (error) { + console.log('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForSelector('id=btn-form-close'); + await page.click('id=btn-form-close'); + await page.waitForTimeout(2000); +}); + +test('ทดสอบการเพิ่มนิติบุคคลในกรณีที่กรอกเฉพาะส่วนเกี่ยวกับ', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click('id=btn-add'); + await page.waitForSelector('id=add-customer-legal-entity'); + await page.click('id=add-customer-legal-entity'); + + // ส่วนเกี่ยวกับ + await page.fill( + 'id=input-register-name', + 'บริษัท เอเชียเทค ซิสเต็มส์ จำกัด ', + ); + await page.fill('id=input-register-name-en', 'AsiaTech Systems Co., Ltd.'); + await page.fill('id=input-legal-person-no', 'อนุชา ศรีสวัสดิ์'); + await page.fill('id=input-legal-person-code', '2022822642228'); + + // จดทะเบียนเมื่อ + await page.click("(//input[@id='form-input-register-date'])[1]"); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); + await page.click("//div[text()='2020']"); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[1]"); + await page.click("//div[text()='ก.ย.']"); + await page.click("//div[@id='2020-09-18']/div[1]"); + + await page.fill('id=input-authorized-capital', '10000000'); + await page.fill('id=input-telephone-no', '022202002'); + await page.click("//button[@type='submit']"); + const headPopupError = await page.locator( + "//span[normalize-space(text())='กรอกข้อมูลไม่ครบ']", + ); + const detailPopupError = await page.locator( + "//span[normalize-space(text())='กรอกข้อมูลไม่ครบในหน้า ข้อมูลธุรกิจ, ที่อยู่นายจ้าง']", + ); + + await expect(headPopupError).toHaveText('กรอกข้อมูลไม่ครบ'); + await expect(detailPopupError).toHaveText( + 'กรอกข้อมูลไม่ครบในหน้า ข้อมูลธุรกิจ, ที่อยู่นายจ้าง', + ); + } catch (error) { + console.log('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForSelector('id=btn-ok-dialog'); + await page.click('id=btn-ok-dialog'); + await page.waitForSelector('id=btn-form-close'); + await page.click('id=btn-form-close'); + await page.waitForTimeout(2000); +}); + +test('ทดสอบการเพิ่มนิติบุคคลในกรณีที่ไม่กรอกข้อมูลส่วนข้อมูลธุรกิจ', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click('id=btn-add'); + await page.waitForSelector('id=add-customer-legal-entity'); + await page.click('id=add-customer-legal-entity'); + + await page.waitForSelector("(//div[@class='q-tab__label'])[2]"); + await page.click("(//div[@class='q-tab__label'])[2]"); + await page.click("//button[@type='submit']"); + + const expectedErrors = [ + { + locator: "(//div[@class='q-field__messages col']//div)[1]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[2]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[3]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[4]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + ]; + + for (const error of expectedErrors) { + const locator = page.locator(error.locator); + await expect(locator).toHaveText(error.message); + } + } catch (error) { + console.log('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForSelector('id=btn-form-close'); + await page.click('id=btn-form-close'); + await page.waitForTimeout(2000); +}); + +test('ทดสอบการเพิ่มนิติบุคคลในกรณีที่กรอกข้อมูลเฉพาะส่วนข้อมูลธุรกิจ', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + await page.click('id=btn-add'); + await page.waitForSelector('id=add-customer-legal-entity'); + await page.click('id=add-customer-legal-entity'); + + await page.waitForSelector("(//div[@class='q-tab__label'])[2]"); + await page.click("(//div[@class='q-tab__label'])[2]"); + await page.click('id=form-select-business-type'); + await page.waitForSelector('id=form-select-business-type_5'); + await page.click('id=form-select-business-type_5'); + await page.click('id=form-select-job-position'); + await page.waitForSelector('id=form-select-job-position_2'); + await page.click('id=form-select-job-position_2'); + + await page.fill('id=form-input-job-description', 'รายละเอียดงาน'); + await page.fill( + "(//input[@id='form-input-pay-rate'])[1]", + 'วันที่จ่ายเงินเดือน', + ); + await page.fill("(//input[@id='form-input-pay-rate'])[2]", 'Pay Day'); + await page.fill("(//input[@id='form-input-pay-rate'])[3]", '500'); + + await page.click("//button[@type='submit']"); + + const headPopupError = page.locator( + "//span[normalize-space(text())='กรอกข้อมูลไม่ครบ']", + ); + const detailPopupError = page.locator( + "//span[normalize-space(text())='กรอกข้อมูลไม่ครบในหน้า เกี่ยวกับ, ที่อยู่นายจ้าง']", + ); + + await expect(headPopupError).toHaveText('กรอกข้อมูลไม่ครบ'); + await expect(detailPopupError).toHaveText( + 'กรอกข้อมูลไม่ครบในหน้า เกี่ยวกับ, ที่อยู่นายจ้าง', + ); + } catch (error) { + console.log('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForSelector('id=btn-ok-dialog'); + await page.click('id=btn-ok-dialog'); + await page.waitForSelector('id=btn-form-close'); + await page.click('id=btn-form-close'); + await page.waitForTimeout(2000); +}); + +test('ทดสอบการเพิ่มนิติบุคคลในกรณีที่ไม่กรอกข้อมูลส่วนผู้มีอำนาจลงนาม', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click('id=btn-add'); + await page.waitForSelector('id=add-customer-legal-entity'); + await page.click('id=add-customer-legal-entity'); + + await page.waitForSelector("(//div[@class='q-tab__label'])[3]"); + await page.click("(//div[@class='q-tab__label'])[3]"); + await page.click("//button[@type='submit']"); + + const headPopupError = page.locator( + "//span[normalize-space(text())='กรอกข้อมูลไม่ครบ']", + ); + const detailPopupError = page.locator( + "//span[normalize-space(text())='กรอกข้อมูลไม่ครบในหน้า เกี่ยวกับ, ข้อมูลธุรกิจ, ที่อยู่นายจ้าง']", + ); + + await expect(headPopupError).toHaveText('กรอกข้อมูลไม่ครบ'); + await expect(detailPopupError).toHaveText( + 'กรอกข้อมูลไม่ครบในหน้า เกี่ยวกับ, ข้อมูลธุรกิจ, ที่อยู่นายจ้าง', + ); + } catch (error) { + console.log('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForSelector('id=btn-ok-dialog'); + await page.click('id=btn-ok-dialog'); + await page.waitForSelector('id=btn-form-close'); + await page.click('id=btn-form-close'); + await page.waitForTimeout(2000); +}); + +test('ทดสอบการเพิ่มนิติบุคคลในกรณีที่กรอกข้อมูลเฉพาะส่วนผู้มีอำนาจลงนาม', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click('id=btn-add'); + await page.waitForSelector('id=add-customer-legal-entity'); + await page.click('id=add-customer-legal-entity'); + + await page.waitForSelector("(//div[@class='q-tab__label'])[3]"); + await page.click("(//div[@class='q-tab__label'])[3]"); + await page.fill( + "(//input[@id='form-input-contact-name'])[1]", + 'ผู้มีอำนาจลงนาม', + ); + await page.fill( + "(//input[@id='form-input-contact-name'])[2]", + 'ผู้มีอำนาจลงนาม EN', + ); + await page.click("//button[@type='submit']"); + + const headPopupError = page.locator( + "//span[normalize-space(text())='กรอกข้อมูลไม่ครบ']", + ); + const detailPopupError = page.locator( + "//span[normalize-space(text())='กรอกข้อมูลไม่ครบในหน้า เกี่ยวกับ, ข้อมูลธุรกิจ, ที่อยู่นายจ้าง']", + ); + + await expect(headPopupError).toHaveText('กรอกข้อมูลไม่ครบ'); + await expect(detailPopupError).toHaveText( + 'กรอกข้อมูลไม่ครบในหน้า เกี่ยวกับ, ข้อมูลธุรกิจ, ที่อยู่นายจ้าง', + ); + } catch (error) { + console.log('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForSelector('id=btn-ok-dialog'); + await page.click('id=btn-ok-dialog'); + await page.waitForSelector('id=btn-form-close'); + await page.click('id=btn-form-close'); + await page.waitForTimeout(2000); +}); + +test('ทดสอบการเพิ่มนิติบุคคลในกรณีที่ไม่กรอกข้อมูลส่วนที่อยู๋นายจ้าง', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click('id=btn-add'); + await page.waitForSelector('id=add-customer-legal-entity'); + await page.click('id=add-customer-legal-entity'); + + await page.waitForSelector("(//div[@class='q-tab__label'])[4]"); + await page.click("(//div[@class='q-tab__label'])[4]"); + await page.click("//button[@type='submit']"); + + const expectedErrors = [ + { + locator: "(//div[@class='q-field__messages col']//div)[1]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[2]", + message: 'โปรดเลือกจังหวัด', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[3]", + message: 'โปรดเลือกเขต/อำเภอ', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[4]", + message: 'โปรดเลือกแขวง/ตำบล', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[5]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + ]; + + for (const error of expectedErrors) { + const locator = page.locator(error.locator); + await expect(locator).toHaveText(error.message); + } + } catch (error) { + console.log('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForSelector('id=btn-form-close'); + await page.click('id=btn-form-close'); + await page.waitForTimeout(2000); +}); + +test('ทดสอบการเพิ่มนิติบุคคลในกรณีที่กรอกเฉพาะข้อมูลส่วนที่อยู๋นายจ้าง', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click('id=btn-add'); + await page.waitForSelector('id=add-customer-legal-entity'); + await page.click('id=add-customer-legal-entity'); + + await page.waitForSelector("(//div[@class='q-tab__label'])[4]"); + await page.click("(//div[@class='q-tab__label'])[4]"); + await page.fill("(//input[@id='form-input-address'])[1]", '22082202202'); + await page.fill('id=form-input-address-no', '20/02'); + await page.click('id=form-select-province'); + await page.waitForSelector('id=form-select-province_3'); + await page.click('id=form-select-province_3'); + await page.click('id=form-select-district'); + await page.waitForSelector('id=form-select-district_5'); + await page.click('id=form-select-district_5'); + await page.click('id=form-select-sub-district'); + await page.waitForSelector('id=form-select-sub-district_2'); + await page.click('id=form-select-sub-district_2'); + await page.fill('id=form-input-address-en', '20/02'); + await page.click("//button[@type='submit']"); + + const headPopupError = await page.locator( + "//span[normalize-space(text())='กรอกข้อมูลไม่ครบ']", + ); + const detailPopupError = await page.locator( + "//span[normalize-space(text())='กรอกข้อมูลไม่ครบในหน้า เกี่ยวกับ, ข้อมูลธุรกิจ']", + ); + + await expect(headPopupError).toHaveText('กรอกข้อมูลไม่ครบ'); + await expect(detailPopupError).toHaveText( + 'กรอกข้อมูลไม่ครบในหน้า เกี่ยวกับ, ข้อมูลธุรกิจ', + ); + } catch (error) { + console.log('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForSelector('id=btn-ok-dialog'); + await page.click('id=btn-ok-dialog'); + await page.waitForSelector('id=btn-form-close'); + await page.click('id=btn-form-close'); + await page.waitForTimeout(2000); +}); + +test('ทดสอบการเพิ่มนิติบุคคลในกรณีที่กรอกช่องรหัสประจำบ้านไม่ครบ 11 หลัก', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click('id=btn-add'); + await page.waitForSelector('id=add-customer-legal-entity'); + await page.click('id=add-customer-legal-entity'); + + await page.waitForSelector("(//div[@class='q-tab__label'])[4]"); + await page.click("(//div[@class='q-tab__label'])[4]"); + await page.fill("(//input[@id='form-input-address'])[1]", '123'); + + const addressNumberError = await page.locator( + "//div[@class='q-field__messages col']//div[1]", + ); + await expect(addressNumberError).toHaveText( + 'ข้อมูลไม่ถูกต้อง กรุณากรอกให้ครบ 11 หลัก', + ); + } catch (error) { + console.log('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForSelector('id=btn-form-close'); + await page.click('id=btn-form-close'); + await page.waitForTimeout(2000); +}); + +test('ทดสอบการเพิ่มนิติบุคคลในกรณีที่ไม่กรอกข้อมูลส่วนข้อมูลติดต่อ', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click('id=btn-add'); + await page.waitForSelector('id=add-customer-legal-entity'); + await page.click('id=add-customer-legal-entity'); + + await page.waitForSelector("(//div[@class='q-tab__label'])[5]"); + await page.click("(//div[@class='q-tab__label'])[5]"); + await page.click("//button[@type='submit']"); + const headPopupError = await page.locator( + "//span[normalize-space(text())='กรอกข้อมูลไม่ครบ']", + ); + const detailPopupError = await page.locator( + "//span[normalize-space(text())='กรอกข้อมูลไม่ครบในหน้า เกี่ยวกับ, ข้อมูลธุรกิจ, ที่อยู่นายจ้าง']", + ); + + await expect(headPopupError).toHaveText('กรอกข้อมูลไม่ครบ'); + await expect(detailPopupError).toHaveText( + 'กรอกข้อมูลไม่ครบในหน้า เกี่ยวกับ, ข้อมูลธุรกิจ, ที่อยู่นายจ้าง', + ); + } catch (error) { + console.log('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForSelector('id=btn-ok-dialog'); + await page.click('id=btn-ok-dialog'); + await page.waitForSelector('id=btn-form-close'); + await page.click('id=btn-form-close'); + await page.waitForTimeout(2000); +}); + +test('ทดสอบการเพิ่มนิติบุคคลในกรณีที่กรอกข้อมูลเฉพาะส่วนข้อมูลติดต่อ', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click('id=btn-add'); + await page.waitForSelector('id=add-customer-legal-entity'); + await page.click('id=add-customer-legal-entity'); + + await page.waitForSelector("(//div[@class='q-tab__label'])[5]"); + await page.click("(//div[@class='q-tab__label'])[5]"); + await page.fill('id=form-input-contact-name', 'ชื่อผู้ติดต่อ'); + await page.fill('id=form-input-mail', 'mail@mail.com'); + await page.fill("(//input[@id='form-input-telephone'])[1]", '0886224228'); + await page.fill("(//input[@id='form-input-telephone'])[2]", '022002800'); + await page.click('id=quotation-branch'); + await page.waitForSelector('id=quotation-branch_0'); + await page.click('id=quotation-branch_0'); + await page.click("//button[@type='submit']"); + + const headPopupError = await page.locator( + "//span[normalize-space(text())='กรอกข้อมูลไม่ครบ']", + ); + const detailPopupError = await page.locator( + "//span[normalize-space(text())='กรอกข้อมูลไม่ครบในหน้า เกี่ยวกับ, ข้อมูลธุรกิจ, ที่อยู่นายจ้าง']", + ); + + await expect(headPopupError).toHaveText('กรอกข้อมูลไม่ครบ'); + await expect(detailPopupError).toHaveText( + 'กรอกข้อมูลไม่ครบในหน้า เกี่ยวกับ, ข้อมูลธุรกิจ, ที่อยู่นายจ้าง', + ); + } catch (error) { + console.log('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForSelector('id=btn-ok-dialog'); + await page.click('id=btn-ok-dialog'); + await page.waitForSelector('id=btn-form-close'); + await page.click('id=btn-form-close'); + await page.waitForTimeout(2000); +}); + +test('ทดสอบการเพิ่มนิติบุคคลในกรณีที่กรอกอีเมลไม่ตรงรูปแบบของส่วนข้อมูลติดต่อ', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click('id=btn-add'); + await page.waitForSelector('id=add-customer-legal-entity'); + await page.click('id=add-customer-legal-entity'); + + await page.waitForSelector("(//div[@class='q-tab__label'])[5]"); + await page.click("(//div[@class='q-tab__label'])[5]"); + await page.fill('id=form-input-mail', 'mail'); + + const emailError = await page.locator( + "//div[@class='q-field__messages col']//div[1]", + ); + + await expect(emailError).toHaveText('ข้อมูลไม่ถูกต้อง'); + } catch (error) { + console.log('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForSelector('id=btn-form-close'); + await page.click('id=btn-form-close'); + await page.waitForTimeout(2000); +}); diff --git a/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_009_DetailLegalentitly.spec.ts b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_009_DetailLegalentitly.spec.ts new file mode 100644 index 00000000..dfea7b30 --- /dev/null +++ b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_009_DetailLegalentitly.spec.ts @@ -0,0 +1,120 @@ +import { test, expect, Page } from '@playwright/test'; +import { strictEqual } from 'assert'; +import { log } from 'console'; +import { LOADIPHLPAPI } from 'dns'; + +let page: Page; +let isLoginSuccessful = false; + +test.beforeAll(async ({ browser }) => { + page = await browser.newPage(); +}); + +test.afterAll(async () => { + if (page !== undefined) { + await page.close(); + } +}); + +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + // เข้าสู่เมนูลูกค้า + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-customer'); + await page.click('id=sub-menu-customer'); + await page.waitForTimeout(2000); + + isLoginSuccessful = true; + console.log('Login สำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการ Login', error); + isLoginSuccessful = false; + } +} + +test('Login', async () => { + await login(page); +}); + +test('ทดสอบการดูรายละเอียดนิติบุคคลโดยการคลิกไอคอนดวงตา', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click("(//button[@id='btn-eye-อนุชา ศรีสวัสดิ์'])[2]"); + await page.waitForTimeout(2000); + const fullNamelegal = await page.locator( + "//div[@class='col column']//span[1]", + ); + + await expect(fullNamelegal).toHaveText('บริษัท เอเชียเทค ซิสเต็มส์ จำกัด'); + } catch (error) { + console.log('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForSelector('id=btn-info-close'); + await page.click('id=btn-info-close'); + await page.waitForTimeout(2000); +}); + +test('ทดสอบการดูรายละเอียดนิติบุคคลโดยการคลิกเมนูย่อย', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click('id=btn-kebab-action-อนุชา ศรีสวัสดิ์'); + await page.waitForSelector('id=btn-kebab-view-detail-อนุชา ศรีสวัสดิ์'); + await page.click('id=btn-kebab-view-detail-อนุชา ศรีสวัสดิ์'); + await page.waitForTimeout(2000); + const fullNamelegal = await page.locator( + "//div[@class='col column']//span[1]", + ); + + await expect(fullNamelegal).toHaveText('บริษัท เอเชียเทค ซิสเต็มส์ จำกัด'); + } catch (error) { + console.log('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForSelector('id=btn-info-close'); + await page.click('id=btn-info-close'); + await page.waitForTimeout(2000); +}); + +test('ทดสอบการดูรายละเอียดนิติบุคคลในรูปแบบการ์ด', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.waitForSelector("//button[@aria-pressed='false']"); + await page.click("//button[@aria-pressed='false']"); + + const isCardView = await page + .locator("(//div[@id='branch-card-undefined'])[2]") + .isVisible(); + const fullNamelegal = await page.locator( + "//b[normalize-space(text())='บริษัท เอเชียเทค ซิสเต็มส์ จำกัด']", + ); + await expect(isCardView).toBe(true); + await expect(fullNamelegal).toHaveText('บริษัท เอเชียเทค ซิสเต็มส์ จำกัด'); + console.log('ระบบทำการเปลี่ยนรูปแบบเป็นการ์ดแล้ว'); + } catch (error) { + console.log('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForTimeout(2000); +}); diff --git a/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_010_EditLegalentitly.spec.ts b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_010_EditLegalentitly.spec.ts new file mode 100644 index 00000000..8ee2bdc9 --- /dev/null +++ b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_010_EditLegalentitly.spec.ts @@ -0,0 +1,113 @@ +import { test, expect, Page } from '@playwright/test'; +import { strictEqual } from 'assert'; + +let page: Page; +let isLoginSuccessful = false; + +test.beforeAll(async ({ browser }) => { + page = await browser.newPage(); +}); + +test.afterAll(async () => { + if (page !== undefined) { + await page.close(); + } +}); + +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + // เข้าสู่เมนูลูกค้า + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-customer'); + await page.click('id=sub-menu-customer'); + await page.waitForTimeout(2000); + + isLoginSuccessful = true; + console.log('Login สำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการ Login', error); + isLoginSuccessful = false; + } +} + +test('Login', async () => { + await login(page); +}); + +test('ทดสอบการแก้ไขนายจ้างนิติบุคคล', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.waitForSelector('id=btn-kebab-action-ณัฐวุฒิ เกียรติกุล'); + await page.click('id=btn-kebab-action-ณัฐวุฒิ เกียรติกุล'); + await page.waitForSelector('id=btn-kebab-edit-ณัฐวุฒิ เกียรติกุล'); + await page.click('id=btn-kebab-edit-ณัฐวุฒิ เกียรติกุล'); + + // ส่วนเกี่ยวกับ + await page.fill( + 'id=input-register-name', + 'บริษัท สยาม เอ็นเนอร์จี โซลูชั่น จำกัด', + ); + await page.fill( + 'id=input-register-name-en', + 'Siam Energy Solutions Co., Ltd.', + ); + await page.fill('id=input-legal-person-no', 'ภาคิน วงศ์ศรีสุข'); + await page.fill('id=input-authorized-capital', '15000000'); + + // ส่วนที่อยู่นายจ้าง + await page.click("(//div[@class='q-tab__label'])[4]"); + await page.fill( + 'id=info-input-address-no', + '123/45 อาคารเพิร์ล ทาวเวอร์ ชั้น 10', + ); + await page.fill("(//input[@id='info-input-street'])[1]", 'พหลโยธิน'); + await page.click('id=info-select-province'); + await page.waitForSelector('id=info-select-province_0'); + await page.click('id=info-select-province_0'); + await page.click('id=info-select-district'); + await page.waitForSelector('id=info-select-district_26'); + await page.click('id=info-select-district_26'); + await page.click('id=info-select-sub-district'); + await page.waitForSelector('id=info-select-sub-district_1'); + await page.click('id=info-select-sub-district_1'); + await page.fill( + 'id=info-input-address-en', + '123/45 Pearl Tower, 10th Floor', + ); + await page.fill("(//input[@id='info-input-street'])[2]", 'Phahonyothin'); + + await page.waitForSelector("//button[@type='submit']"); + await page.click("//button[@type='submit']"); + await page.waitForTimeout(2000); + await page.waitForSelector('id=btn-info-close'); + await page.click('id=btn-info-close'); + await page.waitForTimeout(2000); + + const legalAfterEdit = await page.locator( + "//tr[contains(.,'บริษัท สยาม เอ็นเนอร์จี โซลูชั่น จำกัด') and contains (.,'022022000')]", + ); + + await expect(legalAfterEdit).toContainText( + 'บริษัท สยาม เอ็นเนอร์จี โซลูชั่น จำกัด', + ); + await expect(legalAfterEdit).toContainText('022022000'); + console.log('ระบบทดสอบการแก้ไขสำเร็จ'); + } catch (error) { + console.log('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForTimeout(2000); +}); diff --git a/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_011_DeleteLegalentitly.spec.ts b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_011_DeleteLegalentitly.spec.ts new file mode 100644 index 00000000..341248e7 --- /dev/null +++ b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_011_DeleteLegalentitly.spec.ts @@ -0,0 +1,72 @@ +import { test, expect, Page } from '@playwright/test'; +import { strictEqual } from 'assert'; +import { it } from 'node:test'; + +let page: Page; +let isLoginSuccessful = false; + +test.beforeAll(async ({ browser }) => { + page = await browser.newPage(); +}); + +test.afterAll(async () => { + if (page !== undefined) { + await page.close(); + } +}); + +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + // เข้าสู่เมนูลูกค้า + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-customer'); + await page.click('id=sub-menu-customer'); + await page.waitForTimeout(2000); + + isLoginSuccessful = true; + console.log('Login สำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการ Login', error); + isLoginSuccessful = false; + } +} + +test('Login', async () => { + await login(page); +}); + +test('Delete Legalentitly', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click('id=btn-kebab-action-ภาคิน วงศ์ศรีสุข'); + await page.waitForSelector('id=btn-kebab-delete-ภาคิน วงศ์ศรีสุข'); + await page.click('id=btn-kebab-delete-ภาคิน วงศ์ศรีสุข'); + await page.waitForSelector('id=btn-ok-dialog'); + await page.click('id=btn-ok-dialog'); + + const itemLocator = await page.locator( + "//tr[contains(.,'บริษัท สยาม เอ็นเนอร์จี โซลูชั่น จำกัด') and contains (.,'022022000')]", + ); + + await expect(itemLocator).toBeHidden(); + + console.log('ระบบทำการลบนายจ้างนิติบุคคลแล้ว'); + } catch (error) { + console.log('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForTimeout(2000); +}); diff --git a/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_012_StatusLegalentitly.spec.ts b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_012_StatusLegalentitly.spec.ts new file mode 100644 index 00000000..e92796d6 --- /dev/null +++ b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_012_StatusLegalentitly.spec.ts @@ -0,0 +1,122 @@ +import { test, expect, Page } from '@playwright/test'; +import { strictEqual } from 'assert'; + +let page: Page; +let isLoginSuccessful = false; + +test.beforeAll(async ({ browser }) => { + page = await browser.newPage(); +}); + +test.afterAll(async () => { + if (page !== undefined) { + await page.close(); + } +}); + +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + // เข้าสู่เมนูลูกค้า + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-customer'); + await page.click('id=sub-menu-customer'); + await page.waitForTimeout(2000); + + isLoginSuccessful = true; + console.log('Login สำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + } +} + +test('Login', async () => { + await login(page); +}); + +test('ปิดสถานะนายจ้างนิติบุคคล', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + await page.click('id=btn-kebab-action-อนุชา ศรีสวัสดิ์'); + + await page.click('id=btn-kebab-status-อนุชา ศรีสวัสดิ์', { + force: true, + }); + await page.click('id=btn-ok-dialog'); + console.log('เปลี่ยนสถานะสำเร็จ'); + + // รอ Update + await page.waitForTimeout(2000); + console.log('สถานะถูกเปลี่ยนแล้ว'); + + // ตรวจสอบสีของแถวหลังจากทำการเปลี่ยนสถานะ + const rowLocator = page.locator( + "//tr[contains(.,'บริษัท เอเชียเทค ซิสเต็มส์ จำกัด') and contains (.,'022022002')]", + ); + const backgroundColor = await rowLocator.evaluate( + (el) => window.getComputedStyle(el).backgroundColor, + ); + + // กำหนดสีหลัเปลี่ยนสถานะการใช้งาน + const expectedColor = 'rgb(249, 250, 252)'; + + // ตรวจสอบสีที่เปลี่ยนไป + expect(backgroundColor.trim()).toBe(expectedColor); + console.log('สีของแถวถูกเปลี่ยนเป็นสีเทาอ่อน'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ'); + isLoginSuccessful = false; + throw error; + } + await page.waitForTimeout(2000); +}); + +test('เปิดสถานะนายจ้างนิติบุคคล', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + await page.click('id=btn-kebab-action-อนุชา ศรีสวัสดิ์'); + + await page.click('id=btn-kebab-status-อนุชา ศรีสวัสดิ์', { + force: true, + }); + await page.click('id=btn-ok-dialog'); + console.log('เปลี่ยนสถานะสำเร็จ'); + + // รอ Update + await page.waitForTimeout(2000); + console.log('สถานะถูกเปลี่ยนแล้ว'); + + // ตรวจสอบสีของแถวหลังจากทำการเปลี่ยนสถานะ + const rowLocator = page.locator( + "//tr[contains(.,'บริษัท เอเชียเทค ซิสเต็มส์ จำกัด') and contains (.,'022022002')]", + ); + const backgroundColor = await rowLocator.evaluate( + (el) => window.getComputedStyle(el).backgroundColor, + ); + + // กำหนดสีหลัเปลี่ยนสถานะการใช้งาน + const expectedColor = 'rgb(249, 250, 252)'; + + // ตรวจสอบสีที่เปลี่ยนไป + expect(backgroundColor.trim()).toBe(expectedColor); + console.log('สีของแถวถูกเปลี่ยนเป็นของสถานะการใช้งาน'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ'); + isLoginSuccessful = false; + throw error; + } + await page.waitForTimeout(2000); +}); diff --git a/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_013_DropdownEmployertype.spec.ts b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_013_DropdownEmployertype.spec.ts new file mode 100644 index 00000000..6e0fb092 --- /dev/null +++ b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_013_DropdownEmployertype.spec.ts @@ -0,0 +1,477 @@ +import { test, expect, Page } from '@playwright/test'; +import { strictEqual } from 'assert'; + +let page: Page; +let isLoginSuccessful = false; + +test.beforeAll(async ({ browser }) => { + page = await browser.newPage(); +}); + +test.afterAll(async () => { + if (page !== undefined) { + await page.close(); + } +}); + +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + // เข้าสู่เมนูลูกค้า + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-customer'); + await page.click('id=sub-menu-customer'); + await page.waitForTimeout(2000); + + isLoginSuccessful = true; + console.log('Login สำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการ Login'); + isLoginSuccessful = false; + } +} + +test('Login', async () => { + await login(page); +}); + +test('ตรวจสอบการแสดงผลฟิลด์แสดงลำดับ', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + // คลิกเพื่อเปิด dropdown + await page.click("(//input[@id='select-field'])[1]"); + await page.waitForTimeout(1000); // รอให้ dropdown เปิด + + // คลิกเพื่อปิดคอลัมน์ที่ 1 + await page.click('id=select-field_0'); + await page.waitForTimeout(1000); // รอให้ UI อัปเดต + + // ตรวจสอบว่าคอลัมน์ถูกซ่อน + const column1 = page.locator('id=select-field_0'); + const column1Cells = page.locator("//th[normalize-space(text())='ลําดับ']"); + + const isColumn1Hidden = await column1.evaluate( + (el) => window.getComputedStyle(el).display === 'none', + ); + console.log('คอลัมน์ที่ 1 ซ่อนอยู่:', isColumn1Hidden); // เช็ค + + const areCellsHidden = await column1Cells.evaluateAll((cells) => + cells.every((cell) => window.getComputedStyle(cell).display === 'none'), + ); + console.log('เซลล์ในคอลัมน์ที่ 1 ซ่อนอยู่:', areCellsHidden); // เช็ค + + expect(isColumn1Hidden).toBe(false); + expect(areCellsHidden).toBe(true); + + // คลิกอีกครั้งเพื่อเปิดคอลัมน์ที่ 1 + await page.keyboard.press('Escape'); + await page.click("(//input[@id='select-field'])[1]"); + await page.waitForTimeout(1000); // รอให้ dropdown เปิด + await page.click('id=select-field_0'); // คลิกเพื่อเปิดคอลัมน์ + await page.waitForTimeout(1000); // รอให้ UI อัปเดต + + // ตรวจสอบว่าคอลัมน์แสดงอยู่ + const isColumn1Visible = await column1.evaluate( + (el) => window.getComputedStyle(el).display !== 'none', + ); + console.log('คอลัมน์ที่ 1 แสดงอยู่:', isColumn1Visible); // เช็ค + + const areCellsVisible = await column1Cells.evaluateAll((cells) => + cells.every((cell) => window.getComputedStyle(cell).display !== 'none'), + ); + console.log('เซลล์ในคอลัมน์ที่ 1 แสดงอยู่:', areCellsVisible); // เช็ค + + expect(isColumn1Visible).toBe(true); + expect(areCellsVisible).toBe(true); + + console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; + throw error; + } + await page.keyboard.press('Escape'); +}); + +test('ตรวจสอบการแสดงผลฟิลด์แสดงผลชื่อ บริษัท/นิติบุคคล', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + // คลิกเพื่อเปิด dropdown + await page.click("(//input[@id='select-field'])[1]"); + await page.waitForTimeout(1000); // รอให้ dropdown เปิด + + // คลิกเพื่อปิดคอลัมน์ที่ 1 + await page.click('id=select-field_1'); + await page.waitForTimeout(1000); // รอให้ UI อัปเดต + + // ตรวจสอบว่าคอลัมน์ถูกซ่อน + const column1 = page.locator('id=select-field_1'); + const column1Cells = page.locator( + "//th[normalize-space(text())='ชื่อ บริษัท/นิติบุคคล']", + ); + + const isColumn1Hidden = await column1.evaluate( + (el) => window.getComputedStyle(el).display === 'none', + ); + console.log('คอลัมน์ที่ 1 ซ่อนอยู่:', isColumn1Hidden); // เช็ค + + const areCellsHidden = await column1Cells.evaluateAll((cells) => + cells.every((cell) => window.getComputedStyle(cell).display === 'none'), + ); + console.log('เซลล์ในคอลัมน์ที่ 1 ซ่อนอยู่:', areCellsHidden); // เช็ค + + expect(isColumn1Hidden).toBe(false); + expect(areCellsHidden).toBe(true); + + // คลิกอีกครั้งเพื่อเปิดคอลัมน์ที่ 1 + await page.keyboard.press('Escape'); + await page.click("(//input[@id='select-field'])[1]"); + await page.waitForTimeout(1000); // รอให้ dropdown เปิด + await page.click('id=select-field_1'); // คลิกเพื่อเปิดคอลัมน์ + await page.waitForTimeout(1000); // รอให้ UI อัปเดต + + // ตรวจสอบว่าคอลัมน์แสดงอยู่ + const isColumn1Visible = await column1.evaluate( + (el) => window.getComputedStyle(el).display !== 'none', + ); + console.log('คอลัมน์ที่ 2 แสดงอยู่:', isColumn1Visible); // เช็ค + + const areCellsVisible = await column1Cells.evaluateAll((cells) => + cells.every((cell) => window.getComputedStyle(cell).display !== 'none'), + ); + console.log('เซลล์ในคอลัมน์ที่ 2 แสดงอยู่:', areCellsVisible); // เช็ค + + expect(isColumn1Visible).toBe(true); + expect(areCellsVisible).toBe(true); + + console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; + throw error; + } + await page.keyboard.press('Escape'); +}); + +test('ตรวจสอบการแสดงผลฟิลด์แสดงผลประเภทกิจการ', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + // คลิกเพื่อเปิด dropdown + await page.click("(//input[@id='select-field'])[1]"); + await page.waitForTimeout(1000); // รอให้ dropdown เปิด + + // คลิกเพื่อปิดคอลัมน์ที่ 1 + await page.click('id=select-field_2'); + await page.waitForTimeout(1000); // รอให้ UI อัปเดต + + // ตรวจสอบว่าคอลัมน์ถูกซ่อน + const column1 = page.locator('id=select-field_2'); + const column1Cells = page.locator( + "//th[normalize-space(text())='ประเภทกิจการ']", + ); + + const isColumn1Hidden = await column1.evaluate( + (el) => window.getComputedStyle(el).display === 'none', + ); + console.log('คอลัมน์ที่ 3 ซ่อนอยู่:', isColumn1Hidden); // เช็ค + + const areCellsHidden = await column1Cells.evaluateAll((cells) => + cells.every((cell) => window.getComputedStyle(cell).display === 'none'), + ); + console.log('เซลล์ในคอลัมน์ที่ 3 ซ่อนอยู่:', areCellsHidden); // เช็ค + + expect(isColumn1Hidden).toBe(false); + expect(areCellsHidden).toBe(true); + + // คลิกอีกครั้งเพื่อเปิดคอลัมน์ที่ 1 + await page.keyboard.press('Escape'); + await page.click("(//input[@id='select-field'])[1]"); + await page.waitForTimeout(1000); // รอให้ dropdown เปิด + await page.click('id=select-field_2'); // คลิกเพื่อเปิดคอลัมน์ + await page.waitForTimeout(1000); // รอให้ UI อัปเดต + + // ตรวจสอบว่าคอลัมน์แสดงอยู่ + const isColumn1Visible = await column1.evaluate( + (el) => window.getComputedStyle(el).display !== 'none', + ); + console.log('คอลัมน์ที่ 3 แสดงอยู่:', isColumn1Visible); // เช็ค + + const areCellsVisible = await column1Cells.evaluateAll((cells) => + cells.every((cell) => window.getComputedStyle(cell).display !== 'none'), + ); + console.log('เซลล์ในคอลัมน์ที่ 3 แสดงอยู่:', areCellsVisible); // เช็ค + + expect(isColumn1Visible).toBe(true); + expect(areCellsVisible).toBe(true); + + console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; + throw error; + } + await page.keyboard.press('Escape'); +}); + +test('ตรวจสอบการแสดงผลฟิลด์แสดงผลตำแหน่งงาน', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + // คลิกเพื่อเปิด dropdown + await page.click("(//input[@id='select-field'])[1]"); + await page.waitForTimeout(1000); // รอให้ dropdown เปิด + + // คลิกเพื่อปิดคอลัมน์ที่ 1 + await page.click('id=select-field_3'); + await page.waitForTimeout(1000); // รอให้ UI อัปเดต + + // ตรวจสอบว่าคอลัมน์ถูกซ่อน + const column1 = page.locator('id=select-field_3'); + const column1Cells = page.locator( + "//th[normalize-space(text())='ตำแหน่งงาน']", + ); + + const isColumn1Hidden = await column1.evaluate( + (el) => window.getComputedStyle(el).display === 'none', + ); + console.log('คอลัมน์ที่ 4 ซ่อนอยู่:', isColumn1Hidden); // เช็ค + + const areCellsHidden = await column1Cells.evaluateAll((cells) => + cells.every((cell) => window.getComputedStyle(cell).display === 'none'), + ); + console.log('เซลล์ในคอลัมน์ที่ 4 ซ่อนอยู่:', areCellsHidden); // เช็ค + + expect(isColumn1Hidden).toBe(false); + expect(areCellsHidden).toBe(true); + + // คลิกอีกครั้งเพื่อเปิดคอลัมน์ที่ 1 + await page.keyboard.press('Escape'); + await page.click("(//input[@id='select-field'])[1]"); + await page.waitForTimeout(1000); // รอให้ dropdown เปิด + await page.click('id=select-field_3'); // คลิกเพื่อเปิดคอลัมน์ + await page.waitForTimeout(1000); // รอให้ UI อัปเดต + + // ตรวจสอบว่าคอลัมน์แสดงอยู่ + const isColumn1Visible = await column1.evaluate( + (el) => window.getComputedStyle(el).display !== 'none', + ); + console.log('คอลัมน์ที่ 4 แสดงอยู่:', isColumn1Visible); // เช็ค + + const areCellsVisible = await column1Cells.evaluateAll((cells) => + cells.every((cell) => window.getComputedStyle(cell).display !== 'none'), + ); + console.log('เซลล์ในคอลัมน์ที่ 4 แสดงอยู่:', areCellsVisible); // เช็ค + + expect(isColumn1Visible).toBe(true); + expect(areCellsVisible).toBe(true); + + console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; + throw error; + } + await page.keyboard.press('Escape'); +}); + +test('ตรวจสอบการแสดงผลฟิลด์แสดงผลที่อยู่', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + // คลิกเพื่อเปิด dropdown + await page.click("(//input[@id='select-field'])[1]"); + await page.waitForTimeout(1000); // รอให้ dropdown เปิด + + // คลิกเพื่อปิดคอลัมน์ที่ 1 + await page.click('id=select-field_4'); + await page.waitForTimeout(1000); // รอให้ UI อัปเดต + + // ตรวจสอบว่าคอลัมน์ถูกซ่อน + const column1 = page.locator('id=select-field_4'); + const column1Cells = page.locator( + "//th[normalize-space(text())='ที่อยู่']", + ); + + const isColumn1Hidden = await column1.evaluate( + (el) => window.getComputedStyle(el).display === 'none', + ); + console.log('คอลัมน์ที่ 5 ซ่อนอยู่:', isColumn1Hidden); // เช็ค + + const areCellsHidden = await column1Cells.evaluateAll((cells) => + cells.every((cell) => window.getComputedStyle(cell).display === 'none'), + ); + console.log('เซลล์ในคอลัมน์ที่ 5 ซ่อนอยู่:', areCellsHidden); // เช็ค + + expect(isColumn1Hidden).toBe(false); + expect(areCellsHidden).toBe(true); + + // คลิกอีกครั้งเพื่อเปิดคอลัมน์ที่ 1 + await page.keyboard.press('Escape'); + await page.click("(//input[@id='select-field'])[1]"); + await page.waitForTimeout(1000); // รอให้ dropdown เปิด + await page.click('id=select-field_4'); // คลิกเพื่อเปิดคอลัมน์ + await page.waitForTimeout(1000); // รอให้ UI อัปเดต + + // ตรวจสอบว่าคอลัมน์แสดงอยู่ + const isColumn1Visible = await column1.evaluate( + (el) => window.getComputedStyle(el).display !== 'none', + ); + console.log('คอลัมน์ที่ 5 แสดงอยู่:', isColumn1Visible); // เช็ค + + const areCellsVisible = await column1Cells.evaluateAll((cells) => + cells.every((cell) => window.getComputedStyle(cell).display !== 'none'), + ); + console.log('เซลล์ในคอลัมน์ที่ 5 แสดงอยู่:', areCellsVisible); // เช็ค + + expect(isColumn1Visible).toBe(true); + expect(areCellsVisible).toBe(true); + + console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; + throw error; + } + await page.keyboard.press('Escape'); +}); + +test('ตรวจสอบการแสดงผลฟิลด์แสดงผลชื่อผู้ติดต่อ', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + // คลิกเพื่อเปิด dropdown + await page.click("(//input[@id='select-field'])[1]"); + await page.waitForTimeout(1000); // รอให้ dropdown เปิด + + // คลิกเพื่อปิดคอลัมน์ที่ 1 + await page.click('id=select-field_5'); + await page.waitForTimeout(1000); // รอให้ UI อัปเดต + + // ตรวจสอบว่าคอลัมน์ถูกซ่อน + const column1 = page.locator('id=select-field_5'); + const column1Cells = page.locator( + "//th[normalize-space(text())='ชื่อผู้ติดต่อ']", + ); + + const isColumn1Hidden = await column1.evaluate( + (el) => window.getComputedStyle(el).display === 'none', + ); + console.log('คอลัมน์ที่ 6 ซ่อนอยู่:', isColumn1Hidden); // เช็ค + + const areCellsHidden = await column1Cells.evaluateAll((cells) => + cells.every((cell) => window.getComputedStyle(cell).display === 'none'), + ); + console.log('เซลล์ในคอลัมน์ที่ 6 ซ่อนอยู่:', areCellsHidden); // เช็ค + + expect(isColumn1Hidden).toBe(false); + expect(areCellsHidden).toBe(true); + + // คลิกอีกครั้งเพื่อเปิดคอลัมน์ที่ 1 + await page.keyboard.press('Escape'); + await page.click("(//input[@id='select-field'])[1]"); + await page.waitForTimeout(1000); // รอให้ dropdown เปิด + await page.click('id=select-field_5'); // คลิกเพื่อเปิดคอลัมน์ + await page.waitForTimeout(1000); // รอให้ UI อัปเดต + + // ตรวจสอบว่าคอลัมน์แสดงอยู่ + const isColumn1Visible = await column1.evaluate( + (el) => window.getComputedStyle(el).display !== 'none', + ); + console.log('คอลัมน์ที่ 6 แสดงอยู่:', isColumn1Visible); // เช็ค + + const areCellsVisible = await column1Cells.evaluateAll((cells) => + cells.every((cell) => window.getComputedStyle(cell).display !== 'none'), + ); + console.log('เซลล์ในคอลัมน์ที่ 6 แสดงอยู่:', areCellsVisible); // เช็ค + + expect(isColumn1Visible).toBe(true); + expect(areCellsVisible).toBe(true); + + console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; + throw error; + } + await page.keyboard.press('Escape'); +}); + +test('ตรวจสอบการแสดงผลฟิลด์แสดงผลเบอร์โทรติดต่อ', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + // คลิกเพื่อเปิด dropdown + await page.click("(//input[@id='select-field'])[1]"); + await page.waitForTimeout(1000); // รอให้ dropdown เปิด + + // คลิกเพื่อปิดคอลัมน์ที่ 1 + await page.click('id=select-field_6'); + await page.waitForTimeout(1000); // รอให้ UI อัปเดต + + // ตรวจสอบว่าคอลัมน์ถูกซ่อน + const column1 = page.locator('id=select-field_6'); + const column1Cells = page.locator( + "//th[normalize-space(text())='เบอร์โทรติดต่อ']", + ); + + const isColumn1Hidden = await column1.evaluate( + (el) => window.getComputedStyle(el).display === 'none', + ); + console.log('คอลัมน์ที่ 7 ซ่อนอยู่:', isColumn1Hidden); // เช็ค + + const areCellsHidden = await column1Cells.evaluateAll((cells) => + cells.every((cell) => window.getComputedStyle(cell).display === 'none'), + ); + console.log('เซลล์ในคอลัมน์ที่ 7 ซ่อนอยู่:', areCellsHidden); // เช็ค + + expect(isColumn1Hidden).toBe(false); + expect(areCellsHidden).toBe(true); + + // คลิกอีกครั้งเพื่อเปิดคอลัมน์ที่ 1 + await page.keyboard.press('Escape'); + await page.click("(//input[@id='select-field'])[1]"); + await page.waitForTimeout(1000); // รอให้ dropdown เปิด + await page.click('id=select-field_6'); // คลิกเพื่อเปิดคอลัมน์ + await page.waitForTimeout(1000); // รอให้ UI อัปเดต + + // ตรวจสอบว่าคอลัมน์แสดงอยู่ + const isColumn1Visible = await column1.evaluate( + (el) => window.getComputedStyle(el).display !== 'none', + ); + console.log('คอลัมน์ที่ 7 แสดงอยู่:', isColumn1Visible); // เช็ค + + const areCellsVisible = await column1Cells.evaluateAll((cells) => + cells.every((cell) => window.getComputedStyle(cell).display !== 'none'), + ); + console.log('เซลล์ในคอลัมน์ที่ 7 แสดงอยู่:', areCellsVisible); // เช็ค + + expect(isColumn1Visible).toBe(true); + expect(areCellsVisible).toBe(true); + + console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; + throw error; + } + await page.keyboard.press('Escape'); + await page.waitForTimeout(2000); +}); diff --git a/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_014_SearchManageCustomer.spec.ts b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_014_SearchManageCustomer.spec.ts new file mode 100644 index 00000000..42981749 --- /dev/null +++ b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_014_SearchManageCustomer.spec.ts @@ -0,0 +1,102 @@ +import { test, expect, Page } from '@playwright/test'; +import { strictEqual } from 'assert'; + +let page: Page; +let isLoginSuccessful = false; + +test.beforeAll(async ({ browser }) => { + page = await browser.newPage(); +}); + +test.afterAll(async () => { + if (page !== undefined) { + await page.close(); + } +}); + +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + // เข้าสู่เมนูลูกค้า + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-customer'); + await page.click('id=sub-menu-customer'); + await page.waitForTimeout(2000); + + isLoginSuccessful = true; + console.log('Login สำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการ Login', error); + isLoginSuccessful = false; + } +} + +test('Login', async () => { + await login(page); +}); + +test('ทดสอบการค้นหาข้อมูลเมนูลูกค้า', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + // กำหนดคำที่จะค้นหา + const searchDatas = [ + 'Yossapat', + 'ยศพัฒน์ ธนากานต์', + 'AsiaTech Systems Co., Ltd', + 'Systems', + 'Tanakarn', + ]; + + for (const searchData of searchDatas) { + // พิมพ์คำที่ต้องการค้นหา + await page.fill('id=input-search', searchData); // ดึงคำมาจาก searchDatas + await page.waitForTimeout(2000); + + // ดึงผลลัพฑ์การค้นหาทั้งหมด + const searchResults = page.locator("//table[@class='q-table']//tbody[1]"); + const resultCount = await searchResults.count(); + + // ถ้าไม่มีผลลัพธ์ให้ข้ามคำถัดไป + if (resultCount === 0) { + console.error(`ไม่พบการค้นหา: '${searchData}', ข้ามไปคำถัดไป`); + continue; // ข้ามคำค้นหาคำถัดไป + } + + // ดึงข้อความทั้งหมดของผลลัพธ์การค้นหา + const searchResultTexts = await searchResults.allTextContents(); + console.log(`ผลลัพธ์ของการค้นหา '${searchData}'`, searchDatas); + + // ตรวจสอบว่าผลลัพธ์ทั้งหมดมีคำที่ค้นหาหรือไม่ + const allResultContainSearchData = searchResultTexts.every((result) => + result.includes(searchData), + ); + + // ถ้าไม่พบคำค้นหา ให้แค่แจ้งเตือนและข้ามไปคำถัดไป + if (!allResultContainSearchData) { + console.error( + `\x1b[31mผลลัพธ์บางรายการไม่ตรงกับคำค้นหา: '${searchData}', ข้ามไปคำถัดไป\x1b[0m`, + ); + continue; // ข้ามไปคำค้นหาถัดไป + } + + expect(allResultContainSearchData).toBe(true); + + console.log(`การค้นหา '${searchData}' และการแสดงผลสำเร็จ`); + } + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบการค้นหาหลายคำค้นหา', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForTimeout(2000); +}); diff --git a/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_015_ManageStatusCustomerType.spec.ts b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_015_ManageStatusCustomerType.spec.ts new file mode 100644 index 00000000..8e84b82a --- /dev/null +++ b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_015_ManageStatusCustomerType.spec.ts @@ -0,0 +1,113 @@ +import { test, expect, Page } from '@playwright/test'; +import { strictEqual } from 'assert'; + +let page: Page; +let isLoginSuccessful = false; + +test.beforeAll(async ({ browser }) => { + page = await browser.newPage(); +}); + +test.afterAll(async () => { + if (page !== undefined) { + await page.close(); + } +}); + +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + // เข้าสู่เมนูลูกค้า + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-customer'); + await page.click('id=sub-menu-customer'); + await page.waitForTimeout(2000); + + isLoginSuccessful = true; + console.log('Login สำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการ Login', error); + isLoginSuccessful = false; + } +} + +test('Login', async () => { + await login(page); +}); + +test('ตรวจสอบการแสดงสถานะใช้งาน เปิด/ปิด นายจ้าง', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + // แสดงสถานะที่ใช้งาน + // คลิกเพื่อเปิด dropdown + await page.waitForTimeout(1000); + await page.click('id=select-status'); + //รอให้ dropdown เปิด + await page.waitForSelector('id=select-status_1'); + + // คลิกเพื่อแสดงสถานะกำลังใช้งานอยู่ + await page.click('id=select-status_1'); + await page.waitForTimeout(1000); // รอให้ UI อัปเดต + + // ตรวจสอบว่ามีแต่สถานะใช้งานหรือไม่ + const statusActive = await page.isVisible('id=select-status_1'); + + console.log('มีเพียงสถานะการใช้งานเท่านั้น', statusActive); // เช็ค + + expect(statusActive).toBe(false); + + console.log('ตรวจสอบสถานะการใช้งานมีแต่สถานะกำลังใช้งานเท่านั้น'); + + // แสดงสถานะที่ไม่ใช้งาน + // คลิกเพื่อเปิด dropdown + await page.keyboard.press('Escape'); + await page.click('id=select-status'); + await page.waitForTimeout(1000); // รอให้ dropdown เปิด + + // คลิกเพื่อแสดงสถานะกำลังไม่ใช้งาน + await page.click('id=select-status_2'); + await page.waitForTimeout(1000); // รอให้ UI อัปเดต + + // ตรวจสอบว่ามีแต่สถานะไม่ใช้งานหรือไม่ + const statusInActive = await page.isVisible('id=select-status_1'); + + console.log('มีเพียงสถานะการใช้งานเท่านั้น', statusInActive); // เช็ค + + expect(statusActive).toBe(false); + + console.log('ตรวจสอบสถานะการใช้งานมีแต่สถานะที่ไม่ใช้งาน'); + + // แสดงสถานะทั้งหมด + // คลิกเพื่อเปิด dropdown + await page.keyboard.press('Escape'); + await page.click('id=select-status'); + await page.waitForTimeout(1000); // รอให้ dropdown เปิด + + // คลิกเพื่อแสดงสถานะทั้งหมด + await page.click('id=select-status_0'); + await page.waitForTimeout(1000); // รอให้ UI อัปเดต + + // ตรวจสอบว่าแสดงทุกสถานะหรือไม่ + const statusAll = await page.isVisible('id=select-status_1'); + + console.log('สถานะทั้งหมด', statusAll); // เช็ค + + expect(statusActive).toBe(false); + + console.log('ตรวจสอบสถานะทั้งหมด'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; + throw error; + } +}); diff --git a/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_016_CreateEmployee.spec.ts b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_016_CreateEmployee.spec.ts new file mode 100644 index 00000000..c5fe5b99 --- /dev/null +++ b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_016_CreateEmployee.spec.ts @@ -0,0 +1,331 @@ +import { test, expect, Page } from '@playwright/test'; +import { strictEqual } from 'assert'; +import { writeFileSync } from 'fs'; + +let page: Page; +let isLoginSuccessful = false; + +test.beforeAll(async ({ browser }) => { + page = await browser.newPage(); +}); + +test.afterAll(async () => { + if (page !== undefined) { + await page.close(); + } +}); + +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + // เข้าสู่เมนูลูกค้า + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-customer'); + await page.click('id=sub-menu-customer'); + await page.waitForSelector('id=tab-employee'); + await page.click('id=tab-employee'); + await page.waitForTimeout(2000); + + isLoginSuccessful = true; + console.log('Login สำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการ Login', error); + isLoginSuccessful = false; + } +} + +test('Login', async () => { + await login(page); +}); + +test('ทดสอบการสร้างลูกจ้างนรูปแบบใช้ที่อยู่นายจ้าง', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + await page.click('id=btn-add'); + await page.waitForTimeout(2000); + // ส่วนข้อมูลพื้นฐาน + await page.click('id=form-employee-select-employer-branch'); + await page.waitForSelector('id=form-employee-select-employer-branch_1'); + await page.click('id=form-employee-select-employer-branch_1'); + await page.fill('id=form-employee-input-nrc-no', '2822022820220'); + // ส่วนข้้อมูลส่วนตัว + await page.click('id=form-employee-select-prefix-name'); + await page.waitForSelector('id=form-employee-select-prefix-name_0'); + await page.click('id=form-employee-select-prefix-name_0'); + await page.fill( + "(//input[@id='form-employee-input-first-name'])[1]", + 'กิตติศักดิ์', + ); + await page.fill('id=form-employee-input-last-name', 'วิจิตรานนท์'); + await page.fill('id=form-employee-input-first-name-en', 'Kittisak'); + await page.fill('id=form-employee-input-last-name-en', 'Wijitranon'); + + // วันเดิิอนปีเกิด + await page.click('id=form-employee-input-birth-date'); + await page.waitForSelector( + "(//button[@class='dp__btn dp__month_year_select'])[2]", + ); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); + await page.click("//div[text()='1996']"); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[1]"); + await page.click("//div[text()='พ.ค.']"); + await page.click("//div[@id='1996-05-02']/div[1]"); + + // สัญชาติ + await page.click('id=form-employee-select-nationality'); + await page.waitForSelector('id=form-employee-select-nationality_2'); + await page.click('id=form-employee-select-nationality_2'); + + await page.click('id=btn-info-basic-save'); + await page.waitForTimeout(2000); + + // -------------------- Tab ข้อมูลหนังสือเดินทาง ------------------------------ + await page.waitForSelector( + 'id=dialog-tab-customerEmployee.fileType.passport', + { + state: 'visible', + }, + ); + + await page.click('id=dialog-tab-customerEmployee.fileType.passport', { + force: true, + }); + await page.fill( + "(//input[@id='drawer-info-employee-input-passport-no'])[2]", + 'MM202228', + ); + await page.click( + "(//input[@id='drawer-info-employee-select-passport-country'])[2]", + ); + await page.waitForSelector( + 'id=drawer-info-employee-select-passport-country_1', + ); + await page.click('id=drawer-info-employee-select-passport-country_1'); + + // วันหมดอายุหนังสือเดือนทาง + await page.waitForTimeout(1000); + await page.click( + "(//input[@id='drawer-info-employee-date-picker-passport-expire'])[2]", + ); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); + await page.click("//div[text()='2030']"); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[1]"); + await page.click("//div[@data-test='ส.ค.']"); + await page.click("//div[@id='2030-08-10']/div[1]"); + + await page.waitForSelector("(//button[@type='submit'])[2]"); + await page.click("(//button[@type='submit'])[2]"); + await page.waitForTimeout(2000); + + // -------------------- Tab ข้อมูล Visa ------------------------------------ + await page.waitForSelector( + 'id=dialog-tab-customerEmployee.form.group.visa', + { + state: 'visible', + }, + ); + + await page.click('id=dialog-tab-customerEmployee.form.group.visa', { + force: true, + }); + + // ใช้ได้ถึงวันที่ + await page.click( + "(//input[@id='drawer-info-employee-date-picker-visa-expire'])[2]", + ); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); + await page.click("//div[text()='2030']"); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[1]"); + await page.click("//div[text()='ธ.ค.']"); + await page.click("//div[@id='2030-12-04']/div[1]"); + await page.click("(//button[@type='submit'])[2]"); + await page.waitForTimeout(2000); + await page.click('id=btn-form-close'); + await page.waitForTimeout(2000); + + const employeeCheck = await page.locator( + "//tr[contains(.,'Kittisak Wijitranon') and contains (.,'บริษัท เอเชียเทค ซิสเต็มส์ จำกัด')]", + ); + + await expect(employeeCheck).toContainText('Kittisak Wijitranon'); + await expect(employeeCheck).toContainText( + 'บริษัท เอเชียเทค ซิสเต็มส์ จำกัด', + ); + console.log('ระบบทำการตรวจสอบการจ้างลูกจ้างถูกต้อง'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForTimeout(2000); +}); + +test('ทดสอบการสร้างลูกจ้างนรูปแบบใช้ที่อยู่แบบกำหนดเอง', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + await page.reload(); + await page.waitForSelector('id=tab-employee'); + await page.click('id=tab-employee'); + await page.waitForTimeout(1000); + await page.click('id=btn-add'); + await page.waitForTimeout(2000); + // ส่วนข้อมูลพื้นฐาน + await page.click('id=form-employee-select-employer-branch'); + await page.waitForSelector('id=form-employee-select-employer-branch_0'); + await page.click('id=form-employee-select-employer-branch_0'); + await page.fill('id=form-employee-input-nrc-no', '2822022820222'); + // ส่วนข้้อมูลส่วนตัว + await page.click('id=form-employee-select-prefix-name'); + await page.waitForSelector('id=form-employee-select-prefix-name_1'); + await page.click('id=form-employee-select-prefix-name_1'); + await page.fill( + "(//input[@id='form-employee-input-first-name'])[1]", + 'วรัญญา', + ); + await page.fill('id=form-employee-input-last-name', 'สุขเกษม'); + await page.fill('id=form-employee-input-first-name-en', 'Waranya'); + await page.fill('id=form-employee-input-last-name-en', 'Sukkasem'); + + // วันเดิิอนปีเกิด + await page.click('id=form-employee-input-birth-date'); + await page.waitForSelector( + "(//button[@class='dp__btn dp__month_year_select'])[2]", + ); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); + await page.click("//div[text()='1994']"); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[1]"); + await page.click("//div[text()='เม.ย.']"); + await page.click("//div[@id='1994-04-02']/div[1]"); + + // สัญชาติ + await page.click('id=form-employee-select-nationality'); + await page.waitForSelector('id=form-employee-select-nationality_4'); + await page.click('id=form-employee-select-nationality_4'); + + // ส่วนที่อยู่ + await page.click('id=form-employee-custom'); + await page.fill( + 'id=form-employee-input-address-no', + '89/15 หมู่บ้านเพชรทวี', + ); + await page.fill( + "(//input[@id='form-employee-input-soi'])[1]", + 'สุขุมวิท 55 ', + ); + await page.fill( + "(//input[@id='form-employee-input-street'])[1]", + 'สุขุมวิท', + ); + await page.click('id=form-employee-select-district'); + (await page.waitForSelector('id=form-employee-select-district_13')) + .scrollIntoViewIfNeeded; + await page.click('id=form-employee-select-district_13'); + await page.click('id=form-employee-select-sub-district'); + await page.waitForSelector('id=form-employee-select-sub-district_1'); + await page.click('id=form-employee-select-sub-district_1'); + await page.fill( + 'id=form-employee-input-address-en', + '89/15 Phetthawee Village', + ); + await page.fill( + "(//input[@id='form-employee-input-soi'])[2]", + 'Sukhumvit 55', + ); + await page.fill( + "(//input[@id='form-employee-input-street'])[2]", + 'Sukhumvit', + ); + await page.waitForTimeout(2000); + await page.click("//button[@type='submit']"); + await page.waitForTimeout(2000); + + // -------------------- Tab ข้อมูลหนังสือเดินทาง ------------------------------ + await page.waitForSelector( + 'id=dialog-tab-customerEmployee.fileType.passport', + { + state: 'visible', + }, + ); + + await page.click('id=dialog-tab-customerEmployee.fileType.passport', { + force: true, + }); + await page.fill( + "(//input[@id='drawer-info-employee-input-passport-no'])[2]", + 'VN220228', + ); + await page.click( + "(//input[@id='drawer-info-employee-select-passport-country'])[2]", + ); + await page.waitForSelector( + 'id=drawer-info-employee-select-passport-country_4', + ); + await page.click('id=drawer-info-employee-select-passport-country_4'); + + // วันหมดอายุหนังสือเดือนทาง + await page.waitForTimeout(1000); + await page.click( + "(//input[@id='drawer-info-employee-date-picker-passport-expire'])[2]", + ); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); + await page.click("//div[text()='2032']"); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[1]"); + await page.click("//div[@data-test='ส.ค.']"); + await page.click("//div[@id='2032-08-10']/div[1]"); + + await page.waitForSelector("(//button[@type='submit'])[2]"); + await page.click("(//button[@type='submit'])[2]"); + await page.waitForTimeout(2000); + + // -------------------- Tab ข้อมูล Visa ------------------------------------ + await page.waitForSelector( + 'id=dialog-tab-customerEmployee.form.group.visa', + { + state: 'visible', + }, + ); + + await page.click('id=dialog-tab-customerEmployee.form.group.visa', { + force: true, + }); + + // ใช้ได้ถึงวันที่ + await page.click( + "(//input[@id='drawer-info-employee-date-picker-visa-expire'])[2]", + ); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); + await page.click("//div[text()='2032']"); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[1]"); + await page.click("//div[text()='ธ.ค.']"); + await page.click("//div[@id='2032-12-04']/div[1]"); + await page.click("(//button[@type='submit'])[2]"); + await page.waitForTimeout(2000); + await page.click('id=btn-form-close'); + await page.waitForTimeout(2000); + + const employeeCheck = await page.locator( + "//tr[contains(.,'Waranya Sukkasem') and contains (.,'1524428220420-00')]", + ); + + await expect(employeeCheck).toContainText('Waranya Sukkasem'); + await expect(employeeCheck).toContainText('1524428220420-00'); + console.log('ระบบทำการตรวจสอบการจ้างลูกจ้างถูกต้อง'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForTimeout(2000); +}); diff --git a/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_017-1_CreateEmployeeFailEn.spec.ts b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_017-1_CreateEmployeeFailEn.spec.ts new file mode 100644 index 00000000..f95b86e4 --- /dev/null +++ b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_017-1_CreateEmployeeFailEn.spec.ts @@ -0,0 +1,273 @@ +import { test, expect, Page } from '@playwright/test'; +import { strictEqual } from 'assert'; + +let page: Page; +let isLoginSuccessful = false; + +test.beforeAll(async ({ browser }) => { + page = await browser.newPage(); +}); + +test.afterAll(async () => { + if (page !== undefined) { + await page.close(); + } +}); + +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + // เข้าสู่เมนูลูกค้า + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-customer'); + await page.click('id=sub-menu-customer'); + await page.waitForSelector('id=tab-employee'); + await page.click('id=tab-employee'); + await page.waitForTimeout(2000); + + // เปลี่ยนภาษา + await page.click('id=btn-change-language'); + await page.waitForSelector('id=btn-change-language-eng'); + await page.click('id=btn-change-language-eng'); + await page.waitForTimeout(2000); + + isLoginSuccessful = true; + console.log('Login สำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการ Login', error); + isLoginSuccessful = false; + } +} + +test('Login', async () => { + await login(page); +}); + +test('เพิ่มลูกจ้างในกรณีที่ไม่กรอกข้อมูล', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + await page.click('id=btn-add'); + await page.waitForTimeout(2000); + await page.click('id=btn-info-basic-save'); + await page.waitForTimeout(2000); + + const selectBranchError = await page.locator( + "(//div[@class='q-field__messages col']//div)[1]", + ); + const firstNameError = await page.locator( + "(//div[@class='q-field__messages col']//div)[2]", + ); + const lastNameError = await page.locator( + "(//div[@class='q-field__messages col']//div)[3]", + ); + const firstNameEngError = await page.locator( + "(//div[@class='q-field__messages col']//div)[4]", + ); + const lastNameEngError = await page.locator( + "(//div[@class='q-field__messages col']//div)[5]", + ); + const brithdateError = await page.locator( + "(//div[@class='q-field__messages col']//div)[6]", + ); + const genderError = await page.locator( + "(//div[@class='q-field__messages col']//div)[7]", + ); + const nationalityError = await page.locator( + "(//div[@class='q-field__messages col']//div)[8]", + ); + const addressError = await page.locator( + "(//div[@class='q-field__messages col']//div)[9]", + ); + const provinceError = await page.locator( + "(//div[@class='q-field__messages col']//div)[10]", + ); + const districtError = await page.locator( + "(//div[@class='q-field__messages col']//div)[11]", + ); + const subdistrictError = await page.locator( + "(//div[@class='q-field__messages col']//div)[12]", + ); + const addressEngError = await page.locator( + "(//div[@class='q-field__messages col']//div)[13]", + ); + + await expect(selectBranchError).toHaveText('Please select Branch.'); + await expect(firstNameError).toHaveText('This field is required.'); + await expect(lastNameError).toHaveText('This field is required.'); + await expect(firstNameEngError).toHaveText('This field is required.'); + await expect(lastNameEngError).toHaveText('This field is required.'); + await expect(brithdateError).toHaveText('Please select Birth Date.'); + await expect(genderError).toHaveText('This field is required.'); + await expect(nationalityError).toHaveText('This field is required.'); + await expect(addressError).toHaveText('This field is required.'); + await expect(provinceError).toHaveText('Please select Province.'); + await expect(districtError).toHaveText('Please select District.'); + await expect(subdistrictError).toHaveText('Please select Sub-district.'); + await expect(addressEngError).toHaveText('This field is required.'); + + console.log('ระบบทำการตรวจสอบการแจ้งเตือนเรียบร้อย'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForSelector('id=btn-form-close'); + await page.click('id=btn-form-close'); + await page.waitForTimeout(2000); +}); + +test('เพิ่มลูกจ้างในกรณีที่กรอกเลข N.R.C No. ไม่ครบ 13 หลัก', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + await page.click('id=btn-add'); + await page.waitForTimeout(2000); + await page.fill('id=form-employee-input-nrc-no', '123'); + await page.waitForTimeout(2000); + + const numbernrc = await page.locator( + "(//div[@class='q-field__messages col']//div)[1]", + ); + + await expect(numbernrc).toHaveText( + 'Invalid value. Please enter 13 character', + ); + + console.log('ระบบทำการตรวจสอบการแจ้งเตือนเรียบร้อย'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + throw error; + } + await page.waitForSelector('id=btn-form-close'); + await page.click('id=btn-form-close'); + await page.waitForSelector('id=btn-ok-dialog'); + await page.click('id=btn-ok-dialog'); + await page.waitForTimeout(2000); +}); + +test('เพิ่มลูกจ้างในกรณีที่กรอกช่องชื่อนามสกุลภาษาอังกฤษไม่ถูกต้อง', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + await page.click('id=btn-add'); + await page.waitForTimeout(2000); + await page.fill('id=form-employee-input-first-name-en', 'ชื่อ'); + await page.fill('id=form-employee-input-last-name-en', 'นามสกุล'); + await page.waitForTimeout(2000); + + const firstNameEngError = await page.locator( + "(//div[@class='q-field__messages col']//div)[1]", + ); + const lastNameEngError = await page.locator( + "(//div[@class='q-field__messages col']//div)[2]", + ); + + await expect(firstNameEngError).toHaveText('Only letters are allowed'); + await expect(lastNameEngError).toHaveText('Only letters are allowed'); + console.log('ระบบทำการตรวจสอบการแจ้งเตือนเรียบร้อย'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForSelector('id=btn-form-close'); + await page.click('id=btn-form-close'); + await page.waitForSelector('id=btn-ok-dialog'); + await page.click('id=btn-ok-dialog'); + await page.waitForTimeout(2000); +}); + +test('ทดสอบการสร้างลูกจ้างในกรณีที่เพิ่มข้อมูล Tab ข้อมูลหนังสือเดินทาง แต่ไม่กรอกข้อมูล', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + await page.click('id=btn-add'); + await page.waitForTimeout(2000); + // ส่วนข้อมูลพื้นฐาน + await page.click('id=form-employee-select-employer-branch'); + await page.waitForSelector('id=form-employee-select-employer-branch_1'); + await page.click('id=form-employee-select-employer-branch_1'); + await page.fill('id=form-employee-input-nrc-no', '2822022820220'); + // ส่วนข้้อมูลส่วนตัว + await page.click('id=form-employee-select-prefix-name'); + await page.waitForSelector('id=form-employee-select-prefix-name_0'); + await page.click('id=form-employee-select-prefix-name_0'); + await page.fill( + "(//input[@id='form-employee-input-first-name'])[1]", + 'นราธิป', + ); + await page.fill('id=form-employee-input-last-name', 'แสงรุ่ง'); + await page.fill('id=form-employee-input-first-name-en', 'Narathip'); + await page.fill('id=form-employee-input-last-name-en', 'Saengrung'); + + // วันเดิิอนปีเกิด + await page.click('id=form-employee-input-birth-date'); + await page.waitForSelector( + "(//button[@class='dp__btn dp__month_year_select'])[2]", + ); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); + await page.click("//div[text()='1996']"); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[1]"); + await page.click("//div[text()='May']"); + await page.click("//div[@id='1996-05-02']/div[1]"); + + // สัญชาติ + await page.click('id=form-employee-select-nationality'); + await page.waitForSelector('id=form-employee-select-nationality_2'); + await page.click('id=form-employee-select-nationality_2'); + + await page.click('id=btn-info-basic-save'); + await page.waitForTimeout(2000); + + // -------------------- Tab ข้อมูลหนังสือเดินทาง ------------------------------ + await page.waitForSelector( + 'id=dialog-tab-customerEmployee.fileType.passport', + { + state: 'visible', + }, + ); + + await page.click('id=dialog-tab-customerEmployee.fileType.passport', { + force: true, + }); + await page.waitForSelector("(//button[@type='submit'])[2]"); + await page.click("(//button[@type='submit'])[2]"); + await page.waitForTimeout(2000); + + const numberPassport = await page.locator( + "(//div[@class='q-field__messages col']//div)[1]", + ); + const typeCountryPassport = await page.locator( + "(//div[@class='q-field__messages col']//div)[2]", + ); + const typeLocationCountry = await page.locator( + "(//div[@class='q-field__messages col']//div)[3]", + ); + + await expect(numberPassport).toHaveText('This field is required.'); + await expect(typeCountryPassport).toHaveText( + 'Please select Passport Issuing Country.', + ); + await expect(typeLocationCountry).toHaveText('This field is required.'); + console.log('ระบบทำการตรวจสอบการแจ้งเตือนแล้ว'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.click('id=btn-form-close'); + await page.waitForTimeout(2000); +}); diff --git a/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_017_CreateEmployeeFail.spec.ts b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_017_CreateEmployeeFail.spec.ts new file mode 100644 index 00000000..9f72b368 --- /dev/null +++ b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_017_CreateEmployeeFail.spec.ts @@ -0,0 +1,271 @@ +import { test, expect, Page } from '@playwright/test'; +import { strictEqual } from 'assert'; + +let page: Page; +let isLoginSuccessful = false; + +test.beforeAll(async ({ browser }) => { + page = await browser.newPage(); +}); + +test.afterAll(async () => { + if (page !== undefined) { + await page.close(); + } +}); + +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + // เข้าสู่เมนูลูกค้า + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-customer'); + await page.click('id=sub-menu-customer'); + await page.waitForSelector('id=tab-employee'); + await page.click('id=tab-employee'); + await page.waitForTimeout(2000); + + isLoginSuccessful = true; + console.log('Login สำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการ Login', error); + isLoginSuccessful = false; + } +} + +test('Login', async () => { + await login(page); +}); + +test('เพิ่มลูกจ้างในกรณีที่ไม่กรอกข้อมูล', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + await page.click('id=btn-add'); + await page.waitForTimeout(2000); + await page.click('id=btn-info-basic-save'); + await page.waitForTimeout(2000); + + const selectBranchError = await page.locator( + "(//div[@class='q-field__messages col']//div)[1]", + ); + const firstNameError = await page.locator( + "(//div[@class='q-field__messages col']//div)[2]", + ); + const lastNameError = await page.locator( + "(//div[@class='q-field__messages col']//div)[3]", + ); + const firstNameEngError = await page.locator( + "(//div[@class='q-field__messages col']//div)[4]", + ); + const lastNameEngError = await page.locator( + "(//div[@class='q-field__messages col']//div)[5]", + ); + const brithdateError = await page.locator( + "(//div[@class='q-field__messages col']//div)[6]", + ); + const genderError = await page.locator( + "(//div[@class='q-field__messages col']//div)[7]", + ); + const nationalityError = await page.locator( + "(//div[@class='q-field__messages col']//div)[8]", + ); + const addressError = await page.locator( + "(//div[@class='q-field__messages col']//div)[9]", + ); + const provinceError = await page.locator( + "(//div[@class='q-field__messages col']//div)[10]", + ); + const districtError = await page.locator( + "(//div[@class='q-field__messages col']//div)[11]", + ); + const subdistrictError = await page.locator( + "(//div[@class='q-field__messages col']//div)[12]", + ); + const addressEngError = await page.locator( + "(//div[@class='q-field__messages col']//div)[13]", + ); + + await expect(selectBranchError).toHaveText('โปรดเลือกสาขา'); + await expect(firstNameError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้'); + await expect(lastNameError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้'); + await expect(firstNameEngError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้'); + await expect(lastNameEngError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้'); + await expect(brithdateError).toHaveText('โปรดเลือกวันเดือนปีเกิด'); + await expect(genderError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้'); + await expect(nationalityError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้'); + await expect(addressError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้'); + await expect(provinceError).toHaveText('โปรดเลือกจังหวัด'); + await expect(districtError).toHaveText('โปรดเลือกเขต/อำเภอ'); + await expect(subdistrictError).toHaveText('โปรดเลือกแขวง/ตำบล'); + await expect(addressEngError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้'); + + console.log('ระบบทำการตรวจสอบการแจ้งเตือนเรียบร้อย'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForSelector('id=btn-form-close'); + await page.click('id=btn-form-close'); + await page.waitForTimeout(2000); +}); + +test('เพิ่มลูกจ้างในกรณีที่กรอกเลข N.R.C No. ไม่ครบ 13 หลัก', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + await page.click('id=btn-add'); + await page.waitForTimeout(2000); + await page.fill('id=form-employee-input-nrc-no', '123'); + await page.waitForTimeout(2000); + + const numbernrc = await page.locator( + "(//div[@class='q-field__messages col']//div)[1]", + ); + + await expect(numbernrc).toHaveText( + 'ข้อมูลไม่ถูกต้อง กรุณากรอกให้ครบ 13 หลัก', + ); + + console.log('ระบบทำการตรวจสอบการแจ้งเตือนเรียบร้อย'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForSelector('id=btn-form-close'); + await page.click('id=btn-form-close'); + await page.waitForSelector('id=btn-ok-dialog'); + await page.click('id=btn-ok-dialog'); + await page.waitForTimeout(2000); +}); + +test('เพิ่มลูกจ้างในกรณีที่กรอกช่องชื่อนามสกุลภาษาอังกฤษไม่ถูกต้อง', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + await page.click('id=btn-add'); + await page.waitForTimeout(2000); + await page.fill('id=form-employee-input-first-name-en', 'ชื่อ'); + await page.fill('id=form-employee-input-last-name-en', 'นามสกุล'); + await page.waitForTimeout(2000); + + const firstNameEngError = await page.locator( + "(//div[@class='q-field__messages col']//div)[1]", + ); + const lastNameEngError = await page.locator( + "(//div[@class='q-field__messages col']//div)[2]", + ); + + await expect(firstNameEngError).toHaveText( + 'โปรดใช้เฉพาะตัวอักษรภาษาอังกฤษเท่านั้น', + ); + await expect(lastNameEngError).toHaveText( + 'โปรดใช้เฉพาะตัวอักษรภาษาอังกฤษเท่านั้น', + ); + console.log('ระบบทำการตรวจสอบการแจ้งเตือนเรียบร้อย'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + throw error; + } + await page.waitForSelector('id=btn-form-close'); + await page.click('id=btn-form-close'); + await page.waitForSelector('id=btn-ok-dialog'); + await page.click('id=btn-ok-dialog'); + await page.waitForTimeout(2000); +}); + +test('ทดสอบการสร้างลูกจ้างในกรณีที่เพิ่มข้อมูล Tab ข้อมูลหนังสือเดินทาง แต่ไม่กรอกข้อมูล', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + await page.click('id=btn-add'); + await page.waitForTimeout(2000); + // ส่วนข้อมูลพื้นฐาน + await page.click('id=form-employee-select-employer-branch'); + await page.waitForSelector('id=form-employee-select-employer-branch_1'); + await page.click('id=form-employee-select-employer-branch_1'); + await page.fill('id=form-employee-input-nrc-no', '2822022820220'); + // ส่วนข้้อมูลส่วนตัว + await page.click('id=form-employee-select-prefix-name'); + await page.waitForSelector('id=form-employee-select-prefix-name_0'); + await page.click('id=form-employee-select-prefix-name_0'); + await page.fill( + "(//input[@id='form-employee-input-first-name'])[1]", + 'นราธิป', + ); + await page.fill('id=form-employee-input-last-name', 'แสงรุ่ง'); + await page.fill('id=form-employee-input-first-name-en', 'Narathip'); + await page.fill('id=form-employee-input-last-name-en', 'Saengrung'); + + // วันเดิิอนปีเกิด + await page.click('id=form-employee-input-birth-date'); + await page.waitForSelector( + "(//button[@class='dp__btn dp__month_year_select'])[2]", + ); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); + await page.click("//div[text()='1996']"); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[1]"); + await page.click("//div[text()='พ.ค.']"); + await page.click("//div[@id='1996-05-02']/div[1]"); + + // สัญชาติ + await page.click('id=form-employee-select-nationality'); + await page.waitForSelector('id=form-employee-select-nationality_2'); + await page.click('id=form-employee-select-nationality_2'); + + await page.click('id=btn-info-basic-save'); + await page.waitForTimeout(2000); + + // -------------------- Tab ข้อมูลหนังสือเดินทาง ------------------------------ + await page.waitForSelector( + 'id=dialog-tab-customerEmployee.fileType.passport', + { + state: 'visible', + }, + ); + + await page.click('id=dialog-tab-customerEmployee.fileType.passport', { + force: true, + }); + await page.waitForSelector("(//button[@type='submit'])[2]"); + await page.click("(//button[@type='submit'])[2]"); + await page.waitForTimeout(2000); + + const numberPassport = await page.locator( + "(//div[@class='q-field__messages col']//div)[1]", + ); + const typeCountryPassport = await page.locator( + "(//div[@class='q-field__messages col']//div)[2]", + ); + const typeLocationCountry = await page.locator( + "(//div[@class='q-field__messages col']//div)[3]", + ); + + await expect(numberPassport).toHaveText('จำเป็นต้องกรอกข้อมูลนี้'); + await expect(typeCountryPassport).toHaveText( + 'โปรดเลือกประเทศที่ออกหนังสือเดินทาง', + ); + await expect(typeLocationCountry).toHaveText('จำเป็นต้องกรอกข้อมูลนี้'); + console.log('ระบบทำการตรวจสอบการแจ้งเตือนแล้ว'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.click('id=btn-form-close'); + await page.waitForTimeout(2000); +}); diff --git a/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_018_SeachEmployee.spec.ts b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_018_SeachEmployee.spec.ts new file mode 100644 index 00000000..5fb9a312 --- /dev/null +++ b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_018_SeachEmployee.spec.ts @@ -0,0 +1,105 @@ +import { test, expect, Page } from '@playwright/test'; +import { strictEqual } from 'assert'; + +let page: Page; +let isLoginSuccessful = false; + +test.beforeAll(async ({ browser }) => { + page = await browser.newPage(); +}); + +test.afterAll(async () => { + if (page !== undefined) { + await page.close(); + } +}); + +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + // เข้าสู่เมนูลูกจ้าง + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-customer'); + await page.click('id=sub-menu-customer'); + await page.waitForSelector('id=tab-employee'); + await page.click('id=tab-employee'); + await page.waitForTimeout(2000); + + isLoginSuccessful = true; + console.log('Login สำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการ Login', error); + isLoginSuccessful = false; + } +} + +test('Login', async () => { + await login(page); +}); + +test('ทดสอบการค้นหาข้อมูลเมนูลูกค้า', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + // กำหนดคำที่จะค้นหา + const searchDatas = [ + 'Kittisak', + 'Sukkasem', + 'กิตติศักดิ์ วิจิตรานนท์', + 'Waranya Sukkasem', + 'บริษัท เอเชียเทค ซิสเต็มส์ จำกัด', + '1524428220420-00', + ]; + + for (const searchData of searchDatas) { + // พิมพ์คำที่ต้องการค้นหา + await page.fill('id=input-search', searchData); // ดึงคำมาจาก searchDatas + await page.waitForTimeout(2000); + + // ดึงผลลัพฑ์การค้นหาทั้งหมด + const searchResults = page.locator("//table[@class='q-table']//tbody[1]"); + const resultCount = await searchResults.count(); + + // ถ้าไม่มีผลลัพธ์ให้ข้ามคำถัดไป + if (resultCount === 0) { + console.error(`ไม่พบการค้นหา: '${searchData}', ข้ามไปคำถัดไป`); + continue; // ข้ามคำค้นหาคำถัดไป + } + + // ดึงข้อความทั้งหมดของผลลัพธ์การค้นหา + const searchResultTexts = await searchResults.allTextContents(); + console.log(`ผลลัพธ์ของการค้นหา '${searchData}'`, searchDatas); + + // ตรวจสอบว่าผลลัพธ์ทั้งหมดมีคำที่ค้นหาหรือไม่ + const allResultContainSearchData = searchResultTexts.every((result) => + result.includes(searchData), + ); + + // ถ้าไม่พบคำค้นหา ให้แค่แจ้งเตือนและข้ามไปคำถัดไป + if (!allResultContainSearchData) { + console.error( + `\x1b[31mผลลัพธ์บางรายการไม่ตรงกับคำค้นหา: '${searchData}', ข้ามไปคำถัดไป\x1b[0m`, + ); + continue; // ข้ามไปคำค้นหาถัดไป + } + + expect(allResultContainSearchData).toBe(true); + + console.log(`การค้นหา '${searchData}' และการแสดงผลสำเร็จ`); + } + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบการค้นหาหลายคำค้นหา', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForTimeout(2000); +}); diff --git a/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_019_StatusEmployeeType.spec.ts b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_019_StatusEmployeeType.spec.ts new file mode 100644 index 00000000..4ecb3bb3 --- /dev/null +++ b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_019_StatusEmployeeType.spec.ts @@ -0,0 +1,115 @@ +import { test, expect, Page } from '@playwright/test'; +import { strictEqual } from 'assert'; + +let page: Page; +let isLoginSuccessful = false; + +test.beforeAll(async ({ browser }) => { + page = await browser.newPage(); +}); + +test.afterAll(async () => { + if (page !== undefined) { + await page.close(); + } +}); + +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + // เข้าสู่เมนูลูกจ้าง + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-customer'); + await page.click('id=sub-menu-customer'); + await page.waitForSelector('id=tab-employee'); + await page.click('id=tab-employee'); + await page.waitForTimeout(2000); + + isLoginSuccessful = true; + console.log('Login สำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการ Login', error); + isLoginSuccessful = false; + } +} + +test('Login', async () => { + await login(page); +}); + +test('ตรวจสอบการแสดงสถานะใช้งาน เปิด/ปิด ลูกจ้าง', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + // แสดงสถานะที่ใช้งาน + // คลิกเพื่อเปิด dropdown + await page.waitForTimeout(1000); + await page.click('id=select-status'); + //รอให้ dropdown เปิด + await page.waitForSelector('id=select-status_1'); + + // คลิกเพื่อแสดงสถานะกำลังใช้งานอยู่ + await page.click('id=select-status_1'); + await page.waitForTimeout(1000); // รอให้ UI อัปเดต + + // ตรวจสอบว่ามีแต่สถานะใช้งานหรือไม่ + const statusActive = await page.isVisible('id=select-status_1'); + + console.log('มีเพียงสถานะการใช้งานเท่านั้น', statusActive); // เช็ค + + expect(statusActive).toBe(false); + + console.log('ตรวจสอบสถานะการใช้งานมีแต่สถานะกำลังใช้งานเท่านั้น'); + + // แสดงสถานะที่ไม่ใช้งาน + // คลิกเพื่อเปิด dropdown + await page.keyboard.press('Escape'); + await page.click('id=select-status'); + await page.waitForTimeout(1000); // รอให้ dropdown เปิด + + // คลิกเพื่อแสดงสถานะกำลังไม่ใช้งาน + await page.click('id=select-status_2'); + await page.waitForTimeout(1000); // รอให้ UI อัปเดต + + // ตรวจสอบว่ามีแต่สถานะไม่ใช้งานหรือไม่ + const statusInActive = await page.isVisible('id=select-status_1'); + + console.log('มีเพียงสถานะการใช้งานเท่านั้น', statusInActive); // เช็ค + + expect(statusActive).toBe(false); + + console.log('ตรวจสอบสถานะการใช้งานมีแต่สถานะที่ไม่ใช้งาน'); + + // แสดงสถานะทั้งหมด + // คลิกเพื่อเปิด dropdown + await page.keyboard.press('Escape'); + await page.click('id=select-status'); + await page.waitForTimeout(1000); // รอให้ dropdown เปิด + + // คลิกเพื่อแสดงสถานะทั้งหมด + await page.click('id=select-status_0'); + await page.waitForTimeout(1000); // รอให้ UI อัปเดต + + // ตรวจสอบว่าแสดงทุกสถานะหรือไม่ + const statusAll = await page.isVisible('id=select-status_1'); + + console.log('สถานะทั้งหมด', statusAll); // เช็ค + + expect(statusActive).toBe(false); + + console.log('ตรวจสอบสถานะทั้งหมด'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; + throw error; + } +}); diff --git a/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_020_DetailEmployee.spec.ts b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_020_DetailEmployee.spec.ts new file mode 100644 index 00000000..d98a44af --- /dev/null +++ b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_020_DetailEmployee.spec.ts @@ -0,0 +1,112 @@ +import { test, expect, Page } from '@playwright/test'; +import { strictEqual } from 'assert'; + +let page: Page; +let isLoginSuccessful = false; + +test.beforeAll(async ({ browser }) => { + page = await browser.newPage(); +}); + +test.afterAll(async () => { + if (page !== undefined) { + await page.close(); + } +}); + +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + // เข้าสู่เมนูลูกจ้าง + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-customer'); + await page.click('id=sub-menu-customer'); + await page.waitForSelector('id=tab-employee'); + await page.click('id=tab-employee'); + await page.waitForTimeout(2000); + + isLoginSuccessful = true; + console.log('Login สำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการ Login', error); + isLoginSuccessful = false; + } +} + +test('Login', async () => { + await login(page); +}); + +test('ทดสอบการดูรายละเอียดลูกจ้างโดยการคลิกไอคอนดวงตา', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click('id=btn-eye-กิตติศักดิ์'); + + const fullNameEmployee = await page.locator( + "//span[text()='กิตติศักดิ์ วิจิตรานนท์']", + ); + await expect(fullNameEmployee).toHaveText('กิตติศักดิ์ วิจิตรานนท์'); + console.log('ระบบตรวจสอบรายละเอียดถูกต้อง'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.click("(//button[@id='btn-info-close'])[2]"); + await page.waitForTimeout(1000); +}); + +test('ทดสอบการดูรายละเอียดลูกจ้างโดยการคลิกเมนูย่อย', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + await page.click('id=btn-kebab-action-กิตติศักดิ์'); + await page.waitForSelector('id=btn-kebab-view-detail-กิตติศักดิ์'); + await page.click('id=btn-kebab-view-detail-กิตติศักดิ์'); + + const fullNameEmployee = await page.locator( + "//span[text()='กิตติศักดิ์ วิจิตรานนท์']", + ); + await expect(fullNameEmployee).toHaveText('กิตติศักดิ์ วิจิตรานนท์'); + console.log('ระบบตรวจสอบรายละเอียดถูกต้อง'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.click("(//button[@id='btn-info-close'])[2]"); + await page.waitForTimeout(1000); +}); + +test('ทดสอบการดูรายละเอียดลูกจ้างในรูปแบบการ์ด', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + await page.waitForSelector("//button[@aria-pressed='false']"); + await page.click("//button[@aria-pressed='false']"); + + const fullNameEmployee = await page.locator( + "//div[normalize-space(text())='กิตติศักดิ์ วิจิตรานนท์']", + ); + await expect(fullNameEmployee).toHaveText('กิตติศักดิ์ วิจิตรานนท์'); + console.log('ระบบทำการเปลี่ยนเป็นรูปแบบการ์ดแล้ว'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + + await page.waitForTimeout(1000); +}); diff --git a/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_021_EditEmployee.spec.ts b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_021_EditEmployee.spec.ts new file mode 100644 index 00000000..99f56c49 --- /dev/null +++ b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_021_EditEmployee.spec.ts @@ -0,0 +1,93 @@ +import { test, expect, Page } from '@playwright/test'; +import { strictEqual } from 'assert'; + +let page: Page; +let isLoginSuccessful = false; + +test.beforeAll(async ({ browser }) => { + page = await browser.newPage(); +}); + +test.afterAll(async () => { + if (page !== undefined) { + await page.close(); + } +}); + +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + // เข้าสู่เมนูลูกจ้าง + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-customer'); + await page.click('id=sub-menu-customer'); + await page.waitForSelector('id=tab-employee'); + await page.click('id=tab-employee'); + await page.waitForTimeout(2000); + + isLoginSuccessful = true; + console.log('Login สำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการ Login', error); + isLoginSuccessful = false; + } +} + +test('Login', async () => { + await login(page); +}); + +test('ทดสอบการแก้ไขลูกจ้าง', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + await page.click('id=btn-kebab-action-วรัญญา'); + await page.waitForSelector('id=btn-kebab-edit-วรัญญา'); + await page.click('id=btn-kebab-edit-วรัญญา'); + + await page.click( + "(//div[contains(@class,'q-field__append q-field__marginal')]//i)[3]", + ); + await page.waitForSelector( + 'id=drawer-info-employee-select-employer-branch_1', + ); + await page.click('id=drawer-info-employee-select-employer-branch_1'); + + await page.fill( + "(//input[@id='drawer-info-employee-input-first-name'])[1]", + 'พิชญา', + ); + await page.fill('id=drawer-info-employee-input-last-name', 'วัฒนธนากุล'); + await page.fill('id=drawer-info-employee-input-first-name-en', 'Pichaya'); + await page.fill( + 'id=drawer-info-employee-input-last-name-en', + 'Watthanathanakul', + ); + + await page.click('id=btn-info-basic-save'); + await page.waitForTimeout(1000); + await page.click("(//button[@id='btn-info-close'])[2]"); + + const rowItemName = await page.locator( + "//tr[contains(.,'Pichaya Watthanathanakul') and contains (.,'บริษัท เอเชียเทค ซิสเต็มส์ จำกัด')]", + ); + + await expect(rowItemName).toContainText('Pichaya Watthanathanakul'); + await expect(rowItemName).toContainText('บริษัท เอเชียเทค ซิสเต็มส์ จำกัด'); + console.log('ระบบทำการแก้ไขลูกจ้างแล้ว'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForTimeout(2000); +}); diff --git a/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_022_DeleteEmployee.spec.ts b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_022_DeleteEmployee.spec.ts new file mode 100644 index 00000000..07dc72a3 --- /dev/null +++ b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_022_DeleteEmployee.spec.ts @@ -0,0 +1,125 @@ +import { test, expect, Page } from '@playwright/test'; +import { strictEqual } from 'assert'; +import { it } from 'node:test'; + +let page: Page; +let isLoginSuccessful = false; + +test.beforeAll(async ({ browser }) => { + page = await browser.newPage(); +}); + +test.afterAll(async () => { + if (page !== undefined) { + await page.close(); + } +}); + +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + // เข้าสู่เมนูลูกจ้าง + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-customer'); + await page.click('id=sub-menu-customer'); + await page.waitForSelector('id=tab-employee'); + await page.click('id=tab-employee'); + await page.waitForTimeout(2000); + + isLoginSuccessful = true; + console.log('Login สำเร็จ'); + } catch (error) { + console.error('เกืดข้อผิดพลาดในการ Login', error); + isLoginSuccessful = false; + } +} + +test('Login', async () => { + await login(page); +}); + +test('จำลองการสร้างลูกจ้าง', async () => { + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click('id=btn-add'); + await page.waitForTimeout(2000); + // ส่วนข้อมูลพื้นฐาน + await page.click('id=form-employee-select-employer-branch'); + await page.waitForSelector('id=form-employee-select-employer-branch_1'); + await page.click('id=form-employee-select-employer-branch_1'); + await page.fill('id=form-employee-input-nrc-no', '2822022820228'); + // ส่วนข้้อมูลส่วนตัว + await page.click('id=form-employee-select-prefix-name'); + await page.waitForSelector('id=form-employee-select-prefix-name_0'); + await page.click('id=form-employee-select-prefix-name_0'); + await page.fill( + "(//input[@id='form-employee-input-first-name'])[1]", + 'ธนกร', + ); + await page.fill('id=form-employee-input-last-name', 'ศรีสวัสดิ์'); + await page.fill('id=form-employee-input-first-name-en', 'Thanakorn'); + await page.fill('id=form-employee-input-last-name-en', 'Srisawat'); + + // วันเดิิอนปีเกิด + await page.click('id=form-employee-input-birth-date'); + await page.waitForSelector( + "(//button[@class='dp__btn dp__month_year_select'])[2]", + ); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); + await page.click("//div[text()='1992']"); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[1]"); + await page.click("//div[text()='พ.ค.']"); + await page.click("//div[@id='1992-05-02']/div[1]"); + + // สัญชาติ + await page.click('id=form-employee-select-nationality'); + await page.waitForSelector('id=form-employee-select-nationality_2'); + await page.click('id=form-employee-select-nationality_2'); + + await page.click('id=btn-info-basic-save'); + await page.waitForTimeout(2000); + await page.click('id=btn-form-close'); + await page.waitForTimeout(2000); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } +}); + +test('ทดสอบการลบลูกจ้าง', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + await page.click('id=btn-kebab-action-ธนกร'); + await page.waitForSelector('id=btn-kebab-delete-ธนกร'); + await page.click('id=btn-kebab-delete-ธนกร'); + await page.waitForSelector('id=btn-ok-dialog'); + await page.click('id=btn-ok-dialog'); + + const itemLocator = await page.locator( + "//tr[contains(.,'Thanakorn Srisawat') and contains (.,'บริษัท เอเชียเทค ซิสเต็มส์ จำกัด')]", + ); + + await expect(itemLocator).toBeHidden(); + + console.log('ระบบทำการลบลูกจ้างแล้ว'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForTimeout(2000); +}); diff --git a/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_023_StatusEmployee.spec.ts b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_023_StatusEmployee.spec.ts new file mode 100644 index 00000000..2cc41ff6 --- /dev/null +++ b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_023_StatusEmployee.spec.ts @@ -0,0 +1,124 @@ +import { test, expect, Page } from '@playwright/test'; +import { strictEqual } from 'assert'; + +let page: Page; +let isLoginSuccessful = false; + +test.beforeAll(async ({ browser }) => { + page = await browser.newPage(); +}); + +test.afterAll(async () => { + if (page !== undefined) { + await page.close(); + } +}); + +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + // เข้าสู่เมนูลูกจ้าง + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-customer'); + await page.click('id=sub-menu-customer'); + await page.waitForSelector('id=tab-employee'); + await page.click('id=tab-employee'); + await page.waitForTimeout(2000); + + isLoginSuccessful = true; + console.log('Login สำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการ Login', error); + isLoginSuccessful = false; + } +} + +test('Login', async () => { + await login(page); +}); + +test('ปิดสถานะลูกจ้าง', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + await page.click('id=btn-kebab-action-กิตติศักดิ์'); + + await page.click('id=btn-kebab-status-กิตติศักดิ์', { + force: true, + }); + await page.click('id=btn-ok-dialog'); + console.log('เปลี่ยนสถานะสำเร็จ'); + + // รอ Update + await page.waitForTimeout(2000); + console.log('สถานะถูกเปลี่ยนแล้ว'); + + // ตรวจสอบสีของแถวหลังจากทำการเปลี่ยนสถานะ + const rowLocator = page.locator( + "//tr[contains(.,'Kittisak Wijitranon') and contains (.,'บริษัท เอเชียเทค ซิสเต็มส์ จำกัด')]", + ); + const backgroundColor = await rowLocator.evaluate( + (el) => window.getComputedStyle(el).backgroundColor, + ); + + // กำหนดสีหลัเปลี่ยนสถานะการใช้งาน + const expectedColor = 'rgb(249, 250, 252)'; + + // ตรวจสอบสีที่เปลี่ยนไป + expect(backgroundColor.trim()).toBe(expectedColor); + console.log('สีของแถวถูกเปลี่ยนเป็นสีเทาอ่อน'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ'); + isLoginSuccessful = false; + throw error; + } + await page.waitForTimeout(2000); +}); + +test('เปิดสถานะลูกจ้าง', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + await page.click('id=btn-kebab-action-กิตติศักดิ์'); + + await page.click('id=btn-kebab-status-กิตติศักดิ์', { + force: true, + }); + await page.click('id=btn-ok-dialog'); + console.log('เปลี่ยนสถานะสำเร็จ'); + + // รอ Update + await page.waitForTimeout(2000); + console.log('สถานะถูกเปลี่ยนแล้ว'); + + // ตรวจสอบสีของแถวหลังจากทำการเปลี่ยนสถานะ + const rowLocator = page.locator( + "//tr[contains(.,'Kittisak Wijitranon') and contains (.,'บริษัท เอเชียเทค ซิสเต็มส์ จำกัด')]", + ); + const backgroundColor = await rowLocator.evaluate( + (el) => window.getComputedStyle(el).backgroundColor, + ); + + // กำหนดสีหลัเปลี่ยนสถานะการใช้งาน + const expectedColor = 'rgb(249, 250, 252)'; + + // ตรวจสอบสีที่เปลี่ยนไป + expect(backgroundColor.trim()).toBe(expectedColor); + console.log('สีของแถวถูกเปลี่ยนเป็นของสถานะการใช้งาน'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ'); + isLoginSuccessful = false; + throw error; + } + await page.waitForTimeout(2000); +}); diff --git a/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_024_DropdownEmployeetype.spec.ts b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_024_DropdownEmployeetype.spec.ts new file mode 100644 index 00000000..78d6f50b --- /dev/null +++ b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_024_DropdownEmployeetype.spec.ts @@ -0,0 +1,612 @@ +import { test, expect, Page } from '@playwright/test'; +import { strictEqual } from 'assert'; +import { sign } from 'crypto'; +import { escape } from 'querystring'; + +let page: Page; +let isLoginSuccessful = false; + +test.beforeAll(async ({ browser }) => { + page = await browser.newPage(); +}); + +test.afterAll(async () => { + if (page !== undefined) { + await page.close(); + } +}); + +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + // เข้าสู่เมนูลูกจ้าง + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-customer'); + await page.click('id=sub-menu-customer'); + await page.waitForSelector('id=tab-employee'); + await page.click('id=tab-employee'); + await page.waitForTimeout(2000); + + isLoginSuccessful = true; + console.log('Login สำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการ Login'); + isLoginSuccessful = false; + } +} + +test('Login', async () => { + await login(page); +}); + +test('ตรวจสอบการแสดงผลฟิลด์แสดงลำดับที่', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + // คลิกเพื่อเปิด dropdown + await page.click("(//div[@id='select-field'])[1]"); + await page.waitForTimeout(1000); // รอให้ dropdown เปิด + + // คลิกเพื่อปิดคอลัมน์ที่ 1 + await page.click('id=select-field_0'); + await page.waitForTimeout(1000); // รอให้ UI อัปเดต + + // ตรวจสอบว่าคอลัมน์ถูกซ่อน + const column1 = page.locator('id=select-field_0'); + const column1Cells = page.locator("//th[contains(.,'ลำดับที่')]"); + + const isColumn1Hidden = await column1.evaluate( + (el) => window.getComputedStyle(el).display === 'none', + ); + console.log('คอลัมน์ที่ 1 ซ่อนอยู่:', isColumn1Hidden); // เช็ค + + const areCellsHidden = await column1Cells.evaluateAll((cells) => + cells.every((cell) => window.getComputedStyle(cell).display === 'none'), + ); + console.log('เซลล์ในคอลัมน์ที่ 1 ซ่อนอยู่:', areCellsHidden); // เช็ค + + expect(isColumn1Hidden).toBe(false); + expect(areCellsHidden).toBe(true); + + // คลิกอีกครั้งเพื่อเปิดคอลัมน์ที่ 1 + await page.keyboard.press('Escape'); + await page.click("(//div[@id='select-field'])[1]"); + + await page.waitForTimeout(1000); // รอให้ dropdown เปิด + await page.click('id=select-field_0'); // คลิกเพื่อเปิดคอลัมน์ + await page.waitForTimeout(1000); // รอให้ UI อัปเดต + + // ตรวจสอบว่าคอลัมน์แสดงอยู่ + const isColumn1Visible = await column1.evaluate( + (el) => window.getComputedStyle(el).display !== 'none', + ); + console.log('คอลัมน์ที่ 1 แสดงอยู่:', isColumn1Visible); // เช็ค + + const areCellsVisible = await column1Cells.evaluateAll((cells) => + cells.every((cell) => window.getComputedStyle(cell).display !== 'none'), + ); + console.log('เซลล์ในคอลัมน์ที่ 1 แสดงอยู่:', areCellsVisible); // เช็ค + + expect(isColumn1Visible).toBe(true); + expect(areCellsVisible).toBe(true); + + console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; + throw error; + } + await page.keyboard.press('Escape'); +}); + +test('ตรวจสอบการแสดงผลฟิลด์แสดงผลชื่อ', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + // คลิกเพื่อเปิด dropdown + await page.click("(//div[@id='select-field'])[1]"); + + await page.waitForTimeout(1000); // รอให้ dropdown เปิด + + // คลิกเพื่อปิดคอลัมน์ที่ 1 + await page.click('id=select-field_1'); + await page.waitForTimeout(1000); // รอให้ UI อัปเดต + + // ตรวจสอบว่าคอลัมน์ถูกซ่อน + const column1 = page.locator('id=select-field_1'); + const column1Cells = page.locator("//th[contains(.,'ชื่อ')]"); + + const isColumn1Hidden = await column1.evaluate( + (el) => window.getComputedStyle(el).display === 'none', + ); + console.log('คอลัมน์ที่ 1 ซ่อนอยู่:', isColumn1Hidden); // เช็ค + + const areCellsHidden = await column1Cells.evaluateAll((cells) => + cells.every((cell) => window.getComputedStyle(cell).display === 'none'), + ); + console.log('เซลล์ในคอลัมน์ที่ 1 ซ่อนอยู่:', areCellsHidden); // เช็ค + + expect(isColumn1Hidden).toBe(false); + expect(areCellsHidden).toBe(true); + + // คลิกอีกครั้งเพื่อเปิดคอลัมน์ที่ 1 + await page.keyboard.press('Escape'); + await page.click("(//div[@id='select-field'])[1]"); + + await page.waitForTimeout(1000); // รอให้ dropdown เปิด + await page.click('id=select-field_1'); // คลิกเพื่อเปิดคอลัมน์ + await page.waitForTimeout(1000); // รอให้ UI อัปเดต + + // ตรวจสอบว่าคอลัมน์แสดงอยู่ + const isColumn1Visible = await column1.evaluate( + (el) => window.getComputedStyle(el).display !== 'none', + ); + console.log('คอลัมน์ที่ 2 แสดงอยู่:', isColumn1Visible); // เช็ค + + const areCellsVisible = await column1Cells.evaluateAll((cells) => + cells.every((cell) => window.getComputedStyle(cell).display !== 'none'), + ); + console.log('เซลล์ในคอลัมน์ที่ 2 แสดงอยู่:', areCellsVisible); // เช็ค + + expect(isColumn1Visible).toBe(true); + expect(areCellsVisible).toBe(true); + + console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; + throw error; + } + await page.keyboard.press('Escape'); +}); + +test('ตรวจสอบการแสดงผลฟิลด์แสดงผลอายุ', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + // คลิกเพื่อเปิด dropdown + await page.click("(//div[@id='select-field'])[1]"); + + await page.waitForTimeout(1000); // รอให้ dropdown เปิด + + // คลิกเพื่อปิดคอลัมน์ที่ 1 + await page.click('id=select-field_2'); + await page.waitForTimeout(1000); // รอให้ UI อัปเดต + + // ตรวจสอบว่าคอลัมน์ถูกซ่อน + const column1 = page.locator('id=select-field_2'); + const column1Cells = page.locator("//th[contains(.,'อายุ')]"); + + const isColumn1Hidden = await column1.evaluate( + (el) => window.getComputedStyle(el).display === 'none', + ); + console.log('คอลัมน์ที่ 3 ซ่อนอยู่:', isColumn1Hidden); // เช็ค + + const areCellsHidden = await column1Cells.evaluateAll((cells) => + cells.every((cell) => window.getComputedStyle(cell).display === 'none'), + ); + console.log('เซลล์ในคอลัมน์ที่ 3 ซ่อนอยู่:', areCellsHidden); // เช็ค + + expect(isColumn1Hidden).toBe(false); + expect(areCellsHidden).toBe(false); + + // คลิกอีกครั้งเพื่อเปิดคอลัมน์ที่ 1 + await page.keyboard.press('Escape'); + await page.click("(//div[@id='select-field'])[1]"); + + await page.waitForTimeout(1000); // รอให้ dropdown เปิด + await page.click('id=select-field_2'); // คลิกเพื่อเปิดคอลัมน์ + await page.waitForTimeout(1000); // รอให้ UI อัปเดต + + // ตรวจสอบว่าคอลัมน์แสดงอยู่ + const isColumn1Visible = await column1.evaluate( + (el) => window.getComputedStyle(el).display !== 'none', + ); + console.log('คอลัมน์ที่ 3 แสดงอยู่:', isColumn1Visible); // เช็ค + + const areCellsVisible = await column1Cells.evaluateAll((cells) => + cells.every((cell) => window.getComputedStyle(cell).display !== 'none'), + ); + console.log('เซลล์ในคอลัมน์ที่ 3 แสดงอยู่:', areCellsVisible); // เช็ค + + expect(isColumn1Visible).toBe(true); + expect(areCellsVisible).toBe(true); + + console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; + throw error; + } + await page.keyboard.press('Escape'); +}); + +test('ตรวจสอบการแสดงผลฟิลด์แสดงผลสัญชาติ', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + // คลิกเพื่อเปิด dropdown + await page.click("(//div[@id='select-field'])[1]"); + + await page.waitForTimeout(1000); // รอให้ dropdown เปิด + + // คลิกเพื่อปิดคอลัมน์ที่ 1 + await page.click('id=select-field_3'); + await page.waitForTimeout(1000); // รอให้ UI อัปเดต + + // ตรวจสอบว่าคอลัมน์ถูกซ่อน + const column1 = page.locator('id=select-field_3'); + const column1Cells = page.locator("//th[contains(.,'สัญชาติ')]"); + + const isColumn1Hidden = await column1.evaluate( + (el) => window.getComputedStyle(el).display === 'none', + ); + console.log('คอลัมน์ที่ 4 ซ่อนอยู่:', isColumn1Hidden); // เช็ค + + const areCellsHidden = await column1Cells.evaluateAll((cells) => + cells.every((cell) => window.getComputedStyle(cell).display === 'none'), + ); + console.log('เซลล์ในคอลัมน์ที่ 4 ซ่อนอยู่:', areCellsHidden); // เช็ค + + expect(isColumn1Hidden).toBe(false); + expect(areCellsHidden).toBe(true); + + // คลิกอีกครั้งเพื่อเปิดคอลัมน์ที่ 1 + await page.keyboard.press('Escape'); + await page.click("(//div[@id='select-field'])[1]"); + + await page.waitForTimeout(1000); // รอให้ dropdown เปิด + await page.click('id=select-field_3'); // คลิกเพื่อเปิดคอลัมน์ + await page.waitForTimeout(1000); // รอให้ UI อัปเดต + + // ตรวจสอบว่าคอลัมน์แสดงอยู่ + const isColumn1Visible = await column1.evaluate( + (el) => window.getComputedStyle(el).display !== 'none', + ); + console.log('คอลัมน์ที่ 4 แสดงอยู่:', isColumn1Visible); // เช็ค + + const areCellsVisible = await column1Cells.evaluateAll((cells) => + cells.every((cell) => window.getComputedStyle(cell).display !== 'none'), + ); + console.log('เซลล์ในคอลัมน์ที่ 4 แสดงอยู่:', areCellsVisible); // เช็ค + + expect(isColumn1Visible).toBe(true); + expect(areCellsVisible).toBe(true); + + console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; + throw error; + } + await page.keyboard.press('Escape'); +}); + +test('ตรวจสอบการแสดงผลฟิลด์แสดงผลหมายเลขหนังสือเดินทาง', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + // คลิกเพื่อเปิด dropdown + await page.click("(//div[@id='select-field'])[1]"); + + await page.waitForTimeout(1000); // รอให้ dropdown เปิด + + // คลิกเพื่อปิดคอลัมน์ที่ 1 + await page.click('id=select-field_4'); + await page.waitForTimeout(1000); // รอให้ UI อัปเดต + + // ตรวจสอบว่าคอลัมน์ถูกซ่อน + const column1 = page.locator('id=select-field_4'); + const column1Cells = page.locator( + "//th[contains(.,'หมายเลขหนังสือเดินทาง')]", + ); + + const isColumn1Hidden = await column1.evaluate( + (el) => window.getComputedStyle(el).display === 'none', + ); + console.log('คอลัมน์ที่ 5 ซ่อนอยู่:', isColumn1Hidden); // เช็ค + + const areCellsHidden = await column1Cells.evaluateAll((cells) => + cells.every((cell) => window.getComputedStyle(cell).display === 'none'), + ); + console.log('เซลล์ในคอลัมน์ที่ 5 ซ่อนอยู่:', areCellsHidden); // เช็ค + + expect(isColumn1Hidden).toBe(false); + expect(areCellsHidden).toBe(true); + + // คลิกอีกครั้งเพื่อเปิดคอลัมน์ที่ 1 + await page.keyboard.press('Escape'); + await page.click("(//div[@id='select-field'])[1]"); + + await page.waitForTimeout(1000); // รอให้ dropdown เปิด + await page.click('id=select-field_4'); // คลิกเพื่อเปิดคอลัมน์ + await page.waitForTimeout(1000); // รอให้ UI อัปเดต + + // ตรวจสอบว่าคอลัมน์แสดงอยู่ + const isColumn1Visible = await column1.evaluate( + (el) => window.getComputedStyle(el).display !== 'none', + ); + console.log('คอลัมน์ที่ 5 แสดงอยู่:', isColumn1Visible); // เช็ค + + const areCellsVisible = await column1Cells.evaluateAll((cells) => + cells.every((cell) => window.getComputedStyle(cell).display !== 'none'), + ); + console.log('เซลล์ในคอลัมน์ที่ 5 แสดงอยู่:', areCellsVisible); // เช็ค + + expect(isColumn1Visible).toBe(true); + expect(areCellsVisible).toBe(true); + + console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; + throw error; + } + await page.keyboard.press('Escape'); +}); + +test('ตรวจสอบการแสดงผลฟิลด์แสดงผลวันหมดอายุหนังสือเดินทาง', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + // คลิกเพื่อเปิด dropdown + await page.click("(//div[@id='select-field'])[1]"); + + await page.waitForTimeout(1000); // รอให้ dropdown เปิด + + // คลิกเพื่อปิดคอลัมน์ที่ 1 + await page.click('id=select-field_5'); + await page.waitForTimeout(1000); // รอให้ UI อัปเดต + + // ตรวจสอบว่าคอลัมน์ถูกซ่อน + const column1 = page.locator('id=select-field_5'); + const column1Cells = page.locator( + "//th[contains(.,'วันหมดอายุหนังสือเดินทาง')]", + ); + + const isColumn1Hidden = await column1.evaluate( + (el) => window.getComputedStyle(el).display === 'none', + ); + console.log('คอลัมน์ที่ 6 ซ่อนอยู่:', isColumn1Hidden); // เช็ค + + const areCellsHidden = await column1Cells.evaluateAll((cells) => + cells.every((cell) => window.getComputedStyle(cell).display === 'none'), + ); + console.log('เซลล์ในคอลัมน์ที่ 6 ซ่อนอยู่:', areCellsHidden); // เช็ค + + expect(isColumn1Hidden).toBe(false); + expect(areCellsHidden).toBe(true); + + // คลิกอีกครั้งเพื่อเปิดคอลัมน์ที่ 1 + await page.keyboard.press('Escape'); + await page.click("(//div[@id='select-field'])[1]"); + + await page.waitForTimeout(1000); // รอให้ dropdown เปิด + await page.click('id=select-field_5'); // คลิกเพื่อเปิดคอลัมน์ + await page.waitForTimeout(1000); // รอให้ UI อัปเดต + + // ตรวจสอบว่าคอลัมน์แสดงอยู่ + const isColumn1Visible = await column1.evaluate( + (el) => window.getComputedStyle(el).display !== 'none', + ); + console.log('คอลัมน์ที่ 6 แสดงอยู่:', isColumn1Visible); // เช็ค + + const areCellsVisible = await column1Cells.evaluateAll((cells) => + cells.every((cell) => window.getComputedStyle(cell).display !== 'none'), + ); + console.log('เซลล์ในคอลัมน์ที่ 6 แสดงอยู่:', areCellsVisible); // เช็ค + + expect(isColumn1Visible).toBe(true); + expect(areCellsVisible).toBe(true); + + console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; + throw error; + } + await page.keyboard.press('Escape'); +}); + +test('ตรวจสอบการแสดงผลฟิลด์แสดงผลวันหมดอายุ visa', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + // คลิกเพื่อเปิด dropdown + await page.click("(//div[@id='select-field'])[1]"); + + await page.waitForTimeout(1000); // รอให้ dropdown เปิด + + // คลิกเพื่อปิดคอลัมน์ที่ 1 + await page.click('id=select-field_6'); + await page.waitForTimeout(1000); // รอให้ UI อัปเดต + + // ตรวจสอบว่าคอลัมน์ถูกซ่อน + const column1 = page.locator('id=select-field_6'); + const column1Cells = page.locator("//th[contains(.,'วันหมดอายุ visa')]"); + + const isColumn1Hidden = await column1.evaluate( + (el) => window.getComputedStyle(el).display === 'none', + ); + console.log('คอลัมน์ที่ 7 ซ่อนอยู่:', isColumn1Hidden); // เช็ค + + const areCellsHidden = await column1Cells.evaluateAll((cells) => + cells.every((cell) => window.getComputedStyle(cell).display === 'none'), + ); + console.log('เซลล์ในคอลัมน์ที่ 7 ซ่อนอยู่:', areCellsHidden); // เช็ค + + expect(isColumn1Hidden).toBe(false); + expect(areCellsHidden).toBe(true); + + // คลิกอีกครั้งเพื่อเปิดคอลัมน์ที่ 1 + await page.keyboard.press('Escape'); + await page.click("(//div[@id='select-field'])[1]"); + + await page.waitForTimeout(1000); // รอให้ dropdown เปิด + await page.click('id=select-field_6'); // คลิกเพื่อเปิดคอลัมน์ + await page.waitForTimeout(1000); // รอให้ UI อัปเดต + + // ตรวจสอบว่าคอลัมน์แสดงอยู่ + const isColumn1Visible = await column1.evaluate( + (el) => window.getComputedStyle(el).display !== 'none', + ); + console.log('คอลัมน์ที่ 7 แสดงอยู่:', isColumn1Visible); // เช็ค + + const areCellsVisible = await column1Cells.evaluateAll((cells) => + cells.every((cell) => window.getComputedStyle(cell).display !== 'none'), + ); + console.log('เซลล์ในคอลัมน์ที่ 7 แสดงอยู่:', areCellsVisible); // เช็ค + + expect(isColumn1Visible).toBe(true); + expect(areCellsVisible).toBe(true); + + console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; + throw error; + } + await page.keyboard.press('Escape'); + await page.waitForTimeout(2000); +}); + +test('ตรวจสอบการแสดงผลฟิลด์แสดงผลจะครบกำหนดในอีก', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + // คลิกเพื่อเปิด dropdown + await page.click("(//div[@id='select-field'])[1]"); + + await page.waitForTimeout(1000); // รอให้ dropdown เปิด + + // คลิกเพื่อปิดคอลัมน์ที่ 1 + await page.click('id=select-field_7'); + await page.waitForTimeout(1000); // รอให้ UI อัปเดต + + // ตรวจสอบว่าคอลัมน์ถูกซ่อน + const column1 = page.locator('id=select-field_7'); + const column1Cells = page.locator("//th[contains(.,'จะครบกำหนดในอีก')]"); + + const isColumn1Hidden = await column1.evaluate( + (el) => window.getComputedStyle(el).display === 'none', + ); + console.log('คอลัมน์ที่ 8 ซ่อนอยู่:', isColumn1Hidden); // เช็ค + + const areCellsHidden = await column1Cells.evaluateAll((cells) => + cells.every((cell) => window.getComputedStyle(cell).display === 'none'), + ); + console.log('เซลล์ในคอลัมน์ที่ 8 ซ่อนอยู่:', areCellsHidden); // เช็ค + + expect(isColumn1Hidden).toBe(false); + expect(areCellsHidden).toBe(true); + + // คลิกอีกครั้งเพื่อเปิดคอลัมน์ที่ 1 + await page.keyboard.press('Escape'); + await page.click("(//div[@id='select-field'])[1]"); + + await page.waitForTimeout(1000); // รอให้ dropdown เปิด + await page.click('id=select-field_7'); // คลิกเพื่อเปิดคอลัมน์ + await page.waitForTimeout(1000); // รอให้ UI อัปเดต + + // ตรวจสอบว่าคอลัมน์แสดงอยู่ + const isColumn1Visible = await column1.evaluate( + (el) => window.getComputedStyle(el).display !== 'none', + ); + console.log('คอลัมน์ที่ 8 แสดงอยู่:', isColumn1Visible); // เช็ค + + const areCellsVisible = await column1Cells.evaluateAll((cells) => + cells.every((cell) => window.getComputedStyle(cell).display !== 'none'), + ); + console.log('เซลล์ในคอลัมน์ที่ 8 แสดงอยู่:', areCellsVisible); // เช็ค + + expect(isColumn1Visible).toBe(true); + expect(areCellsVisible).toBe(true); + + console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; + throw error; + } + await page.keyboard.press('Escape'); + await page.waitForTimeout(2000); +}); + +test('ตรวจสอบการแสดงผลฟิลด์แสดงผลสาขา', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + // คลิกเพื่อเปิด dropdown + await page.click("(//div[@id='select-field'])[1]"); + + await page.waitForTimeout(1000); // รอให้ dropdown เปิด + + // คลิกเพื่อปิดคอลัมน์ที่ 1 + await page.click('id=select-field_8'); + await page.waitForTimeout(1000); // รอให้ UI อัปเดต + + // ตรวจสอบว่าคอลัมน์ถูกซ่อน + const column1 = page.locator('id=select-field_8'); + const column1Cells = page.locator("//th[contains(.,'สาขา')]"); + + const isColumn1Hidden = await column1.evaluate( + (el) => window.getComputedStyle(el).display === 'none', + ); + console.log('คอลัมน์ที่ 9 ซ่อนอยู่:', isColumn1Hidden); // เช็ค + + const areCellsHidden = await column1Cells.evaluateAll((cells) => + cells.every((cell) => window.getComputedStyle(cell).display === 'none'), + ); + console.log('เซลล์ในคอลัมน์ที่ 9 ซ่อนอยู่:', areCellsHidden); // เช็ค + + expect(isColumn1Hidden).toBe(false); + expect(areCellsHidden).toBe(true); + + // คลิกอีกครั้งเพื่อเปิดคอลัมน์ที่ 1 + await page.keyboard.press('Escape'); + await page.click("(//div[@id='select-field'])[1]"); + + await page.waitForTimeout(1000); // รอให้ dropdown เปิด + await page.click('id=select-field_8'); // คลิกเพื่อเปิดคอลัมน์ + await page.waitForTimeout(1000); // รอให้ UI อัปเดต + + // ตรวจสอบว่าคอลัมน์แสดงอยู่ + const isColumn1Visible = await column1.evaluate( + (el) => window.getComputedStyle(el).display !== 'none', + ); + console.log('คอลัมน์ที่ 9 แสดงอยู่:', isColumn1Visible); // เช็ค + + const areCellsVisible = await column1Cells.evaluateAll((cells) => + cells.every((cell) => window.getComputedStyle(cell).display !== 'none'), + ); + console.log('เซลล์ในคอลัมน์ที่ 9 แสดงอยู่:', areCellsVisible); // เช็ค + + expect(isColumn1Visible).toBe(true); + expect(areCellsVisible).toBe(true); + + console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; + throw error; + } + await page.keyboard.press('Escape'); + await page.waitForTimeout(2000); +}); diff --git a/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_025_CreateInNaturalperson.spec.ts b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_025_CreateInNaturalperson.spec.ts new file mode 100644 index 00000000..10f2460c --- /dev/null +++ b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_025_CreateInNaturalperson.spec.ts @@ -0,0 +1,454 @@ +import { test, expect, Page, errors } from '@playwright/test'; +import { strictEqual } from 'assert'; +import { writeFileSync } from 'fs'; + +let page: Page; +let isLoginSuccessful = false; + +test.beforeAll(async ({ browser }) => { + page = await browser.newPage(); +}); + +test.afterAll(async () => { + if (page !== undefined) { + await page.close(); + } +}); + +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + // เข้าสู่เมนูลูกค้า + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-customer'); + await page.click('id=sub-menu-customer'); + await page.waitForTimeout(2000); + await page.click('id=row-table-cm372yq4r0043u3phfvz5l2dq'); + await page.click('id=btn-add'); + await page.waitForTimeout(2000); + + isLoginSuccessful = true; + console.log('Login สำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการ Login', error); + isLoginSuccessful = false; + } +} + +test('Login', async () => { + await login(page); +}); + +test('ทดสอบการเพิ่มสาขาในนายจ้างบุคคลธรรมดา', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + // ส่วนเกี่ยวกับ + await page.click('id=dialog-select-prefix-name'); + await page.waitForSelector('id=dialog-select-prefix-name_0'); + await page.click('id=dialog-select-prefix-name_0'); + await page.fill('id=dialog-input-first-name', 'ก้องภพ'); + await page.fill('id=dialog-input-last-name', 'ทิพย์สุวรรณ'); + await page.fill('id=dialog-input-first-name-en', 'Kongpop'); + await page.fill('id=dialog-input-last-name-en', 'Tipsuwan'); + await page.fill("(//input[@id='dialog-input-telephone'])[1]", '0886242202'); + // วันเกิด + await page.click('id=dialog-input-birth-date'); + await page.waitForSelector( + "(//button[@class='dp__btn dp__month_year_select'])[2]", + ); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); + await page.waitForSelector("//div[text()='2000']"); + await page.click("//div[text()='2000']"); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[1]"); + await page.waitForSelector("//div[text()='ก.พ.']"); + await page.click("//div[text()='ก.พ.']"); + await page.waitForSelector("//div[@id='2000-02-04']/div[1]"); + await page.click("//div[@id='2000-02-04']/div[1]"); + + // ส่วนข้อมูลธุรกิจ + await page.click('id=employer-branch-select-business-type'); + await page.waitForSelector('id=employer-branch-select-business-type_0'); + await page.click('id=employer-branch-select-business-type_0'); + await page.click('id=employer-branch-select-job-position'); + await page.waitForSelector('id=employer-branch-select-job-position_0'); + await page.click('id=employer-branch-select-job-position_0'); + await page.fill( + 'id=employer-branch-input-job-description', + 'รายละเอียดงาน', + ); + await page.fill( + "(//input[@id='employer-branch-input-pay-rate'])[1]", + 'วันจ่ายเงินเดือน', + ); + await page.fill( + "(//input[@id='employer-branch-input-pay-rate'])[2]", + 'Pay day', + ); + await page.fill( + "(//input[@id='employer-branch-input-pay-rate'])[3]", + '500', + ); + + // ส่วนผู้มีอำนาจลงนาม + await page.fill( + "(//input[@id='employer-branch-input-contact-name'])[1]", + 'ก้องภพ ทิพย์สุวรรณ', + ); + await page.fill( + "(//input[@id='employer-branch-input-contact-name'])[2]", + 'Kongpop Tipsuwan', + ); + + // ส่วนที่อยู่นายจ้าง + await page.fill( + "(//input[@id='employer-branch-input-address'])[1]", + '22292282202', + ); + await page.fill( + 'id=employer-branch-input-address-no', + '45/9 หมู่บ้านสิริสุข', + ); + await page.fill( + "(//input[@id='employer-branch-input-soi'])[1]", + 'วิภาวดี 16', + ); + await page.fill( + "(//input[@id='employer-branch-input-street'])[1]", + 'วิภาวดีรังสิต ', + ); + await page.click('id=employer-branch-select-province'); + await page.waitForSelector('id=employer-branch-select-province_0'); + await page.click('id=employer-branch-select-province_0'); + // คลิก dropdown เพื่อเปิด + await page.click('id=employer-branch-select-district'); + + // กำหนดตัวเลือกที่ต้องการ + const targetOptionId = 'id=employer-branch-select-district_42'; // id ของตัวเลือกที่ต้องการ + let isVisible = false; + const maxScrollAttempts = 10; // จำนวนครั้งสูงสุดในการเลื่อน + let attempt = 0; + + while (!isVisible && attempt < maxScrollAttempts) { + // ตรวจสอบว่า dropdown แสดงหรือไม่ + const dropdown = page.locator('#employer-branch-select-district_lb'); + if ((await dropdown.count()) === 0) { + console.error('ไม่พบ dropdown ที่ต้องการ'); + break; + } + + // ใช้ page.locator() เลื่อน dropdown ลงไป + await dropdown.evaluate((element) => { + element.scrollTop += 150; // เลื่อนลง 150px + }); + + // รอให้เลื่อนเสร็จ + await page.waitForTimeout(100); // รอ 0.1 วินาทีเพื่อให้การเลื่อนเสร็จสิ้น + + // ตรวจสอบว่าตัวเลือกแสดงอยู่ใน viewport หรือไม่ + isVisible = await page.locator(targetOptionId).isVisible(); + attempt++; + } + + // หากตัวเลือกที่ต้องการอยู่ใน viewport ให้คลิก + if (isVisible) { + const targetOption = page.locator(targetOptionId); + await targetOption.click(); + } else { + console.error('ไม่พบตัวเลือกที่ต้องการ'); + } + await page.click('id=employer-branch-select-sub-district'); + await page.waitForSelector('id=employer-branch-select-sub-district_2'); + await page.click('id=employer-branch-select-sub-district_2'); + await page.fill( + 'id=employer-branch-input-address-en', + '45/9 Sirisuk Village', + ); + await page.fill( + "(//input[@id='employer-branch-input-soi'])[2]", + 'Vibhavadi 16', + ); + await page.fill( + "(//input[@id='employer-branch-input-street'])[2]", + 'Vibhavadi Rangsit', + ); + + // ส่วนข้อมูลติดต่อ + await page.fill('id=dialog-input-contact-name', 'ก้องภพ ทิพย์สุวรรณ'); + await page.fill('id=dialog-input-mail', 'kongpop@mail.com'); + await page.fill("(//input[@id='dialog-input-telephone'])[2]", '0866224228'); + await page.fill("(//input[@id='dialog-input-telephone'])[3]", '022014220'); + await page.click('id=quotation-branch'); + await page.keyboard.press('Escape'); + await page.waitForTimeout(1000); + + // กำหนดการคลิก dropdown หลายครั้งเพราะคลิกครั้งแรกแล้วไม่เจอ + let dropdownVisible = false; + const maxAttempts = 5; // จำนวนครั้งสูงสุดในการคลิก dropdown + let attemptCount = 0; + + while (!dropdownVisible && attemptCount < maxAttempts) { + // คลิกเปิด dropdown + await page.click('id=quotation-branch'); + + // ตรวจสอบว่าตัวเลือกภายใน dropdown ถูกแสดงแล้วหรือยัง + try { + await page.waitForSelector('id=quotation-branch_1', { + state: 'visible', + timeout: 2000, // รอ 2 วินาทีในแต่ละรอบ + }); + dropdownVisible = true; // ถ้าตัวเลือกถูกแสดงแล้ว เปลี่ยนสถานะเป็น true + } catch (error) { + console.warn( + `ไม่เจอ dropdown ในรอบที่ ${attemptCount + 1}, ลองใหม่อีกครั้ง`, + ); + } + + attemptCount++; + } + + if (dropdownVisible) { + // เมื่อ dropdown แสดงผลแล้ว คลิกตัวเลือกที่ต้องการ + await page.click('id=quotation-branch_1'); + } else { + console.error('ไม่สามารถแสดง dropdown ได้หลังจากพยายามหลายครั้ง'); + } + + await page.click("//button[@type='submit']"); + await page.waitForTimeout(2000); + await page.waitForSelector('id=btn-form-close', { state: 'visible' }); + await page.click('id=btn-form-close', { force: true }); + + const fullNameSubBranch = await page.locator( + "//tr[contains(.,'ก้องภพ ทิพย์สุวรรณ') and contains (.,'0')]", + ); + + await expect(fullNameSubBranch).toContainText('ก้องภพ ทิพย์สุวรรณ'); + await expect(fullNameSubBranch).toContainText('0'); + + console.log('ทดสอบการสร้างสาขาในบุคคลธรรมดาสำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForTimeout(2000); +}); + +test('ทดสอบการสร้างลูกจ้างภายในนายจ้างบุคคลธรรมดาในกรณีที่ใช้ที่อยู่ของนายจ้าง', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + await page.waitForSelector( + "(//button[@id='btn-show-employee-ยศพัฒน์ ธนากานต์'])[3]", + ); + await page.click("(//button[@id='btn-show-employee-ยศพัฒน์ ธนากานต์'])[3]"); + await page.waitForSelector('id=ก้องภพ-btn-add-employee'); + await page.click('id=ก้องภพ-btn-add-employee'); + + // ส่วนข้อมูลพื้นฐาน + await page.fill('id=form-employee-input-nrc-no', '2202282262282'); + + // ส่วนข้อมูลส่วนตัว + await page.click('id=form-employee-select-prefix-name'); + await page.waitForSelector('id=form-employee-select-prefix-name_0'); + await page.click('id=form-employee-select-prefix-name_0'); + await page.fill( + "(//input[@id='form-employee-input-first-name'])[1]", + 'ปริญญา', + ); + await page.fill('id=form-employee-input-last-name', 'อินทรวิชัย'); + await page.fill('id=form-employee-input-first-name-en', 'Parinya'); + await page.fill('id=form-employee-input-last-name-en', 'Intaravichai'); + + //วันเกิด + await page.click('id=form-employee-input-birth-date'); + await page.waitForSelector( + "(//button[@class='dp__btn dp__month_year_select'])[2]", + ); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); + await page.waitForSelector("//div[text()='1994']"); + await page.click("//div[text()='1994']"); + await page.waitForSelector( + "(//button[@class='dp__btn dp__month_year_select'])[1]", + ); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[1]"); + await page.waitForSelector("//div[text()='พ.ค.']"); + await page.click("//div[text()='พ.ค.']"); + await page.waitForSelector("//div[@id='1994-05-06']/div[1]"); + await page.click("//div[@id='1994-05-06']/div[1]"); + + await page.click('id=form-employee-select-nationality'); + await page.waitForSelector('id=form-employee-select-nationality_2'); + await page.click('id=form-employee-select-nationality_2'); + + await page.waitForSelector('id=btn-info-basic-save'); + await page.click('id=btn-info-basic-save'); + await page.waitForTimeout(2000); + + await page.waitForSelector('id=btn-form-close'); + await page.click('id=btn-form-close'); + await page.waitForTimeout(2000); + + const employeeCheck = await page.locator( + "(//tr[@id='row-table-Parinya'])[2]", + ); + console.log('แสดงข้อความ :', employeeCheck); + + await expect(employeeCheck).toHaveText( + '1Parinya Intaravichai ปริญญา อินทรวิชัย30 ปี 6 เดือน 18 วัน ลาว---- ', + ); + console.log('ระบบสามารถสร้างลูกจ้างได้'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForTimeout(2000); +}); + +test('ทดสอบการสร้างลูกจ้างภายในนายจ้างบุคคลธรรมดาในกรณีที่ใช้ที่อยู่แบบกำหนดเอง', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + await page.waitForSelector('id=ก้องภพ-btn-add-employee'); + await page.click('id=ก้องภพ-btn-add-employee'); + + // ส่วนข้อมูลพื้นฐาน + await page.fill('id=form-employee-input-nrc-no', '2202282262284'); + + // ส่วนข้อมูลส่วนตัว + await page.click('id=form-employee-select-prefix-name'); + await page.waitForSelector('id=form-employee-select-prefix-name_1'); + await page.click('id=form-employee-select-prefix-name_1'); + await page.fill( + "(//input[@id='form-employee-input-first-name'])[1]", + 'จิราพร', + ); + await page.fill('id=form-employee-input-last-name', 'นนทรี'); + await page.fill('id=form-employee-input-first-name-en', 'Jiraporn'); + await page.fill('id=form-employee-input-last-name-en', 'Nontree'); + + //วันเกิด + await page.click('id=form-employee-input-birth-date'); + await page.waitForSelector( + "(//button[@class='dp__btn dp__month_year_select'])[2]", + ); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); + await page.waitForSelector("//div[text()='1992']"); + await page.click("//div[text()='1992']"); + await page.waitForSelector( + "(//button[@class='dp__btn dp__month_year_select'])[1]", + ); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[1]"); + await page.waitForSelector("//div[text()='พ.ค.']"); + await page.click("//div[text()='พ.ค.']"); + await page.waitForSelector("//div[@id='1992-05-06']/div[1]"); + await page.click("//div[@id='1992-05-06']/div[1]"); + + await page.click('id=form-employee-select-nationality'); + await page.waitForSelector('id=form-employee-select-nationality_4'); + await page.click('id=form-employee-select-nationality_4'); + + // ส่วนข้อมูลที่อยู่ + await page.waitForSelector('id=form-employee-custom'); + await page.click('id=form-employee-custom'); + await page.fill( + 'id=form-employee-input-address-no', + '90/12 หมู่บ้านภูพิมาน', + ); + await page.fill("(//input[@id='form-employee-input-moo'])[1]", '4'); + await page.fill("(//input[@id='form-employee-input-soi'])[1]", 'ศรีตรัง'); + await page.fill( + "(//input[@id='form-employee-input-street'])[1]", + 'นครศรี-ทุ่งสง', + ); + await page.click('id=form-employee-select-province'); + + // กำหนดตัวเลือกที่ต้องการ + const targetOptionId = 'id=form-employee-select-province_38'; // id ของตัวเลือกที่ต้องการ + let isVisible = false; + const maxScrollAttempts = 10; // จำนวนครั้งสูงสุดในการเลื่อน + let attempt = 0; + + while (!isVisible && attempt < maxScrollAttempts) { + // ตรวจสอบว่า dropdown แสดงหรือไม่ + const dropdown = page.locator('#form-employee-select-province_lb'); + if ((await dropdown.count()) === 0) { + console.error('ไม่พบ dropdown ที่ต้องการ'); + break; + } + + // ใช้ page.locator() เลื่อน dropdown ลงไป + await dropdown.evaluate((element) => { + element.scrollTop += 150; // เลื่อนลง 150px + }); + + // รอให้เลื่อนเสร็จ + await page.waitForTimeout(100); // รอ 0.1 วินาทีเพื่อให้การเลื่อนเสร็จสิ้น + + // ตรวจสอบว่าตัวเลือกแสดงอยู่ใน viewport หรือไม่ + isVisible = await page.locator(targetOptionId).isVisible(); + attempt++; + } + + // หากตัวเลือกที่ต้องการอยู่ใน viewport ให้คลิก + if (isVisible) { + const targetOption = page.locator(targetOptionId); + await targetOption.click(); + } else { + console.error('ไม่พบตัวเลือกที่ต้องการ'); + } + await page.click('id=form-employee-select-district'); + await page.waitForSelector('id=form-employee-select-district_0'); + await page.click('id=form-employee-select-district_0'); + await page.click('id=form-employee-select-sub-district'); + await page.waitForSelector('id=form-employee-select-sub-district_0'); + await page.click('id=form-employee-select-sub-district_0'); + await page.fill( + 'id=form-employee-input-address-en', + '90/12 Phupiman Village', + ); + await page.fill("(//input[@id='form-employee-input-moo'])[2]", '4'); + await page.fill("(//input[@id='form-employee-input-soi'])[2]", 'Sri Trang'); + await page.fill( + "(//input[@id='form-employee-input-street'])[2]", + 'Nakhon Si-Thung Song', + ); + + // บันทึกการสร้างลูกจ้าง + await page.waitForSelector('id=btn-info-basic-save'); + await page.click('id=btn-info-basic-save'); + await page.waitForTimeout(2000); + + await page.waitForSelector('id=btn-form-close'); + await page.click('id=btn-form-close'); + await page.waitForTimeout(2000); + + const employeeCheck = await page.locator( + "(//tr[@id='row-table-Jiraporn'])[2]", + ); + console.log('แสดงข้อความ :', employeeCheck); + + await expect(employeeCheck).toHaveText( + '2Jiraporn Nontree จิราพร นนทรี32 ปี 6 เดือน 18 วัน เวียดนาม---- ', + ); + console.log('ระบบสามารถสร้างลูกจ้างได้'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForTimeout(2000); +}); diff --git a/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_026_CreateInNaturalpersonFail.spec.ts b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_026_CreateInNaturalpersonFail.spec.ts new file mode 100644 index 00000000..e5397a55 --- /dev/null +++ b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_026_CreateInNaturalpersonFail.spec.ts @@ -0,0 +1,292 @@ +import { test, expect, Page, errors } from '@playwright/test'; +import { strictEqual } from 'assert'; +import { error } from 'console'; +import { writeFileSync } from 'fs'; +import { errorMonitor } from 'stream'; + +let page: Page; +let isLoginSuccessful = false; + +test.beforeAll(async ({ browser }) => { + page = await browser.newPage(); +}); + +test.afterAll(async () => { + if (page !== undefined) { + await page.close(); + } +}); + +//สร้าง Function สำหรับ Login +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + // เข้าสู่เมนูลูกค้า + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-customer'); + await page.click('id=sub-menu-customer'); + await page.waitForTimeout(2000); + await page.click('id=row-table-cm372yq4r0043u3phfvz5l2dq'); + + // ถ้าขั้นตอนทั้งหมดสำเร็จ + isLoginSuccessful = true; + console.log('Login สำเร็จ'); + } catch (error) { + console.error('ข้อผิดพลาดในการ Login', error); + isLoginSuccessful = false; + } +} + +test('Login', async () => { + await login(page); +}); + +test('ทดสอบการเพิ่มสาขาในนายจ้างบุคคลธรรมดาในกรณีที่ไม่กรอกข้อมูล', async () => { + // ถ้ายังไม่ได้ Login ให้ทำการ Login + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click('id=btn-add'); + await page.waitForTimeout(2000); + await page.waitForSelector("//button[@type='submit']"); + await page.click("//button[@type='submit']"); + await page.waitForTimeout(2000); + + //ตรวจสอบข้อผิดพลาดที่ต้องแสดง + const expectedErrors = [ + { + locator: "(//div[@class='q-field__messages col']//div)[1]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[2]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[3]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[4]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[5]", + message: 'โปรดเลือกวันเดือนปีเกิด', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[6]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[7]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[8]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[9]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[10]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[11]", + message: 'โปรดเลือกจังหวัด', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[12]", + message: 'โปรดเลือกเขต/อำเภอ', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[13]", + message: 'โปรดเลือกแขวง/ตำบล', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[14]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[15]", + message: 'โปรดเลือกจังหวัด', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[16]", + message: 'โปรดเลือกเขต/อำเภอ', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[17]", + message: 'โปรดเลือกแขวง/ตำบล', + }, + ]; + + for (const error of expectedErrors) { + const locator = page.locator(error.locator); + await expect(locator).toHaveText(error.message); + } + + console.log('ระบบตรวจสอบการแจ้งเตือนเรียบร้อยแล้ว'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + // ถ้าล้มเหลวให้ทเครื่องหมายว่าล้มเหลว + isLoginSuccessful = false; + throw error; + } + await page.waitForSelector('id=btn-form-close'); + await page.click('id=btn-form-close'); + await page.waitForTimeout(2000); +}); + +test('ทดสอบการเพิ่มสาขาในนายจ้างบุคคลธรรมดาในกรณีที่กรอกข้อมูลเฉพาะส่วนเกี่ยวกับ', async () => { + // ถ้ายังไม่ได้ Login ให้ทำการ Login + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click('id=btn-add'); + await page.waitForTimeout(2000); + await page.fill('id=dialog-input-first-name', 'ชื่อ'); + await page.fill('id=dialog-input-last-name', 'นามสกุล'); + await page.fill('id=dialog-input-first-name-en', 'Name'); + await page.fill('id=dialog-input-last-name-en', 'surname'); + // วันเดือนปีเกิด + await page.click('id=dialog-input-birth-date'); + await page.waitForSelector( + "(//button[@class='dp__btn dp__month_year_select'])[2]", + ); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); + await page.waitForSelector("//div[text()='2006']"); + await page.click("//div[text()='2006']"); + await page.waitForSelector( + "(//button[@class='dp__btn dp__month_year_select'])[1]", + ); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[1]"); + await page.waitForSelector("//div[text()='มิ.ย.']"); + await page.click("//div[text()='มิ.ย.']"); + await page.waitForSelector("//div[@id='2006-06-24']/div[1]"); + await page.click("//div[@id='2006-06-24']/div[1]"); + await page.waitForSelector("//button[@type='submit']"); + await page.click("//button[@type='submit']"); + await page.waitForTimeout(2000); + //ตรวจสอบข้อผิดพลาดที่ต้องแสดง + const expectedErrors = [ + { + locator: "(//div[@class='q-field__messages col']//div)[1]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[2]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[3]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[4]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[5]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[6]", + message: 'โปรดเลือกจังหวัด', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[7]", + message: 'โปรดเลือกเขต/อำเภอ', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[8]", + message: 'โปรดเลือกแขวง/ตำบล', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[9]", + message: 'จำเป็นต้องกรอกข้อมูลนี้', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[10]", + message: 'โปรดเลือกจังหวัด', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[11]", + message: 'โปรดเลือกเขต/อำเภอ', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[12]", + message: 'โปรดเลือกแขวง/ตำบล', + }, + ]; + + for (const error of expectedErrors) { + const locator = page.locator(error.locator); + await expect(locator).toHaveText(error.message); + } + + console.log('ระบบตรวจสอบการแจ้งเตือนเรียบร้อยแล้ว'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + // ถ้าล้มเหลว + isLoginSuccessful = false; + throw error; + } + await page.waitForSelector('id=btn-form-close'); + await page.click('id=btn-form-close'); + await page.waitForTimeout(2000); +}); + +test('ทดสอบการเพิ่มสาขาในนายจ้างบุคคลธรรมดาในกรณีที่กรอกข้อมูลชื่อและนามสกุลภาษาอังกฤษไม่ตรงรูปแบบ', async () => { + // ถ้ายังไม่ได้ Login ให้ทำการ Login + if (!isLoginSuccessful) { + await login(page); + } + + try { + await page.click('id=btn-add'); + await page.waitForTimeout(2000); + await page.fill('id=dialog-input-first-name-en', 'ชื่อ'); + await page.fill('id=dialog-input-last-name-en', 'นามสกุล'); + await page.waitForTimeout(2000); + + const expectedErrors = [ + { + locator: "(//div[@class='q-field__messages col']//div)[1]", + message: 'โปรดใช้เฉพาะตัวอักษรภาษาอังกฤษเท่านั้น', + }, + { + locator: "(//div[@class='q-field__messages col']//div)[2]", + message: 'โปรดใช้เฉพาะตัวอักษรภาษาอังกฤษเท่านั้น', + }, + ]; + for (const error of expectedErrors) { + const locator = page.locator(error.locator); + await expect(locator).toHaveText(error.message); + } + console.log('ระบบตรวจสอบการแจ้งเตือนแล้ว'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + // ถ้าล้มเหลว + isLoginSuccessful = false; + throw error; + } + await page.waitForSelector('id=btn-form-close'); + await page.click('id=btn-form-close'); + await page.waitForTimeout(2000); +}); diff --git a/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_027_CreateInLegalentitly.spec.ts b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_027_CreateInLegalentitly.spec.ts new file mode 100644 index 00000000..221f525d --- /dev/null +++ b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_027_CreateInLegalentitly.spec.ts @@ -0,0 +1,470 @@ +import { test, expect, Page } from '@playwright/test'; +import { strictEqual } from 'assert'; + +let page: Page; +let isLoginSuccessful = false; + +test.beforeAll(async ({ browser }) => { + page = await browser.newPage(); +}); + +test.afterAll(async () => { + if (page !== undefined) { + await page.close(); + } +}); + +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + // เข้าสู่เมนูลูกค้า + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-customer'); + await page.click('id=sub-menu-customer'); + await page.waitForTimeout(2000); + await page.click('id=row-table-cm38dee6s000dip2c6vye04bw'); + await page.click('id=btn-add'); + await page.waitForTimeout(2000); + + isLoginSuccessful = true; + console.log('Login สำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการ Login', error); + isLoginSuccessful = false; + } +} + +test('Login', async () => { + await login(page); +}); + +test('ทดสอบการเพิ่มสาขาในนายจ้างนิติบุคคล', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + // ส่วนเกี่ยวกับ + await page.fill( + 'id=input-register-name', + 'บริษัท พีคเวิลด์ คอนซัลติ้ง จำกัด', + ); + await page.fill( + 'id=input-register-name-en', + 'Peak World Consulting Co., Ltd.', + ); + await page.fill('id=input-legal-person-no', 'ธนกฤต ศรีประเสริฐ'); + await page.fill('id=input-legal-person-code', '2202264280648'); + //จดทะเบียนเมื่อ + await page.click('id=dialog-input-register-date'); + await page.waitForSelector( + "(//button[@class='dp__btn dp__month_year_select'])[2]", + ); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); + await page.waitForSelector("//div[text()='2020']"); + await page.click("//div[text()='2020']"); + await page.waitForSelector( + "(//button[@class='dp__btn dp__month_year_select'])[1]", + ); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[1]"); + await page.waitForSelector("//div[text()='ส.ค.']"); + await page.click("//div[text()='ส.ค.']"); + await page.waitForSelector("//div[@id='2020-08-06']/div[1]"); + await page.click("//div[@id='2020-08-06']/div[1]"); + + await page.fill('id=input-authorized-capital', '10000000'); + await page.fill('id=input-telephone-no', '022066060'); + + // ส่วนข้อมูลธุรกิจ + await page.click('id=employer-branch-select-business-type'); + await page.waitForSelector('id=employer-branch-select-business-type_3'); + await page.click('id=employer-branch-select-business-type_3'); + await page.click('id=employer-branch-select-job-position'); + await page.waitForSelector('id=employer-branch-select-job-position_0'); + await page.click('id=employer-branch-select-job-position_0'); + await page.fill( + 'id=employer-branch-input-job-description', + 'รายละเอียดงาน', + ); + await page.fill( + "(//input[@id='employer-branch-input-pay-rate'])[1]", + 'วันที่จ่ายเงินเดือน', + ); + await page.fill( + "(//input[@id='employer-branch-input-pay-rate'])[2]", + 'Pay day', + ); + await page.fill( + "(//input[@id='employer-branch-input-pay-rate'])[3]", + '550', + ); + + // ส่วนผู้มีอำนาจลงนาม + await page.fill( + "(//input[@id='employer-branch-input-contact-name'])[1]", + 'ธนกฤต ศรีประเสริฐ', + ); + await page.fill( + "(//input[@id='employer-branch-input-contact-name'])[2]", + 'Thanakrit Sriprasert', + ); + // ส่วนที่อยู่นายจ้าง + await page.fill( + "(//input[@id='employer-branch-input-address'])[1]", + '20264282028', + ); + await page.fill( + 'id=employer-branch-input-address-no', + '99/12 อาคารซัมเมอร์ฮับ ชั้น 8', + ); + await page.fill( + "(//input[@id='employer-branch-input-soi'])[1]", + 'สุขุมวิท 23', + ); + await page.fill( + "(//input[@id='employer-branch-input-street'])[1]", + 'สุขุมวิท', + ); + await page.click('id=employer-branch-select-province'); + await page.waitForSelector('id=employer-branch-select-province_0'); + await page.click('id=employer-branch-select-province_0'); + + // คลิก dropdown เพื่อเปิด + await page.click('id=employer-branch-select-district'); + + // กำหนดตัวเลือกที่ต้องการ + const targetOptionId = 'id=employer-branch-select-district_13'; // id ของตัวเลือกที่ต้องการ + let isVisible = false; + const maxScrollAttempts = 10; // จำนวนครั้งสูงสุดในการเลื่อน + let attempt = 0; + + while (!isVisible && attempt < maxScrollAttempts) { + // ตรวจสอบว่า dropdown แสดงหรือไม่ + const dropdown = page.locator('#employer-branch-select-district_lb'); + if ((await dropdown.count()) === 0) { + console.error('ไม่พบ dropdown ที่ต้องการ'); + break; + } + + // ใช้ page.locator() เลื่อน dropdown ลงไป + await dropdown.evaluate((element) => { + element.scrollTop += 150; // เลื่อนลง 150px + }); + + // รอให้เลื่อนเสร็จ + await page.waitForTimeout(100); // รอ 0.1 วินาทีเพื่อให้การเลื่อนเสร็จสิ้น + + // ตรวจสอบว่าตัวเลือกแสดงอยู่ใน viewport หรือไม่ + isVisible = await page.locator(targetOptionId).isVisible(); + attempt++; + } + + // หากตัวเลือกที่ต้องการอยู่ใน viewport ให้คลิก + if (isVisible) { + const targetOption = page.locator(targetOptionId); + await targetOption.click(); + } else { + console.error('ไม่พบตัวเลือกที่ต้องการ'); + } + await page.click('id=employer-branch-select-sub-district'); + await page.waitForSelector('id=employer-branch-select-sub-district_0'); + await page.click('id=employer-branch-select-sub-district_0'); + await page.fill( + 'id=employer-branch-input-address-en', + '99/12 Summer Hub Building, 8th Floor', + ); + await page.fill( + "(//input[@id='employer-branch-input-soi'])[2]", + 'Sukhumvit 23', + ); + await page.fill( + "(//input[@id='employer-branch-input-street'])[2]", + 'Sukhumvit', + ); + // ส่วนข้อมูลติดต่อ + await page.fill('id=dialog-input-contact-name', 'ธนกฤต ศรีประเสริฐ'); + await page.fill('id=dialog-input-mail', 'peakworld@support.com'); + await page.fill("(//input[@id='dialog-input-telephone'])[1]", '0864462828'); + await page.fill("(//input[@id='dialog-input-telephone'])[2]", '022066060'); + + // การเลือก Dropdown โดยการวนลูป เพราะว่าหลังจากคลิก Dropdown ครั้งแรกแล้วข้อมูลที่ให้เลือกใน Dropdown ไม่แสดง + // กำหนดการคลิก dropdown หลายครั้งเพราะคลิกครั้งแรกแล้วไม่เจอ + let dropdownVisible = false; + const maxAttempts = 5; // จำนวนครั้งสูงสุดในการคลิก dropdown + let attemptCount = 0; + + while (!dropdownVisible && attemptCount < maxAttempts) { + // คลิกเปิด dropdown + await page.click('id=quotation-branch'); + + // ตรวจสอบว่าตัวเลือกภายใน dropdown ถูกแสดงแล้วหรือยัง + try { + await page.waitForSelector('id=quotation-branch_0', { + state: 'visible', + timeout: 1000, // รอ 1 วินาทีในแต่ละรอบ + }); + dropdownVisible = true; // ถ้าตัวเลือกถูกแสดงแล้ว เปลี่ยนสถานะเป็น true + } catch (error) { + console.warn( + `ไม่เจอ dropdown ในรอบที่ ${attemptCount + 1}, ลองใหม่อีกครั้ง`, + ); + } + + attemptCount++; + } + + if (dropdownVisible) { + // เมื่อ dropdown แสดงผลแล้ว คลิกตัวเลือกที่ต้องการ + await page.click('id=quotation-branch_0'); + } else { + console.error('ไม่สามารถแสดง dropdown ได้หลังจากพยายามหลายครั้ง'); + } + + await page.waitForSelector("//button[@type='submit']"); + await page.click("//button[@type='submit']"); + await page.waitForTimeout(2000); + await page.waitForSelector('id=btn-form-close'); + await page.click('id=btn-form-close'); + await page.waitForTimeout(2000); + + const subBranchCheck = await page.locator( + "//tr[contains(.,'บริษัท พีคเวิลด์ คอนซัลติ้ง จำกัด') and contains (.,'0')]", + ); + + await expect(subBranchCheck).toContainText( + 'บริษัท พีคเวิลด์ คอนซัลติ้ง จำกัด', + ); + await expect(subBranchCheck).toContainText('0'); + console.log('ระบบทำการสร้างสาขาในนายจ้างนิติบุคคลแล้ว'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForTimeout(2000); +}); + +test('ทดสอบการสร้างลูกจ้างภายในนายจ้างนิติบุคคลในกรณีที่ใช้ที่อยู่ของนายจ้าง', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + await page.waitForSelector( + "(//button[@id='btn-show-employee-บริษัท เอเชียเทค ซิสเต็มส์ จำกัด '])[2]", + ); + await page.click( + "(//button[@id='btn-show-employee-บริษัท เอเชียเทค ซิสเต็มส์ จำกัด '])[2]", + ); + await page.waitForSelector( + 'id=บริษัท พีคเวิลด์ คอนซัลติ้ง จำกัด-btn-add-employee', + ); + await page.click('id=บริษัท พีคเวิลด์ คอนซัลติ้ง จำกัด-btn-add-employee'); + + // ส่วนข้อมูลพื้นฐาน + await page.fill('id=form-employee-input-nrc-no', '2202282262260'); + + // ส่วนข้อมูลส่วนตัว + await page.click('id=form-employee-select-prefix-name'); + await page.waitForSelector('id=form-employee-select-prefix-name_0'); + await page.click('id=form-employee-select-prefix-name_0'); + await page.fill( + "(//input[@id='form-employee-input-first-name'])[1]", + 'ณัฐวุฒิ', + ); + await page.fill('id=form-employee-input-last-name', 'วงศ์เจริญ'); + await page.fill('id=form-employee-input-first-name-en', 'Nattawut'); + await page.fill('id=form-employee-input-last-name-en', 'Wongcharoen'); + + //วันเกิด + await page.click('id=form-employee-input-birth-date'); + await page.waitForSelector( + "(//button[@class='dp__btn dp__month_year_select'])[2]", + ); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); + await page.waitForSelector("//div[text()='1990']"); + await page.click("//div[text()='1990']"); + await page.waitForSelector( + "(//button[@class='dp__btn dp__month_year_select'])[1]", + ); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[1]"); + await page.waitForSelector("//div[text()='พ.ค.']"); + await page.click("//div[text()='พ.ค.']"); + await page.waitForSelector("//div[@id='1990-05-10']/div[1]"); + await page.click("//div[@id='1990-05-10']/div[1]"); + + await page.click('id=form-employee-select-nationality'); + await page.waitForSelector('id=form-employee-select-nationality_4'); + await page.click('id=form-employee-select-nationality_4'); + + await page.waitForSelector('id=btn-info-basic-save'); + await page.click('id=btn-info-basic-save'); + await page.waitForTimeout(2000); + + await page.waitForSelector('id=btn-form-close'); + await page.click('id=btn-form-close'); + await page.waitForTimeout(2000); + + const employeeCheck = await page.locator( + "(//tr[@id='row-table-Nattawut'])[2]", + ); + console.log('แสดงข้อความ :', employeeCheck); + + await expect(employeeCheck).toHaveText( + '1Nattawut Wongcharoen ณัฐวุฒิ วงศ์เจริญ34 ปี 6 เดือน 15 วัน เวียดนาม---- ', + ); + console.log('ระบบสามารถสร้างลูกจ้างได้'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForTimeout(2000); +}); + +test('ทดสอบการสร้างลูกจ้างภายในนายจ้างนิติบุคคลในกรณีที่ใช้ที่อยู่แบบกำหนดเอง', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + await page.waitForSelector( + 'id=บริษัท พีคเวิลด์ คอนซัลติ้ง จำกัด-btn-add-employee', + ); + await page.click('id=บริษัท พีคเวิลด์ คอนซัลติ้ง จำกัด-btn-add-employee'); + + // ส่วนข้อมูลพื้นฐาน + await page.fill('id=form-employee-input-nrc-no', '2202282262262'); + + // ส่วนข้อมูลส่วนตัว + await page.click('id=form-employee-select-prefix-name'); + await page.waitForSelector('id=form-employee-select-prefix-name_1'); + await page.click('id=form-employee-select-prefix-name_1'); + await page.fill( + "(//input[@id='form-employee-input-first-name'])[1]", + 'พิชชา', + ); + await page.fill('id=form-employee-input-last-name', 'สุวรรณภา'); + await page.fill('id=form-employee-input-first-name-en', 'Pitcha'); + await page.fill('id=form-employee-input-last-name-en', 'Suwannapha'); + + //วันเกิด + await page.click('id=form-employee-input-birth-date'); + await page.waitForSelector( + "(//button[@class='dp__btn dp__month_year_select'])[2]", + ); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); + await page.waitForSelector("//div[text()='1999']"); + await page.click("//div[text()='1999']"); + await page.waitForSelector( + "(//button[@class='dp__btn dp__month_year_select'])[1]", + ); + await page.click("(//button[@class='dp__btn dp__month_year_select'])[1]"); + await page.waitForSelector("//div[text()='ธ.ค.']"); + await page.click("//div[text()='ธ.ค.']"); + await page.waitForSelector("//div[@id='1999-12-06']/div[1]"); + await page.click("//div[@id='1999-12-06']/div[1]"); + + await page.click('id=form-employee-select-nationality'); + await page.waitForSelector('id=form-employee-select-nationality_6'); + await page.click('id=form-employee-select-nationality_6'); + + // ส่วนข้อมูลที่อยู่ + await page.waitForSelector('id=form-employee-custom'); + await page.click('id=form-employee-custom'); + await page.fill( + 'id=form-employee-input-address-no', + '88/14 หมู่บ้านลักขณา', + ); + await page.fill("(//input[@id='form-employee-input-moo'])[1]", '7'); + await page.fill("(//input[@id='form-employee-input-soi'])[1]", 'เจริญสุข'); + await page.fill( + "(//input[@id='form-employee-input-street'])[1]", + 'ร้อยเอ็ด-กาฬสินธุ์', + ); + await page.click('id=form-employee-select-province'); + + // กำหนดตัวเลือกที่ต้องการ + const targetOptionId = 'id=form-employee-select-province_23'; // id ของตัวเลือกที่ต้องการ + let isVisible = false; + const maxScrollAttempts = 10; // จำนวนครั้งสูงสุดในการเลื่อน + let attempt = 0; + + while (!isVisible && attempt < maxScrollAttempts) { + // ตรวจสอบว่า dropdown แสดงหรือไม่ + const dropdown = page.locator('#form-employee-select-province_lb'); + if ((await dropdown.count()) === 0) { + console.error('ไม่พบ dropdown ที่ต้องการ'); + break; + } + + // ใช้ page.locator() เลื่อน dropdown ลงไป + await dropdown.evaluate((element) => { + element.scrollTop += 150; // เลื่อนลง 150px + }); + + // รอให้เลื่อนเสร็จ + await page.waitForTimeout(100); // รอ 0.1 วินาทีเพื่อให้การเลื่อนเสร็จสิ้น + + // ตรวจสอบว่าตัวเลือกแสดงอยู่ใน viewport หรือไม่ + isVisible = await page.locator(targetOptionId).isVisible(); + attempt++; + } + + // หากตัวเลือกที่ต้องการอยู่ใน viewport ให้คลิก + if (isVisible) { + const targetOption = page.locator(targetOptionId); + await targetOption.click(); + } else { + console.error('ไม่พบตัวเลือกที่ต้องการ'); + } + await page.click('id=form-employee-select-district'); + await page.waitForSelector('id=form-employee-select-district_9'); + await page.click('id=form-employee-select-district_9'); + await page.click('id=form-employee-select-sub-district'); + await page.waitForSelector('id=form-employee-select-sub-district_11'); + await page.click('id=form-employee-select-sub-district_11'); + await page.fill( + 'id=form-employee-input-address-en', + '88/14 Lakkana Village', + ); + await page.fill("(//input[@id='form-employee-input-moo'])[2]", '7'); + await page.fill( + "(//input[@id='form-employee-input-soi'])[2]", + 'Charoen Suk', + ); + await page.fill( + "(//input[@id='form-employee-input-street'])[2]", + 'Roi Et-Kalasin', + ); + + // บันทึกการสร้างลูกจ้าง + await page.waitForSelector('id=btn-info-basic-save'); + await page.click('id=btn-info-basic-save'); + await page.waitForTimeout(2000); + + await page.waitForSelector('id=btn-form-close'); + await page.click('id=btn-form-close'); + await page.waitForTimeout(2000); + + const employeeCheck = await page.locator( + "(//tr[@id='row-table-Pitcha'])[2]", + ); + console.log('แสดงข้อความ :', employeeCheck); + + await expect(employeeCheck).toHaveText( + '2Pitcha Suwannapha พิชชา สุวรรณภา24 ปี 11 เดือน 18 วัน จีน---- ', + ); + console.log('ระบบสามารถสร้างลูกจ้างได้'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForTimeout(2000); +}); diff --git a/tests/04-ProductandService/JWS_PD_012_SearchProductandService.spec.ts b/tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_028_CreateInLegalentitlyFail.spec.ts similarity index 100% rename from tests/04-ProductandService/JWS_PD_012_SearchProductandService.spec.ts rename to tests/01-Manage/03-Admin-ManageCustomer/JWS_MC_028_CreateInLegalentitlyFail.spec.ts diff --git a/tests/04-ProductandService/JWS_PD_001_CreateProductandServiceGroup.spec.ts b/tests/01-Manage/04-ProductandService/JWS_PD_001_CreateProductandServiceGroup.spec.ts similarity index 71% rename from tests/04-ProductandService/JWS_PD_001_CreateProductandServiceGroup.spec.ts rename to tests/01-Manage/04-ProductandService/JWS_PD_001_CreateProductandServiceGroup.spec.ts index 8ffc7e99..07a9ece6 100644 --- a/tests/04-ProductandService/JWS_PD_001_CreateProductandServiceGroup.spec.ts +++ b/tests/01-Manage/04-ProductandService/JWS_PD_001_CreateProductandServiceGroup.spec.ts @@ -3,6 +3,7 @@ import { strictEqual } from 'assert'; import { log } from 'console'; let page: Page; +let isLoginSuccessful = false; test.beforeAll(async ({ browser }) => { page = await browser.newPage(); @@ -14,24 +15,42 @@ test.afterAll(async () => { } }); +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + // เข้าสู่เมนูสินค้าและบริการ + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-productService'); + await page.click('id=sub-menu-productService'); + + isLoginSuccessful = true; + console.log('Login สำเร็จ'); + } catch (error) { + console.error('เกืดข้อผิดพลาดในการ Login', error); + isLoginSuccessful = false; + } +} + test('Login', async () => { - // Login - await page.goto('http://192.168.1.62:20101/'); - 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'); + await login(page); }); test('ทดสอบการเพิ่มกลุ่มสินค้าและบริการ', async () => { - await page.click('id=menu-icon-product-service'); - + if (!isLoginSuccessful) { + await login(page); + } try { // เพิ่มกลุ่มสินค้าและบริการ + await page.click('id=btn-add'); - await page.click('id=btn-add-product-group'); // กรอกข้อมูลกลุ่มสินค้าและบริการ // await page.click("(//i[@aria-hidden='false'])[2]"); @@ -44,7 +63,7 @@ test('ทดสอบการเพิ่มกลุ่มสินค้า await page.fill("(//textarea[@id='input-remark'])[2]", 'หมายเหตุประกัน'); // บันทึกการสร้างกลุ่มสินค้นและบริการ - await page.click('id=btn-form-submit'); + await page.click('id=btn-info-basic-save'); // ตรวจสอบหลังทำการสร้างกลุ่มสินค้าและบริการ const newProductAndServiceLocator = page.locator( @@ -67,6 +86,7 @@ test('ทดสอบการเพิ่มกลุ่มสินค้า } } catch (error) { console.error('เกิดข้อผิดการในการทดสอบ'); + isLoginSuccessful = false; throw error; } diff --git a/tests/01-Manage/04-ProductandService/JWS_PD_002-1_CreateProductandServiceGroupFailEn.spec.ts b/tests/01-Manage/04-ProductandService/JWS_PD_002-1_CreateProductandServiceGroupFailEn.spec.ts new file mode 100644 index 00000000..b87a8062 --- /dev/null +++ b/tests/01-Manage/04-ProductandService/JWS_PD_002-1_CreateProductandServiceGroupFailEn.spec.ts @@ -0,0 +1,75 @@ +import { test, expect, Page } from '@playwright/test'; +import { strictEqual } from 'assert'; +import { log } from 'console'; + +let page: Page; +let isLoginSuccessful = false; + +test.beforeAll(async ({ browser }) => { + page = await browser.newPage(); +}); + +test.afterAll(async () => { + if (page !== undefined) { + await page.close(); + } +}); + +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + // เข้าสู่เมนูสินค้าและบริการ + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-productService'); + await page.click('id=sub-menu-productService'); + await page.waitForTimeout(2000); + + // เปลี่ยนภาษา + await page.click('id=btn-change-language'); + await page.waitForSelector('id=btn-change-language-eng'); + await page.click('id=btn-change-language-eng'); + + isLoginSuccessful = true; + console.log('Login สำเร็จ'); + } catch (error) { + console.error('เกืดข้อผิดพลาดในการ Login', error); + isLoginSuccessful = false; + } +} + +test('Login', async () => { + await login(page); +}); + +test('ทดสอบการเพิ่มกลุ่มสินค้าและบริการในกรณีที่ไม่กรอกข้อมูล', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + await page.click('id=btn-add'); + await page.waitForSelector('id=btn-info-basic-save'); + await page.click('id=btn-info-basic-save'); + + const nameProductGroupandService = await page.locator( + "//div[@class='q-field__messages col']//div[1]", + ); + + await expect(nameProductGroupandService).toHaveText( + 'This field is required.', + ); + console.log('ระบบทำการแจ้งเตือนถูกต้อง'); + } catch (error) { + console.log('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForTimeout(2000); +}); diff --git a/tests/01-Manage/04-ProductandService/JWS_PD_002_CreateProductandServiceGroupFail.spec.ts b/tests/01-Manage/04-ProductandService/JWS_PD_002_CreateProductandServiceGroupFail.spec.ts new file mode 100644 index 00000000..ac139bcd --- /dev/null +++ b/tests/01-Manage/04-ProductandService/JWS_PD_002_CreateProductandServiceGroupFail.spec.ts @@ -0,0 +1,69 @@ +import { test, expect, Page } from '@playwright/test'; +import { strictEqual } from 'assert'; +import { log } from 'console'; + +let page: Page; +let isLoginSuccessful = false; + +test.beforeAll(async ({ browser }) => { + page = await browser.newPage(); +}); + +test.afterAll(async () => { + if (page !== undefined) { + await page.close(); + } +}); + +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + // เข้าสู่เมนูสินค้าและบริการ + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-productService'); + await page.click('id=sub-menu-productService'); + + isLoginSuccessful = true; + console.log('Login สำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการ Login', error); + isLoginSuccessful = false; + } +} + +test('Login', async () => { + await login(page); +}); + +test('ทดสอบการเพิ่มกลุ่มสินค้าและบริการในกรณีที่ไม่กรอกข้อมูล', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + await page.click('id=btn-add'); + await page.waitForSelector('id=btn-info-basic-save'); + await page.click('id=btn-info-basic-save'); + + const nameProductGroupandService = await page.locator( + "//div[@class='q-field__messages col']//div[1]", + ); + + await expect(nameProductGroupandService).toHaveText( + 'จำเป็นต้องกรอกข้อมูลนี้', + ); + console.log('ระบบทำการแจ้งเตือนถูกต้อง'); + } catch (error) { + console.log('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; + throw error; + } + await page.waitForTimeout(2000); +}); diff --git a/tests/01-Manage/04-ProductandService/JWS_PD_003_CreateProductandService.spec.ts b/tests/01-Manage/04-ProductandService/JWS_PD_003_CreateProductandService.spec.ts new file mode 100644 index 00000000..57564bb4 --- /dev/null +++ b/tests/01-Manage/04-ProductandService/JWS_PD_003_CreateProductandService.spec.ts @@ -0,0 +1,96 @@ +import { test, expect, Page } from '@playwright/test'; +import { strictEqual } from 'assert'; +import { log } from 'console'; + +let page: Page; +let isLoginSuccessful = false; + +test.beforeAll(async ({ browser }) => { + page = await browser.newPage(); +}); + +test.afterAll(async () => { + if (page !== undefined) { + await page.close(); + } +}); + +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + // เข้าสู่เมนูสินค้าและบริการ + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-productService'); + await page.click('id=sub-menu-productService'); + await page.waitForTimeout(2000); + + isLoginSuccessful = true; + console.log('Login สำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการ Login', error); + isLoginSuccessful = false; + } +} + +test('Login', async () => { + await login(page); +}); + +test('ทดสอบการเพิ่มสินค้า', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + await page.waitForSelector('id=tree-enter-ประกัน', { state: 'visible' }); + await page.click('id=tree-enter-ประกัน'); + await page.waitForSelector('id=tree-enter-สินค้าและบริการ-ประกัน', { + state: 'visible', + }); + await page.click('id=tree-enter-สินค้าและบริการ-ประกัน'); + await page.click('id=btn-add'); + + // ส่วนข้อมูลพื้นฐาน + await page.click("(//input[@id='select-br-id'])[1]"); + await page.waitForSelector('id=select-br-id_0'); + await page.click('id=select-br-id_0'); + + await page.fill( + "(//input[@id='input-name'])[2]", + 'ชื่อกลุ่มสินค้าและบริการ', + ); + await page.click("(//input[@id='select-br-id'])[2]"); + await page.waitForSelector('id=select-br-id_0'); + await page.click('id=select-br-id_0'); + + // ส่วนข้อมูลราคา + await page.click("(//div[@role='listitem'])[2]"); + await page.fill('id=input-price', '2000'); + await page.fill('id=input-agent-price', '2000'); + await page.fill('id=input-service-charge', '2000'); + + // ส่วนข้อมูลเอกสาร + await page.click('id=btn-info-basic-save'); + + const productCheck = await page.locator( + "//tr[contains(.,'ชื่อกลุ่มสินค้าและบริการ') and contains (.,'฿2,000.00')]", + ); + + await expect(productCheck).toContainText('ชื่อกลุ่มสินค้าและบริการ'); + await expect(productCheck).toContainText('฿2,000.00'); + + console.log('ระบบทำการสร้างสินค้าถูกต้อง'); + } catch (error) { + console.log('เกิดข้อผิดพลาดในการทดสอบ'); + isLoginSuccessful = false; + throw error; + } + await page.waitForTimeout(2000); +}); diff --git a/tests/01-Manage/04-ProductandService/JWS_PD_004-1_CreateProductandServiceFailEn.spec.ts b/tests/01-Manage/04-ProductandService/JWS_PD_004-1_CreateProductandServiceFailEn.spec.ts new file mode 100644 index 00000000..c740d572 --- /dev/null +++ b/tests/01-Manage/04-ProductandService/JWS_PD_004-1_CreateProductandServiceFailEn.spec.ts @@ -0,0 +1,87 @@ +import { test, expect, Page } from '@playwright/test'; +import { strictEqual } from 'assert'; +import { log } from 'console'; + +let page: Page; +let isLoginSuccessful = false; + +test.beforeAll(async ({ browser }) => { + page = await browser.newPage(); +}); + +test.afterAll(async () => { + if (page !== undefined) { + await page.close(); + } +}); + +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + // เข้าสู่เมนูสินค้าและบริการ + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-productService'); + await page.click('id=sub-menu-productService'); + await page.waitForTimeout(2000); + + // เปลี่ยนภาษา + await page.click('id=btn-change-language'); + await page.waitForSelector('id=btn-change-language-eng'); + await page.click('id=btn-change-language-eng'); + + isLoginSuccessful = true; + console.log('Login สำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการ Login', error); + isLoginSuccessful = false; + } +} + +test('Login', async () => { + await login(page); +}); + +test('ทดสอบการเพิ่มสินค้าในกรณีที่ไม่กรอกข้อมูล', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + await page.waitForSelector('id=tree-enter-ประกัน', { state: 'visible' }); + await page.click('id=tree-enter-ประกัน'); + await page.waitForSelector('id=tree-enter-Products and Services-ประกัน', { + state: 'visible', + }); + await page.click('id=tree-enter-Products and Services-ประกัน'); + await page.click('id=btn-add'); + await page.click('id=btn-info-basic-save'); + + // ตรวจสอบหลังการแจ้งเตือนหลังจากคลิกปุ่มบันทึก + const ProduceandSeviceCodeError = page.locator( + "(//div[@class='q-field__messages col']//div)[1]", + ); + const nameProduceandSeviceError = page.locator( + "(//div[@class='q-field__messages col']//div)[2]", + ); + await expect(ProduceandSeviceCodeError).toHaveText( + 'This field is required.', + ); + await expect(nameProduceandSeviceError).toHaveText( + 'This field is required.', + ); + + console.log('ระบบแสดงการแจ้งเตือนถูกต้อง'); + } catch (error) { + console.log('เกิดข้อผิดพลาดในการทดสอบ'); + isLoginSuccessful = false; + throw error; + } + await page.waitForTimeout(2000); +}); diff --git a/tests/01-Manage/04-ProductandService/JWS_PD_004_CreateProductandServiceFail.spec.ts b/tests/01-Manage/04-ProductandService/JWS_PD_004_CreateProductandServiceFail.spec.ts new file mode 100644 index 00000000..0d1ed0cd --- /dev/null +++ b/tests/01-Manage/04-ProductandService/JWS_PD_004_CreateProductandServiceFail.spec.ts @@ -0,0 +1,82 @@ +import { test, expect, Page } from '@playwright/test'; +import { strictEqual } from 'assert'; +import { log } from 'console'; + +let page: Page; +let isLoginSuccessful = false; + +test.beforeAll(async ({ browser }) => { + page = await browser.newPage(); +}); + +test.afterAll(async () => { + if (page !== undefined) { + await page.close(); + } +}); + +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + // เข้าสู่เมนูสินค้าและบริการ + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-productService'); + await page.click('id=sub-menu-productService'); + await page.waitForTimeout(2000); + + isLoginSuccessful = true; + console.log('Login สำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการ Login', error); + isLoginSuccessful = false; + } +} + +test('Login', async () => { + await login(page); +}); + +test('ทดสอบการเพิ่มสินค้าในกรณีที่ไม่กรอกข้อมูล', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + await page.waitForSelector('id=tree-enter-ประกัน', { state: 'visible' }); + await page.click('id=tree-enter-ประกัน'); + await page.waitForSelector('id=tree-enter-สินค้าและบริการ-ประกัน', { + state: 'visible', + }); + await page.click('id=tree-enter-สินค้าและบริการ-ประกัน'); + await page.click('id=btn-add'); + await page.click('id=btn-info-basic-save'); + + // ตรวจสอบหลังการแจ้งเตือนหลังจากคลิกปุ่มบันทึก + const ProduceandSeviceCodeError = page.locator( + "(//div[@class='q-field__messages col']//div)[1]", + ); + const nameProduceandSeviceError = page.locator( + "(//div[@class='q-field__messages col']//div)[2]", + ); + await expect(ProduceandSeviceCodeError).toHaveText( + 'จำเป็นต้องกรอกข้อมูลนี้', + ); + await expect(nameProduceandSeviceError).toHaveText( + 'จำเป็นต้องกรอกข้อมูลนี้', + ); + + console.log('ระบบแสดงการแจ้งเตือนถูกต้อง'); + } catch (error) { + console.log('เกิดข้อผิดพลาดในการทดสอบ'); + isLoginSuccessful = false; + throw error; + } + await page.waitForTimeout(2000); +}); diff --git a/tests/01-Manage/04-ProductandService/JWS_PD_005_CreatePackage.spec.ts b/tests/01-Manage/04-ProductandService/JWS_PD_005_CreatePackage.spec.ts new file mode 100644 index 00000000..b0a15af3 --- /dev/null +++ b/tests/01-Manage/04-ProductandService/JWS_PD_005_CreatePackage.spec.ts @@ -0,0 +1,108 @@ +import { test, expect, Page } from '@playwright/test'; +import { strictEqual } from 'assert'; +import { log } from 'console'; + +let page: Page; +let isLoginSuccessful = false; + +test.beforeAll(async ({ browser }) => { + page = await browser.newPage(); +}); + +test.afterAll(async () => { + if (page !== undefined) { + await page.close(); + } +}); + +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + // เข้าสู่เมนูสินค้าและบริการ + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-productService'); + await page.click('id=sub-menu-productService'); + await page.waitForTimeout(2000); + + isLoginSuccessful = true; + console.log('Login สำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการ Login', error); + isLoginSuccessful = false; + } +} + +test('Login', async () => { + await login(page); +}); + +test('ทดสอบการเพิ่มประเภท', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { + await page.waitForSelector('id=tree-enter-ประกัน', { state: 'visible' }); + await page.click('id=tree-enter-ประกัน'); + // เข้าสู่หน้าประเภท + await page.waitForSelector('id=tree-enter-แพ็คเกจ-ประกัน', { + state: 'visible', + }); + await page.click('id=tree-enter-แพ็คเกจ-ประกัน'); + await page.click('id=btn-add'); + + // ส่วนข้อมูลแพ็คเกจ + await page.fill('id=input-service-code', 'MOU'); + await page.fill('id=input-service-name', 'ประกันภัยแบบกลุ่ม'); + await page.fill('id=input-service-description', 'รายละเอียดประภัยแบบกลุ่ม'); + + // ส่วนข้อมูลงาน + await page.click("(//div[@role='listitem']//div)[2]"); + await page.waitForSelector("(//button[@id='btn-add-work'])[1]"); + await page.click("(//button[@id='btn-add-work'])[1]"); + + // เพิ่มชื่องาน + await page.click("//div[@for='select-work-name-1']"); + await page.waitForSelector("//button[contains(.,'จัดการ')]"); + await page.click("//button[contains(.,'จัดการ')]"); + await page.waitForSelector("//span[normalize-space(text())='เพิ่มงาน']"); + await page.click("//span[normalize-space(text())='เพิ่มงาน']"); + await page.fill('id=input-work-name-2', 'อักคคีภัย'); + await page.waitForSelector('id=btn-save-work-name'); + await page.click('id=btn-save-work-name'); + await page.click("(//button[@id='btn-form-close'])[2]"); + await page.waitForSelector("//div[@for='select-work-name-1']"); + await page.click("//div[@for='select-work-name-1']"); + await page.waitForSelector("//div[normalize-space(text())='อัคคีภัย']"); + await page.click("//div[normalize-space(text())='อัคคีภัย']"); + + // เพิ่มสินค้า + await page.click("(//button[@id='btn-add-work-product'])[2]"); + await page.waitForSelector("//div[text()='ชื่อกลุ่มสินค้าและบริการ']"); + await page.click("//div[text()='ชื่อกลุ่มสินค้าและบริการ']"); + await page.click('id=btn-form-submit'); + + // ขั้นตอนการทำงาน + await page.click("(//button[@id='btn-add-work-product']//span)[2]"); + await page.click('id=select-workflow'); + const propertiesServiceRecordName = page.locator( + "//span[normalize-space(text())='บันทึกบริการ_Name']", + ); + + expect(propertiesServiceRecordName).toHaveText('บันทึกบริการ_Name'); + console.log(propertiesServiceRecordName, 'เลือกdropdown แล้ว'); + } catch (error) { + console.error('เกิดข้อผิดการในการทดสอบ'); + isLoginSuccessful = false; + throw error; + } + + await page.waitForTimeout(2000); +}); diff --git a/tests/04-ProductandService/JWS_PD_006_CreateTypeFail.spec.ts b/tests/01-Manage/04-ProductandService/JWS_PD_006_CreatePackageFail.spec.ts similarity index 54% rename from tests/04-ProductandService/JWS_PD_006_CreateTypeFail.spec.ts rename to tests/01-Manage/04-ProductandService/JWS_PD_006_CreatePackageFail.spec.ts index a917df40..2de304e5 100644 --- a/tests/04-ProductandService/JWS_PD_006_CreateTypeFail.spec.ts +++ b/tests/01-Manage/04-ProductandService/JWS_PD_006_CreatePackageFail.spec.ts @@ -3,6 +3,7 @@ import { strictEqual } from 'assert'; import { log } from 'console'; let page: Page; +let isLoginSuccessful = false; test.beforeAll(async ({ browser }) => { page = await browser.newPage(); @@ -14,27 +15,42 @@ test.afterAll(async () => { } }); +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + await page.click('id=menu-icon-product-service'); + await page.waitForSelector('id=tree-enter-ประกัน', { state: 'visible' }); + await page.click('id=tree-enter-ประกัน'); + // เข้าสู่หน้าประเภท + await page.waitForSelector('id=tree-enter-ประเภท-ประกัน', { + state: 'visible', + }); + await page.click('id=tree-enter-ประเภท-ประกัน'); + + isLoginSuccessful = true; + console.log('Login สำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการ Login', error); + isLoginSuccessful = false; + } +} + test('Login', async () => { - // Login - await page.goto('http://192.168.1.62:20101/'); - 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'); + await login(page); }); test('ทดสอบการเพิ่มประเภท', async () => { - await page.click('id=menu-icon-product-service'); - await page.waitForSelector('id=tree-enter-ประกัน', { state: 'visible' }); - await page.click('id=tree-enter-ประกัน'); - // เข้าสู่หน้าประเภท - await page.waitForSelector('id=tree-enter-ประเภท-ประกัน', { - state: 'visible', - }); - await page.click('id=tree-enter-ประเภท-ประกัน'); - + if (!isLoginSuccessful) { + await login(page); + } try { // เพิ่มประเภท await page.click('id=btn-add'); @@ -53,6 +69,7 @@ test('ทดสอบการเพิ่มประเภท', async () => { await expect(nameTypeError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้'); } catch (error) { console.error('เกิดข้อผิดการในการทดสอบ'); + isLoginSuccessful = false; throw error; } diff --git a/tests/04-ProductandService/JWS_PD_007_DetailProductandService.spec.ts b/tests/01-Manage/04-ProductandService/JWS_PD_007_DetailProductandService.spec.ts similarity index 86% rename from tests/04-ProductandService/JWS_PD_007_DetailProductandService.spec.ts rename to tests/01-Manage/04-ProductandService/JWS_PD_007_DetailProductandService.spec.ts index a7c990b7..cd7dde2e 100644 --- a/tests/04-ProductandService/JWS_PD_007_DetailProductandService.spec.ts +++ b/tests/01-Manage/04-ProductandService/JWS_PD_007_DetailProductandService.spec.ts @@ -1,9 +1,10 @@ import { test, expect, Page } from '@playwright/test'; import { strictEqual, throws } from 'assert'; import { error, log } from 'console'; -import { date } from 'quasar'; +import { date, is } from 'quasar'; let page: Page; +let isLoginSuccessful = false; test.beforeAll(async ({ browser }) => { page = await browser.newPage(); @@ -15,20 +16,36 @@ test.afterAll(async () => { } }); +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + await page.click('id=menu-icon-product-service'); + + isLoginSuccessful = true; + console.log('Login สำเร็จ'); + } catch (error) { + console.error('เกืดข้อผิดพลาดในการ Login', error); + isLoginSuccessful = false; + } +} + test('Login', async () => { - // Login - await page.goto('http://192.168.1.62:20101/'); - 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'); + await login(page); }); test('ดูรายละเอียดกลุ่มสินค้าและบริการ โดยการคลิกไอคอนรูปดวงตา', async () => { + if (!isLoginSuccessful) { + await login(page); + } try { - await page.click('id=menu-icon-product-service'); await page.click('id=btn-eye-ประกัน'); // กำหนดค่าเพื่อนำไปตรวจสอบความถูกต้อง @@ -39,6 +56,7 @@ test('ดูรายละเอียดกลุ่มสินค้าแ console.log('ตรวจสอบข้อมูลกลุ่มสินค้าและบริการถูกต้อง'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; throw error; } await page.waitForTimeout(2000); @@ -46,6 +64,9 @@ test('ดูรายละเอียดกลุ่มสินค้าแ }); test('ดูรายละเอียดกลุ่มสินค้าและบริการ ', async () => { + if (!isLoginSuccessful) { + await login(page); + } try { await page.click('id=btn-kebab-action-ประกัน'); await page.click('id=btn-kebab-view-detail-ประกัน'); @@ -58,6 +79,7 @@ test('ดูรายละเอียดกลุ่มสินค้าแ console.log('ตรวจสอบข้อมูลกลุ่มสินค้าและบริการถูกต้อง'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; throw error; } await page.waitForTimeout(2000); @@ -65,6 +87,9 @@ test('ดูรายละเอียดกลุ่มสินค้าแ }); test('ดูรายละเอียดประเภทของสินค้าและบริการ โดยการคลิกไอคอนรูปดวงตา', async () => { + if (!isLoginSuccessful) { + await login(page); + } try { await page.reload(); await page.click('id=tree-enter-ประกัน'); @@ -81,6 +106,7 @@ test('ดูรายละเอียดประเภทของสิน console.log('ตรวจสอบข้อมูลประเภทของสินค้าและบริการถูกต้อง'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; throw error; } await page.waitForTimeout(2000); @@ -88,6 +114,9 @@ test('ดูรายละเอียดประเภทของสิน }); test('ดูรายละเอียดประเภทของสินค้าและบริการ', async () => { + if (!isLoginSuccessful) { + await login(page); + } try { await page.click('id=tree-enter-ประกัน'); await page.click('id=tree-enter-ประเภท-ประกัน'); @@ -104,6 +133,7 @@ test('ดูรายละเอียดประเภทของสิน console.log('ตรวจสอบข้อมูลประเภทของสินค้าและบริการถูกต้อง'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; throw error; } await page.waitForTimeout(2000); @@ -111,6 +141,9 @@ test('ดูรายละเอียดประเภทของสิน }); test('ดูรายละเอียดสินค้าและบริการของสินค้าและบริการ โดยการคลิกไอคอนรูปดวงตา', async () => { + if (!isLoginSuccessful) { + await login(page); + } try { await page.click('id=tree-enter-ประกัน'); await page.click('id=tree-enter-สินค้าและบริการ-ประกัน'); @@ -126,6 +159,7 @@ test('ดูรายละเอียดสินค้าและบริ console.log('ตรวจสอบข้อมูลสินค้าและบริการของสินค้าและบริการถูกต้อง'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; throw error; } await page.waitForTimeout(2000); @@ -133,6 +167,9 @@ test('ดูรายละเอียดสินค้าและบริ }); test('ดูรายละเอียดสินค้าและบริการของสินค้าและบริการ', async () => { + if (!isLoginSuccessful) { + await login(page); + } try { await page.click('id=tree-enter-ประกัน'); await page.click('id=tree-enter-สินค้าและบริการ-ประกัน'); @@ -149,6 +186,7 @@ test('ดูรายละเอียดสินค้าและบริ console.log('ตรวจสอบข้อมูลสินค้าและบริการของสินค้าและบริการถูกต้อง'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; throw error; } await page.waitForTimeout(2000); diff --git a/tests/04-ProductandService/JWS_PD_008_EditProductandService.spec.ts b/tests/01-Manage/04-ProductandService/JWS_PD_008_EditProductandService.spec.ts similarity index 82% rename from tests/04-ProductandService/JWS_PD_008_EditProductandService.spec.ts rename to tests/01-Manage/04-ProductandService/JWS_PD_008_EditProductandService.spec.ts index 5836ab6c..5a9f36b2 100644 --- a/tests/04-ProductandService/JWS_PD_008_EditProductandService.spec.ts +++ b/tests/01-Manage/04-ProductandService/JWS_PD_008_EditProductandService.spec.ts @@ -1,10 +1,11 @@ import { test, expect, Page } from '@playwright/test'; import { strictEqual, throws } from 'assert'; import { error, log } from 'console'; -import { date } from 'quasar'; +import { date, is } from 'quasar'; import { Card } from 'react-bootstrap'; let page: Page; +let isLoginSuccessful = false; test.beforeAll(async ({ browser }) => { page = await browser.newPage(); @@ -16,19 +17,35 @@ test.afterAll(async () => { } }); +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + await page.click('id=menu-icon-product-service'); + + isLoginSuccessful = true; + console.log('Login สำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการ Login', error); + isLoginSuccessful = false; + } +} + test('Login', async () => { - // Login - await page.goto('http://192.168.1.62:20101/'); - 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'); + await login(page); }); test('ทดสอบการแก้ไขกลุ่มสินค้าและบริการ', async () => { - await page.click('id=menu-icon-product-service'); + if (!isLoginSuccessful) { + await login(page); + } try { await page.click('id=btn-kebab-action-ประกัน'); await page.click('id=btn-kebab-edit-ประกัน'); @@ -46,12 +63,16 @@ test('ทดสอบการแก้ไขกลุ่มสินค้า ); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; throw error; } await page.waitForTimeout(2000); }); test('ทดสอบการแก้ไขประเภทสินค้าและบริการ', async () => { + if (!isLoginSuccessful) { + await login(page); + } try { await page.waitForSelector('id=tree-enter-ประกันทั้งหมด', { state: 'visible', @@ -79,12 +100,16 @@ test('ทดสอบการแก้ไขประเภทสินค้ console.log('การตรวจสอบการแก้ไขชื่อประเภทสินค้าและบริการถูกต้อง'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; throw error; } await page.waitForTimeout(2000); }); test('ทดสอบการแก้ไขสินค้าและบริการ', async () => { + if (!isLoginSuccessful) { + await login(page); + } try { await page.waitForSelector('id=tree-enter-สินค้าและบริการ-ประกันทั้งหมด', { state: 'visible', @@ -105,6 +130,7 @@ test('ทดสอบการแก้ไขสินค้าและบร console.log('การตรวจสอบการแก้ไขชื่อสินค้าและบริการถูกต้อง'); } catch (error) { console.log('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; throw error; } }); diff --git a/tests/04-ProductandService/JWS_PD_009_StatusProductandServiceType.spec.ts b/tests/01-Manage/04-ProductandService/JWS_PD_009_StatusProductandServiceType.spec.ts similarity index 82% rename from tests/04-ProductandService/JWS_PD_009_StatusProductandServiceType.spec.ts rename to tests/01-Manage/04-ProductandService/JWS_PD_009_StatusProductandServiceType.spec.ts index 41e1ee10..d1653d12 100644 --- a/tests/04-ProductandService/JWS_PD_009_StatusProductandServiceType.spec.ts +++ b/tests/01-Manage/04-ProductandService/JWS_PD_009_StatusProductandServiceType.spec.ts @@ -1,9 +1,10 @@ import { test, expect, Page } from '@playwright/test'; import { strictEqual, throws } from 'assert'; import { error, log } from 'console'; -import { date } from 'quasar'; +import { date, is } from 'quasar'; let page: Page; +let isLoginSuccessful = false; test.beforeAll(async ({ browser }) => { page = await browser.newPage(); @@ -15,22 +16,37 @@ test.afterAll(async () => { } }); -test('Login', async () => { - // Login - await page.goto('http://192.168.1.62:20101/'); - 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('ตรวจสอบการแสดงผลสถานะการใช้งาน เปิด/ปิด สินค้าและบริการ', async () => { +async function login(page) { try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + // คลิกเมนูเพื่อเข้าสู่หน้าสินค้าและบริการ await page.click('id=menu-icon-product-service'); + isLoginSuccessful = true; + console.log('Login สำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการ Login', error); + isLoginSuccessful = false; + } +} + +test('Login', async () => { + await login(page); +}); + +test('ตรวจสอบการแสดงผลสถานะการใช้งาน เปิด/ปิด สินค้าและบริการ', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { // แสดงสถานะที่ใช้งาน // คลิกเพื่อเปิด dropdown await page.click('id=select-status'); @@ -88,6 +104,7 @@ test('ตรวจสอบการแสดงผลสถานะการ console.log('ตรวจสอบสถานะทั้งหมด'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; throw error; } diff --git a/tests/04-ProductandService/JWS_PD_010_SelectTypeFields.spec.ts b/tests/01-Manage/04-ProductandService/JWS_PD_010_SelectTypeFields.spec.ts similarity index 93% rename from tests/04-ProductandService/JWS_PD_010_SelectTypeFields.spec.ts rename to tests/01-Manage/04-ProductandService/JWS_PD_010_SelectTypeFields.spec.ts index f23fc2a1..f75097f9 100644 --- a/tests/04-ProductandService/JWS_PD_010_SelectTypeFields.spec.ts +++ b/tests/01-Manage/04-ProductandService/JWS_PD_010_SelectTypeFields.spec.ts @@ -4,6 +4,7 @@ import { watchFile } from 'fs'; import { waitForDebugger } from 'inspector'; let page: Page; +let isLoginSuccessful = false; test.beforeAll(async ({ browser }) => { page = await browser.newPage(); @@ -15,22 +16,37 @@ test.afterAll(async () => { } }); -test('Login', async () => { - // Login - await page.goto('http://192.168.1.62:20101/'); - 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('ตรวจสอบการแสดงผลฟิลด์แสดงผลลำดับ', async () => { +async function login(page) { try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + // คลิกเมนูเพื่อเข้าสู่หน้าสินค้าและบริการ await page.click('id=menu-icon-product-service'); + isLoginSuccessful = true; + console.log('Login สำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการ Login', error); + isLoginSuccessful = false; + } +} + +test('Login', async () => { + await login(page); +}); + +test('ตรวจสอบการแสดงผลฟิลด์แสดงผลลำดับ', async () => { + if (!isLoginSuccessful) { + await login(page); + } + try { // คลิกเพื่อเปิด dropdown await page.click("(//input[@id='select-field'])[1]"); await page.waitForTimeout(1000); // รอให้ dropdown เปิด @@ -80,6 +96,7 @@ test('ตรวจสอบการแสดงผลฟิลด์แสด console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; throw error; } @@ -87,6 +104,9 @@ test('ตรวจสอบการแสดงผลฟิลด์แสด }); test('ตรวจสอบการแสดงผลฟิลด์แสดงผลชื่อ', async () => { + if (!isLoginSuccessful) { + await login(page); + } try { // คลิกเพื่อเปิด dropdown await page.keyboard.press('Escape'); @@ -138,6 +158,7 @@ test('ตรวจสอบการแสดงผลฟิลด์แสด console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; throw error; } @@ -145,6 +166,9 @@ test('ตรวจสอบการแสดงผลฟิลด์แสด }); test('ตรวจสอบการแสดงผลฟิลด์แสดงผลรายละเอียด', async () => { + if (!isLoginSuccessful) { + await login(page); + } try { // คลิกเพื่อเปิด dropdown await page.keyboard.press('Escape'); @@ -198,6 +222,7 @@ test('ตรวจสอบการแสดงผลฟิลด์แสด console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; throw error; } @@ -205,6 +230,9 @@ test('ตรวจสอบการแสดงผลฟิลด์แสด }); test('ตรวจสอบการแสดงผลฟิลด์แสดงผลหมายเหตุ', async () => { + if (!isLoginSuccessful) { + await login(page); + } try { // คลิกเพื่อเปิด dropdown await page.keyboard.press('Escape'); @@ -258,6 +286,7 @@ test('ตรวจสอบการแสดงผลฟิลด์แสด console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; throw error; } @@ -265,6 +294,9 @@ test('ตรวจสอบการแสดงผลฟิลด์แสด }); test('ตรวจสอบการแสดงผลฟิลด์แสดงผลสร้างเมื่อ', async () => { + if (!isLoginSuccessful) { + await login(page); + } try { // คลิกเพื่อเปิด dropdown await page.keyboard.press('Escape'); @@ -318,6 +350,7 @@ test('ตรวจสอบการแสดงผลฟิลด์แสด console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ:', error); + isLoginSuccessful = false; throw error; } diff --git a/tests/04-ProductandService/JWS_PD_011_StatusProductandService.spec.ts b/tests/01-Manage/04-ProductandService/JWS_PD_011_StatusProductandService.spec.ts similarity index 85% rename from tests/04-ProductandService/JWS_PD_011_StatusProductandService.spec.ts rename to tests/01-Manage/04-ProductandService/JWS_PD_011_StatusProductandService.spec.ts index 75f31c1f..78dc17c9 100644 --- a/tests/04-ProductandService/JWS_PD_011_StatusProductandService.spec.ts +++ b/tests/01-Manage/04-ProductandService/JWS_PD_011_StatusProductandService.spec.ts @@ -2,6 +2,7 @@ import { test, expect, Page } from '@playwright/test'; import { strictEqual } from 'assert'; let page: Page; +let isLoginSuccessful = false; test.beforeAll(async ({ browser }) => { page = await browser.newPage(); @@ -13,21 +14,37 @@ test.afterAll(async () => { } }); +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + await page.click('id=menu-icon-product-service'); + await page.click('id=tree-enter-ประกันทั้งหมด'); + await page.click('id=tree-enter-สินค้าและบริการ-ประกันทั้งหมด'); + + isLoginSuccessful = true; + console.log('Login สำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการ Login', error); + isLoginSuccessful = false; + } +} + test('Login', async () => { - // Login - await page.goto('http://192.168.1.62:20101/'); - 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'); + await login(page); }); test('ปิดสถานะการใช้งานสินค้าและบริการ', async () => { - await page.click('id=menu-icon-product-service'); - await page.click('id=tree-enter-ประกันทั้งหมด'); - await page.click('id=tree-enter-สินค้าและบริการ-ประกันทั้งหมด'); + if (!isLoginSuccessful) { + await login(page); + } try { await page.click('id=btn-kebab-action-ประเภทบุคคล'); @@ -58,12 +75,16 @@ test('ปิดสถานะการใช้งานสินค้าแ console.log('สีของแถวถูกเปลี่ยนเป็นสีเทาอ่อน'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ'); + isLoginSuccessful = false; throw error; } await page.waitForTimeout(2000); }); test('เปิดสถานะการใช้งานสินค้าและบริการ', async () => { + if (!isLoginSuccessful) { + await login(page); + } try { await page.click('id=btn-kebab-action-ประเภทบุคคล'); @@ -94,14 +115,18 @@ test('เปิดสถานะการใช้งานสินค้า console.log('สีของแถวถูกเปลี่ยนเป็นของสถานะการใช้งาน'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ'); + isLoginSuccessful = false; throw error; } await page.waitForTimeout(2000); }); test('ปิดสถานะการใช้งานประเภทสินค้าและบริการ', async () => { - await page.click('id=tree-enter-ประเภท-ประกันทั้งหมด'); + if (!isLoginSuccessful) { + await login(page); + } try { + await page.click('id=tree-enter-ประเภท-ประกันทั้งหมด'); await page.click('id=btn-kebab-action-ประกันชีวิต'); await page.click('id=btn-kebab-status-ประกันชีวิต', { @@ -131,12 +156,16 @@ test('ปิดสถานะการใช้งานประเภทส console.log('สีของแถวถูกเปลี่ยนเป็นสีเทาอ่อน'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ'); + isLoginSuccessful = false; throw error; } await page.waitForTimeout(2000); }); test('เปิดสถานะการใช้งานประเภทสินค้าและบริการ', async () => { + if (!isLoginSuccessful) { + await login(page); + } try { await page.click('id=btn-kebab-action-ประกันชีวิต'); await page.click('id=btn-kebab-status-ประกันชีวิต', { @@ -166,14 +195,18 @@ test('เปิดสถานะการใช้งานประเภท console.log('สีของแถวถูกเปลี่ยนเป็นของสถานะการใช้งาน'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ'); + isLoginSuccessful = false; throw error; } await page.waitForTimeout(2000); }); test('ปิดสถานะการใช้งานกลุ่มสินค้าและบริการ', async () => { - await page.click('id=tree-enter-ประกันทั้งหมด'); + if (!isLoginSuccessful) { + await login(page); + } try { + await page.click('id=tree-enter-ประกันทั้งหมด'); await page.click("(//button[@id='btn-kebab-action-ประกันทั้งหมด'])[2]"); await page.click('id=btn-kebab-status-ประกันทั้งหมด', { @@ -203,12 +236,16 @@ test('ปิดสถานะการใช้งานกลุ่มสิ console.log('สีของแถวถูกเปลี่ยนเป็นสีเทาอ่อน'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ'); + isLoginSuccessful = false; throw error; } await page.waitForTimeout(2000); }); test('เปิดสถานะการใช้งานกลุ่มสินค้าและบริการ', async () => { + if (!isLoginSuccessful) { + await login(page); + } try { await page.click("(//button[@id='btn-kebab-action-ประกันทั้งหมด'])[2]"); await page.click('id=btn-kebab-status-ประกันทั้งหมด', { @@ -238,6 +275,7 @@ test('เปิดสถานะการใช้งานกลุ่มส console.log('สีของแถวถูกเปลี่ยนเป็นของสถานะการใช้งาน'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ'); + isLoginSuccessful = false; throw error; } await page.waitForTimeout(2000); diff --git a/tests/01-Manage/04-ProductandService/JWS_PD_012_SearchProductandService.spec.ts b/tests/01-Manage/04-ProductandService/JWS_PD_012_SearchProductandService.spec.ts new file mode 100644 index 00000000..e69de29b diff --git a/tests/04-ProductandService/JWS_PD_013_DeleteProductandService.spec.ts b/tests/01-Manage/04-ProductandService/JWS_PD_013_DeleteProductandService.spec.ts similarity index 91% rename from tests/04-ProductandService/JWS_PD_013_DeleteProductandService.spec.ts rename to tests/01-Manage/04-ProductandService/JWS_PD_013_DeleteProductandService.spec.ts index 4fc3f04c..e86fcf8b 100644 --- a/tests/04-ProductandService/JWS_PD_013_DeleteProductandService.spec.ts +++ b/tests/01-Manage/04-ProductandService/JWS_PD_013_DeleteProductandService.spec.ts @@ -3,6 +3,7 @@ import { strictEqual } from 'assert'; import { it } from 'node:test'; let page: Page; +let isLoginSuccessful = false; test.beforeAll(async ({ browser }) => { page = await browser.newPage(); @@ -14,18 +15,33 @@ test.afterAll(async () => { } }); +async function login(page) { + try { + // Login + await page.goto('http://192.168.1.62:20101/'); + 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'); + + isLoginSuccessful = true; + console.log('Login สำเร็จ'); + } catch (error) { + console.error('เกิดข้อผิดพลาดในการ Login', error); + isLoginSuccessful = false; + } +} + test('Login', async () => { - // Login - await page.goto('http://192.168.1.62:20101/'); - 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'); + await login(page); }); test('จำลองการสร้างสินค้าและบริการเพิื่อทำการทดสอบลบ', async () => { + if (!isLoginSuccessful) { + await login(page); + } //-----------------------------------------สร้างกลุ่มสินค้าและบริการ------------------------------// await page.click('id=menu-icon-product-service'); @@ -168,6 +184,9 @@ test('จำลองการสร้างสินค้าและบร }); test('ทดสอบการลบประเภทสินค้าและบริการ', async () => { + if (!isLoginSuccessful) { + await login(page); + } try { await page.click('id=btn-kebab-action-ประเภทสินค้าและบริการ'); await page.click('id=btn-kebab-delete-ประเภทสินค้าและบริการ'); @@ -182,11 +201,15 @@ test('ทดสอบการลบประเภทสินค้าแล console.log('ตรวจสอบการลบประเภทสินค้าและบริการสำเร็จ'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; throw error; } }); test('ทดสอบการลบสินค้าและบริการ', async () => { + if (!isLoginSuccessful) { + await login(page); + } try { await page.click('id=tree-enter-สินค้าและบริการ-กลุ่มสินค้าและบริการ'); await page.click('id=btn-kebab-action-สินค้าและบริการ'); @@ -202,6 +225,7 @@ test('ทดสอบการลบสินค้าและบริกา console.log('ตรวจสอบการลบสินค้าและบริการสำเร็จ'); } catch (error) { console.error('เกิดข้อผิดพลาดในการทดสอบ', error); + isLoginSuccessful = false; throw error; } }); diff --git a/tests/03-Admin-ManageCustomer/JWS_MC_009_DetailLegalentitly.spec.ts b/tests/01-Manage/05-Workflow/JWS_WF_001_CreateWorkflow.spec.ts similarity index 58% rename from tests/03-Admin-ManageCustomer/JWS_MC_009_DetailLegalentitly.spec.ts rename to tests/01-Manage/05-Workflow/JWS_WF_001_CreateWorkflow.spec.ts index d1401ba3..6c11eab2 100644 --- a/tests/03-Admin-ManageCustomer/JWS_MC_009_DetailLegalentitly.spec.ts +++ b/tests/01-Manage/05-Workflow/JWS_WF_001_CreateWorkflow.spec.ts @@ -1,5 +1,6 @@ import { test, expect, Page } from '@playwright/test'; import { strictEqual } from 'assert'; +import { log } from 'console'; let page: Page; @@ -24,10 +25,15 @@ test('Login', async () => { // await page.click('id=acceptBtn'); }); -test('View Detail Legalentitly', async () => { - await page.click('id=menu-icon-customer-management'); - await page.click("//button[@id='btn-dots-CORP000002']"); - - await page.click('id=view-detail-btn-undefined-view'); +test('ทดสอบการเพิ่มขั้นตอนการทำงาน', async () => { + // เข้าสู่เมนูสินค้าและบริการ + await page.click('id=menu.manage'); + await page.waitForSelector('id=sub-menu-workflow'); + await page.click('id=sub-menu-workflow'); await page.waitForTimeout(2000); + + await page.waitForSelector('id=btn-Add'); + await page.click('id=btn-Add'); + + // ส่วนชื่อแม่แบบ }); diff --git a/tests/02-Admin-PersonnelManagement/JWS_PM_001_CreatePersonnel.spec.ts b/tests/02-Admin-PersonnelManagement/JWS_PM_001_CreatePersonnel.spec.ts deleted file mode 100644 index 608b2191..00000000 --- a/tests/02-Admin-PersonnelManagement/JWS_PM_001_CreatePersonnel.spec.ts +++ /dev/null @@ -1,793 +0,0 @@ -import { test, expect, Page } from '@playwright/test'; -import { strictEqual } from 'assert'; -import exp from 'constants'; - -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.62:20101/'); - 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('Create Personnel พนักงาน ชาย', async () => { - await page.click('id=menu-icon-personnel-management'); - await page.click('id=btn-add'); - await page.click('id=btn-add-personne'); - - // กรอกข้อมูลพื้นฐานของบุคคลากร - await page.click("//i[@aria-hidden='false']"); - await page.waitForSelector('id=select-hq-id', { - state: 'visible', - }); - await page.click('id=select-hq-id'); - await page.click("//span[normalize-space(text())='CMO00000']"); - - await page.waitForSelector('id=select-br-id', { state: 'visible' }); - await page.click('id=select-br-id'); - await page.click('id=select-br-id_4'); - await page.fill('id=input-username', 'employeem'); - await page.click('id=select-user-type'); - await page.click('id=select-user-type_0'); - await page.click('id=select-user-role'); - await page.click('id=select-user-role_2'); - // await page.click("//div[@role='option']"); - - // กรอกชื่อข้อมูลพื้นฐาน - await page.fill('id=input-citizen-id', '1282262422820'); - await page.click("//label[@for='form-dialog-personnel-select-prefix-name']"); - await page.click('id=form-dialog-personnel-select-prefix-name_0'); - await page.fill('id=form-dialog-personnel-input-first-name', 'ธรรมรงด์'); - await page.fill('id=form-dialog-personnel-input-last-name', 'ดำรงธรรม'); - await page.fill('id=form-dialog-personnel-input-first-name-en', 'Thamrong'); - await page.fill('id=form-dialog-personnel-input-last-name-en', 'Dumrongtum'); - await page.fill('id=form-dialog-personnel-input-telephone', '08422622282'); - await page.fill('id=form-dialog-personnel-input-email', 'employeem@mail.com'); - - // เลือกเพศ - await page.click('id=form-dialog-personnel-select-gender'); - await page.click("//span[text()='ชาย']"); - - // เลือกวันเกิด - await page.click('id=form-dialog-personnel-input-birth-date'); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2561']"); - await page.click("//div[text()='8']"); - - // วันออกบัตร วันที่หมออายุ - await page.click( - "(//input[@id='form-dialog-personnel-input-citizen-issue'])[1]", - ); - await page.click("//div[@id='2024-09-02']"); - await page.click( - "(//input[@id='form-dialog-personnel-input-citizen-expire'])[1]", - ); - await page.click("//div[@id='2024-09-17']/div[1]"); - - // กรอกที่อยู่ - await page.fill('id=drawer-info-personnel-input-address-no', '20/1'); - await page.click('id=drawer-info-personnel-select-province'); - await page.waitForSelector('id=drawer-info-personnel-select-province_6', { - state: 'visible', - }); - await page.click('id=drawer-info-personnel-select-province_6'); - await page.click('id=drawer-info-personnel-select-district'); - await page.waitForSelector('id=drawer-info-personnel-select-district_2', { - state: 'visible', - }); - await page.click('id=drawer-info-personnel-select-district_2'); - await page.click('id=drawer-info-personnel-select-sub-district'); - await page.waitForSelector('id=drawer-info-personnel-select-sub-district_1', { - state: 'visible', - }); - await page.click('id=drawer-info-personnel-select-sub-district_1'); - - // กรอกที่อยู่ภาษาอังกฤษ - await page.fill('id=drawer-info-personnel-input-address-en', '20/01'); - - // กรอกข้อมูลการทำงาน - await page.fill('id=input-regis-no', '2822282222421'); - await page.click('id=input-start-date'); - await page.click("//div[text()='11']"); - await page.click('id=input-retire-date'); - await page.click("//div[text()='21']"); - - // กดปุ่มเพื่อสร้างบุคคลากร - await page.click('id=btn-info-basic-save'); - await page.waitForTimeout(2000); - - // ดึงข้อมูลจาก Locator และนำ .textContent() เพื่อดึงมาแต่ข้อความจริง ๆ - await page.waitForSelector; - const displayNameLocator = page.locator( - "//div[normalize-space(text())='ธรรมรงด์ ดำรงธรรม']", - ); - - const displayName = (await displayNameLocator.textContent())?.trim() || ''; - - // ตรวจสอบข้อมูลที่ดึงออกมา - expect(displayName).toBe('ธรรมรงด์ ดำรงธรรม'); - console.log(displayName); - - console.log('ตรวจสอบการสร้างพนักงานชายถูกต้อง'); -}); - -test('Create Personnel พนักงาน หญิง', async () => { - await page.click('id=btn-add'); - await page.click('id=btn-add-personne'); - - // กรอกข้อมูลพื้นฐานของบุคคลากร - await page.click("//i[@aria-hidden='false']"); - await page.waitForSelector('id=select-hq-id', { - state: 'visible', - }); - await page.click('id=select-hq-id'); - await page.click("//span[normalize-space(text())='CMO00000']"); - - await page.waitForSelector('id=select-br-id', { state: 'visible' }); - await page.click('id=select-br-id'); - await page.click('id=select-br-id_4'); - await page.fill('id=input-username', 'employeew'); - await page.click('id=select-user-role'); - await page.click('id=select-user-role_6'); - // await page.click("//div[@role='option']"); - - // กรอกชื่อข้อมูลพื้นฐาน - await page.fill('id=input-citizen-id', '1282262422820'); - await page.click("//label[@for='form-dialog-personnel-select-prefix-name']"); - await page.click('id=form-dialog-personnel-select-prefix-name_0'); - await page.fill('id=form-dialog-personnel-input-first-name', 'อารยา'); - await page.fill('id=form-dialog-personnel-input-last-name', 'มาลา'); - await page.fill('id=form-dialog-personnel-input-first-name-en', 'Araya'); - await page.fill('id=form-dialog-personnel-input-last-name-en', 'Mala'); - await page.fill('id=form-dialog-personnel-input-telephone', '08422622282'); - await page.fill('id=form-dialog-personnel-input-email', 'employeew@mail.com'); - - // เลือกเพศ - await page.click('id=form-dialog-personnel-select-gender'); - await page.click("//span[text()='หญิง']"); - - // เลือกวันเกิด - await page.click('id=form-dialog-personnel-input-birth-date'); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2561']"); - await page.click("//div[text()='8']"); - - // วันออกบัตร วันที่หมออายุ - await page.click( - "(//input[@id='form-dialog-personnel-input-citizen-issue'])[1]", - ); - await page.click("//div[@id='2024-09-02']"); - await page.click( - "(//input[@id='form-dialog-personnel-input-citizen-expire'])[1]", - ); - await page.click("//div[@id='2024-09-16']/div[1]"); - - // กรอกที่อยู่ - await page.fill('id=drawer-info-personnel-input-address-no', '20/1'); - await page.click('id=drawer-info-personnel-select-province'); - await page.waitForSelector('id=drawer-info-personnel-select-province_6', { - state: 'visible', - }); - await page.click('id=drawer-info-personnel-select-province_6'); - await page.click('id=drawer-info-personnel-select-district'); - await page.waitForSelector('id=drawer-info-personnel-select-district_2', { - state: 'visible', - }); - await page.click('id=drawer-info-personnel-select-district_2'); - await page.click('id=drawer-info-personnel-select-sub-district'); - await page.waitForSelector('id=drawer-info-personnel-select-sub-district_1', { - state: 'visible', - }); - await page.click('id=drawer-info-personnel-select-sub-district_1'); - - // กรอกที่อยู่ภาษาอังกฤษ - await page.fill('id=drawer-info-personnel-input-address-en', '20/01'); - - // กรอกข้อมูลการทำงาน - await page.fill('id=input-regis-no', '2822282222421'); - await page.click('id=input-start-date'); - await page.click("//div[text()='11']"); - await page.click('id=input-retire-date'); - await page.click("//div[text()='21']"); - - // กดปุ่มเพื่อสร้างบุคคลากร - await page.click('id=btn-info-basic-save'); - await page.waitForTimeout(2000); - - // ดึงข้อมูลจาก Locator และนำ .textContent() เพื่อดึงมาแต่ข้อความจริง ๆ - const displayNameLocator = page.locator( - "//div[normalize-space(text())='อารยา มาลา']", - ); - const displayName = (await displayNameLocator.textContent())?.trim(); - - // ตรวจสอบข้อมูลที่ดึงออกมา - expect(displayName).toBe('อารยา มาลา'); - - console.log('ตรวจสอบการสร้างพนักงานหญิงถูกต้อง'); -}); - -test('Create Personnel พนักงานส่งเอกสาร หญิง', async () => { - await page.click("(//div[@role='tab'])[3]"); - await page.click('id=btn-add'); - await page.click('id=btn-add-personne'); - - // กรอกข้อมูลพื้นฐานของบุคคลากร - await page.click("//i[@aria-hidden='false']"); - await page.waitForSelector('id=select-hq-id', { - state: 'visible', - }); - await page.click('id=select-hq-id'); - await page.click("//span[normalize-space(text())='CMO00000']"); - - await page.waitForSelector('id=select-br-id', { state: 'visible' }); - await page.click('id=select-br-id'); - await page.click('id=select-br-id_4'); - await page.fill('id=input-username', 'courierw'); - await page.click('id=select-user-role'); - await page.click('id=select-user-role_6'); - // await page.click("//div[@role='option']"); - - // กรอกชื่อข้อมูลพื้นฐาน - await page.fill('id=input-citizen-id', '1282262422820'); - await page.click("//label[@for='form-dialog-personnel-select-prefix-name']"); - await page.click('id=form-dialog-personnel-select-prefix-name_0'); - await page.fill('id=form-dialog-personnel-input-first-name', 'มาตา'); - await page.fill('id=form-dialog-personnel-input-last-name', 'ลดา'); - await page.fill('id=form-dialog-personnel-input-first-name-en', 'Mata'); - await page.fill('id=form-dialog-personnel-input-last-name-en', 'Lada'); - await page.fill('id=form-dialog-personnel-input-telephone', '08422622282'); - await page.fill('id=form-dialog-personnel-input-email', 'employeew@mail.com'); - - // เลือกเพศ - await page.click('id=form-dialog-personnel-select-gender'); - await page.click("//span[text()='หญิง']"); - - // เลือกวันเกิด - await page.click('id=form-dialog-personnel-input-birth-date'); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2561']"); - await page.click("//div[text()='8']"); - - // วันออกบัตร วันที่หมออายุ - await page.click( - "(//input[@id='form-dialog-personnel-input-citizen-issue'])[1]", - ); - await page.click("//div[@id='2024-09-02']"); - await page.click( - "(//input[@id='form-dialog-personnel-input-citizen-expire'])[1]", - ); - await page.click("//div[@id='2024-09-15']/div[1]"); - - // กรอกที่อยู่ - await page.fill('id=drawer-info-personnel-input-address-no', '20/1'); - await page.click('id=drawer-info-personnel-select-province'); - await page.waitForSelector('id=drawer-info-personnel-select-province_6', { - state: 'visible', - }); - await page.click('id=drawer-info-personnel-select-province_6'); - await page.click('id=drawer-info-personnel-select-district'); - await page.waitForSelector('id=drawer-info-personnel-select-district_2', { - state: 'visible', - }); - await page.click('id=drawer-info-personnel-select-district_2'); - await page.click('id=drawer-info-personnel-select-sub-district'); - await page.waitForSelector('id=drawer-info-personnel-select-sub-district_1', { - state: 'visible', - }); - await page.click('id=drawer-info-personnel-select-sub-district_1'); - - // กรอกที่อยู่ภาษาอังกฤษ - await page.fill('id=drawer-info-personnel-input-address-en', '20/01'); - - // กรอกข้อมูลการทำงาน - await page.fill('id=input-regis-no', '2822282222421'); - await page.click('id=input-start-date'); - await page.click("//div[text()='11']"); - await page.click('id=input-retire-date'); - await page.click("//div[text()='21']"); - - // กดปุ่มเพื่อสร้างบุคคลากร - await page.click('id=btn-info-basic-save'); - await page.waitForTimeout(2000); - - // ดึงข้อมูลจาก Locator และนำ .textContent() เพื่อดึงมาแต่ข้อความจริง ๆ - const displayNameLocator = page.locator( - "//div[normalize-space(text())='มาตา ลดา']", - ); - const displayName = (await displayNameLocator.textContent())?.trim(); - - // ตรวจสอบข้อมูลที่ดึงออกมา - expect(displayName).toBe('มาตา ลดา'); - - console.log('ตรวจสอบการสร้างพนักงานส่งเอกสารหญิงถูกต้อง'); -}); - -test('Create Personnel พนักงานส่งเอกสาร ชาย', async () => { - await page.click('id=btn-add'); - await page.click('id=btn-add-personne'); - - // กรอกข้อมูลพื้นฐานของบุคคลากร - await page.click("//i[@aria-hidden='false']"); - await page.waitForSelector('id=select-hq-id', { - state: 'visible', - }); - await page.click('id=select-hq-id'); - await page.click("//span[normalize-space(text())='CMO00000']"); - - await page.waitForSelector('id=select-br-id', { state: 'visible' }); - await page.click('id=select-br-id'); - await page.click('id=select-br-id_4'); - await page.fill('id=input-username', 'courierm'); - await page.click('id=select-user-role'); - await page.click('id=select-user-role_6'); - // await page.click("//div[@role='option']"); - - // กรอกชื่อข้อมูลพื้นฐาน - await page.fill('id=input-citizen-id', '1282262422820'); - await page.click("//label[@for='form-dialog-personnel-select-prefix-name']"); - await page.click('id=form-dialog-personnel-select-prefix-name_0'); - await page.fill('id=form-dialog-personnel-input-first-name', 'ธันวา'); - await page.fill('id=form-dialog-personnel-input-last-name', 'มานา'); - await page.fill('id=form-dialog-personnel-input-first-name-en', 'Thanwa'); - await page.fill('id=form-dialog-personnel-input-last-name-en', 'Mana'); - await page.fill('id=form-dialog-personnel-input-telephone', '08422622282'); - await page.fill('id=form-dialog-personnel-input-email', 'employeew@mail.com'); - - // เลือกเพศ - await page.click('id=form-dialog-personnel-select-gender'); - await page.click("//span[text()='ชาย']"); - - // เลือกวันเกิด - await page.click('id=form-dialog-personnel-input-birth-date'); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2561']"); - await page.click("//div[text()='8']"); - - // วันออกบัตร วันที่หมออายุ - await page.click( - "(//input[@id='form-dialog-personnel-input-citizen-issue'])[1]", - ); - await page.click("//div[@id='2024-09-02']"); - await page.click( - "(//input[@id='form-dialog-personnel-input-citizen-expire'])[1]", - ); - await page.click("//div[@id='2024-09-14']/div[1]"); - - // กรอกที่อยู่ - await page.fill('id=drawer-info-personnel-input-address-no', '20/1'); - await page.click('id=drawer-info-personnel-select-province'); - await page.waitForSelector('id=drawer-info-personnel-select-province_6', { - state: 'visible', - }); - await page.click('id=drawer-info-personnel-select-province_6'); - await page.click('id=drawer-info-personnel-select-district'); - await page.waitForSelector('id=drawer-info-personnel-select-district_2', { - state: 'visible', - }); - await page.click('id=drawer-info-personnel-select-district_2'); - await page.click('id=drawer-info-personnel-select-sub-district'); - await page.waitForSelector('id=drawer-info-personnel-select-sub-district_1', { - state: 'visible', - }); - await page.click('id=drawer-info-personnel-select-sub-district_1'); - - // กรอกที่อยู่ภาษาอังกฤษ - await page.fill('id=drawer-info-personnel-input-address-en', '20/01'); - - // กรอกข้อมูลการทำงาน - await page.fill('id=input-regis-no', '2822282222421'); - await page.click('id=input-start-date'); - await page.click("//div[text()='11']"); - await page.click('id=input-retire-date'); - await page.click("//div[text()='21']"); - - // กดปุ่มเพื่อสร้างบุคคลากร - await page.click('id=btn-info-basic-save'); - await page.waitForTimeout(2000); - - // ดึงข้อมูลจาก Locator และนำ .textContent() เพื่อดึงมาแต่ข้อความจริง ๆ - const displayNameLocator = page.locator( - "//div[normalize-space(text())='ธันวา มานา']", - ); - const displayName = (await displayNameLocator.textContent())?.trim(); - - // ตรวจสอบข้อมูลที่ดึงออกมา - expect(displayName).toBe('ธันวา มานา'); - - console.log('ตรวจสอบการสร้างพนักงานส่งเอกสารชายถูกต้อง'); -}); - -test('Create Personnel ตัวแทน ชาย', async () => { - await page.click("(//div[@role='tab'])[4]"); - await page.click('id=btn-add'); - await page.click('id=btn-add-personne'); - - // กรอกข้อมูลพื้นฐานของบุคคลากร - await page.click("//i[@aria-hidden='false']"); - await page.waitForSelector('id=select-hq-id', { - state: 'visible', - }); - await page.click('id=select-hq-id'); - await page.click("//span[normalize-space(text())='CMO00000']"); - - await page.waitForSelector('id=select-br-id', { state: 'visible' }); - await page.click('id=select-br-id'); - await page.click('id=select-br-id_4'); - await page.fill('id=input-username', 'delegatem'); - await page.click('id=select-user-role'); - await page.click('id=select-user-role_8'); - // await page.click("//div[@role='option']"); - - // กรอกชื่อข้อมูลพื้นฐาน - await page.fill('id=input-citizen-id', '1282262422820'); - await page.click("//label[@for='form-dialog-personnel-select-prefix-name']"); - await page.click('id=form-dialog-personnel-select-prefix-name_0'); - await page.fill('id=form-dialog-personnel-input-first-name', 'อาคม'); - await page.fill('id=form-dialog-personnel-input-last-name', 'พลัง'); - await page.fill('id=form-dialog-personnel-input-first-name-en', 'Akom'); - await page.fill('id=form-dialog-personnel-input-last-name-en', 'Palang'); - await page.fill('id=form-dialog-personnel-input-telephone', '08422622282'); - await page.fill('id=form-dialog-personnel-input-email', 'employeew@mail.com'); - - // เลือกเพศ - await page.click('id=form-dialog-personnel-select-gender'); - await page.click("//span[text()='ชาย']"); - - // เลือกวันเกิด - await page.click('id=form-dialog-personnel-input-birth-date'); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2561']"); - await page.click("//div[text()='8']"); - - // วันออกบัตร วันที่หมออายุ - await page.click( - "(//input[@id='form-dialog-personnel-input-citizen-issue'])[1]", - ); - await page.click("//div[@id='2024-09-02']"); - await page.click( - "(//input[@id='form-dialog-personnel-input-citizen-expire'])[1]", - ); - await page.click("//div[@id='2024-09-13']/div[1]"); - - // กรอกที่อยู่ - await page.fill('id=drawer-info-personnel-input-address-no', '20/1'); - await page.click('id=drawer-info-personnel-select-province'); - await page.waitForSelector('id=drawer-info-personnel-select-province_6', { - state: 'visible', - }); - await page.click('id=drawer-info-personnel-select-province_6'); - await page.click('id=drawer-info-personnel-select-district'); - await page.waitForSelector('id=drawer-info-personnel-select-district_2', { - state: 'visible', - }); - await page.click('id=drawer-info-personnel-select-district_2'); - await page.click('id=drawer-info-personnel-select-sub-district'); - await page.waitForSelector('id=drawer-info-personnel-select-sub-district_1', { - state: 'visible', - }); - await page.click('id=drawer-info-personnel-select-sub-district_1'); - - // กรอกที่อยู่ภาษาอังกฤษ - await page.fill('id=drawer-info-personnel-input-address-en', '20/01'); - - // กรอกข้อมูลการทำงาน - await page.fill('id=input-discount-condition', 'ทดสอบข้อมูลการทำงาน'); - - // กดปุ่มเพื่อสร้างบุคคลากร - await page.click('id=btn-info-basic-save'); - await page.waitForTimeout(2000); - - // ดึงข้อมูลจาก Locator และนำ .textContent() เพื่อดึงมาแต่ข้อความจริง ๆ - const displayNameLocator = page.locator( - "//div[normalize-space(text())='อาคม พลัง']", - ); - const displayName = (await displayNameLocator.textContent())?.trim(); - - // ตรวจสอบข้อมูลที่ดึงออกมา - expect(displayName).toBe('อาคม พลัง'); - - console.log('ตรวจสอบการสร้างตัวแทนชายถูกต้อง'); -}); - -test('Create Personnel ตัวแทน หญิง', async () => { - await page.click('id=btn-add'); - await page.click('id=btn-add-personne'); - - // กรอกข้อมูลพื้นฐานของบุคคลากร - await page.click("//i[@aria-hidden='false']"); - await page.waitForSelector('id=select-hq-id', { - state: 'visible', - }); - await page.click('id=select-hq-id'); - await page.click("//span[normalize-space(text())='CMO00000']"); - - await page.waitForSelector('id=select-br-id', { state: 'visible' }); - await page.click('id=select-br-id'); - await page.click('id=select-br-id_4'); - await page.fill('id=input-username', 'delegatew'); - await page.click('id=select-user-role'); - await page.click('id=select-user-role_10'); - // await page.click("//div[@role='option']"); - - // กรอกชื่อข้อมูลพื้นฐาน - await page.fill('id=input-citizen-id', '1282262422820'); - await page.click("//label[@for='form-dialog-personnel-select-prefix-name']"); - await page.click('id=form-dialog-personnel-select-prefix-name_0'); - await page.fill('id=form-dialog-personnel-input-first-name', 'สโรชา'); - await page.fill('id=form-dialog-personnel-input-last-name', 'มีนา'); - await page.fill('id=form-dialog-personnel-input-first-name-en', 'Sarocha'); - await page.fill('id=form-dialog-personnel-input-last-name-en', 'Mena'); - await page.fill('id=form-dialog-personnel-input-telephone', '08422622282'); - await page.fill('id=form-dialog-personnel-input-email', 'employeew@mail.com'); - - // เลือกเพศ - await page.click('id=form-dialog-personnel-select-gender'); - await page.click("//span[text()='หญิง']"); - - // เลือกวันเกิด - await page.click('id=form-dialog-personnel-input-birth-date'); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2561']"); - await page.click("//div[text()='8']"); - - // วันออกบัตร วันที่หมออายุ - await page.click( - "(//input[@id='form-dialog-personnel-input-citizen-issue'])[1]", - ); - await page.click("//div[@id='2024-09-02']"); - await page.click( - "(//input[@id='form-dialog-personnel-input-citizen-expire'])[1]", - ); - await page.click("//div[@id='2024-09-12']/div[1]"); - - // กรอกที่อยู่ - await page.fill('id=drawer-info-personnel-input-address-no', '20/1'); - await page.click('id=drawer-info-personnel-select-province'); - await page.waitForSelector('id=drawer-info-personnel-select-province_6', { - state: 'visible', - }); - await page.click('id=drawer-info-personnel-select-province_6'); - await page.click('id=drawer-info-personnel-select-district'); - await page.waitForSelector('id=drawer-info-personnel-select-district_2', { - state: 'visible', - }); - await page.click('id=drawer-info-personnel-select-district_2'); - await page.click('id=drawer-info-personnel-select-sub-district'); - await page.waitForSelector('id=drawer-info-personnel-select-sub-district_1', { - state: 'visible', - }); - await page.click('id=drawer-info-personnel-select-sub-district_1'); - - // กรอกที่อยู่ภาษาอังกฤษ - await page.fill('id=drawer-info-personnel-input-address-en', '20/01'); - - // กรอกข้อมูลการทำงาน - await page.fill('id=input-discount-condition', 'ทดสอบข้อมูลการทำงาน'); - - // กดปุ่มเพื่อสร้างบุคคลากร - await page.click('id=btn-info-basic-save'); - await page.waitForTimeout(2000); - - // ดึงข้อมูลจาก Locator และนำ .textContent() เพื่อดึงมาแต่ข้อความจริง ๆ - const displayNameLocator = page.locator( - "//div[normalize-space(text())='สโรชา มีนา']", - ); - const displayName = (await displayNameLocator.textContent())?.trim(); - - // ตรวจสอบข้อมูลที่ดึงออกมา - expect(displayName).toBe('สโรชา มีนา'); - - console.log('ตรวจสอบการสร้างตัวแทนหญิงถูกต้อง'); -}); - -test('Create Personnel เอเจนซี่ หญิง', async () => { - await page.click("(//div[@role='tab'])[5]"); - await page.click('id=btn-add'); - await page.click('id=btn-add-personne'); - - // กรอกข้อมูลพื้นฐานของบุคคลากร - await page.click("//i[@aria-hidden='false']"); - await page.waitForSelector('id=select-hq-id', { - state: 'visible', - }); - await page.click('id=select-hq-id'); - await page.click("//span[normalize-space(text())='CMO00000']"); - - await page.waitForSelector('id=select-br-id', { state: 'visible' }); - await page.click('id=select-br-id'); - await page.click('id=select-br-id_4'); - await page.fill('id=input-username', 'agencyw'); - await page.click('id=select-user-role'); - await page.click('id=select-user-role_2'); - // await page.click("//div[@role='option']"); - - // กรอกชื่อข้อมูลพื้นฐาน - await page.fill('id=input-citizen-id', '1282262422820'); - await page.click("//label[@for='form-dialog-personnel-select-prefix-name']"); - await page.click('id=form-dialog-personnel-select-prefix-name_0'); - await page.fill('id=form-dialog-personnel-input-first-name', 'ธิดา'); - await page.fill('id=form-dialog-personnel-input-last-name', 'งามตา'); - await page.fill('id=form-dialog-personnel-input-first-name-en', 'Thida'); - await page.fill('id=form-dialog-personnel-input-last-name-en', 'Yamta'); - await page.fill('id=form-dialog-personnel-input-telephone', '08422622282'); - await page.fill('id=form-dialog-personnel-input-email', 'employeew@mail.com'); - - // เลือกเพศ - await page.click('id=form-dialog-personnel-select-gender'); - await page.click("//span[text()='หญิง']"); - - // เลือกวันเกิด - await page.click('id=form-dialog-personnel-input-birth-date'); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2561']"); - await page.click("//div[text()='8']"); - - // วันออกบัตร วันที่หมออายุ - await page.click( - "(//input[@id='form-dialog-personnel-input-citizen-issue'])[1]", - ); - await page.click("//div[@id='2024-09-02']"); - await page.click( - "(//input[@id='form-dialog-personnel-input-citizen-expire'])[1]", - ); - await page.click("//div[@id='2024-09-11']/div[1]"); - - // กรอกที่อยู่ - await page.fill('id=drawer-info-personnel-input-address-no', '20/1'); - await page.click('id=drawer-info-personnel-select-province'); - await page.waitForSelector('id=drawer-info-personnel-select-province_6', { - state: 'visible', - }); - await page.click('id=drawer-info-personnel-select-province_6'); - await page.click('id=drawer-info-personnel-select-district'); - await page.waitForSelector('id=drawer-info-personnel-select-district_2', { - state: 'visible', - }); - await page.click('id=drawer-info-personnel-select-district_2'); - await page.click('id=drawer-info-personnel-select-sub-district'); - await page.waitForSelector('id=drawer-info-personnel-select-sub-district_1', { - state: 'visible', - }); - await page.click('id=drawer-info-personnel-select-sub-district_1'); - - // กรอกที่อยู่ภาษาอังกฤษ - await page.fill('id=drawer-info-personnel-input-address-en', '20/01'); - - // กรอกข้อมูลการทำงาน - await page.click('id=input-source-nationality'); - await page.click("(//div[@role='option'])[1]"); - await page.click('id=input-import-nationality'); - await page.click("(//div[@role='option'])[1]"); - await page.click('id=select-trainig-place'); - await page.click("//span[text()='สถานที่อบรมแรงงานเมียนมา-แม่สอด จ.ตาก']"); - await page.fill('id=input-checkpoint', 'แม่สอด'); - await page.fill('id=input-checkpoint-en', 'Maesod'); - - // กดปุ่มเพื่อสร้างบุคคลากร - await page.click('id=btn-info-basic-save'); - await page.waitForTimeout(2000); - - // ดึงข้อมูลจาก Locator และนำ .textContent() เพื่อดึงมาแต่ข้อความจริง ๆ - const displayNameLocator = page.locator( - "//div[normalize-space(text())='ธิดา งามตา']", - ); - const displayName = (await displayNameLocator.textContent())?.trim(); - - // ตรวจสอบข้อมูลที่ดึงออกมา - expect(displayName).toBe('ธิดา งามตา'); - - console.log('ตรวจสอบการสร้างเอเจนซี่หญิงถูกต้อง'); -}); - -test('Create Personnel เอเจนซี่ ชาย', async () => { - await page.click('id=btn-add'); - await page.click('id=btn-add-personne'); - - // กรอกข้อมูลพื้นฐานของบุคคลากร - await page.click("//i[@aria-hidden='false']"); - await page.waitForSelector('id=select-hq-id', { - state: 'visible', - }); - await page.click('id=select-hq-id'); - await page.click("//span[normalize-space(text())='CMO00000']"); - - await page.waitForSelector('id=select-br-id', { state: 'visible' }); - await page.click('id=select-br-id'); - await page.click('id=select-br-id_4'); - await page.fill('id=input-username', 'agencym'); - await page.click('id=select-user-role'); - await page.click('id=select-user-role_8'); - // await page.click("//div[@role='option']"); - - // กรอกชื่อข้อมูลพื้นฐาน - await page.fill('id=input-citizen-id', '1282262422820'); - await page.click("//label[@for='form-dialog-personnel-select-prefix-name']"); - await page.click('id=form-dialog-personnel-select-prefix-name_0'); - await page.fill('id=form-dialog-personnel-input-first-name', 'อันดา'); - await page.fill('id=form-dialog-personnel-input-last-name', 'ธรรมา'); - await page.fill('id=form-dialog-personnel-input-first-name-en', 'Aunda'); - await page.fill('id=form-dialog-personnel-input-last-name-en', 'Thamma'); - await page.fill('id=form-dialog-personnel-input-telephone', '08422622282'); - await page.fill('id=form-dialog-personnel-input-email', 'employeew@mail.com'); - - // เลือกเพศ - await page.click('id=form-dialog-personnel-select-gender'); - await page.click("//span[text()='ชาย']"); - - // เลือกวันเกิด - await page.click('id=form-dialog-personnel-input-birth-date'); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2561']"); - await page.click("//div[text()='8']"); - - // วันออกบัตร วันที่หมออายุ - await page.click( - "(//input[@id='form-dialog-personnel-input-citizen-issue'])[1]", - ); - await page.click("//div[@id='2024-09-02']"); - await page.click( - "(//input[@id='form-dialog-personnel-input-citizen-expire'])[1]", - ); - await page.click("//div[@id='2024-09-10']/div[1]"); - - // กรอกที่อยู่ - await page.fill('id=drawer-info-personnel-input-address-no', '20/1'); - await page.click('id=drawer-info-personnel-select-province'); - await page.waitForSelector('id=drawer-info-personnel-select-province_6', { - state: 'visible', - }); - await page.click('id=drawer-info-personnel-select-province_6'); - await page.click('id=drawer-info-personnel-select-district'); - await page.waitForSelector('id=drawer-info-personnel-select-district_2', { - state: 'visible', - }); - await page.click('id=drawer-info-personnel-select-district_2'); - await page.click('id=drawer-info-personnel-select-sub-district'); - await page.waitForSelector('id=drawer-info-personnel-select-sub-district_1', { - state: 'visible', - }); - await page.click('id=drawer-info-personnel-select-sub-district_1'); - - // กรอกที่อยู่ภาษาอังกฤษ - await page.fill('id=drawer-info-personnel-input-address-en', '20/01'); - - // กรอกข้อมูลการทำงาน - await page.click('id=input-source-nationality'); - await page.click("(//div[@role='option'])[1]"); - await page.click('id=input-import-nationality'); - await page.click("(//div[@role='option'])[1]"); - await page.click('id=select-trainig-place'); - await page.click("//span[text()='สถานที่อบรมแรงงานเมียนมา-แม่สอด จ.ตาก']"); - await page.fill('id=input-checkpoint', 'แม่สอด'); - await page.fill('id=input-checkpoint-en', 'Maesod'); - - // กดปุ่มเพื่อสร้างบุคคลากร - await page.click('id=btn-info-basic-save'); - await page.waitForTimeout(2000); - - // ดึงข้อมูลจาก Locator และนำ .textContent() เพื่อดึงมาแต่ข้อความจริง ๆ - const displayNameLocator = page.locator( - "//div[normalize-space(text())='อันดา ธรรมา']", - ); - const displayName = (await displayNameLocator.textContent())?.trim(); - - // ตรวจสอบข้อมูลที่ดึงออกมา - expect(displayName).toBe('อันดา ธรรมา'); - - console.log('ตรวจสอบการสร้างเอเจนซี่ชายถูกต้อง'); -}); diff --git a/tests/02-Admin-PersonnelManagement/JWS_PM_002_CreatePersonnelFail.spec.ts b/tests/02-Admin-PersonnelManagement/JWS_PM_002_CreatePersonnelFail.spec.ts deleted file mode 100644 index 62aa319b..00000000 --- a/tests/02-Admin-PersonnelManagement/JWS_PM_002_CreatePersonnelFail.spec.ts +++ /dev/null @@ -1,128 +0,0 @@ -import { test, expect, Page } from '@playwright/test'; -import { strictEqual } from 'assert'; -import exp from 'constants'; - -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.62:20101/'); - 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('Create Personnel - ในกรณีที่ไม่กรอกข้อมูล', async () => { - await page.click('id=menu-icon-personnel-management'); - await page.click('id=btn-add'); - await page.click('id=btn-add-personne'); - await page.click('id=btn-info-basic-save'); - await page.waitForTimeout(2000); - - const usernameError = page.locator("(//div[@role='alert'])[1]"); - const userTypeError = page.locator("(//div[@role='alert'])[2]"); - const userPermisionError = page.locator("(//div[@role='alert'])[3]"); - const citizenIdError = page.locator("(//div[@role='alert'])[4]"); - const firstNameError = page.locator("(//div[@role='alert'])[5]"); - const lastNameError = page.locator("(//div[@role='alert'])[6]"); - const firstNameEnError = page.locator("(//div[@role='alert'])[7]"); - const lastNameEnError = page.locator("(//div[@role='alert'])[8]"); - const brithDateError = page.locator("(//div[@role='alert'])[9]"); - const citizenIdInError = page.locator("(//div[@role='alert'])[10]"); - const addressError = page.locator("(//div[@role='alert'])[11]"); - const provinceError = page.locator("(//div[@role='alert'])[12]"); - const districtError = page.locator("(//div[@role='alert'])[13]"); - const subDistrictErrorError = page.locator("(//div[@role='alert'])[14]"); - const addressEnErrorError = page.locator("(//div[@role='alert'])[15]"); - - await expect(usernameError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้'); - await expect(userTypeError).toHaveText('โปรดเลือกประเภทผู้ใช้งาน'); - await expect(userPermisionError).toHaveText('โปรดเลือกสิทธิ์ผู้ใช้งาน'); - await expect(citizenIdError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้'); - await expect(firstNameError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้'); - await expect(lastNameError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้'); - await expect(firstNameEnError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้'); - await expect(lastNameEnError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้'); - await expect(brithDateError).toHaveText('โปรดเลือกวันเดือนปีเกิด'); - await expect(citizenIdInError).toHaveText('โปรดเลือกวันที่ออกบัตร'); - await expect(addressError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้'); - await expect(provinceError).toHaveText('โปรดเลือกจังหวัด'); - await expect(districtError).toHaveText('โปรดเลือกอำเภอ'); - await expect(subDistrictErrorError).toHaveText('โปรดเลือกตำบล'); - await expect(addressEnErrorError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้'); - - await page.waitForTimeout(2000); - await page.click('id=btn-form-close'); - console.log('การตรวจสอบการทำงานถูกต้อง'); -}); - -test('Create Personnel - ในกรณีที่กรอกชื่อผู้ใช้งานที่ไม่ตรงกับตัวอักษรที่กำหนด', async () => { - await page.click('id=btn-add'); - await page.click('id=btn-add-personne'); - - // กรอกชื่อผู้ใช้งาน - await page.fill('id=input-username', 'ทดสอบ'); - - const usernameError = page.locator("(//div[@role='alert'])[1]"); - - await expect(usernameError).toHaveText( - 'โปรดใช้เฉพาะตัวอักษรภาษาอังกฤษและตัวเลขเท่านั้น', - ); - - await page.waitForTimeout(2000); - await page.click('id=btn-form-close'); - console.log('การตรวจสอบการทำงานถูกต้อง'); -}); - -test('Create Personnel - ในกรณีที่กรอกชื่อและนามสกุลภาษาอังกฤษไม่ตรงตามรูปแบบ', async () => { - await page.click('id=btn-add'); - await page.click('id=btn-add-personne'); - - // กรอกชื่อผู้ใช้งาน - await page.fill('id=form-dialog-personnel-input-first-name-en', 'ทดสอบ'); - await page.fill('id=form-dialog-personnel-input-last-name-en', 'ทดสอบ'); - - const firstNameEnError = page.locator("(//div[@role='alert'])[1]"); - const lastNameEnError = page.locator("(//div[@role='alert'])[2]"); - - await expect(firstNameEnError).toHaveText( - 'โปรดใช้เฉพาะตัวอักษรภาษาอังกฤษเท่านั้น', - ); - await expect(lastNameEnError).toHaveText( - 'โปรดใช้เฉพาะตัวอักษรภาษาอังกฤษเท่านั้น', - ); - - await page.waitForTimeout(2000); - await page.click('id=btn-form-close'); - console.log('การตรวจสอบการทำงานถูกต้อง'); -}); - -test('Create Personnel - ในกรณีที่กรอกอีเมลไม่ตรงรูปแบบ', async () => { - await page.click('id=menu-icon-personnel-management'); - await page.click('id=btn-add'); - await page.click('id=btn-add-personne'); - - // กรอกชื่อผู้ใช้งาน - await page.fill('id=form-dialog-personnel-input-email', 'ทดสอบ'); - - const firstNameEnError = page.locator("(//div[@role='alert'])[1]"); - - await expect(firstNameEnError).toHaveText('ข้อมูลไม่ถูกต้อง'); - - await page.waitForTimeout(2000); - await page.click('id=btn-form-close'); - console.log('การตรวจสอบการทำงานถูกต้อง'); -}); diff --git a/tests/02-Admin-PersonnelManagement/JWS_PM_003_ViewDetail.spec.ts b/tests/02-Admin-PersonnelManagement/JWS_PM_003_ViewDetail.spec.ts deleted file mode 100644 index 7916cb81..00000000 --- a/tests/02-Admin-PersonnelManagement/JWS_PM_003_ViewDetail.spec.ts +++ /dev/null @@ -1,109 +0,0 @@ -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.62:20101/'); - 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('View Deatil Personnel Employee', async () => { - await page.click('id=menu-icon-personnel-management'); - await page.click("(//div[@role='tab'])[2]"); - - try { - await page.waitForSelector('id=btn-kebab-action-employeem', { - state: 'visible', - }); - await page.click('id=btn-kebab-action-employeem'); - await page.click('id=btn-kebab-view-detail-employeem'); - - const detailTitle = page.locator("//span[text()='ธรรมรงด์ ดำรงธรรม']"); - - await expect(detailTitle).toHaveText('ธรรมรงด์ ดำรงธรรม'); - console.log('ตรวจสอบรายละเอียดพนักงานถูกต้อง'); - } catch (error) { - console.log('เกิดข้อผิดพลาดในการทดสอบ'); - throw error; - } - - await page.waitForTimeout(2000); - await page.click('id=btn-info-close'); -}); - -test('View Deatil Personnel Courier', async () => { - try { - await page.click("(//div[@role='tab'])[3]"); - await page.click('id=btn-kebab-action-courierw'); - await page.click('id=btn-kebab-view-detail-courierw'); - - const detailTitle = page.locator("//span[text()='มาตา ลดา']"); - - await expect(detailTitle).toHaveText('มาตา ลดา'); - console.log('ตรวจสอบรายละเอียดพนักงานส่งเอกสารถูกต้อง'); - } catch (error) { - console.log('เกิดข้อผิดพลาดในการทดสอบ'); - throw error; - } - - await page.waitForTimeout(2000); - await page.click('id=btn-info-close'); -}); - -test('View Deatil Personnel Delegate', async () => { - try { - await page.click("(//div[@role='tab'])[4]"); - await page.click('id=btn-kebab-action-delegatem'); - await page.click('id=btn-kebab-view-detail-delegatem'); - - const detailTitle = page.locator("//span[text()='อาคม พลัง']"); - - await expect(detailTitle).toHaveText('อาคม พลัง'); - console.log('ตรวจสอบรายละเอียดตัวแทนถูกต้อง'); - } catch (error) { - console.log('เกิดข้อผิดพลาดในการทดสอบ'); - throw error; - } - - await page.waitForTimeout(2000); - await page.click('id=btn-info-close'); -}); - -test('View Deatil Personnel Agency', async () => { - try { - await page.click("(//div[@role='tab'])[5]"); - await page.click('id=btn-kebab-action-agencyw'); - await page.waitForSelector('id=btn-kebab-view-detail-agencyw', { - state: 'visible', - }); - await page.click('id=btn-kebab-view-detail-agencyw'); - - const detailTitle = await page.locator("//span[text()='ธิดา งามตา']"); - - await expect(detailTitle).toHaveText('ธิดา งามตา'); - console.log('ตรวจสอบรายละเอียดเอเจนซี่ถูกต้อง'); - } catch (error) { - console.log('เกิดข้อผิดพลาดในการทดสอบ'); - throw error; - } - - await page.waitForTimeout(2000); - await page.click('id=btn-info-close'); -}); diff --git a/tests/02-Admin-PersonnelManagement/JWS_PM_006_SearchPersonnel(ยังไม่เสร็จทำทีหลัง).spec.ts b/tests/02-Admin-PersonnelManagement/JWS_PM_006_SearchPersonnel(ยังไม่เสร็จทำทีหลัง).spec.ts deleted file mode 100644 index 31701423..00000000 --- a/tests/02-Admin-PersonnelManagement/JWS_PM_006_SearchPersonnel(ยังไม่เสร็จทำทีหลัง).spec.ts +++ /dev/null @@ -1,41 +0,0 @@ -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.62:20101/'); - 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('Search Personnel', async () => { - await page.click('id=menu-icon-personnel-management'); - await page.fill('id=input-search', 'ทดสอบ'); - await page.waitForTimeout(2000); - await page.fill('id=input-search', 'ทด'); - await page.waitForTimeout(2000); - await page.fill('id=input-search', '1'); - await page.waitForTimeout(2000); - await page.fill('id=input-search', 'พนักงาน'); - await page.waitForTimeout(2000); - await page.fill('id=input-search', 'พนัก '); - await page.waitForTimeout(2000); - await page.fill('id=input-search', '1000006'); - await page.waitForTimeout(2000); -}); diff --git a/tests/03-Admin-ManageCustomer/JWS_MC_003_DetailNaturalperson.spec.ts b/tests/03-Admin-ManageCustomer/JWS_MC_003_DetailNaturalperson.spec.ts deleted file mode 100644 index 23a5b289..00000000 --- a/tests/03-Admin-ManageCustomer/JWS_MC_003_DetailNaturalperson.spec.ts +++ /dev/null @@ -1,34 +0,0 @@ -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.62:20101/'); - 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('ตรวจสอบดูรายละเอียดบุคคลธรรมดาโดยการคลิกไอคอนดวงตา', async () => { - await page.click('id=menu-icon-customer-management'); - try { - } catch (error) { - console.error('เกิดข้อผิดพลาดในการทดสอบ', error); - throw error; - } -}); diff --git a/tests/03-Admin-ManageCustomer/JWS_MC_004_EditNaturalperson.spec.ts b/tests/03-Admin-ManageCustomer/JWS_MC_004_EditNaturalperson.spec.ts deleted file mode 100644 index 5b31e4d5..00000000 --- a/tests/03-Admin-ManageCustomer/JWS_MC_004_EditNaturalperson.spec.ts +++ /dev/null @@ -1,41 +0,0 @@ -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.62:20101/'); - 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); -}); diff --git a/tests/03-Admin-ManageCustomer/JWS_MC_005_DeleteNaturalperson.spec.ts b/tests/03-Admin-ManageCustomer/JWS_MC_005_DeleteNaturalperson.spec.ts deleted file mode 100644 index b0de834f..00000000 --- a/tests/03-Admin-ManageCustomer/JWS_MC_005_DeleteNaturalperson.spec.ts +++ /dev/null @@ -1,34 +0,0 @@ -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.62:20101/'); - 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('Delete Naturalperson', async () => { - // รออัพเดท PATH - await page.click('id=menu-icon-customer-management'); - await page.click("//button[@id='btn-dots-PERS000002']"); - await page.click('id=view-detail-btn-undefined-delete'); - await page.click('id=btn-ok-dialog'); - await page.waitForTimeout(2000); -}); diff --git a/tests/03-Admin-ManageCustomer/JWS_MC_006_StatusNaturalperson.spec.ts b/tests/03-Admin-ManageCustomer/JWS_MC_006_StatusNaturalperson.spec.ts deleted file mode 100644 index 66f8ac44..00000000 --- a/tests/03-Admin-ManageCustomer/JWS_MC_006_StatusNaturalperson.spec.ts +++ /dev/null @@ -1,38 +0,0 @@ -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.62:20101/'); - 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('Status On Natural Person', async () => { - await page.click('id=menu-icon-customer-management'); - await page.click("//button[@id='btn-dots-PERS000002']"); - await page.click('id=view-detail-btn-undefined-status'); - await page.waitForTimeout(2000); -}); - -test('Status Off Natural Person', async () => { - await page.click('id=btn-dots-โคโม่'); - await page.click('id=view-detail-btn-undefined-status'); - await page.waitForTimeout(2000); -}); diff --git a/tests/03-Admin-ManageCustomer/JWS_MC_007_CreateLegalentitly.spec.ts b/tests/03-Admin-ManageCustomer/JWS_MC_007_CreateLegalentitly.spec.ts deleted file mode 100644 index 7f5aac4d..00000000 --- a/tests/03-Admin-ManageCustomer/JWS_MC_007_CreateLegalentitly.spec.ts +++ /dev/null @@ -1,132 +0,0 @@ -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.62:20101/'); - 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('Create Legalentitly Person', async () => { - await page.click('id=menu-icon-customer-management'); - await page.click("(//div[@id='btn-add'])[1]"); - await page.click('id=add-customer-legal-entity'); - await page.click("(//div[@id='input-source-nationality'])[3]"); - await page.click("//span[text()='บางรัก']"); - await page.fill("(//input[@id='input-customer-name'])[3]", 'ลอย'); - await page.fill("(//input[@id='input-customer-name-en'])[3]", 'Loi'); - await page.fill("(//input[@id='input-owner-name'])[3]", 'ปิงปิง'); - await page.fill("(//input[@id='input-customerEnglishName'])[3]", 'Bangrak'); - await page.fill("(//input[@id='input-customerName'])[3]", 'บางรัก'); - await page.fill("(//input[@id='input-taxNo'])[3]", '1284262822028'); - await page.fill("(//input[@id='input-registerName'])[3]", 'ปองพล กันธะณะ'); - await page.fill("(//input[@id='input-authorizedCapital'])[3]", '20000000'); - await page.click("(//input[@aria-label='จดทะเบียนเมื่อ'])[3]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2560']"); - await page.click("(//div[text()='30'])[2]"); - await page.fill("(//input[@id='input-address-0'])[3]", '20/02'); - await page.click("(//div[@id='select-province-0'])[3]"); - await page.click("//span[text()='เชียงใหม่']"); - await page.click("(//div[@id='select-district-0'])[3]"); - await page.waitForTimeout(2000); - await page.click("//div[@role='option']"); - await page.click("(//div[@id='select-sub-district-0'])[3]"); - await page.waitForTimeout(2000); - await page.click("//div[@role='option']"); - await page.fill("(//input[@id='input-address-en-0'])[3]", '20/02'); - await page.fill( - "(//input[@id='input-employment-office'])[3]", - 'กรุงเทพมหานคร', - ); - await page.click("(//div[@id='select-business-type'])[3]"); - await page.click("//span[text()='ประมง']"); - await page.click("(//div[@id='select-job-position'])[3]"); - await page.click("(//div[@role='option'])[1]"); - await page.fill( - "(//input[@id='input-job-description'])[3]", - 'ตรวจสอบการทำการลักษณะงาน', - ); - await page.click("(//input[@aria-label='วันที่จ่ายค่าแรง'])[3]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2561']"); - await page.click("//div[text()='12']"); - await page.fill("(//input[@id='input-sales-person'])[3]", 'พนักงานขาย'); - await page.fill("(//input[@id='input-mail'])[3]", 'jws@local.com'); - await page.fill("(//input[@id='input-telephone'])[3]", '0864228464'); - await page.setInputFiles( - "(//input[contains(@class,'q-field__input fit')])[3]", - '/Users/linping/Desktop/Chamomind&FrappeT/JWS_TestScript/tests/Datafile/Pic1.jpg', - ); // UploadFile - await page.click('id=submitBtn'); - await page.waitForTimeout(2000); -}); - -test('Create Legalentitly Person Second', async () => { - await page.click("(//div[@id='btn-add'])[1]"); - await page.click('id=add-customer-legal-entity'); - await page.fill("(//input[@id='input-customer-name'])[3]", 'ลาภ'); - await page.fill("(//input[@id='input-customer-name-en'])[3]", 'Lab'); - await page.fill("(//input[@id='input-owner-name'])[3]", 'ปิงปิง'); - await page.fill("(//input[@id='input-customerEnglishName'])[3]", 'Silom'); - await page.fill("(//input[@id='input-customerName'])[3]", 'สีลม'); - await page.fill("(//input[@id='input-taxNo'])[3]", '1284262822028'); - await page.fill("(//input[@id='input-registerName'])[3]", 'ปองพล กันธะณะ'); - await page.fill("(//input[@id='input-authorizedCapital'])[3]", '20000000'); - await page.click("(//input[@aria-label='จดทะเบียนเมื่อ'])[3]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2560']"); - await page.click("(//div[text()='30'])[2]"); - await page.fill("(//input[@id='input-address-0'])[3]", '20/02'); - await page.click("(//div[@id='select-province-0'])[3]"); - await page.click("//span[text()='เชียงใหม่']"); - await page.click("(//div[@id='select-district-0'])[3]"); - await page.waitForTimeout(2000); - await page.click("//div[@role='option']"); - await page.click("(//div[@id='select-sub-district-0'])[3]"); - await page.waitForTimeout(2000); - await page.click("//div[@role='option']"); - await page.fill("(//input[@id='input-address-en-0'])[3]", '20/02'); - await page.fill( - "(//input[@id='input-employment-office'])[3]", - 'กรุงเทพมหานคร', - ); - await page.click("(//div[@id='select-business-type'])[3]"); - await page.click("//span[text()='ประมง']"); - await page.click("(//div[@id='select-job-position'])[3]"); - await page.click("(//div[@role='option'])[1]"); - await page.fill( - "(//input[@id='input-job-description'])[3]", - 'ตรวจสอบการทำการลักษณะงาน', - ); - await page.click("(//input[@aria-label='วันที่จ่ายค่าแรง'])[3]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2561']"); - await page.click("//div[text()='12']"); - await page.fill("(//input[@id='input-sales-person'])[3]", 'พนักงานขาย'); - await page.fill("(//input[@id='input-mail'])[3]", 'jws@local.com'); - await page.fill("(//input[@id='input-telephone'])[3]", '0864228464'); - await page.setInputFiles( - "(//input[contains(@class,'q-field__input fit')])[3]", - '/Users/linping/Desktop/Chamomind&FrappeT/JWS_TestScript/tests/Datafile/Pic1.jpg', - ); // UploadFile - await page.click('id=submitBtn'); - await page.waitForTimeout(2000); -}); diff --git a/tests/03-Admin-ManageCustomer/JWS_MC_008_CreateLegalentitlyfail.spec.ts b/tests/03-Admin-ManageCustomer/JWS_MC_008_CreateLegalentitlyfail.spec.ts deleted file mode 100644 index ee3d21b8..00000000 --- a/tests/03-Admin-ManageCustomer/JWS_MC_008_CreateLegalentitlyfail.spec.ts +++ /dev/null @@ -1,1226 +0,0 @@ -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.62:20101/'); - 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('Create Natural Person Not Input Data', async () => { - await page.click('id=menu-icon-customer-management'); - await page.click("(//div[@id='btn-add'])[1]"); - await page.click('id=add-customer-legal-entity'); - await page.click('id=submitBtn'); - await page.waitForTimeout(2000); - await page.click('id=cancelBtn'); - await page.waitForTimeout(2000); -}); - -test('Create Natural Person Not Input Name TH', async () => { - await page.click("(//div[@id='btn-add'])[1]"); - await page.click('id=add-customer-legal-entity'); - await page.click("(//div[@id='input-source-nationality'])[3]"); - await page.click("(//div[@id='input-source-nationality'])[3]"); - await page.fill("(//input[@id='input-customer-name'])[3]", ''); - await page.fill("(//input[@id='input-customer-name-en'])[3]", 'Loi'); - await page.fill("(//input[@id='input-owner-name'])[3]", 'ปิงปิง'); - await page.fill("(//input[@id='input-customerEnglishName'])[3]", 'Silom'); - await page.fill("(//input[@id='input-customerName'])[3]", 'สีลม'); - await page.fill("(//input[@id='input-taxNo'])[3]", '1284262822028'); - await page.fill("(//input[@id='input-registerName'])[3]", 'ปองพล กันธะณะ'); - await page.fill("(//input[@id='input-authorizedCapital'])[3]", '20000000'); - await page.click("(//input[@aria-label='จดทะเบียนเมื่อ'])[3]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2560']"); - await page.click("(//div[text()='30'])[2]"); - await page.fill("(//input[@id='input-address-0'])[3]", '20/02'); - await page.click("(//div[@id='select-province-0'])[3]"); - await page.click("//span[text()='เชียงใหม่']"); - await page.click("(//div[@id='select-district-0'])[3]"); - await page.click("//span[text()='สารภี']"); - await page.click("(//div[@id='select-sub-district-0'])[3]"); - await page.click("//span[text()='ท่าวังตาล']"); - await page.fill("(//input[@id='input-address-en-0'])[3]", '20/02'); - await page.fill( - "(//input[@id='input-employment-office'])[3]", - 'กรุงเทพมหานคร', - ); - await page.click("(//div[@id='select-business-type'])[3]"); - await page.click("//span[text()='ประมง']"); - await page.click("(//div[@id='select-job-position'])[3]"); - await page.click("(//div[@role='option'])[1]"); - await page.fill( - "(//input[@id='input-job-description'])[3]", - 'ตรวจสอบการทำการลักษณะงาน', - ); - await page.click("(//input[@aria-label='วันที่จ่ายค่าแรง'])[3]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2561']"); - await page.click("//div[text()='12']"); - await page.fill("(//input[@id='input-sales-person'])[3]", 'พนักงานขาย'); - await page.fill("(//input[@id='input-mail'])[3]", 'jws@local.com'); - await page.fill("(//input[@id='input-telephone'])[3]", '0864228464'); - await page.setInputFiles( - "(//input[contains(@class,'q-field__input fit')])[3]", - '/Users/linping/Desktop/Chamomind&FrappeT/JWS_TestScript/tests/Datafile/Pic1.jpg', - ); // UploadFile - await page.click('id=submitBtn'); - await page.waitForTimeout(2000); -}); - -test('Create Natural Person Not Input Name ENG', async () => { - await page.click("(//div[@id='btn-add'])[1]"); - await page.click('id=add-customer-legal-entity'); - await page.click("(//div[@id='input-source-nationality'])[3]"); - await page.click("(//div[@id='input-source-nationality'])[3]"); - await page.fill("(//input[@id='input-customer-name'])[3]", 'ลอย'); - await page.fill("(//input[@id='input-customer-name-en'])[3]", ''); - await page.fill("(//input[@id='input-owner-name'])[3]", 'ปิงปิง'); - await page.fill("(//input[@id='input-customerEnglishName'])[3]", 'Silom'); - await page.fill("(//input[@id='input-customerName'])[3]", 'สีลม'); - - await page.fill("(//input[@id='input-taxNo'])[3]", '1284262822028'); - await page.fill("(//input[@id='input-registerName'])[3]", 'ปองพล กันธะณะ'); - await page.fill("(//input[@id='input-authorizedCapital'])[3]", '20000000'); - await page.click("(//input[@aria-label='จดทะเบียนเมื่อ'])[3]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2560']"); - await page.click("(//div[text()='30'])[2]"); - await page.fill("(//input[@id='input-address-0'])[3]", '20/02'); - await page.click("(//div[@id='select-province-0'])[3]"); - await page.click("//span[text()='เชียงใหม่']"); - await page.click("(//div[@id='select-district-0'])[3]"); - await page.click("//span[text()='สารภี']"); - await page.click("(//div[@id='select-sub-district-0'])[3]"); - await page.click("//span[text()='ท่าวังตาล']"); - await page.fill("(//input[@id='input-address-en-0'])[3]", '20/02'); - await page.fill( - "(//input[@id='input-employment-office'])[3]", - 'กรุงเทพมหานคร', - ); - await page.click("(//div[@id='select-business-type'])[3]"); - await page.click("//span[text()='ประมง']"); - await page.click("(//div[@id='select-job-position'])[3]"); - await page.click("(//div[@role='option'])[1]"); - await page.fill( - "(//input[@id='input-job-description'])[3]", - 'ตรวจสอบการทำการลักษณะงาน', - ); - await page.click("(//input[@aria-label='วันที่จ่ายค่าแรง'])[3]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2561']"); - await page.click("//div[text()='12']"); - await page.fill("(//input[@id='input-sales-person'])[3]", 'พนักงานขาย'); - await page.fill("(//input[@id='input-mail'])[3]", 'jws@local.com'); - await page.fill("(//input[@id='input-telephone'])[3]", '0864228464'); - await page.setInputFiles( - "(//input[contains(@class,'q-field__input fit')])[3]", - '/Users/linping/Desktop/Chamomind&FrappeT/JWS_TestScript/tests/Datafile/Pic1.jpg', - ); // UploadFile - await page.click('id=submitBtn'); - await page.waitForTimeout(2000); -}); - -test('Create Natural Person Not Input Name Company', async () => { - await page.click("(//div[@id='btn-add'])[1]"); - await page.click('id=add-customer-legal-entity'); - await page.click("(//div[@id='input-source-nationality'])[3]"); - await page.click("(//div[@id='input-source-nationality'])[3]"); - await page.fill("(//input[@id='input-customer-name'])[3]", 'ลอย'); - await page.fill("(//input[@id='input-customer-name-en'])[3]", 'Loi'); - await page.fill("(//input[@id='input-owner-name'])[3]", ''); - await page.fill("(//input[@id='input-customerEnglishName'])[3]", 'Silom'); - await page.fill("(//input[@id='input-customerName'])[3]", 'สีลม'); - - await page.fill("(//input[@id='input-taxNo'])[3]", '1284262822028'); - await page.fill("(//input[@id='input-registerName'])[3]", 'ปองพล กันธะณะ'); - await page.fill("(//input[@id='input-authorizedCapital'])[3]", '20000000'); - await page.click("(//input[@aria-label='จดทะเบียนเมื่อ'])[3]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2560']"); - await page.click("(//div[text()='30'])[2]"); - await page.fill("(//input[@id='input-address-0'])[3]", '20/02'); - await page.click("(//div[@id='select-province-0'])[3]"); - await page.click("//span[text()='เชียงใหม่']"); - await page.click("(//div[@id='select-district-0'])[3]"); - await page.click("//span[text()='สารภี']"); - await page.click("(//div[@id='select-sub-district-0'])[3]"); - await page.click("//span[text()='ท่าวังตาล']"); - await page.fill("(//input[@id='input-address-en-0'])[3]", '20/02'); - await page.fill( - "(//input[@id='input-employment-office'])[3]", - 'กรุงเทพมหานคร', - ); - await page.click("(//div[@id='select-business-type'])[3]"); - await page.click("//span[text()='ประมง']"); - await page.click("(//div[@id='select-job-position'])[3]"); - await page.click("(//div[@role='option'])[1]"); - await page.fill( - "(//input[@id='input-job-description'])[3]", - 'ตรวจสอบการทำการลักษณะงาน', - ); - await page.click("(//input[@aria-label='วันที่จ่ายค่าแรง'])[3]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2561']"); - await page.click("//div[text()='12']"); - await page.fill("(//input[@id='input-sales-person'])[3]", 'พนักงานขาย'); - await page.fill("(//input[@id='input-mail'])[3]", 'jws@local.com'); - await page.fill("(//input[@id='input-telephone'])[3]", '0864228464'); - await page.setInputFiles( - "(//input[contains(@class,'q-field__input fit')])[3]", - '/Users/linping/Desktop/Chamomind&FrappeT/JWS_TestScript/tests/Datafile/Pic1.jpg', - ); // UploadFile - await page.click('id=submitBtn'); - await page.waitForTimeout(2000); -}); - -test('Create Natural Person Not Input Customername ENG ', async () => { - await page.click("(//div[@id='btn-add'])[1]"); - await page.click('id=add-customer-legal-entity'); - await page.click("(//div[@id='input-source-nationality'])[3]"); - await page.click("(//div[@id='input-source-nationality'])[3]"); - await page.fill("(//input[@id='input-customer-name'])[3]", 'ลอย'); - await page.fill("(//input[@id='input-customer-name-en'])[3]", 'Loi'); - await page.fill("(//input[@id='input-owner-name'])[3]", 'ปิงปิง'); - await page.fill("(//input[@id='input-customerEnglishName'])[3]", ''); - await page.fill("(//input[@id='input-customerName'])[3]", 'สีลม'); - await page.fill("(//input[@id='input-taxNo'])[3]", '1284262822028'); - await page.fill("(//input[@id='input-registerName'])[3]", 'ปองพล กันธะณะ'); - await page.fill("(//input[@id='input-authorizedCapital'])[3]", '20000000'); - await page.click("(//input[@aria-label='จดทะเบียนเมื่อ'])[3]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2560']"); - await page.click("(//div[text()='30'])[2]"); - await page.fill("(//input[@id='input-address-0'])[3]", '20/02'); - await page.click("(//div[@id='select-province-0'])[3]"); - await page.click("//span[text()='เชียงใหม่']"); - await page.click("(//div[@id='select-district-0'])[3]"); - await page.click("//span[text()='สารภี']"); - await page.click("(//div[@id='select-sub-district-0'])[3]"); - await page.click("//span[text()='ท่าวังตาล']"); - await page.fill("(//input[@id='input-address-en-0'])[3]", '20/02'); - await page.fill( - "(//input[@id='input-employment-office'])[3]", - 'กรุงเทพมหานคร', - ); - await page.click("(//div[@id='select-business-type'])[3]"); - await page.click("//span[text()='ประมง']"); - await page.click("(//div[@id='select-job-position'])[3]"); - await page.click("(//div[@role='option'])[1]"); - await page.fill( - "(//input[@id='input-job-description'])[3]", - 'ตรวจสอบการทำการลักษณะงาน', - ); - await page.click("(//input[@aria-label='วันที่จ่ายค่าแรง'])[3]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2561']"); - await page.click("//div[text()='12']"); - await page.fill("(//input[@id='input-sales-person'])[3]", 'พนักงานขาย'); - await page.fill("(//input[@id='input-mail'])[3]", 'jws@local.com'); - await page.fill("(//input[@id='input-telephone'])[3]", '0864228464'); - await page.setInputFiles( - "(//input[contains(@class,'q-field__input fit')])[3]", - '/Users/linping/Desktop/Chamomind&FrappeT/JWS_TestScript/tests/Datafile/Pic1.jpg', - ); // UploadFile - await page.click('id=submitBtn'); - await page.waitForTimeout(2000); -}); - -test('Create Natural Person Not Input Customername TH', async () => { - await page.click("(//div[@id='btn-add'])[1]"); - await page.click('id=add-customer-legal-entity'); - await page.click("(//div[@id='input-source-nationality'])[3]"); - await page.click("(//div[@id='input-source-nationality'])[3]"); - await page.fill("(//input[@id='input-customer-name'])[3]", 'ลอย'); - await page.fill("(//input[@id='input-customer-name-en'])[3]", 'Loi'); - await page.fill("(//input[@id='input-owner-name'])[3]", 'ปิงปิง'); - await page.fill("(//input[@id='input-customerEnglishName'])[3]", 'Silom'); - await page.fill("(//input[@id='input-customerName'])[3]", ''); - await page.fill("(//input[@id='input-taxNo'])[3]", '1284262822028'); - await page.fill("(//input[@id='input-registerName'])[3]", 'ปองพล กันธะณะ'); - await page.fill("(//input[@id='input-authorizedCapital'])[3]", '20000000'); - await page.click("(//input[@aria-label='จดทะเบียนเมื่อ'])[3]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2560']"); - await page.click("(//div[text()='30'])[2]"); - await page.fill("(//input[@id='input-address-0'])[3]", '20/02'); - await page.click("(//div[@id='select-province-0'])[3]"); - await page.click("//span[text()='เชียงใหม่']"); - await page.click("(//div[@id='select-district-0'])[3]"); - await page.click("//span[text()='สารภี']"); - await page.click("(//div[@id='select-sub-district-0'])[3]"); - await page.click("//span[text()='ท่าวังตาล']"); - await page.fill("(//input[@id='input-address-en-0'])[3]", '20/02'); - await page.fill( - "(//input[@id='input-employment-office'])[3]", - 'กรุงเทพมหานคร', - ); - await page.click("(//div[@id='select-business-type'])[3]"); - await page.click("//span[text()='ประมง']"); - await page.click("(//div[@id='select-job-position'])[3]"); - await page.click("(//div[@role='option'])[1]"); - await page.fill( - "(//input[@id='input-job-description'])[3]", - 'ตรวจสอบการทำการลักษณะงาน', - ); - await page.click("(//input[@aria-label='วันที่จ่ายค่าแรง'])[3]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2561']"); - await page.click("//div[text()='12']"); - await page.fill("(//input[@id='input-sales-person'])[3]", 'พนักงานขาย'); - await page.fill("(//input[@id='input-mail'])[3]", 'jws@local.com'); - await page.fill("(//input[@id='input-telephone'])[3]", '0864228464'); - await page.setInputFiles( - "(//input[contains(@class,'q-field__input fit')])[3]", - '/Users/linping/Desktop/Chamomind&FrappeT/JWS_TestScript/tests/Datafile/Pic1.jpg', - ); // UploadFile - await page.click('id=submitBtn'); - await page.waitForTimeout(2000); -}); - -test('Create Natural Person Not Input Tax No', async () => { - await page.click("(//div[@id='btn-add'])[1]"); - await page.click('id=add-customer-legal-entity'); - await page.click("(//div[@id='input-source-nationality'])[3]"); - await page.click("(//div[@id='input-source-nationality'])[3]"); - await page.fill("(//input[@id='input-customer-name'])[3]", 'ลอย'); - await page.fill("(//input[@id='input-customer-name-en'])[3]", 'Loi'); - await page.fill("(//input[@id='input-owner-name'])[3]", 'ปิงปิง'); - await page.fill("(//input[@id='input-customerEnglishName'])[3]", 'Silom'); - await page.fill("(//input[@id='input-customerName'])[3]", 'สีลม'); - - await page.fill("(//input[@id='input-taxNo'])[3]", ''); - await page.fill("(//input[@id='input-registerName'])[3]", 'ปองพล กันธะณะ'); - await page.fill("(//input[@id='input-authorizedCapital'])[3]", '20000000'); - await page.click("(//input[@aria-label='จดทะเบียนเมื่อ'])[3]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2560']"); - await page.click("(//div[text()='30'])[2]"); - await page.fill("(//input[@id='input-address-0'])[3]", '20/02'); - await page.click("(//div[@id='select-province-0'])[3]"); - await page.click("//span[text()='เชียงใหม่']"); - await page.click("(//div[@id='select-district-0'])[3]"); - await page.click("//span[text()='สารภี']"); - await page.click("(//div[@id='select-sub-district-0'])[3]"); - await page.click("//span[text()='ท่าวังตาล']"); - await page.fill("(//input[@id='input-address-en-0'])[3]", '20/02'); - await page.fill( - "(//input[@id='input-employment-office'])[3]", - 'กรุงเทพมหานคร', - ); - await page.click("(//div[@id='select-business-type'])[3]"); - await page.click("//span[text()='ประมง']"); - await page.click("(//div[@id='select-job-position'])[3]"); - await page.click("(//div[@role='option'])[1]"); - await page.fill( - "(//input[@id='input-job-description'])[3]", - 'ตรวจสอบการทำการลักษณะงาน', - ); - await page.click("(//input[@aria-label='วันที่จ่ายค่าแรง'])[3]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2561']"); - await page.click("//div[text()='12']"); - await page.fill("(//input[@id='input-sales-person'])[3]", 'พนักงานขาย'); - await page.fill("(//input[@id='input-mail'])[3]", 'jws@local.com'); - await page.fill("(//input[@id='input-telephone'])[3]", '0864228464'); - await page.setInputFiles( - "(//input[contains(@class,'q-field__input fit')])[3]", - '/Users/linping/Desktop/Chamomind&FrappeT/JWS_TestScript/tests/Datafile/Pic1.jpg', - ); // UploadFile - await page.click('id=submitBtn'); - await page.waitForTimeout(2000); - await page.click('id=cancelBtn'); - await page.waitForTimeout(2000); -}); - -test('Create Natural Person Not Input Registername', async () => { - await page.click("(//div[@id='btn-add'])[1]"); - await page.click('id=add-customer-legal-entity'); - await page.click("(//div[@id='input-source-nationality'])[3]"); - await page.click("(//div[@id='input-source-nationality'])[3]"); - await page.fill("(//input[@id='input-customer-name'])[3]", 'ลอย'); - await page.fill("(//input[@id='input-customer-name-en'])[3]", 'Loi'); - await page.fill("(//input[@id='input-owner-name'])[3]", 'ปิงปิง'); - await page.fill("(//input[@id='input-customerEnglishName'])[3]", 'Silom'); - await page.fill("(//input[@id='input-customerName'])[3]", 'สีลม'); - - await page.fill("(//input[@id='input-taxNo'])[3]", '1284262822028'); - await page.fill("(//input[@id='input-registerName'])[3]", ''); - await page.fill("(//input[@id='input-authorizedCapital'])[3]", '20000000'); - await page.click("(//input[@aria-label='จดทะเบียนเมื่อ'])[3]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2560']"); - await page.click("(//div[text()='30'])[2]"); - await page.fill("(//input[@id='input-address-0'])[3]", '20/02'); - await page.click("(//div[@id='select-province-0'])[3]"); - await page.click("//span[text()='เชียงใหม่']"); - await page.click("(//div[@id='select-district-0'])[3]"); - await page.click("//span[text()='สารภี']"); - await page.click("(//div[@id='select-sub-district-0'])[3]"); - await page.click("//span[text()='ท่าวังตาล']"); - await page.fill("(//input[@id='input-address-en-0'])[3]", '20/02'); - await page.fill( - "(//input[@id='input-employment-office'])[3]", - 'กรุงเทพมหานคร', - ); - await page.click("(//div[@id='select-business-type'])[3]"); - await page.click("//span[text()='ประมง']"); - await page.click("(//div[@id='select-job-position'])[3]"); - await page.click("(//div[@role='option'])[1]"); - await page.fill( - "(//input[@id='input-job-description'])[3]", - 'ตรวจสอบการทำการลักษณะงาน', - ); - await page.click("(//input[@aria-label='วันที่จ่ายค่าแรง'])[3]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2561']"); - await page.click("//div[text()='12']"); - await page.fill("(//input[@id='input-sales-person'])[3]", 'พนักงานขาย'); - await page.fill("(//input[@id='input-mail'])[3]", 'jws@local.com'); - await page.fill("(//input[@id='input-telephone'])[3]", '0864228464'); - await page.setInputFiles( - "(//input[contains(@class,'q-field__input fit')])[3]", - '/Users/linping/Desktop/Chamomind&FrappeT/JWS_TestScript/tests/Datafile/Pic1.jpg', - ); // UploadFile - await page.click('id=submitBtn'); - await page.waitForTimeout(2000); -}); - -test('Create Natural Person Not Input Authorizedcapital', async () => { - await page.click("(//div[@id='btn-add'])[1]"); - await page.click('id=add-customer-legal-entity'); - await page.click("(//div[@id='input-source-nationality'])[3]"); - await page.click("(//div[@id='input-source-nationality'])[3]"); - await page.fill("(//input[@id='input-customer-name'])[3]", 'ลอย'); - await page.fill("(//input[@id='input-customer-name-en'])[3]", 'Loi'); - await page.fill("(//input[@id='input-owner-name'])[3]", 'ปิงปิง'); - await page.fill("(//input[@id='input-customerEnglishName'])[3]", 'Silom'); - await page.fill("(//input[@id='input-customerName'])[3]", 'สีลม'); - - await page.fill("(//input[@id='input-taxNo'])[3]", '1284262822028'); - await page.fill("(//input[@id='input-registerName'])[3]", 'ปองพล กันธะณะ'); - await page.fill("(//input[@id='input-authorizedCapital'])[3]", ''); - await page.click("(//input[@aria-label='จดทะเบียนเมื่อ'])[3]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2560']"); - await page.click("(//div[text()='30'])[2]"); - await page.fill("(//input[@id='input-address-0'])[3]", '20/02'); - await page.click("(//div[@id='select-province-0'])[3]"); - await page.click("//span[text()='เชียงใหม่']"); - await page.click("(//div[@id='select-district-0'])[3]"); - await page.click("//span[text()='สารภี']"); - await page.click("(//div[@id='select-sub-district-0'])[3]"); - await page.click("//span[text()='ท่าวังตาล']"); - await page.fill("(//input[@id='input-address-en-0'])[3]", '20/02'); - await page.fill( - "(//input[@id='input-employment-office'])[3]", - 'กรุงเทพมหานคร', - ); - await page.click("(//div[@id='select-business-type'])[3]"); - await page.click("//span[text()='ประมง']"); - await page.click("(//div[@id='select-job-position'])[3]"); - await page.click("(//div[@role='option'])[1]"); - await page.fill( - "(//input[@id='input-job-description'])[3]", - 'ตรวจสอบการทำการลักษณะงาน', - ); - await page.click("(//input[@aria-label='วันที่จ่ายค่าแรง'])[3]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2561']"); - await page.click("//div[text()='12']"); - await page.fill("(//input[@id='input-sales-person'])[3]", 'พนักงานขาย'); - await page.fill("(//input[@id='input-mail'])[3]", 'jws@local.com'); - await page.fill("(//input[@id='input-telephone'])[3]", '0864228464'); - await page.setInputFiles( - "(//input[contains(@class,'q-field__input fit')])[3]", - '/Users/linping/Desktop/Chamomind&FrappeT/JWS_TestScript/tests/Datafile/Pic1.jpg', - ); // UploadFile - await page.click('id=submitBtn'); - await page.waitForTimeout(2000); -}); - -test('Create Natural Person Not Select Date', async () => { - await page.click("(//div[@id='btn-add'])[1]"); - await page.click('id=add-customer-legal-entity'); - await page.click("(//div[@id='input-source-nationality'])[3]"); - await page.click("(//div[@id='input-source-nationality'])[3]"); - await page.fill("(//input[@id='input-customer-name'])[3]", 'ลอย'); - await page.fill("(//input[@id='input-customer-name-en'])[3]", 'Loi'); - await page.fill("(//input[@id='input-owner-name'])[3]", 'ปิงปิง'); - await page.fill("(//input[@id='input-customerEnglishName'])[3]", 'Silom'); - await page.fill("(//input[@id='input-customerName'])[3]", 'สีลม'); - - await page.fill("(//input[@id='input-taxNo'])[3]", '1284262822028'); - await page.fill("(//input[@id='input-registerName'])[3]", 'ปองพล กันธะณะ'); - await page.fill("(//input[@id='input-authorizedCapital'])[3]", '20000000'); - await page.fill("(//input[@id='input-address-0'])[3]", '20/02'); - await page.click("(//div[@id='select-province-0'])[3]"); - await page.click("//span[text()='เชียงใหม่']"); - await page.click("(//div[@id='select-district-0'])[3]"); - await page.click("//span[text()='สารภี']"); - await page.click("(//div[@id='select-sub-district-0'])[3]"); - await page.click("//span[text()='ท่าวังตาล']"); - await page.fill("(//input[@id='input-address-en-0'])[3]", '20/02'); - await page.fill( - "(//input[@id='input-employment-office'])[3]", - 'กรุงเทพมหานคร', - ); - await page.click("(//div[@id='select-business-type'])[3]"); - await page.click("//span[text()='ประมง']"); - await page.click("(//div[@id='select-job-position'])[3]"); - await page.click("(//div[@role='option'])[1]"); - await page.fill( - "(//input[@id='input-job-description'])[3]", - 'ตรวจสอบการทำการลักษณะงาน', - ); - await page.click("(//input[@aria-label='วันที่จ่ายค่าแรง'])[3]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2561']"); - await page.click("//div[text()='12']"); - await page.fill("(//input[@id='input-sales-person'])[3]", 'พนักงานขาย'); - await page.fill("(//input[@id='input-mail'])[3]", 'jws@local.com'); - await page.fill("(//input[@id='input-telephone'])[3]", '0864228464'); - await page.setInputFiles( - "(//input[contains(@class,'q-field__input fit')])[3]", - '/Users/linping/Desktop/Chamomind&FrappeT/JWS_TestScript/tests/Datafile/Pic1.jpg', - ); // UploadFile - await page.click('id=submitBtn'); - await page.waitForTimeout(2000); -}); - -test('Create Natural Person Not Input Address TH', async () => { - await page.click("(//div[@id='btn-add'])[1]"); - await page.click('id=add-customer-legal-entity'); - await page.click("(//div[@id='input-source-nationality'])[3]"); - await page.click("(//div[@id='input-source-nationality'])[3]"); - await page.fill("(//input[@id='input-customer-name'])[3]", 'ลอย'); - await page.fill("(//input[@id='input-customer-name-en'])[3]", 'Loi'); - await page.fill("(//input[@id='input-owner-name'])[3]", 'ปิงปิง'); - await page.fill("(//input[@id='input-customerEnglishName'])[3]", 'Silom'); - await page.fill("(//input[@id='input-customerName'])[3]", 'สีลม'); - - await page.fill("(//input[@id='input-taxNo'])[3]", '1284262822028'); - await page.fill("(//input[@id='input-registerName'])[3]", 'ปองพล กันธะณะ'); - await page.fill("(//input[@id='input-authorizedCapital'])[3]", '20000000'); - await page.click("(//input[@aria-label='จดทะเบียนเมื่อ'])[3]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2560']"); - await page.click("(//div[text()='30'])[2]"); - await page.fill("(//input[@id='input-address-0'])[3]", ''); - await page.click("(//div[@id='select-province-0'])[3]"); - await page.click("//span[text()='เชียงใหม่']"); - await page.click("(//div[@id='select-district-0'])[3]"); - await page.click("//span[text()='สารภี']"); - await page.click("(//div[@id='select-sub-district-0'])[3]"); - await page.click("//span[text()='ท่าวังตาล']"); - await page.fill("(//input[@id='input-address-en-0'])[3]", '20/02'); - await page.fill( - "(//input[@id='input-employment-office'])[3]", - 'กรุงเทพมหานคร', - ); - await page.click("(//div[@id='select-business-type'])[3]"); - await page.click("//span[text()='ประมง']"); - await page.click("(//div[@id='select-job-position'])[3]"); - await page.click("(//div[@role='option'])[1]"); - await page.fill( - "(//input[@id='input-job-description'])[3]", - 'ตรวจสอบการทำการลักษณะงาน', - ); - await page.click("(//input[@aria-label='วันที่จ่ายค่าแรง'])[3]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2561']"); - await page.click("//div[text()='12']"); - await page.fill("(//input[@id='input-sales-person'])[3]", 'พนักงานขาย'); - await page.fill("(//input[@id='input-mail'])[3]", 'jws@local.com'); - await page.fill("(//input[@id='input-telephone'])[3]", '0864228464'); - await page.setInputFiles( - "(//input[contains(@class,'q-field__input fit')])[3]", - '/Users/linping/Desktop/Chamomind&FrappeT/JWS_TestScript/tests/Datafile/Pic1.jpg', - ); // UploadFile - await page.click('id=submitBtn'); - await page.waitForTimeout(2000); - await page.click('id=cancelBtn'); -}); - -test('Create Natural Person Not Select Province', async () => { - await page.click("(//div[@id='btn-add'])[1]"); - await page.click('id=add-customer-legal-entity'); - await page.click("(//div[@id='input-source-nationality'])[3]"); - await page.click("(//div[@id='input-source-nationality'])[3]"); - await page.fill("(//input[@id='input-customer-name'])[3]", 'ลอย'); - await page.fill("(//input[@id='input-customer-name-en'])[3]", 'Loi'); - await page.fill("(//input[@id='input-owner-name'])[3]", 'ปิงปิง'); - await page.fill("(//input[@id='input-customerEnglishName'])[3]", 'Silom'); - await page.fill("(//input[@id='input-customerName'])[3]", 'สีลม'); - - await page.fill("(//input[@id='input-taxNo'])[3]", '1284262822028'); - await page.fill("(//input[@id='input-registerName'])[3]", 'ปองพล กันธะณะ'); - await page.fill("(//input[@id='input-authorizedCapital'])[3]", '20000000'); - await page.click("(//input[@aria-label='จดทะเบียนเมื่อ'])[3]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2560']"); - await page.click("(//div[text()='30'])[2]"); - await page.fill("(//input[@id='input-address-0'])[3]", '20/02'); - await page.fill("(//input[@id='input-address-en-0'])[3]", '20/02'); - await page.fill( - "(//input[@id='input-employment-office'])[3]", - 'กรุงเทพมหานคร', - ); - await page.click("(//div[@id='select-business-type'])[3]"); - await page.click("//span[text()='ประมง']"); - await page.click("(//div[@id='select-job-position'])[3]"); - await page.click("(//div[@role='option'])[1]"); - await page.fill( - "(//input[@id='input-job-description'])[3]", - 'ตรวจสอบการทำการลักษณะงาน', - ); - await page.click("(//input[@aria-label='วันที่จ่ายค่าแรง'])[3]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2561']"); - await page.click("//div[text()='12']"); - await page.fill("(//input[@id='input-sales-person'])[3]", 'พนักงานขาย'); - await page.fill("(//input[@id='input-mail'])[3]", 'jws@local.com'); - await page.fill("(//input[@id='input-telephone'])[3]", '0864228464'); - await page.setInputFiles( - "(//input[contains(@class,'q-field__input fit')])[3]", - '/Users/linping/Desktop/Chamomind&FrappeT/JWS_TestScript/tests/Datafile/Pic1.jpg', - ); // UploadFile - await page.click('id=submitBtn'); - await page.waitForTimeout(2000); - await page.click('id=cancelBtn'); - await page.waitForTimeout(2000); -}); - -test('Create Natural Person Not Select District', async () => { - await page.click("(//div[@id='btn-add'])[1]"); - await page.click('id=add-customer-legal-entity'); - await page.click("(//div[@id='input-source-nationality'])[3]"); - await page.click("(//div[@id='input-source-nationality'])[3]"); - await page.fill("(//input[@id='input-customer-name'])[3]", 'ลอย'); - await page.fill("(//input[@id='input-customer-name-en'])[3]", 'Loi'); - await page.fill("(//input[@id='input-owner-name'])[3]", 'ปิงปิง'); - await page.fill("(//input[@id='input-customerEnglishName'])[3]", 'Silom'); - await page.fill("(//input[@id='input-customerName'])[3]", 'สีลม'); - - await page.fill("(//input[@id='input-taxNo'])[3]", '1284262822028'); - await page.fill("(//input[@id='input-registerName'])[3]", 'ปองพล กันธะณะ'); - await page.fill("(//input[@id='input-authorizedCapital'])[3]", '20000000'); - await page.click("(//input[@aria-label='จดทะเบียนเมื่อ'])[3]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2560']"); - await page.click("(//div[text()='30'])[2]"); - await page.fill("(//input[@id='input-address-0'])[3]", '20/02'); - await page.click("(//div[@id='select-province-0'])[3]"); - await page.click("//span[text()='เชียงใหม่']"); - await page.fill("(//input[@id='input-address-en-0'])[3]", '20/02'); - await page.fill( - "(//input[@id='input-employment-office'])[3]", - 'กรุงเทพมหานคร', - ); - await page.click("(//div[@id='select-business-type'])[3]"); - await page.click("//span[text()='ประมง']"); - await page.click("(//div[@id='select-job-position'])[3]"); - await page.click("(//div[@role='option'])[1]"); - await page.fill( - "(//input[@id='input-job-description'])[3]", - 'ตรวจสอบการทำการลักษณะงาน', - ); - await page.click("(//input[@aria-label='วันที่จ่ายค่าแรง'])[3]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2561']"); - await page.click("//div[text()='12']"); - await page.fill("(//input[@id='input-sales-person'])[3]", 'พนักงานขาย'); - await page.fill("(//input[@id='input-mail'])[3]", 'jws@local.com'); - await page.fill("(//input[@id='input-telephone'])[3]", '0864228464'); - await page.setInputFiles( - "(//input[contains(@class,'q-field__input fit')])[3]", - '/Users/linping/Desktop/Chamomind&FrappeT/JWS_TestScript/tests/Datafile/Pic1.jpg', - ); // UploadFile - await page.click('id=submitBtn'); - await page.waitForTimeout(2000); - await page.click('id=cancelBtn'); - await page.waitForTimeout(2000); -}); - -test('Create Natural Person Not Select Subdistrict', async () => { - await page.click("(//div[@id='btn-add'])[1]"); - await page.click('id=add-customer-legal-entity'); - await page.click("(//div[@id='input-source-nationality'])[3]"); - await page.click("(//div[@id='input-source-nationality'])[3]"); - await page.fill("(//input[@id='input-customer-name'])[3]", 'ลอย'); - await page.fill("(//input[@id='input-customer-name-en'])[3]", 'Loi'); - await page.fill("(//input[@id='input-owner-name'])[3]", 'ปิงปิง'); - await page.fill("(//input[@id='input-customerEnglishName'])[3]", 'Silom'); - await page.fill("(//input[@id='input-customerName'])[3]", 'สีลม'); - - await page.fill("(//input[@id='input-taxNo'])[3]", '1284262822028'); - await page.fill("(//input[@id='input-registerName'])[3]", 'ปองพล กันธะณะ'); - await page.fill("(//input[@id='input-authorizedCapital'])[3]", '20000000'); - await page.click("(//input[@aria-label='จดทะเบียนเมื่อ'])[3]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2560']"); - await page.click("(//div[text()='30'])[2]"); - await page.fill("(//input[@id='input-address-0'])[3]", '20/02'); - await page.click("(//div[@id='select-province-0'])[3]"); - await page.click("//span[text()='เชียงใหม่']"); - await page.click("(//div[@id='select-district-0'])[3]"); - await page.click("//span[text()='สารภี']"); - await page.fill("(//input[@id='input-address-en-0'])[3]", '20/02'); - await page.fill( - "(//input[@id='input-employment-office'])[3]", - 'กรุงเทพมหานคร', - ); - await page.click("(//div[@id='select-business-type'])[3]"); - await page.click("//span[text()='ประมง']"); - await page.click("(//div[@id='select-job-position'])[3]"); - await page.click("(//div[@role='option'])[1]"); - await page.fill( - "(//input[@id='input-job-description'])[3]", - 'ตรวจสอบการทำการลักษณะงาน', - ); - await page.click("(//input[@aria-label='วันที่จ่ายค่าแรง'])[3]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2561']"); - await page.click("//div[text()='12']"); - await page.fill("(//input[@id='input-sales-person'])[3]", 'พนักงานขาย'); - await page.fill("(//input[@id='input-mail'])[3]", 'jws@local.com'); - await page.fill("(//input[@id='input-telephone'])[3]", '0864228464'); - await page.setInputFiles( - "(//input[contains(@class,'q-field__input fit')])[3]", - '/Users/linping/Desktop/Chamomind&FrappeT/JWS_TestScript/tests/Datafile/Pic1.jpg', - ); // UploadFile - await page.click('id=submitBtn'); - await page.waitForTimeout(2000); - await page.click('id=cancelBtn'); - await page.waitForTimeout(2000); -}); - -test('Create Natural Person Not Input Address ENG', async () => { - await page.click("(//div[@id='btn-add'])[1]"); - await page.click('id=add-customer-legal-entity'); - await page.click("(//div[@id='input-source-nationality'])[3]"); - await page.click("(//div[@id='input-source-nationality'])[3]"); - await page.fill("(//input[@id='input-customer-name'])[3]", 'ลอย'); - await page.fill("(//input[@id='input-customer-name-en'])[3]", 'Loi'); - await page.fill("(//input[@id='input-owner-name'])[3]", 'ปิงปิง'); - await page.fill("(//input[@id='input-customerEnglishName'])[3]", 'Silom'); - await page.fill("(//input[@id='input-customerName'])[3]", 'สีลม'); - - await page.fill("(//input[@id='input-taxNo'])[3]", '1284262822028'); - await page.fill("(//input[@id='input-registerName'])[3]", 'ปองพล กันธะณะ'); - await page.fill("(//input[@id='input-authorizedCapital'])[3]", '20000000'); - await page.click("(//input[@aria-label='จดทะเบียนเมื่อ'])[3]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2560']"); - await page.click("(//div[text()='30'])[2]"); - await page.fill("(//input[@id='input-address-0'])[3]", '20/02'); - await page.click("(//div[@id='select-province-0'])[3]"); - await page.click("//span[text()='เชียงใหม่']"); - await page.click("(//div[@id='select-district-0'])[3]"); - await page.click("//span[text()='สารภี']"); - await page.click("(//div[@id='select-sub-district-0'])[3]"); - await page.click("//span[text()='ท่าวังตาล']"); - await page.fill("(//input[@id='input-address-en-0'])[3]", ''); - await page.fill( - "(//input[@id='input-employment-office'])[3]", - 'กรุงเทพมหานคร', - ); - await page.click("(//div[@id='select-business-type'])[3]"); - await page.click("//span[text()='ประมง']"); - await page.click("(//div[@id='select-job-position'])[3]"); - await page.click("(//div[@role='option'])[1]"); - await page.fill( - "(//input[@id='input-job-description'])[3]", - 'ตรวจสอบการทำการลักษณะงาน', - ); - await page.click("(//input[@aria-label='วันที่จ่ายค่าแรง'])[3]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2561']"); - await page.click("//div[text()='12']"); - await page.fill("(//input[@id='input-sales-person'])[3]", 'พนักงานขาย'); - await page.fill("(//input[@id='input-mail'])[3]", 'jws@local.com'); - await page.fill("(//input[@id='input-telephone'])[3]", '0864228464'); - await page.setInputFiles( - "(//input[contains(@class,'q-field__input fit')])[3]", - '/Users/linping/Desktop/Chamomind&FrappeT/JWS_TestScript/tests/Datafile/Pic1.jpg', - ); // UploadFile - await page.click('id=submitBtn'); - await page.waitForTimeout(2000); - await page.click('id=cancelBtn'); - await page.waitForTimeout(2000); -}); - -test('Create Natural Person Not Input Employee Office', async () => { - await page.click("(//div[@id='btn-add'])[1]"); - await page.click('id=add-customer-legal-entity'); - await page.click("(//div[@id='input-source-nationality'])[3]"); - await page.click("(//div[@id='input-source-nationality'])[3]"); - await page.fill("(//input[@id='input-customer-name'])[3]", 'ลอย'); - await page.fill("(//input[@id='input-customer-name-en'])[3]", 'Loi'); - await page.fill("(//input[@id='input-owner-name'])[3]", 'ปิงปิง'); - await page.fill("(//input[@id='input-customerEnglishName'])[3]", 'Silom'); - await page.fill("(//input[@id='input-customerName'])[3]", 'สีลม'); - - await page.fill("(//input[@id='input-taxNo'])[3]", '1284262822028'); - await page.fill("(//input[@id='input-registerName'])[3]", 'ปองพล กันธะณะ'); - await page.fill("(//input[@id='input-authorizedCapital'])[3]", '20000000'); - await page.click("(//input[@aria-label='จดทะเบียนเมื่อ'])[3]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2560']"); - await page.click("(//div[text()='30'])[2]"); - await page.fill("(//input[@id='input-address-0'])[3]", '20/02'); - await page.click("(//div[@id='select-province-0'])[3]"); - await page.click("//span[text()='เชียงใหม่']"); - await page.click("(//div[@id='select-district-0'])[3]"); - await page.click("//span[text()='สารภี']"); - await page.click("(//div[@id='select-sub-district-0'])[3]"); - await page.click("//span[text()='ท่าวังตาล']"); - await page.fill("(//input[@id='input-address-en-0'])[3]", '20/02'); - await page.click("(//div[@id='select-business-type'])[3]"); - await page.click("//span[text()='ประมง']"); - await page.click("(//div[@id='select-job-position'])[3]"); - await page.click("(//div[@role='option'])[1]"); - await page.fill( - "(//input[@id='input-job-description'])[3]", - 'ตรวจสอบการทำการลักษณะงาน', - ); - await page.click("(//input[@aria-label='วันที่จ่ายค่าแรง'])[3]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2561']"); - await page.click("//div[text()='12']"); - await page.fill("(//input[@id='input-sales-person'])[3]", 'พนักงานขาย'); - await page.fill("(//input[@id='input-mail'])[3]", 'jws@local.com'); - await page.fill("(//input[@id='input-telephone'])[3]", '0864228464'); - await page.setInputFiles( - "(//input[contains(@class,'q-field__input fit')])[3]", - '/Users/linping/Desktop/Chamomind&FrappeT/JWS_TestScript/tests/Datafile/Pic1.jpg', - ); // UploadFile - await page.click('id=submitBtn'); - await page.waitForTimeout(2000); -}); - -test('Create Natural Person Not Select Business Type', async () => { - await page.click("(//div[@id='btn-add'])[1]"); - await page.click('id=add-customer-legal-entity'); - await page.click("(//div[@id='input-source-nationality'])[3]"); - await page.click("(//div[@id='input-source-nationality'])[3]"); - await page.fill("(//input[@id='input-customer-name'])[3]", 'ลอย'); - await page.fill("(//input[@id='input-customer-name-en'])[3]", 'Loi'); - await page.fill("(//input[@id='input-owner-name'])[3]", 'ปิงปิง'); - await page.fill("(//input[@id='input-customerEnglishName'])[3]", 'Silom'); - await page.fill("(//input[@id='input-customerName'])[3]", 'สีลม'); - - await page.fill("(//input[@id='input-taxNo'])[3]", '1284262822028'); - await page.fill("(//input[@id='input-registerName'])[3]", 'ปองพล กันธะณะ'); - await page.fill("(//input[@id='input-authorizedCapital'])[3]", '20000000'); - await page.click("(//input[@aria-label='จดทะเบียนเมื่อ'])[3]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2560']"); - await page.click("(//div[text()='30'])[2]"); - await page.fill("(//input[@id='input-address-0'])[3]", '20/02'); - await page.click("(//div[@id='select-province-0'])[3]"); - await page.click("//span[text()='เชียงใหม่']"); - await page.click("(//div[@id='select-district-0'])[3]"); - await page.click("//span[text()='สารภี']"); - await page.click("(//div[@id='select-sub-district-0'])[3]"); - await page.click("//span[text()='ท่าวังตาล']"); - await page.fill("(//input[@id='input-address-en-0'])[3]", '20/02'); - await page.fill( - "(//input[@id='input-employment-office'])[3]", - 'กรุงเทพมหานคร', - ); - await page.click("(//div[@id='select-job-position'])[3]"); - await page.click("(//div[@role='option'])[1]"); - await page.fill( - "(//input[@id='input-job-description'])[3]", - 'ตรวจสอบการทำการลักษณะงาน', - ); - await page.click("(//input[@aria-label='วันที่จ่ายค่าแรง'])[3]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2561']"); - await page.click("//div[text()='12']"); - await page.fill("(//input[@id='input-sales-person'])[3]", 'พนักงานขาย'); - await page.fill("(//input[@id='input-mail'])[3]", 'jws@local.com'); - await page.fill("(//input[@id='input-telephone'])[3]", '0864228464'); - await page.setInputFiles( - "(//input[contains(@class,'q-field__input fit')])[3]", - '/Users/linping/Desktop/Chamomind&FrappeT/JWS_TestScript/tests/Datafile/Pic1.jpg', - ); // UploadFile - await page.click('id=submitBtn'); - await page.waitForTimeout(2000); -}); - -test('Create Natural Person Not Select Job Position', async () => { - await page.click("(//div[@id='btn-add'])[1]"); - await page.click('id=add-customer-legal-entity'); - await page.click("(//div[@id='input-source-nationality'])[3]"); - await page.click("(//div[@id='input-source-nationality'])[3]"); - await page.fill("(//input[@id='input-customer-name'])[3]", 'ลอย'); - await page.fill("(//input[@id='input-customer-name-en'])[3]", 'Loi'); - await page.fill("(//input[@id='input-owner-name'])[3]", 'ปิงปิง'); - await page.fill("(//input[@id='input-customerEnglishName'])[3]", 'Silom'); - await page.fill("(//input[@id='input-customerName'])[3]", 'สีลม'); - - await page.fill("(//input[@id='input-taxNo'])[3]", '1284262822028'); - await page.fill("(//input[@id='input-registerName'])[3]", 'ปองพล กันธะณะ'); - await page.fill("(//input[@id='input-authorizedCapital'])[3]", '20000000'); - await page.click("(//input[@aria-label='จดทะเบียนเมื่อ'])[3]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2560']"); - await page.click("(//div[text()='30'])[2]"); - await page.fill("(//input[@id='input-address-0'])[3]", '20/02'); - await page.click("(//div[@id='select-province-0'])[3]"); - await page.click("//span[text()='เชียงใหม่']"); - await page.click("(//div[@id='select-district-0'])[3]"); - await page.click("//span[text()='สารภี']"); - await page.click("(//div[@id='select-sub-district-0'])[3]"); - await page.click("//span[text()='ท่าวังตาล']"); - await page.fill("(//input[@id='input-address-en-0'])[3]", '20/02'); - await page.fill( - "(//input[@id='input-employment-office'])[3]", - 'กรุงเทพมหานคร', - ); - await page.click("(//div[@id='select-business-type'])[3]"); - await page.click("//span[text()='ประมง']"); - await page.fill( - "(//input[@id='input-job-description'])[3]", - 'ตรวจสอบการทำการลักษณะงาน', - ); - await page.click("(//input[@aria-label='วันที่จ่ายค่าแรง'])[3]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2561']"); - await page.click("//div[text()='12']"); - await page.fill("(//input[@id='input-sales-person'])[3]", 'พนักงานขาย'); - await page.fill("(//input[@id='input-mail'])[3]", 'jws@local.com'); - await page.fill("(//input[@id='input-telephone'])[3]", '0864228464'); - await page.setInputFiles( - "(//input[contains(@class,'q-field__input fit')])[3]", - '/Users/linping/Desktop/Chamomind&FrappeT/JWS_TestScript/tests/Datafile/Pic1.jpg', - ); // UploadFile - await page.click('id=submitBtn'); - await page.waitForTimeout(2000); -}); - -test('Create Natural Person Not Input Job Discription', async () => { - await page.click("(//div[@id='btn-add'])[1]"); - await page.click('id=add-customer-legal-entity'); - await page.click("(//div[@id='input-source-nationality'])[3]"); - await page.click("(//div[@id='input-source-nationality'])[3]"); - await page.fill("(//input[@id='input-customer-name'])[3]", 'ลอย'); - await page.fill("(//input[@id='input-customer-name-en'])[3]", 'Loi'); - await page.fill("(//input[@id='input-owner-name'])[3]", 'ปิงปิง'); - await page.fill("(//input[@id='input-customerEnglishName'])[3]", 'Silom'); - await page.fill("(//input[@id='input-customerName'])[3]", 'สีลม'); - - await page.fill("(//input[@id='input-taxNo'])[3]", '1284262822028'); - await page.fill("(//input[@id='input-registerName'])[3]", 'ปองพล กันธะณะ'); - await page.fill("(//input[@id='input-authorizedCapital'])[3]", '20000000'); - await page.click("(//input[@aria-label='จดทะเบียนเมื่อ'])[3]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2560']"); - await page.click("(//div[text()='30'])[2]"); - await page.fill("(//input[@id='input-address-0'])[3]", '20/02'); - await page.click("(//div[@id='select-province-0'])[3]"); - await page.click("//span[text()='เชียงใหม่']"); - await page.click("(//div[@id='select-district-0'])[3]"); - await page.click("//span[text()='สารภี']"); - await page.click("(//div[@id='select-sub-district-0'])[3]"); - await page.click("//span[text()='ท่าวังตาล']"); - await page.fill("(//input[@id='input-address-en-0'])[3]", '20/02'); - await page.fill( - "(//input[@id='input-employment-office'])[3]", - 'กรุงเทพมหานคร', - ); - await page.click("(//div[@id='select-business-type'])[3]"); - await page.click("//span[text()='ประมง']"); - await page.click("(//div[@id='select-job-position'])[3]"); - await page.click("(//div[@role='option'])[1]"); - await page.click("(//input[@aria-label='วันที่จ่ายค่าแรง'])[3]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2561']"); - await page.click("//div[text()='12']"); - await page.fill("(//input[@id='input-sales-person'])[3]", 'พนักงานขาย'); - await page.fill("(//input[@id='input-mail'])[3]", 'jws@local.com'); - await page.fill("(//input[@id='input-telephone'])[3]", '0864228464'); - await page.setInputFiles( - "(//input[contains(@class,'q-field__input fit')])[3]", - '/Users/linping/Desktop/Chamomind&FrappeT/JWS_TestScript/tests/Datafile/Pic1.jpg', - ); // UploadFile - await page.click('id=submitBtn'); - await page.waitForTimeout(2000); -}); - -test('Create Natural Person Not Select Paydate', async () => { - await page.click("(//div[@id='btn-add'])[1]"); - await page.click('id=add-customer-legal-entity'); - await page.click("(//div[@id='input-source-nationality'])[3]"); - await page.click("(//div[@id='input-source-nationality'])[3]"); - await page.fill("(//input[@id='input-customer-name'])[3]", 'ลอย'); - await page.fill("(//input[@id='input-customer-name-en'])[3]", 'Loi'); - await page.fill("(//input[@id='input-owner-name'])[3]", 'ปิงปิง'); - await page.fill("(//input[@id='input-customerEnglishName'])[3]", 'Silom'); - await page.fill("(//input[@id='input-customerName'])[3]", 'สีลม'); - - await page.fill("(//input[@id='input-taxNo'])[3]", '1284262822028'); - await page.fill("(//input[@id='input-registerName'])[3]", 'ปองพล กันธะณะ'); - await page.fill("(//input[@id='input-authorizedCapital'])[3]", '20000000'); - await page.click("(//input[@aria-label='จดทะเบียนเมื่อ'])[3]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2560']"); - await page.click("(//div[text()='30'])[2]"); - await page.fill("(//input[@id='input-address-0'])[3]", '20/02'); - await page.click("(//div[@id='select-province-0'])[3]"); - await page.click("//span[text()='เชียงใหม่']"); - await page.click("(//div[@id='select-district-0'])[3]"); - await page.click("//span[text()='สารภี']"); - await page.click("(//div[@id='select-sub-district-0'])[3]"); - await page.click("//span[text()='ท่าวังตาล']"); - await page.fill("(//input[@id='input-address-en-0'])[3]", '20/02'); - await page.fill( - "(//input[@id='input-employment-office'])[3]", - 'กรุงเทพมหานคร', - ); - await page.click("(//div[@id='select-business-type'])[3]"); - await page.click("//span[text()='ประมง']"); - await page.click("(//div[@id='select-job-position'])[3]"); - await page.click("(//div[@role='option'])[1]"); - await page.fill( - "(//input[@id='input-job-description'])[3]", - 'ตรวจสอบการทำการลักษณะงาน', - ); - await page.fill("(//input[@id='input-sales-person'])[3]", 'พนักงานขาย'); - await page.fill("(//input[@id='input-mail'])[3]", 'jws@local.com'); - await page.fill("(//input[@id='input-telephone'])[3]", '0864228464'); - await page.setInputFiles( - "(//input[contains(@class,'q-field__input fit')])[3]", - '/Users/linping/Desktop/Chamomind&FrappeT/JWS_TestScript/tests/Datafile/Pic1.jpg', - ); // UploadFile - await page.click('id=submitBtn'); - await page.waitForTimeout(2000); -}); - -test('Create Natural Person Not Input Sales Person', async () => { - await page.click("(//div[@id='btn-add'])[1]"); - await page.click('id=add-customer-legal-entity'); - await page.click("(//div[@id='input-source-nationality'])[3]"); - await page.click("(//div[@id='input-source-nationality'])[3]"); - await page.fill("(//input[@id='input-customer-name'])[3]", 'ลอย'); - await page.fill("(//input[@id='input-customer-name-en'])[3]", 'Loi'); - await page.fill("(//input[@id='input-owner-name'])[3]", 'ปิงปิง'); - await page.fill("(//input[@id='input-customerEnglishName'])[3]", 'Silom'); - await page.fill("(//input[@id='input-customerName'])[3]", 'สีลม'); - - await page.fill("(//input[@id='input-taxNo'])[3]", '1284262822028'); - await page.fill("(//input[@id='input-registerName'])[3]", 'ปองพล กันธะณะ'); - await page.fill("(//input[@id='input-authorizedCapital'])[3]", '20000000'); - await page.click("(//input[@aria-label='จดทะเบียนเมื่อ'])[3]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2560']"); - await page.click("(//div[text()='30'])[2]"); - await page.fill("(//input[@id='input-address-0'])[3]", '20/02'); - await page.click("(//div[@id='select-province-0'])[3]"); - await page.click("//span[text()='เชียงใหม่']"); - await page.click("(//div[@id='select-district-0'])[3]"); - await page.click("//span[text()='สารภี']"); - await page.click("(//div[@id='select-sub-district-0'])[3]"); - await page.click("//span[text()='ท่าวังตาล']"); - await page.fill("(//input[@id='input-address-en-0'])[3]", '20/02'); - await page.fill( - "(//input[@id='input-employment-office'])[3]", - 'กรุงเทพมหานคร', - ); - await page.click("(//div[@id='select-business-type'])[3]"); - await page.click("//span[text()='ประมง']"); - await page.click("(//div[@id='select-job-position'])[3]"); - await page.click("(//div[@role='option'])[1]"); - await page.fill( - "(//input[@id='input-job-description'])[3]", - 'ตรวจสอบการทำการลักษณะงาน', - ); - await page.click("(//input[@aria-label='วันที่จ่ายค่าแรง'])[3]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2561']"); - await page.click("//div[text()='12']"); - await page.fill("(//input[@id='input-sales-person'])[3]", ''); - await page.fill("(//input[@id='input-mail'])[3]", 'jws@local.com'); - await page.fill("(//input[@id='input-telephone'])[3]", '0864228464'); - await page.setInputFiles( - "(//input[contains(@class,'q-field__input fit')])[3]", - '/Users/linping/Desktop/Chamomind&FrappeT/JWS_TestScript/tests/Datafile/Pic1.jpg', - ); // UploadFile - await page.click('id=submitBtn'); - await page.waitForTimeout(2000); -}); - -test('Create Natural Person Not Input Email', async () => { - await page.click("(//div[@id='btn-add'])[1]"); - await page.click('id=add-customer-legal-entity'); - await page.click("(//div[@id='input-source-nationality'])[3]"); - await page.click("(//div[@id='input-source-nationality'])[3]"); - await page.fill("(//input[@id='input-customer-name'])[3]", 'ลอย'); - await page.fill("(//input[@id='input-customer-name-en'])[3]", 'Loi'); - await page.fill("(//input[@id='input-owner-name'])[3]", 'ปิงปิง'); - await page.fill("(//input[@id='input-customerEnglishName'])[3]", 'Silom'); - await page.fill("(//input[@id='input-customerName'])[3]", 'สีลม'); - - await page.fill("(//input[@id='input-taxNo'])[3]", '1284262822028'); - await page.fill("(//input[@id='input-registerName'])[3]", 'ปองพล กันธะณะ'); - await page.fill("(//input[@id='input-authorizedCapital'])[3]", '20000000'); - await page.click("(//input[@aria-label='จดทะเบียนเมื่อ'])[3]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2560']"); - await page.click("(//div[text()='30'])[2]"); - await page.fill("(//input[@id='input-address-0'])[3]", '20/02'); - await page.click("(//div[@id='select-province-0'])[3]"); - await page.click("//span[text()='เชียงใหม่']"); - await page.click("(//div[@id='select-district-0'])[3]"); - await page.click("//span[text()='สารภี']"); - await page.click("(//div[@id='select-sub-district-0'])[3]"); - await page.click("//span[text()='ท่าวังตาล']"); - await page.fill("(//input[@id='input-address-en-0'])[3]", '20/02'); - await page.fill( - "(//input[@id='input-employment-office'])[3]", - 'กรุงเทพมหานคร', - ); - await page.click("(//div[@id='select-business-type'])[3]"); - await page.click("//span[text()='ประมง']"); - await page.click("(//div[@id='select-job-position'])[3]"); - await page.click("(//div[@role='option'])[1]"); - await page.fill( - "(//input[@id='input-job-description'])[3]", - 'ตรวจสอบการทำการลักษณะงาน', - ); - await page.click("(//input[@aria-label='วันที่จ่ายค่าแรง'])[3]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2561']"); - await page.click("//div[text()='12']"); - await page.fill("(//input[@id='input-sales-person'])[3]", 'พนักงานขาย'); - await page.fill("(//input[@id='input-mail'])[3]", ''); - await page.fill("(//input[@id='input-telephone'])[3]", '0864228464'); - await page.setInputFiles( - "(//input[contains(@class,'q-field__input fit')])[3]", - '/Users/linping/Desktop/Chamomind&FrappeT/JWS_TestScript/tests/Datafile/Pic1.jpg', - ); // UploadFile - await page.click('id=submitBtn'); - await page.waitForTimeout(2000); -}); - -test('Create Natural Person Not Input Telephone Number', async () => { - await page.click("(//div[@id='btn-add'])[1]"); - await page.click('id=add-customer-legal-entity'); - await page.click("(//div[@id='input-source-nationality'])[3]"); - await page.click("(//div[@id='input-source-nationality'])[3]"); - await page.fill("(//input[@id='input-customer-name'])[3]", 'ลอย'); - await page.fill("(//input[@id='input-customer-name-en'])[3]", 'Loi'); - await page.fill("(//input[@id='input-owner-name'])[3]", 'ปิงปิง'); - await page.fill("(//input[@id='input-customerEnglishName'])[3]", 'Silom'); - await page.fill("(//input[@id='input-customerName'])[3]", 'สีลม'); - - await page.fill("(//input[@id='input-taxNo'])[3]", '1284262822028'); - await page.fill("(//input[@id='input-registerName'])[3]", 'ปองพล กันธะณะ'); - await page.fill("(//input[@id='input-authorizedCapital'])[3]", '20000000'); - await page.click("(//input[@aria-label='จดทะเบียนเมื่อ'])[3]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2560']"); - await page.click("(//div[text()='30'])[2]"); - await page.fill("(//input[@id='input-address-0'])[3]", '20/02'); - await page.click("(//div[@id='select-province-0'])[3]"); - await page.click("//span[text()='เชียงใหม่']"); - await page.click("(//div[@id='select-district-0'])[3]"); - await page.click("//span[text()='สารภี']"); - await page.click("(//div[@id='select-sub-district-0'])[3]"); - await page.click("//span[text()='ท่าวังตาล']"); - await page.fill("(//input[@id='input-address-en-0'])[3]", '20/02'); - await page.fill( - "(//input[@id='input-employment-office'])[3]", - 'กรุงเทพมหานคร', - ); - await page.click("(//div[@id='select-business-type'])[3]"); - await page.click("//span[text()='ประมง']"); - await page.click("(//div[@id='select-job-position'])[3]"); - await page.click("(//div[@role='option'])[1]"); - await page.fill( - "(//input[@id='input-job-description'])[3]", - 'ตรวจสอบการทำการลักษณะงาน', - ); - await page.click("(//input[@aria-label='วันที่จ่ายค่าแรง'])[3]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2561']"); - await page.click("//div[text()='12']"); - await page.fill("(//input[@id='input-sales-person'])[3]", 'พนักงานขาย'); - await page.fill("(//input[@id='input-mail'])[3]", 'jws@local.com'); - await page.fill("(//input[@id='input-telephone'])[3]", ''); - await page.setInputFiles( - "(//input[contains(@class,'q-field__input fit')])[3]", - '/Users/linping/Desktop/Chamomind&FrappeT/JWS_TestScript/tests/Datafile/Pic1.jpg', - ); // UploadFile - await page.click('id=submitBtn'); - await page.waitForTimeout(2000); -}); - -test('Create Natural Person Not Input File', async () => { - await page.click("(//div[@id='btn-add'])[1]"); - await page.click('id=add-customer-legal-entity'); - await page.click("(//div[@id='input-source-nationality'])[3]"); - await page.click("(//div[@id='input-source-nationality'])[3]"); - await page.fill("(//input[@id='input-customer-name'])[3]", 'ลอย'); - await page.fill("(//input[@id='input-customer-name-en'])[3]", 'Loi'); - await page.fill("(//input[@id='input-owner-name'])[3]", 'ปิงปิง'); - await page.fill("(//input[@id='input-customerEnglishName'])[3]", 'Silom'); - await page.fill("(//input[@id='input-customerName'])[3]", 'สีลม'); - - await page.fill("(//input[@id='input-taxNo'])[3]", '1284262822028'); - await page.fill("(//input[@id='input-registerName'])[3]", 'ปองพล กันธะณะ'); - await page.fill("(//input[@id='input-authorizedCapital'])[3]", '20000000'); - await page.click("(//input[@aria-label='จดทะเบียนเมื่อ'])[3]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2560']"); - await page.click("(//div[text()='30'])[2]"); - await page.fill("(//input[@id='input-address-0'])[3]", '20/02'); - await page.click("(//div[@id='select-province-0'])[3]"); - await page.click("//span[text()='เชียงใหม่']"); - await page.click("(//div[@id='select-district-0'])[3]"); - await page.click("//span[text()='สารภี']"); - await page.click("(//div[@id='select-sub-district-0'])[3]"); - await page.click("//span[text()='ท่าวังตาล']"); - await page.fill("(//input[@id='input-address-en-0'])[3]", '20/02'); - await page.fill( - "(//input[@id='input-employment-office'])[3]", - 'กรุงเทพมหานคร', - ); - await page.click("(//div[@id='select-business-type'])[3]"); - await page.click("//span[text()='ประมง']"); - await page.click("(//div[@id='select-job-position'])[3]"); - await page.click("(//div[@role='option'])[1]"); - await page.fill( - "(//input[@id='input-job-description'])[3]", - 'ตรวจสอบการทำการลักษณะงาน', - ); - await page.click("(//input[@aria-label='วันที่จ่ายค่าแรง'])[3]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2561']"); - await page.click("//div[text()='12']"); - await page.fill("(//input[@id='input-sales-person'])[3]", 'พนักงานขาย'); - await page.fill("(//input[@id='input-mail'])[3]", 'jws@local.com'); - await page.fill("(//input[@id='input-telephone'])[3]", '0864228464'); - await page.click('id=submitBtn'); - await page.waitForTimeout(2000); -}); diff --git a/tests/03-Admin-ManageCustomer/JWS_MC_010_EditLegalentitly.spec.ts b/tests/03-Admin-ManageCustomer/JWS_MC_010_EditLegalentitly.spec.ts deleted file mode 100644 index 15fe13cb..00000000 --- a/tests/03-Admin-ManageCustomer/JWS_MC_010_EditLegalentitly.spec.ts +++ /dev/null @@ -1,37 +0,0 @@ -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.62:20101/'); - 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 Legalentitly ', async () => { - await page.click('id=menu-icon-customer-management'); - await page.click("//button[@id='btn-dots-CORP000002']"); - await page.click('id=view-detail-btn-undefined-edit'); - await page.click("(//div[@id='input-source-nationality'])[1]"); - await page.click("//span[text()='บางรัก']"); - await page.fill("(//input[@id='input-customerEnglishName'])[1]", 'Bangrak'); - await page.fill("(//input[@id='input-customerName'])[1]", 'บางรัก'); - await page.click('id=submitBtn'); - await page.waitForTimeout(2000); -}); diff --git a/tests/03-Admin-ManageCustomer/JWS_MC_011_DeleteLegalentitly.spec.ts b/tests/03-Admin-ManageCustomer/JWS_MC_011_DeleteLegalentitly.spec.ts deleted file mode 100644 index 9c62e124..00000000 --- a/tests/03-Admin-ManageCustomer/JWS_MC_011_DeleteLegalentitly.spec.ts +++ /dev/null @@ -1,35 +0,0 @@ -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.62:20101/'); - 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('Delete Legalentitly', async () => { - // รออัพเดท PATH - await page.click('id=menu-icon-customer-management'); - await page.click("//button[@id='btn-dots-CORP000002']"); - - await page.click('id=view-detail-btn-undefined-delete'); - await page.click('id=btn-ok-dialog'); - await page.waitForTimeout(2000); -}); diff --git a/tests/03-Admin-ManageCustomer/JWS_MC_012_StatusLegalentitly.spec.ts b/tests/03-Admin-ManageCustomer/JWS_MC_012_StatusLegalentitly.spec.ts deleted file mode 100644 index 91d979bb..00000000 --- a/tests/03-Admin-ManageCustomer/JWS_MC_012_StatusLegalentitly.spec.ts +++ /dev/null @@ -1,39 +0,0 @@ -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.62:20101/'); - 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('Status Off Legalentitly', async () => { - await page.click('id=menu-icon-customer-management'); - await page.click("//button[@id='btn-dots-CORP000002']"); - await page.click('id=view-detail-btn-undefined-status'); - await page.waitForTimeout(2000); -}); - -test('Status On Legalentitly', async () => { - await page.click("//button[@id='btn-dots-CORP000002']"); - await page.waitForTimeout(2000); - await page.click('id=view-detail-btn-undefined-status'); - await page.waitForTimeout(2000); -}); diff --git a/tests/03-Admin-ManageCustomer/JWS_MC_013_DropdownEmployertype.spec.ts b/tests/03-Admin-ManageCustomer/JWS_MC_013_DropdownEmployertype.spec.ts deleted file mode 100644 index 7932ed91..00000000 --- a/tests/03-Admin-ManageCustomer/JWS_MC_013_DropdownEmployertype.spec.ts +++ /dev/null @@ -1,57 +0,0 @@ -import { test, expect, Page } from '@playwright/test'; -import { strictEqual } from 'assert'; -import { escape } from 'querystring'; - -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.62:20101/'); - 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('Select Dropdown Employer Type Off', async () => { - await page.click('id=menu-icon-customer-management'); - await page.click('id=select-field'); - await page.click('id=select-field_0'); - await page.waitForTimeout(2000); - await page.click('id=select-field_1'); - await page.waitForTimeout(2000); - await page.click('id=select-field_2'); - await page.waitForTimeout(2000); - await page.click('id=select-field_3'); - await page.waitForTimeout(2000); - await page.click('id=select-field_4'); - await page.waitForTimeout(2000); - await page.keyboard.press('Escape'); - await page.waitForTimeout(2000); -}); - -test('Select Dropdown Employer Type on', async () => { - await page.click('id=select-field'); - await page.click('id=select-field_0'); - await page.waitForTimeout(2000); - await page.click('id=select-field_1'); - await page.waitForTimeout(2000); - await page.click('id=select-field_2'); - await page.waitForTimeout(2000); - await page.click('id=select-field_3'); - await page.waitForTimeout(2000); - await page.click('id=select-field_4'); - await page.waitForTimeout(2000); -}); diff --git a/tests/03-Admin-ManageCustomer/JWS_MC_014_SearchManageCustomer.spec.ts b/tests/03-Admin-ManageCustomer/JWS_MC_014_SearchManageCustomer.spec.ts deleted file mode 100644 index e9769413..00000000 --- a/tests/03-Admin-ManageCustomer/JWS_MC_014_SearchManageCustomer.spec.ts +++ /dev/null @@ -1,43 +0,0 @@ -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.62:20101/'); - 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('Selete Filter Manage Customer Active', async () => { - await page.click('id=menu-icon-customer-management'); - await page.fill('id=input-search', 'โค'); - await page.waitForTimeout(2000); - await page.fill('id=input-search', 'โคโม่'); - await page.waitForTimeout(2000); - await page.fill('id=input-search', 'นิติบุคคล'); - await page.waitForTimeout(2000); - await page.fill('id=input-search', 'Como'); - await page.waitForTimeout(2000); - await page.fill('id=input-search', 'Co'); - await page.waitForTimeout(2000); - await page.fill('id=input-search', 'Lab'); - await page.waitForTimeout(2000); - await page.fill('id=input-search', 'L'); - await page.waitForTimeout(2000); -}); diff --git a/tests/03-Admin-ManageCustomer/JWS_MC_015_FilterManageStatusCustomer.spec.ts b/tests/03-Admin-ManageCustomer/JWS_MC_015_FilterManageStatusCustomer.spec.ts deleted file mode 100644 index 1443c393..00000000 --- a/tests/03-Admin-ManageCustomer/JWS_MC_015_FilterManageStatusCustomer.spec.ts +++ /dev/null @@ -1,44 +0,0 @@ -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.62:20101/'); - 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('Selete Filter Manage Customer Active', async () => { - await page.click('id=menu-icon-customer-management'); - await page.click('id=select-status'); - await page.click('id=select-status_1'); - await page.waitForTimeout(2000); -}); - -test('Selete Filter Manage Customer Inative', async () => { - await page.click('id=select-status'); - await page.click('id=select-status_2'); - await page.waitForTimeout(2000); -}); - -test('Selete Filter Manage Customer All', async () => { - await page.click('id=select-status'); - await page.click('id=select-status_0'); - await page.waitForTimeout(2000); -}); diff --git a/tests/03-Admin-ManageCustomer/JWS_MC_016_CreateEmployee.spec.ts b/tests/03-Admin-ManageCustomer/JWS_MC_016_CreateEmployee.spec.ts deleted file mode 100644 index 8af5d252..00000000 --- a/tests/03-Admin-ManageCustomer/JWS_MC_016_CreateEmployee.spec.ts +++ /dev/null @@ -1,98 +0,0 @@ -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.62:20101/'); - 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('Select Employee Tab', async () => { - await page.click('id=menu-icon-customer-management'); - await page.click('id=tab-employee'); - await page.click('id=btn-add'); - await page.click('id=add-employee'); - await page.waitForTimeout(2000); -}); - -test('Create Employee', async () => { - await page.click("(//input[@id='select-employer-branch'])[2]"); - await page.click('id=select-employer-branch_0'); - await page.fill("(//input[@id='input-nrcNo'])[2]", '6282282246226'); - await page.fill("(//input[@id='input-first-name'])[2]", 'ปองพล'); - await page.fill("(//input[@id='input-last-name'])[2]", 'กันธะณะ'); - await page.fill("(//input[@id='input-first-name-en'])[2]", 'Pongpon'); - await page.fill("(//input[@id='input-last-name-en'])[2]", 'Kuntana'); - await page.click("(//input[@id='input-birth-date'])[2]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2536']"); - await page.click("//div[text()='8']"); - await page.click("(//div[@id='select-gender'])[2]"); - await page.click("//span[text()='หญิง']"); - await page.click("(//div[@id='select-nationality'])[2]"); - await page.waitForTimeout(2000); - await page.click("(//div[@role='option'])[1]"); - await page.waitForTimeout(2000); -}); - -test('Create Detail OCR ', async () => { - await page.click("(//div[@id='select-passport-type'])[2]"); - await page.click("(//div[@role='option'])[1]"); - await page.fill("(//input[@id='input-passport-no'])[2]", 'TH2862242226262'); - await page.fill("(//input[@id='input-passport-ref'])[2]", '2042022022426'); - await page.fill("(//input[@id='input-passport-place'])[2]", 'Bangkok'); - await page.click("(//div[@id='select-passport-country'])[2]"); - await page.waitForTimeout(2000); - await page.click("(//div[@role='option'])[1]"); - await page.click("(//input[@aria-label='วันที่ออกหนังสือเดินทาง'])[2]"); - await page.click("(//div[text()='2'])[1]"); - await page.click("(//input[@aria-label='วันหมดอายุหนังสือเดินทาง'])[2]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2574']"); - await page.click("//div[text()='8']"); - await page.waitForTimeout(2000); -}); - -test('Create VISA OCR', async () => { - await page.click("(//div[@id='select-visa-type'])[2]"); - await page.waitForTimeout(2000); - await page.click("(//div[@role='option'])[1]"); - await page.fill("(//input[@id='input-visa-no'])[2]", '200222'); - await page.click("(//input[@aria-label='ออกให้วันที่'])[2]"); - await page.click("//div[text()='18']"); - await page.click("(//input[@aria-label='ใช้ได้ถึงวันที่'])[2]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2568']"); - await page.click("//div[text()='8']"); - await page.fill( - "(//input[@id='input-visa-place'])[2]", - 'กรมตรวจคนเข้าเมืองน่าน', - ); - await page.click("(//input[@aria-label='ให้อยู่ในราชอาณาจักรถึงวันที่'])[2]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2568']"); - await page.click("//div[text()='12']"); - await page.fill("(//input[@id='input-tm6'])[2]", '204422002'); - await page.click("(//input[@aria-label='วันที่เดินทางเข้ามาในประเทศ'])[2]"); - await page.click("//div[text()='18']"); - await page.click('id=submitBtn'); - await page.click('id=btn-ok-dialog'); - await page.waitForTimeout(2000); -}); diff --git a/tests/03-Admin-ManageCustomer/JWS_MC_017_CreateEmployeeFail.spec.ts b/tests/03-Admin-ManageCustomer/JWS_MC_017_CreateEmployeeFail.spec.ts deleted file mode 100644 index f25a14cf..00000000 --- a/tests/03-Admin-ManageCustomer/JWS_MC_017_CreateEmployeeFail.spec.ts +++ /dev/null @@ -1,297 +0,0 @@ -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.62:20101/'); - 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('Select Employee Tab', async () => { - await page.click('id=menu-icon-customer-management'); - await page.waitForTimeout(2000); -}); - -test('Create Employee Not Input Data', async () => { - await page.click('id=tab-employee'); - await page.click('id=btn-add'); - await page.click('id=add-employee'); - await page.click('id=submitBtn'); - await page.click('id=cancelBtn'); - await page.waitForTimeout(2000); -}); - -test('Create Employee Not Select Employee Code ', async () => { - await page.click('id=btn-add'); - await page.click('id=add-employee'); - await page.fill("(//input[@id='input-nrcNo'])[2]", '6282282246226'); - await page.fill("(//input[@id='input-first-name'])[2]", 'ปองพล'); - await page.fill("(//input[@id='input-last-name'])[2]", 'กันธะณะ'); - await page.fill("(//input[@id='input-first-name-en'])[2]", 'Pongpon'); - await page.fill("(//input[@id='input-last-name-en'])[2]", 'Kuntana'); - await page.click("(//input[@id='input-birth-date'])[2]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2536']"); - await page.click("//div[text()='8']"); - await page.click("(//div[@id='select-gender'])[2]"); - await page.click("//span[text()='หญิง']"); - await page.click("(//div[@id='select-nationality'])[2]"); - await page.waitForTimeout(2000); - await page.click("(//div[@role='option'])[1]"); - await page.waitForTimeout(2000); - await page.click("(//div[@id='select-passport-type'])[2]"); - await page.click("(//div[@role='option'])[1]"); - await page.fill("(//input[@id='input-passport-no'])[2]", 'TH2862242226262'); - await page.fill("(//input[@id='input-passport-ref'])[2]", '2042022022426'); - await page.fill("(//input[@id='input-passport-place'])[2]", 'Bangkok'); - await page.click("(//div[@id='select-passport-country'])[2]"); - await page.waitForTimeout(2000); - await page.click("(//div[@role='option'])[1]"); - await page.click("(//input[@aria-label='วันที่ออกหนังสือเดินทาง'])[2]"); - await page.click("(//div[text()='2'])[1]"); - await page.click("(//input[@aria-label='วันหมดอายุหนังสือเดินทาง'])[2]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2574']"); - await page.click("//div[text()='8']"); - await page.waitForTimeout(2000); - await page.click("(//div[@id='select-visa-type'])[2]"); - await page.waitForTimeout(2000); - await page.click("(//div[@role='option'])[1]"); - await page.fill("(//input[@id='input-visa-no'])[2]", '200222'); - await page.click("(//input[@aria-label='ออกให้วันที่'])[2]"); - await page.click("//div[text()='18']"); - await page.click("(//input[@aria-label='ใช้ได้ถึงวันที่'])[2]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2568']"); - await page.click("//div[text()='8']"); - await page.fill( - "(//input[@id='input-visa-place'])[2]", - 'กรมตรวจคนเข้าเมืองน่าน', - ); - await page.click("(//input[@aria-label='ให้อยู่ในราชอาณาจักรถึงวันที่'])[2]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2568']"); - await page.click("//div[text()='12']"); - await page.fill("(//input[@id='input-tm6'])[2]", '204422002'); - await page.click("(//input[@aria-label='วันที่เดินทางเข้ามาในประเทศ'])[2]"); - await page.click("//div[text()='18']"); - await page.click('id=submitBtn'); - await page.click('id=cancelBtn'); - await page.waitForTimeout(2000); -}); - -test('Create Employee Not Input Personal Information ', async () => { - await page.click('id=btn-add'); - await page.click('id=add-employee'); - await page.click("(//input[@id='select-employer-branch'])[2]"); - await page.click('id=select-employer-branch_0'); - await page.fill("(//input[@id='input-nrcNo'])[2]", '6282282246226'); - - await page.click("(//div[@id='select-passport-type'])[2]"); - await page.click("(//div[@role='option'])[1]"); - await page.fill("(//input[@id='input-passport-no'])[2]", 'TH2862242226262'); - await page.fill("(//input[@id='input-passport-ref'])[2]", '2042022022426'); - await page.fill("(//input[@id='input-passport-place'])[2]", 'Bangkok'); - await page.click("(//div[@id='select-passport-country'])[2]"); - await page.waitForTimeout(2000); - await page.click("(//div[@role='option'])[1]"); - await page.click("(//input[@aria-label='วันที่ออกหนังสือเดินทาง'])[2]"); - await page.click("(//div[text()='2'])[1]"); - await page.click("(//input[@aria-label='วันหมดอายุหนังสือเดินทาง'])[2]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2574']"); - await page.click("//div[text()='8']"); - await page.waitForTimeout(2000); - - await page.click("(//div[@id='select-visa-type'])[2]"); - await page.waitForTimeout(2000); - await page.click("(//div[@role='option'])[1]"); - await page.fill("(//input[@id='input-visa-no'])[2]", '200222'); - await page.click("(//input[@aria-label='ออกให้วันที่'])[2]"); - await page.click("//div[text()='18']"); - await page.click("(//input[@aria-label='ใช้ได้ถึงวันที่'])[2]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2568']"); - await page.click("//div[text()='8']"); - await page.fill( - "(//input[@id='input-visa-place'])[2]", - 'กรมตรวจคนเข้าเมืองน่าน', - ); - await page.click("(//input[@aria-label='ให้อยู่ในราชอาณาจักรถึงวันที่'])[2]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2568']"); - await page.click("//div[text()='12']"); - await page.fill("(//input[@id='input-tm6'])[2]", '204422002'); - await page.click("(//input[@aria-label='วันที่เดินทางเข้ามาในประเทศ'])[2]"); - await page.click("//div[text()='18']"); - await page.click('id=submitBtn'); - await page.click('id=btn-ok-dialog'); - await page.click('id=submitBtn'); - await page.click('id=cancelBtn'); - await page.waitForTimeout(2000); -}); - -test('Create Employee Not Input Personal Address ', async () => { - await page.click('id=btn-add'); - await page.click('id=add-employee'); - - await page.click("(//input[@id='select-employer-branch'])[2]"); - await page.click('id=select-employer-branch_0'); - await page.fill("(//input[@id='input-nrcNo'])[2]", '6282282246226'); - await page.fill("(//input[@id='input-first-name'])[2]", 'ปองพล'); - await page.fill("(//input[@id='input-last-name'])[2]", 'กันธะณะ'); - await page.fill("(//input[@id='input-first-name-en'])[2]", 'Pongpon'); - await page.fill("(//input[@id='input-last-name-en'])[2]", 'Kuntana'); - await page.click("(//input[@id='input-birth-date'])[2]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2536']"); - await page.click("//div[text()='8']"); - await page.click("(//div[@id='select-gender'])[2]"); - await page.click("//span[text()='หญิง']"); - await page.click("(//div[@id='select-nationality'])[2]"); - await page.waitForTimeout(2000); - await page.click("(//div[@role='option'])[1]"); - await page.waitForTimeout(2000); - - await page.click("(//div[@id='select-passport-type'])[2]"); - await page.click("(//div[@role='option'])[1]"); - await page.fill("(//input[@id='input-passport-no'])[2]", 'TH2862242226262'); - await page.fill("(//input[@id='input-passport-ref'])[2]", '2042022022426'); - await page.fill("(//input[@id='input-passport-place'])[2]", 'Bangkok'); - await page.click("(//div[@id='select-passport-country'])[2]"); - await page.waitForTimeout(2000); - await page.click("(//div[@role='option'])[1]"); - await page.click("(//input[@aria-label='วันที่ออกหนังสือเดินทาง'])[2]"); - await page.click("(//div[text()='2'])[1]"); - await page.click("(//input[@aria-label='วันหมดอายุหนังสือเดินทาง'])[2]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2574']"); - await page.click("//div[text()='8']"); - - await page.click("(//div[@id='select-visa-type'])[2]"); - await page.waitForTimeout(2000); - await page.click("(//div[@role='option'])[1]"); - await page.fill("(//input[@id='input-visa-no'])[2]", '200222'); - await page.click("(//input[@aria-label='ออกให้วันที่'])[2]"); - await page.click("//div[text()='18']"); - await page.click("(//input[@aria-label='ใช้ได้ถึงวันที่'])[2]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2568']"); - await page.click("//div[text()='8']"); - await page.fill( - "(//input[@id='input-visa-place'])[2]", - 'กรมตรวจคนเข้าเมืองน่าน', - ); - await page.click("(//input[@aria-label='ให้อยู่ในราชอาณาจักรถึงวันที่'])[2]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2568']"); - await page.click("//div[text()='12']"); - await page.fill("(//input[@id='input-tm6'])[2]", '204422002'); - await page.click("(//input[@aria-label='วันที่เดินทางเข้ามาในประเทศ'])[2]"); - await page.click("//div[text()='18']"); - await page.click('id=submitBtn'); - await page.click('id=btn-ok-dialog'); - await page.waitForTimeout(2000); -}); - -test('Create Employee Not Input Personal Information OCR ', async () => { - await page.click('id=btn-add'); - await page.click('id=add-employee'); - await page.click("(//input[@id='select-employer-branch'])[2]"); - await page.click('id=select-employer-branch_0'); - await page.fill("(//input[@id='input-nrcNo'])[2]", '6282282246226'); - await page.fill("(//input[@id='input-first-name'])[2]", 'ปองพล'); - await page.fill("(//input[@id='input-last-name'])[2]", 'กันธะณะ'); - await page.fill("(//input[@id='input-first-name-en'])[2]", 'Pongpon'); - await page.fill("(//input[@id='input-last-name-en'])[2]", 'Kuntana'); - await page.click("(//input[@id='input-birth-date'])[2]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2536']"); - await page.click("//div[text()='8']"); - await page.click("(//div[@id='select-gender'])[2]"); - await page.click("//span[text()='หญิง']"); - await page.click("(//div[@id='select-nationality'])[2]"); - await page.waitForTimeout(2000); - await page.click("(//div[@role='option'])[1]"); - - await page.click("(//div[@id='select-visa-type'])[2]"); - await page.waitForTimeout(2000); - await page.click("(//div[@role='option'])[1]"); - await page.fill("(//input[@id='input-visa-no'])[2]", '200222'); - await page.click("(//input[@aria-label='ออกให้วันที่'])[2]"); - await page.click("//div[text()='18']"); - await page.click("(//input[@aria-label='ใช้ได้ถึงวันที่'])[2]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2568']"); - await page.click("//div[text()='8']"); - await page.fill( - "(//input[@id='input-visa-place'])[2]", - 'กรมตรวจคนเข้าเมืองน่าน', - ); - await page.click("(//input[@aria-label='ให้อยู่ในราชอาณาจักรถึงวันที่'])[2]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2568']"); - await page.click("//div[text()='12']"); - await page.fill("(//input[@id='input-tm6'])[2]", '204422002'); - await page.click("(//input[@aria-label='วันที่เดินทางเข้ามาในประเทศ'])[2]"); - await page.click("//div[text()='18']"); - await page.click('id=submitBtn'); - await page.click('id=cancelBtn'); - await page.waitForTimeout(2000); -}); - -test('Create Employee Not Input Visa Information OCR ', async () => { - await page.click('id=btn-add'); - await page.click('id=add-employee'); - - await page.click("(//input[@id='select-employer-branch'])[2]"); - await page.click('id=select-employer-branch_0'); - await page.fill("(//input[@id='input-nrcNo'])[2]", '6282282246226'); - await page.fill("(//input[@id='input-first-name'])[2]", 'ปองพล'); - await page.fill("(//input[@id='input-last-name'])[2]", 'กันธะณะ'); - await page.fill("(//input[@id='input-first-name-en'])[2]", 'Pongpon'); - await page.fill("(//input[@id='input-last-name-en'])[2]", 'Kuntana'); - await page.click("(//input[@id='input-birth-date'])[2]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2536']"); - await page.click("//div[text()='8']"); - await page.click("(//div[@id='select-gender'])[2]"); - await page.click("//span[text()='หญิง']"); - await page.click("(//div[@id='select-nationality'])[2]"); - await page.waitForTimeout(2000); - await page.click("(//div[@role='option'])[1]"); - await page.click("(//div[@id='select-passport-type'])[2]"); - await page.click("(//div[@role='option'])[1]"); - await page.fill("(//input[@id='input-passport-no'])[2]", 'TH2862242226262'); - await page.fill("(//input[@id='input-passport-ref'])[2]", '2042022022426'); - await page.fill("(//input[@id='input-passport-place'])[2]", 'Bangkok'); - await page.click("(//div[@id='select-passport-country'])[2]"); - await page.waitForTimeout(2000); - await page.click("(//div[@role='option'])[1]"); - await page.click("(//input[@aria-label='วันที่ออกหนังสือเดินทาง'])[2]"); - await page.click("(//div[text()='2'])[1]"); - await page.click("(//input[@aria-label='วันหมดอายุหนังสือเดินทาง'])[2]"); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2574']"); - await page.click("//div[text()='8']"); - await page.click('id=submitBtn'); - await page.click('id=btn-ok-dialog'); - await page.waitForTimeout(2000); -}); diff --git a/tests/03-Admin-ManageCustomer/JWS_MC_018_SeachEmployee.spec.ts b/tests/03-Admin-ManageCustomer/JWS_MC_018_SeachEmployee.spec.ts deleted file mode 100644 index 36f30854..00000000 --- a/tests/03-Admin-ManageCustomer/JWS_MC_018_SeachEmployee.spec.ts +++ /dev/null @@ -1,44 +0,0 @@ -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.62:20101/'); - 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('Selete Filter Employee Active', async () => { - await page.click('id=menu-icon-customer-management'); - await page.click('id=tab-employee'); - await page.fill('id=input-search', 'ปองพล กันธะณะ'); - await page.waitForTimeout(2000); - await page.fill('id=input-search', 'ปองพล'); - await page.waitForTimeout(2000); - await page.fill('id=input-search', 'กันธะณะ'); - await page.waitForTimeout(2000); - await page.fill('id=input-search', 'ไทย'); - await page.waitForTimeout(2000); - await page.fill('id=input-search', '6282282246226'); - await page.waitForTimeout(2000); - await page.fill('id=input-search', 'TH2862242226262'); - await page.waitForTimeout(2000); - await page.fill('id=input-search', 'บางรัก'); - await page.waitForTimeout(2000); -}); diff --git a/tests/03-Admin-ManageCustomer/JWS_MC_019_FliterStatusEmployee.spec.ts b/tests/03-Admin-ManageCustomer/JWS_MC_019_FliterStatusEmployee.spec.ts deleted file mode 100644 index f8a15507..00000000 --- a/tests/03-Admin-ManageCustomer/JWS_MC_019_FliterStatusEmployee.spec.ts +++ /dev/null @@ -1,45 +0,0 @@ -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.62:20101/'); - 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('Selete Filter Employee Active', async () => { - await page.click('id=menu-icon-customer-management'); - await page.click('id=tab-employee'); - await page.click('id=select-status'); - await page.click('id=select-status_1'); - await page.waitForTimeout(2000); -}); - -test('Selete Filter Employee Inative', async () => { - await page.click('id=select-status'); - await page.click('id=select-status_2'); - await page.waitForTimeout(2000); -}); - -test('Selete Filter Employee All', async () => { - await page.click('id=select-status'); - await page.click('id=select-status_0'); - await page.waitForTimeout(2000); -}); diff --git a/tests/03-Admin-ManageCustomer/JWS_MC_020_DetailEmployee.spec.ts b/tests/03-Admin-ManageCustomer/JWS_MC_020_DetailEmployee.spec.ts deleted file mode 100644 index d75ea0a2..00000000 --- a/tests/03-Admin-ManageCustomer/JWS_MC_020_DetailEmployee.spec.ts +++ /dev/null @@ -1,33 +0,0 @@ -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.62:20101/'); - 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('Select Detail Employee', async () => { - await page.click('id=menu-icon-customer-management'); - await page.click('id=tab-employee'); - await page.click("//button[@id='btn-dots-CORP000003-01-240003']"); - await page.click('id=view-detail-btn-undefined-view'); - await page.waitForTimeout(2000); -}); diff --git a/tests/03-Admin-ManageCustomer/JWS_MC_021_EditEmployee.spec.ts b/tests/03-Admin-ManageCustomer/JWS_MC_021_EditEmployee.spec.ts deleted file mode 100644 index b49388ae..00000000 --- a/tests/03-Admin-ManageCustomer/JWS_MC_021_EditEmployee.spec.ts +++ /dev/null @@ -1,33 +0,0 @@ -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.62:20101/'); - 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 Employee', async () => { - await page.click('id=menu-icon-customer-management'); - await page.click('id=tab-employee'); - await page.click("//button[@id='btn-dots-CORP000003-01-240003']"); - await page.click('id=view-detail-btn-undefined-edit'); - await page.waitForTimeout(2000); -}); diff --git a/tests/03-Admin-ManageCustomer/JWS_MC_022_DeleteEmployee.spec.ts b/tests/03-Admin-ManageCustomer/JWS_MC_022_DeleteEmployee.spec.ts deleted file mode 100644 index c22400e9..00000000 --- a/tests/03-Admin-ManageCustomer/JWS_MC_022_DeleteEmployee.spec.ts +++ /dev/null @@ -1,33 +0,0 @@ -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.62:20101/'); - 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('Delete Employee', async () => { - await page.click('id=menu-icon-customer-management'); - await page.click('id=tab-employee'); - await page.click("//button[@id='btn-dots-CORP000003-01-240003']"); - await page.click('id=view-detail-btn-undefined-edit'); - await page.waitForTimeout(2000); -}); diff --git a/tests/03-Admin-ManageCustomer/JWS_MC_023_StatusEmployee.spec.ts b/tests/03-Admin-ManageCustomer/JWS_MC_023_StatusEmployee.spec.ts deleted file mode 100644 index 00c20364..00000000 --- a/tests/03-Admin-ManageCustomer/JWS_MC_023_StatusEmployee.spec.ts +++ /dev/null @@ -1,40 +0,0 @@ -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.62:20101/'); - 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('Status off Employee', async () => { - await page.click('id=menu-icon-customer-management'); - await page.click('id=tab-employee'); - await page.click("//button[@id='btn-dots-PERS000001-01-240001']"); - await page.click('id=view-detail-btn-undefined-status'); - await page.waitForTimeout(2000); - await page.keyboard.press('Escape'); -}); - -test('Status on Employee', async () => { - await page.click("//button[@id='btn-dots-PERS000001-01-240001']"); - await page.click('id=view-detail-btn-undefined-status'); - await page.waitForTimeout(2000); -}); diff --git a/tests/03-Admin-ManageCustomer/JWS_MC_024_DropdownEmployeetype.spec.ts b/tests/03-Admin-ManageCustomer/JWS_MC_024_DropdownEmployeetype.spec.ts deleted file mode 100644 index 7eff7649..00000000 --- a/tests/03-Admin-ManageCustomer/JWS_MC_024_DropdownEmployeetype.spec.ts +++ /dev/null @@ -1,72 +0,0 @@ -import { test, expect, Page } from '@playwright/test'; -import { strictEqual } from 'assert'; -import { escape } from 'querystring'; - -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.62:20101/'); - 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('Select Dropdown Employee Type Off', async () => { - await page.click('id=menu-icon-customer-management'); - await page.click('id=tab-employee'); - await page.click('id=select-field'); - await page.click('id=select-field_0'); - await page.waitForTimeout(2000); - await page.click('id=select-field_1'); - await page.waitForTimeout(2000); - await page.click('id=select-field_2'); - await page.waitForTimeout(2000); - await page.click('id=select-field_3'); - await page.waitForTimeout(2000); - await page.click('id=select-field_4'); - await page.waitForTimeout(2000); - await page.click('id=select-field_5'); - await page.waitForTimeout(2000); - await page.click('id=select-field_6'); - await page.waitForTimeout(2000); - await page.click('id=select-field_7'); - await page.waitForTimeout(2000); - await page.keyboard.press('Escape'); - await page.waitForTimeout(2000); -}); - -test('Select Dropdown Employee Type on', async () => { - await page.click('id=select-field'); - await page.click('id=select-field_0'); - await page.waitForTimeout(2000); - await page.click('id=select-field_1'); - await page.waitForTimeout(2000); - await page.click('id=select-field_2'); - await page.waitForTimeout(2000); - await page.click('id=select-field_3'); - await page.waitForTimeout(2000); - await page.click('id=select-field_4'); - await page.waitForTimeout(2000); - await page.click('id=select-field_5'); - await page.waitForTimeout(2000); - await page.click('id=select-field_6'); - await page.waitForTimeout(2000); - await page.click('id=select-field_7'); - await page.waitForTimeout(2000); - await page.keyboard.press('Escape'); - await page.waitForTimeout(2000); -}); diff --git a/tests/03-Admin-ManageCustomer/JWS_MC_025_CreateSubBranchNaturalperson.spec.ts b/tests/03-Admin-ManageCustomer/JWS_MC_025_CreateSubBranchNaturalperson.spec.ts deleted file mode 100644 index d6f81b6e..00000000 --- a/tests/03-Admin-ManageCustomer/JWS_MC_025_CreateSubBranchNaturalperson.spec.ts +++ /dev/null @@ -1,71 +0,0 @@ -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.62:20101/'); - 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('Open Natural Person', async () => { - await page.click('id=menu-icon-customer-management'); - await page.click('id=row-table-โคโม่'); - await page.click("(//div[@id='btn-add']//a)[1]"); - await page.click("(//div[@id='btn-add']//div)[2]"); - await page.waitForTimeout(2000); -}); - -test('Create Sub Branch Natural Person', async () => { - await page.fill('id=form-dialog-input-branch-no', '20'); - await page.fill('id=form-dialog-input-customer-name', 'สยาม'); - await page.fill('id=form-dialog-input-customer-english-name', 'siam'); - await page.fill('id=form-dialog-input-address-0', '20/022'); - await page.click('id=form-dialog-select-province-0'); - await page.click("//div[@role='option']"); - await page.click('id=form-dialog-select-district-0'); - await page.waitForTimeout(1000); - await page.click("//div[@role='option']"); - await page.click('id=form-dialog-select-sub-district-0'); - await page.waitForTimeout(1000); - await page.click("//div[@role='option']"); - await page.fill('id=form-dialog-input-address-en-0', '20/022'); - await page.fill('id=form-dialog-input-employment-office', 'กรุงเทพมหานคร'); - await page.click('id=form-dialog-select-business-type'); - await page.click("//span[text()='ประมง']"); - await page.click("(//div[@id='form-dialog-select-job-position'])[1]"); - await page.click("(//div[@role='option'])[1]"); - await page.fill( - 'id=form-dialog-input-job-description', - 'ตรวจสอบการทำการลักษณะงาน', - ); - await page.click('id=form-dialog-input-start-date'); - await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]"); - await page.click("//div[text()='2561']"); - await page.click("//div[text()='12']"); - await page.fill('id=form-dialog-input-sales-person', 'พนักงานขาย'); - await page.fill('id=form-dialog-input-mail', 'jws@local.com'); - await page.fill('id=form-dialog-input-telephone', '0864228464'); - // await page.setInputFiles( - // "//input[@id='f_55bbcb5d-4316-43c8-93cf-99c4f1f60115']", - // '/Users/linping/Desktop/Chamomind&FrappeT/JWS_TestScript/tests/Datafile/Pic1.jpg', - // ); // UploadFile - await page.click("(//button[@id='submitBtn'])[2]"); - await page.waitForTimeout(2000); -}); diff --git a/tests/03-Admin-ManageCustomer/JWS_MC_026_CreateSubBranchLegalentitly.spec.ts b/tests/03-Admin-ManageCustomer/JWS_MC_026_CreateSubBranchLegalentitly.spec.ts deleted file mode 100644 index d6fec7c2..00000000 --- a/tests/03-Admin-ManageCustomer/JWS_MC_026_CreateSubBranchLegalentitly.spec.ts +++ /dev/null @@ -1,31 +0,0 @@ -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.62:20101/'); - 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('Open Legal Entitly ', async () => { - await page.click('id=menu-icon-customer-management'); - - await page.waitForTimeout(2000); -}); diff --git a/tests/04-ProductandService/JWS_PD_002_CreateProductandServiceGroupFail.spec.ts b/tests/04-ProductandService/JWS_PD_002_CreateProductandServiceGroupFail.spec.ts deleted file mode 100644 index f29359e8..00000000 --- a/tests/04-ProductandService/JWS_PD_002_CreateProductandServiceGroupFail.spec.ts +++ /dev/null @@ -1,53 +0,0 @@ -import { test, expect, Page } from '@playwright/test'; -import { strictEqual } from 'assert'; -import { log } from 'console'; - -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.62:20101/'); - 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('ทดสอบการเพิ่มกลุ่มสินค้าและบริการในกรณีที่ไม่กรอกข้อมูล', async () => { - await page.click('id=menu-icon-product-service'); - - try { - // เพิ่มกลุ่มสินค้าและบริการ - await page.click('id=btn-add'); - await page.click('id=btn-add-product-group'); - - // บันทึกการสร้างกลุ่มสินค้นและบริการ - await page.click('id=btn-form-submit'); - - // ตรวจสอบหลังการแจ้งเตือนหลังจากคลิกปุ่มบันทึก - const nameProduceandSeviceGropError = page.locator( - "//div[normalize-space(text())='จำเป็นต้องกรอกข้อมูลนี้']", - ); - await expect(nameProduceandSeviceGropError).toHaveText( - 'จำเป็นต้องกรอกข้อมูลนี้', - ); - console.log(nameProduceandSeviceGropError, 'ตรวจสอบการแจ้งเตือนถูกต้อง'); - } catch (error) { - console.error('เกิดข้อผิดการในการทดสอบ'); - throw error; - } - - await page.waitForTimeout(2000); -}); diff --git a/tests/04-ProductandService/JWS_PD_003_CreateProductandService.spec.ts b/tests/04-ProductandService/JWS_PD_003_CreateProductandService.spec.ts deleted file mode 100644 index 0247ad21..00000000 --- a/tests/04-ProductandService/JWS_PD_003_CreateProductandService.spec.ts +++ /dev/null @@ -1,75 +0,0 @@ -import { test, expect, Page } from '@playwright/test'; -import { strictEqual } from 'assert'; -import { log } from 'console'; - -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.62:20101/'); - 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('ทดสอบการเพิ่มสินค้า', async () => { - await page.click('id=menu-icon-product-service'); - await page.waitForSelector('id=tree-enter-ประกัน', { state: 'visible' }); - await page.click('id=tree-enter-ประกัน'); - await page.waitForSelector('id=tree-enter-สินค้าและบริการ-ประกัน', { - state: 'visible', - }); - await page.click('id=tree-enter-สินค้าและบริการ-ประกัน'); - try { - await page.click('id=btn-add'); - await page.click('id=btn-add-product'); - - // รหัสสินค้าและบริการ - await page.waitForSelector("(//input[@id='select-br-id'])[1]", { - state: 'visible', - }); - await page.click("(//input[@id='select-br-id'])[1]"); - await page.click('id=select-br-id_0'); - await page.fill("(//input[@id='input-name'])[2]", 'ประเภทกลุ่ม'); - - // ระยะเวลาดำเนินการ - await page.fill('id=input-process', '2'); - - // ประเภทค่าใช้จ่าย - await page.waitForSelector("(//input[@id='select-br-id'])[2]", { - state: 'visible', - }); - await page.click("(//input[@id='select-br-id'])[2]"); - await page.click('id=select-br-id_0'); - - // กรอกรายละเอียด - await page.fill("//div[@contenteditable='true']", 'รายละเอียด'); - - // กรอกสาเหตุ - await page.fill("(//textarea[@id='input-remark'])[2]", 'หมายเหตุ'); - - // ส่วนข้อมูลราคา - await page.click("//span[normalize-space(text())='ข้อมูลราคา']"); - await page.fill('id=input-price', '2000'); - await page.fill('id=input-agent-price', '1800'); - await page.fill('id=input-service-charge', '1000'); - await page.click('id=btn-form-submit'); - } catch (error) { - console.log('เกิดข้อผิดพลาดในการทดสอบ'); - throw error; - } - await page.waitForTimeout(2000); -}); diff --git a/tests/04-ProductandService/JWS_PD_004_CreateProductandServiceFail.spec.ts b/tests/04-ProductandService/JWS_PD_004_CreateProductandServiceFail.spec.ts deleted file mode 100644 index 272fc10d..00000000 --- a/tests/04-ProductandService/JWS_PD_004_CreateProductandServiceFail.spec.ts +++ /dev/null @@ -1,59 +0,0 @@ -import { test, expect, Page } from '@playwright/test'; -import { strictEqual } from 'assert'; -import { log } from 'console'; - -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.62:20101/'); - 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('ทดสอบการเพิ่มสินค้า', async () => { - await page.click('id=menu-icon-product-service'); - await page.waitForSelector('id=tree-enter-ประกัน', { state: 'visible' }); - await page.click('id=tree-enter-ประกัน'); - await page.waitForSelector('id=tree-enter-สินค้าและบริการ-ประกัน', { - state: 'visible', - }); - await page.click('id=tree-enter-สินค้าและบริการ-ประกัน'); - try { - await page.click('id=btn-add'); - await page.click('id=btn-add-product'); - await page.click('id=btn-form-submit'); - - // ตรวจสอบหลังการแจ้งเตือนหลังจากคลิกปุ่มบันทึก - const ProduceandSeviceCodeError = page.locator( - "(//div[@class='q-field__messages col']//div)[1]", - ); - const nameProduceandSeviceError = page.locator( - "(//div[@class='q-field__messages col']//div)[2]", - ); - await expect(ProduceandSeviceCodeError).toHaveText( - 'จำเป็นต้องกรอกข้อมูลนี้', - ); - await expect(nameProduceandSeviceError).toHaveText( - 'จำเป็นต้องกรอกข้อมูลนี้', - ); - } catch (error) { - console.log('เกิดข้อผิดพลาดในการทดสอบ'); - throw error; - } - await page.waitForTimeout(2000); -}); diff --git a/tests/04-ProductandService/JWS_PD_005_CreateType.spec.ts b/tests/04-ProductandService/JWS_PD_005_CreateType.spec.ts deleted file mode 100644 index be4e8c4a..00000000 --- a/tests/04-ProductandService/JWS_PD_005_CreateType.spec.ts +++ /dev/null @@ -1,124 +0,0 @@ -import { test, expect, Page } from '@playwright/test'; -import { strictEqual } from 'assert'; -import { log } from 'console'; - -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.62:20101/'); - 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('ทดสอบการเพิ่มประเภท', async () => { - await page.click('id=menu-icon-product-service'); - await page.waitForSelector('id=tree-enter-ประกัน', { state: 'visible' }); - await page.click('id=tree-enter-ประกัน'); - // เข้าสู่หน้าประเภท - await page.waitForSelector('id=tree-enter-ประเภท-ประกัน', { - state: 'visible', - }); - await page.click('id=tree-enter-ประเภท-ประกัน'); - - try { - // เพิ่มประเภท - await page.click('id=btn-add'); - await page.click('id=btn-add-service'); - - // กรอกข้อมูลประเภทส่วน "ข้อมูลประเภท" - await page.fill('id=input-service-code', 'MOU'); - await page.fill('id=input-service-name', 'ประกันภัยแบบกลุ่ม'); - await page.fill('id=input-service-description', 'รายละเอียดประภัยแบบกลุ่ม'); - - // เพิ่มคุณสมบัติส่วน "คุณสมบัติของประเภท" - await page.click('id=btn-capitalize'); - await page.click('id=btn-dropdow-properties'); - await page.click('id=list-serviceRecordName'); - await page.keyboard.press('Escape'); - - const propertiesServiceRecordName = page.locator( - "//span[normalize-space(text())='บันทึกบริการ_Name']", - ); - - expect(propertiesServiceRecordName).toHaveText('บันทึกบริการ_Name'); - console.log(propertiesServiceRecordName, 'เลือกdropdown แล้ว'); - - // บันทึกการเพิ่มคุณสมบัติ - await page.click("(//button[@id='btn-form-submit'])[2]"); - - // เพิ่มส่วนข้อมูลงาน - await page.click("//span[normalize-space(text())='ข้อมูลงาน']"); - await page.click('id=btn-add-work'); - await page.click("//div[@for='select-work-name-1']"); - await page.waitForTimeout(2000); - await page.click("//span[normalize-space(text())='จัดการ']"); - await page.click("//span[normalize-space(text())='เพิ่มงาน']"); - await page.fill('id=input-work-name-0', 'อัคคีภัย'); - await page.click('id=btn-save-work-name'); - await page.click("(//button[@id='btn-form-close'])[2]"); - await page.waitForTimeout(2000); - await page.click("//div[normalize-space(text())='อัคคีภัย']"); - await page.waitForTimeout(2000); - await page.keyboard.press('Escape'); - - // เพิ่มคุณสมบัติ - await page.click("(//button[@id='btn-add-work-product'])[1]"); - await page.click('id=btn-dropdow-properties'); - await page.click('id=list-refNo'); - await page.keyboard.press('Escape'); - - const propertiesRefNo = page.locator("//span[text()='Ref No:']"); - - expect(propertiesRefNo).toHaveText('Ref No:'); - console.log(propertiesRefNo, 'เลือกdropdown แล้ว'); - - await page.click("(//button[@id='btn-form-submit'])[2]"); - - // เพิ่มสินค้าและบริการ - await page.click("(//button[@id='btn-add-work-product'])[2]"); - await page.click("//div[contains(@class,'column bordered')]"); - await page.click("(//button[@id='btn-form-submit'])[2]"); - - // บันทึกการสร้างประเภท - await page.click('id=btn-form-submit'); - - // ตรวจสอบหลังทำการประเภท - const newTypeLocator = page.locator( - "//div[normalize-space(text())='ประกันภัยแบบกลุ่ม']", - ); - await newTypeLocator.waitFor({ state: 'visible' }); - - // ดึงข้อความให้ตรงจาก XPath - - const newTypeName = await newTypeLocator.textContent(); - - // ตรวจสอบความถูกต้องหลังทำการสร้างประเภท - if (newTypeName !== null) { - const trimmedName = newTypeName.trim(); - expect(trimmedName).toBe('ประกันภัยแบบกลุ่ม'); - console.log('การตรวจสอบสำเร็จ : ถูกต้อง'); - } else { - throw new Error('ไม่พบข้อมูลที่บันทึก'); - } - } catch (error) { - console.error('เกิดข้อผิดการในการทดสอบ'); - throw error; - } - - await page.waitForTimeout(2000); -});