558 lines
21 KiB
TypeScript
558 lines
21 KiB
TypeScript
|
|
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);
|
||
|
|
});
|