test : Update Script

This commit is contained in:
Linpiing 2024-09-26 11:05:54 +07:00
parent 9254c0183e
commit 297ff8c675
73 changed files with 2055 additions and 398 deletions

View file

@ -15,7 +15,7 @@ test.afterAll(async () => {
test('Login', async () => {
// Login
await page.goto('http://192.168.1.90:20001/');
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');
@ -24,95 +24,138 @@ test('Login', async () => {
// await page.click('id=acceptBtn');
});
test('Create Natural Person', async () => {
test('ทดสอบการสร้างนายจ้างบุคคลธรรมดา', async () => {
await page.click('id=menu-icon-customer-management');
await page.click("(//div[@id='btn-add'])[1]");
await page.click('id=add-customer-natural-person');
await page.fill("(//input[@id='input-employer-id'])[3]", 'ปิง');
await page.fill("(//input[@id='input-tax-no'])[3]", '1242822482204');
await page.fill("(//input[@id='input-customer-name'])[3]", 'โคโม่');
await page.fill("(//input[@id='input-customer-name-en'])[3]", 'Como');
await page.fill("(//input[@id='input-customerName'])[3]", 'สีลม');
await page.fill("(//input[@id='input-customerEnglishName'])[3]", 'Silom');
await page.fill("(//input[@id='input-address-0'])[3]", '20/02');
await page.click("(//div[@id='select-province-0'])[3]");
await page.click("//div[@role='option']");
await page.click("(//div[@id='select-district-0'])[3]");
await page.waitForTimeout(1000);
await page.click("//div[@role='option']");
await page.click("(//div[@id='select-sub-district-0'])[3]");
await page.waitForTimeout(1000);
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[@id='input-start-date'])[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');
try {
await page.click('id=btn-Add');
await page.click("(//button[@type='submit'])[2]");
// ส่วนเกี่ยวกับ
await page.fill('id=input-legal-person-no', '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-telephone', '0842262228');
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.waitForSelector("(//div[@aria-selected='false'])[2]");
await page.click("(//div[@aria-selected='false'])[2]");
await page.waitForSelector('id=form-select-business-type');
await page.click('id=form-select-business-type');
await page.click('id=form-select-business-type_6');
await page.waitForSelector('id=form-select-job-position');
await page.click('id=form-select-job-position');
await page.click('id=form-select-job-position_0');
// ส่วนที่อยู่นายจ้าง
await page.click("(//div[@aria-selected='false'])[3]");
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.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', '200');
await page.click("//button[@type='submit']");
await page.click('id=btn-form-close');
// กำหนดค่าเพื่อตรวจสอบความถูกต้องหลังสร้าง
const nameTitleNatrualPerson = await page.locator(
"//div[normalize-space(text())='ยศพัฒน์ ธนากานต์']",
);
expect(nameTitleNatrualPerson).toHaveText('ยศพัฒน์ ธนากานต์');
console.log('ระบบสามารถสร้างนายจ้างบุคคลธรรมดาได้');
} catch (error) {
console.error('เกิดข้อผิดพลาดในการทดสอบ', error);
throw error;
}
await page.waitForTimeout(2000);
});
test('Create Natural Person Second', async () => {
await page.click("(//div[@id='btn-add'])[1]");
await page.click('id=add-customer-natural-person');
await page.fill("(//input[@id='input-employer-id'])[3]", 'วัง');
await page.fill("(//input[@id='input-tax-no'])[3]", 'จคภ/คค/ุ//');
await page.fill("(//input[@id='input-customer-name'])[3]", 'โคโม่');
await page.fill("(//input[@id='input-customer-name-en'])[3]", 'Como');
await page.fill("(//input[@id='input-customerName'])[3]", 'สีลม');
await page.fill("(//input[@id='input-customerEnglishName'])[3]", 'Silom');
await page.fill("(//input[@id='input-address-0'])[3]", '20/02');
await page.click("(//div[@id='select-province-0'])[3]");
await page.click("//div[@role='option']");
await page.click("(//div[@id='select-district-0'])[3]");
await page.waitForTimeout(1000);
await page.click("//div[@role='option']");
await page.click("(//div[@id='select-sub-district-0'])[3]");
await page.waitForTimeout(1000);
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[@id='input-start-date'])[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');
test('ทดสอบการสร้างนายจ้างบุคคลธรรมดาครั้งที่ 2', async () => {
try {
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.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-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.waitForSelector("(//div[@aria-selected='false'])[2]");
await page.click("(//div[@aria-selected='false'])[2]");
await page.waitForSelector('id=form-select-business-type');
await page.click('id=form-select-business-type');
await page.click('id=form-select-business-type_6');
await page.waitForSelector('id=form-select-job-position');
await page.click('id=form-select-job-position');
await page.click('id=form-select-job-position_0');
// ส่วนที่อยู่นายจ้าง
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.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', '400');
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())='สุรวัฒน์ จันทรสมบัติ']",
);
expect(nameTitleNatrualPerson).toHaveText('สุรวัฒน์ จันทรสมบัติ');
console.log('ระบบสามารถสร้างนายจ้างบุคคลธรรมดาได้');
} catch (error) {
console.error('เกิดข้อผิดพลาดในการทดสอบ', error);
throw error;
}
await page.waitForTimeout(2000);
});

View file

@ -1,5 +1,9 @@
import { test, expect, Page } from '@playwright/test';
import { strictEqual } from 'assert';
import { formToJSON } from 'axios';
import { exec } from 'child_process';
import { ToastHeader } from 'react-bootstrap';
import { toHandlerKey } from 'vue';
let page: Page;
@ -15,7 +19,7 @@ test.afterAll(async () => {
test('Login', async () => {
// Login
await page.goto('http://192.168.1.90:20001/');
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');
@ -24,226 +28,362 @@ test('Login', async () => {
// await page.click('id=acceptBtn');
});
test('Create Natural Person No input Data', async () => {
test('ทดสอบการสร้างนายจ้างบุคคลธรรมดาในกรณีที่ไม่กรอกช้อมูล', async () => {
await page.click('id=menu-icon-customer-management');
await page.click("(//div[@id='btn-add'])[1]");
await page.click('id=add-customer-natural-person');
await page.click('id=submitBtn');
await page.waitForTimeout(2000);
await page.click('id=cancelBtn');
try {
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]",
);
// ตรวจสอบการเกิด Validation
expect(citizenNoError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้');
expect(firstNameThError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้');
expect(lastNameThError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้');
expect(firstNameEngError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้');
expect(lastNameEngError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้');
expect(brithDateError).toHaveText('โปรดเลือกวันเดือนปีเกิด');
console.log('ตรวจสอบการแจ้งเตือนทั้งหมดถูกต้อง');
} catch (error) {
console.error('เกิดข้อผิดพลาดในการทดสอบ', error);
throw error;
}
await page.waitForTimeout(2000);
await page.click('id=btn-form-close');
});
test('Create Natural Person No Input Employee name', async () => {
await page.click("(//div[@id='btn-add'])[1]");
await page.click('id=add-customer-natural-person');
await page.fill("(//input[@id='input-employer-id'])[3]", '');
await page.fill("(//input[@id='input-tax-no'])[3]", '1242822482204');
await page.fill("(//input[@id='input-customer-name'])[3]", 'โคโม่');
await page.fill("(//input[@id='input-customer-name-en'])[3]", 'Como');
await page.fill("(//input[@id='input-customerName'])[3]", 'ปองพล กันธะณะ');
await page.fill("(//input[@id='input-address-0'])[3]", '20/02');
await page.click("(//div[@id='select-province-0'])[3]");
await page.click("//div[@role='option']");
await page.click("(//div[@id='select-district-0'])[3]");
await page.waitForTimeout(1000);
await page.click("//div[@role='option']");
await page.click("(//div[@id='select-sub-district-0'])[3]");
await page.waitForTimeout(1000);
await page.click("//div[@role='option']");
await page.fill("(//input[@id='input-address-en-0'])[3]", '20/02');
await page.click('id=submitBtn');
await page.waitForTimeout(2000);
});
test('ทดสอบการสร้างนายจ้างบุคคลธรรมดาในกรณีที่กรอกข้อมูลเฉพาะส่วนเกี่ยวกับ', async () => {
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.waitForSelector("//div[@id='2024-09-18']/div[1]");
await page.click("//div[@id='2024-09-18']/div[1]");
await page.click("//button[@type='submit']");
test('Create Natural Person No Input Tax No', async () => {
await page.click("(//div[@id='btn-add'])[1]");
await page.click('id=add-customer-natural-person');
await page.fill("(//input[@id='input-employer-id'])[3]", 'ปิง');
await page.fill("(//input[@id='input-tax-no'])[3]", '');
await page.fill("(//input[@id='input-customer-name'])[3]", 'โคโม่');
await page.fill("(//input[@id='input-customer-name-en'])[3]", 'Como');
await page.fill("(//input[@id='input-customerName'])[3]", 'ปองพล กันธะณะ');
await page.fill("(//input[@id='input-address-0'])[3]", '20/02');
await page.click("(//div[@id='select-province-0'])[3]");
await page.click("//div[@role='option']");
await page.click("(//div[@id='select-district-0'])[3]");
await page.waitForTimeout(1000);
await page.click("//div[@role='option']");
await page.click("(//div[@id='select-sub-district-0'])[3]");
await page.waitForTimeout(1000);
await page.click("//div[@role='option']");
await page.fill("(//input[@id='input-address-en-0'])[3]", '20/02');
await page.click('id=cancelBtn');
// รอการเกิด Dialog
const textPopupError = await page.locator(
"//span[normalize-space(text())='กรอกข้อมูลไม่ครบ']",
);
await expect(textPopupError).toHaveText('กรอกข้อมูลไม่ครบ');
console.log('ตรวจสอบการแจ้งเตือน Pop-up สำเร็จ');
} 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');
});
test('Create Natural Person No Input Customer Name TH', async () => {
await page.click("(//div[@id='btn-add'])[1]");
await page.click('id=add-customer-natural-person');
await page.fill("(//input[@id='input-employer-id'])[3]", 'ปิง');
await page.fill("(//input[@id='input-tax-no'])[3]", '1242822482204');
await page.fill("(//input[@id='input-customer-name'])[3]", '');
await page.fill("(//input[@id='input-customer-name-en'])[3]", 'Como');
await page.fill("(//input[@id='input-customerName'])[3]", 'ปองพล กันธะณะ');
await page.fill("(//input[@id='input-address-0'])[3]", '20/02');
await page.click("(//div[@id='select-province-0'])[3]");
await page.click("//div[@role='option']");
await page.click("(//div[@id='select-district-0'])[3]");
await page.waitForTimeout(1000);
await page.click("//div[@role='option']");
await page.click("(//div[@id='select-sub-district-0'])[3]");
await page.waitForTimeout(1000);
await page.click("//div[@role='option']");
await page.fill("(//input[@id='input-address-en-0'])[3]", '20/02');
await page.click('id=submitBtn');
test('ทดสอบการสร้างนายจ้างบุคคลธรรมดาในกรณีที่ไม่ได้กรอกข้อมูลส่วนข้อมูลธุรกิจ', async () => {
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]",
);
// ตรวจสอบการแจ้งเตือน
expect(businessTypeError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้');
expect(businessTypeEngError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้');
expect(jobPositionError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้');
expect(jobPositionEnError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้');
console.log('ตรวจสอบการแจ้งเตือนสำเร็จ');
} catch (error) {
console.error('เกิดข้อผิดพลาดในการทดสอบ', error);
}
await page.waitForTimeout(2000);
await page.click('id=btn-form-close');
});
test('Create Natural Person No Input Customer Name EN', async () => {
await page.click("(//div[@id='btn-add'])[1]");
await page.click('id=add-customer-natural-person');
await page.fill("(//input[@id='input-employer-id'])[3]", 'ปิง');
await page.fill("(//input[@id='input-tax-no'])[3]", '1242822482204');
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-customerName'])[3]", 'ปองพล กันธะณะ');
await page.fill("(//input[@id='input-address-0'])[3]", '20/02');
await page.click("(//div[@id='select-province-0'])[3]");
await page.click("//div[@role='option']");
await page.click("(//div[@id='select-district-0'])[3]");
await page.waitForTimeout(1000);
await page.click("//div[@role='option']");
await page.click("(//div[@id='select-sub-district-0'])[3]");
await page.waitForTimeout(1000);
await page.click("//div[@role='option']");
await page.fill("(//input[@id='input-address-en-0'])[3]", '20/02');
await page.click('id=submitBtn');
test('ทดสอบการสร้างนายจ้างบุคคลธรรมดาในกรณีที่กรอกข้อมูลเฉพาะส่วนข้อมูลธุรกิจ', async () => {
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']");
// กำหนดค่าการแจ้งเตือน
const titleError = await page.locator(
"//span[normalize-space(text())='กรอกข้อมูลไม่ครบ']",
);
expect(titleError).toHaveText('กรอกข้อมูลไม่ครบ');
console.log('การแจ้งเตือนถูกต้อง');
} catch (error) {
console.error('เกิดข้อผิดพลาดในการทดสอบ', 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('Create Natural Person No Input Customername', async () => {
await page.click("(//div[@id='btn-add'])[1]");
await page.click('id=add-customer-natural-person');
await page.fill("(//input[@id='input-employer-id'])[3]", 'ปิง');
await page.fill("(//input[@id='input-tax-no'])[3]", '1242822482204');
await page.fill("(//input[@id='input-customer-name'])[3]", 'โคโม่');
await page.fill("(//input[@id='input-customer-name-en'])[3]", 'Como');
await page.fill("(//input[@id='input-customerName'])[3]", '');
await page.fill("(//input[@id='input-address-0'])[3]", '20/02');
await page.click("(//div[@id='select-province-0'])[3]");
await page.click("//div[@role='option']");
await page.click("(//div[@id='select-district-0'])[3]");
await page.waitForTimeout(1000);
await page.click("//div[@role='option']");
await page.click("(//div[@id='select-sub-district-0'])[3]");
await page.waitForTimeout(1000);
await page.click("//div[@role='option']");
await page.fill("(//input[@id='input-address-en-0'])[3]", '20/02');
await page.click('id=submitBtn');
test('ทดสอบการสร้างนายจ้างบุคคลธรรมดาในกรณีที่ไม่กรอกข้อมูลส่วนที่อยู่นายจ้าง', async () => {
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]",
);
// ตรวจสอบการแจ้งเตือน
expect(addressIdentificationError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้');
expect(addressNoError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้');
expect(provinceError).toHaveText('โปรดเลือกจังหวัด');
expect(districtError).toHaveText('โปรดเลือกอำเภอ');
expect(subdistrictError).toHaveText('โปรดเลือกตำบล');
expect(addressNoEngError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้');
console.log('ตรวจสอบการแจ้งเตือนสำเร็จ');
} catch (error) {
console.error('เกิดข้อผิดพลาดในการทดสอบ', error);
throw error;
}
await page.waitForTimeout(2000);
await page.click('id=btn-form-close');
});
test('Create Natural Person No Input Address TH', async () => {
await page.click("(//div[@id='btn-add'])[1]");
await page.click('id=add-customer-natural-person');
await page.fill("(//input[@id='input-employer-id'])[3]", 'ปิง');
await page.fill("(//input[@id='input-tax-no'])[3]", '1242822482204');
await page.fill("(//input[@id='input-customer-name'])[3]", 'โคโม่');
await page.fill("(//input[@id='input-customer-name-en'])[3]", 'Como');
await page.fill("(//input[@id='input-customerName'])[3]", 'ปองพล กันธะณะ');
await page.fill("(//input[@id='input-address-0'])[3]", '');
await page.click("(//div[@id='select-province-0'])[3]");
await page.click("//div[@role='option']");
await page.click("(//div[@id='select-district-0'])[3]");
await page.waitForTimeout(1000);
await page.click("//div[@role='option']");
await page.click("(//div[@id='select-sub-district-0'])[3]");
await page.waitForTimeout(1000);
await page.click("//div[@role='option']");
await page.fill("(//input[@id='input-address-en-0'])[3]", '20/02');
await page.click('id=submitBtn');
await page.waitForTimeout(2000);
await page.click('id=cancelBtn');
test('ทดสอบการสร้างนายจ้างบุคคลธรรมดาในกรณีที่กรอกข้อมูลเฉพาะส่วนที่อยู่นายจ้าง', async () => {
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]", '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']");
// กำหนดค่าการแจ้งเตือน
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');
});
test('Create Natural Person Not Select Province', async () => {
await page.click("(//div[@id='btn-add'])[1]");
await page.click('id=add-customer-natural-person');
await page.fill("(//input[@id='input-employer-id'])[3]", 'ปิง');
await page.fill("(//input[@id='input-tax-no'])[3]", '1242822482204');
await page.fill("(//input[@id='input-customer-name'])[3]", 'โคโม่');
await page.fill("(//input[@id='input-customer-name-en'])[3]", 'Como');
await page.fill("(//input[@id='input-customerName'])[3]", 'ปองพล กันธะณะ');
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.click('id=submitBtn');
await page.waitForTimeout(2000);
await page.click('id=cancelBtn');
test('ทดสอบการสร้างนายจ้างบุคคลธรรมดาในกรณีที่ไม่กรอกข้อมูลส่วนข้อมูลติดต่อ', async () => {
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())='กรอกข้อมูลไม่ครบ']",
);
// ตรวจสอบการแจ้งเตือน
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');
});
test('Create Natural Person Not Select District', async () => {
await page.click("(//div[@id='btn-add'])[1]");
await page.click('id=add-customer-natural-person');
await page.fill("(//input[@id='input-employer-id'])[3]", 'ปิง');
await page.fill("(//input[@id='input-tax-no'])[3]", '1242822482204');
await page.fill("(//input[@id='input-customer-name'])[3]", 'โคโม่');
await page.fill("(//input[@id='input-customer-name-en'])[3]", 'Como');
await page.fill("(//input[@id='input-customerName'])[3]", 'ปองพล กันธะณะ');
await page.fill("(//input[@id='input-address-0'])[3]", '20/02');
await page.click("(//div[@id='select-province-0'])[3]");
await page.click("//div[@role='option']");
await page.fill("(//input[@id='input-address-en-0'])[3]", '20/02');
await page.click('id=submitBtn');
await page.waitForTimeout(2000);
await page.click('id=cancelBtn');
test('ทดสอบการสร้างนายจ้างบุคคลธรรมดาในกรณีที่กรอกข้อมูลเฉพาะส่วนข้อมูลติดต่อ', async () => {
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']");
// กำหนดค่าการแจ้งเตือน
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');
});
test('Create Natural Person Not Select Sub District', async () => {
await page.click("(//div[@id='btn-add'])[1]");
await page.click('id=add-customer-natural-person');
await page.fill("(//input[@id='input-employer-id'])[3]", 'ปิง');
await page.fill("(//input[@id='input-tax-no'])[3]", '1242822482204');
await page.fill("(//input[@id='input-customer-name'])[3]", 'โคโม่');
await page.fill("(//input[@id='input-customer-name-en'])[3]", 'Como');
await page.fill("(//input[@id='input-customerName'])[3]", 'ปองพล กันธะณะ');
await page.fill("(//input[@id='input-address-0'])[3]", '20/02');
await page.click("(//div[@id='select-province-0'])[3]");
await page.click("//div[@role='option']");
await page.click("(//div[@id='select-district-0'])[3]");
await page.waitForTimeout(1000);
await page.click("//div[@role='option']");
await page.fill("(//input[@id='input-address-en-0'])[3]", '20/02');
await page.click('id=submitBtn');
await page.waitForTimeout(2000);
await page.click('id=cancelBtn');
test('ทดสอบการสร้างนายจ้างบุคคลธรรมดาในกรณีที่กรอกรูปแบบอีเมลส่วนข้อมูลติดต่อไม่ถูกต้อง', async () => {
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);
throw error;
}
await page.waitForTimeout(2000);
await page.click('id=btn-form-close');
});
test('Create Natural Person Not Input Address ENG', async () => {
await page.click("(//div[@id='btn-add'])[1]");
await page.click('id=add-customer-natural-person');
await page.fill("(//input[@id='input-employer-id'])[3]", 'ปิง');
await page.fill("(//input[@id='input-tax-no'])[3]", '1242822482204');
await page.fill("(//input[@id='input-customer-name'])[3]", 'โคโม่');
await page.fill("(//input[@id='input-customer-name-en'])[3]", 'Como');
await page.fill("(//input[@id='input-customerName'])[3]", 'ปองพล กันธะณะ');
await page.fill("(//input[@id='input-address-0'])[3]", '20/02');
await page.click("(//div[@id='select-province-0'])[3]");
await page.click("//div[@role='option']");
await page.click("(//div[@id='select-district-0'])[3]");
await page.waitForTimeout(1000);
await page.click("//div[@role='option']");
await page.click("(//div[@id='select-sub-district-0'])[3]");
await page.waitForTimeout(1000);
await page.click("//div[@role='option']");
await page.fill("(//input[@id='input-address-en-0'])[3]", '');
await page.click('id=submitBtn');
await page.waitForTimeout(2000);
await page.click('id=cancelBtn');
test('ทดสอบการสร้างนายจ้างบุคคลธรรมดาในกรณีที่ไม่อัปโหลดข้อมูลส่วนเอกสาร', async () => {
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');
});
// 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');
// });

View file

@ -15,7 +15,7 @@ test.afterAll(async () => {
test('Login', async () => {
// Login
await page.goto('http://192.168.1.90:20001/');
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');
@ -24,10 +24,11 @@ test('Login', async () => {
// await page.click('id=acceptBtn');
});
test('Selete Filter Manage Customer Active', async () => {
test('ตรวจสอบดูรายละเอียดบุคคลธรรมดาโดยการคลิกไอคอนดวงตา', async () => {
await page.click('id=menu-icon-customer-management');
await page.click('id=btn-eye-โคโม่');
await page.waitForTimeout(2000);
await page.click("(//button[@id='closeDialog'])[1]");
await page.waitForTimeout(2000);
try {
} catch (error) {
console.error('เกิดข้อผิดพลาดในการทดสอบ', error);
throw error;
}
});

View file

@ -15,7 +15,7 @@ test.afterAll(async () => {
test('Login', async () => {
// Login
await page.goto('http://192.168.1.90:20001/');
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');

View file

@ -15,7 +15,7 @@ test.afterAll(async () => {
test('Login', async () => {
// Login
await page.goto('http://192.168.1.90:20001/');
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');

View file

@ -15,7 +15,7 @@ test.afterAll(async () => {
test('Login', async () => {
// Login
await page.goto('http://192.168.1.90:20001/');
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');

View file

@ -15,7 +15,7 @@ test.afterAll(async () => {
test('Login', async () => {
// Login
await page.goto('http://192.168.1.90:20001/');
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');

View file

@ -15,7 +15,7 @@ test.afterAll(async () => {
test('Login', async () => {
// Login
await page.goto('http://192.168.1.90:20001/');
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');

View file

@ -15,7 +15,7 @@ test.afterAll(async () => {
test('Login', async () => {
// Login
await page.goto('http://192.168.1.90:20001/');
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');

View file

@ -15,7 +15,7 @@ test.afterAll(async () => {
test('Login', async () => {
// Login
await page.goto('http://192.168.1.90:20001/');
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');

View file

@ -15,7 +15,7 @@ test.afterAll(async () => {
test('Login', async () => {
// Login
await page.goto('http://192.168.1.90:20001/');
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');

View file

@ -15,7 +15,7 @@ test.afterAll(async () => {
test('Login', async () => {
// Login
await page.goto('http://192.168.1.90:20001/');
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');

View file

@ -16,7 +16,7 @@ test.afterAll(async () => {
test('Login', async () => {
// Login
await page.goto('http://192.168.1.90:20001/');
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');

View file

@ -15,7 +15,7 @@ test.afterAll(async () => {
test('Login', async () => {
// Login
await page.goto('http://192.168.1.90:20001/');
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');

View file

@ -15,7 +15,7 @@ test.afterAll(async () => {
test('Login', async () => {
// Login
await page.goto('http://192.168.1.90:20001/');
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');

View file

@ -15,7 +15,7 @@ test.afterAll(async () => {
test('Login', async () => {
// Login
await page.goto('http://192.168.1.90:20001/');
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');

View file

@ -15,7 +15,7 @@ test.afterAll(async () => {
test('Login', async () => {
// Login
await page.goto('http://192.168.1.90:20001/');
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');

View file

@ -15,7 +15,7 @@ test.afterAll(async () => {
test('Login', async () => {
// Login
await page.goto('http://192.168.1.90:20001/');
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');

View file

@ -15,7 +15,7 @@ test.afterAll(async () => {
test('Login', async () => {
// Login
await page.goto('http://192.168.1.90:20001/');
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');

View file

@ -15,7 +15,7 @@ test.afterAll(async () => {
test('Login', async () => {
// Login
await page.goto('http://192.168.1.90:20001/');
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');

View file

@ -15,7 +15,7 @@ test.afterAll(async () => {
test('Login', async () => {
// Login
await page.goto('http://192.168.1.90:20001/');
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');

View file

@ -15,7 +15,7 @@ test.afterAll(async () => {
test('Login', async () => {
// Login
await page.goto('http://192.168.1.90:20001/');
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');

View file

@ -15,7 +15,7 @@ test.afterAll(async () => {
test('Login', async () => {
// Login
await page.goto('http://192.168.1.90:20001/');
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');

View file

@ -16,7 +16,7 @@ test.afterAll(async () => {
test('Login', async () => {
// Login
await page.goto('http://192.168.1.90:20001/');
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');

View file

@ -15,7 +15,7 @@ test.afterAll(async () => {
test('Login', async () => {
// Login
await page.goto('http://192.168.1.90:20001/');
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');

View file

@ -15,7 +15,7 @@ test.afterAll(async () => {
test('Login', async () => {
// Login
await page.goto('http://192.168.1.90:20001/');
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');