test : Create Script Role&Permission
This commit is contained in:
parent
5bc28bf893
commit
9254c0183e
67 changed files with 11224 additions and 729 deletions
|
|
@ -0,0 +1,115 @@
|
|||
import { test, expect, Page } from '@playwright/test';
|
||||
import { strictEqual } from 'assert';
|
||||
|
||||
let page: Page;
|
||||
|
||||
test.beforeAll(async ({ browser }) => {
|
||||
page = await browser.newPage();
|
||||
});
|
||||
|
||||
test.afterAll(async () => {
|
||||
if (page !== undefined) {
|
||||
await page.close();
|
||||
}
|
||||
});
|
||||
|
||||
test('Login', async () => {
|
||||
// Login
|
||||
await page.goto('http://192.168.1.90:20001/');
|
||||
await expect(page).toHaveTitle(/^Sign in to /);
|
||||
await page.fill("input[name='username']", 'admin');
|
||||
await page.fill("input[name='password']", '1234');
|
||||
await page.click('id=kc-login');
|
||||
await page.waitForTimeout(2000);
|
||||
// await page.click('id=acceptBtn');
|
||||
});
|
||||
|
||||
test('ทดสอบการเพิ่มกลุ่มสินค้าและบริการ', 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.fill("(//input[@id='input-name'])[2]", 'ประกัน');
|
||||
await page.fill("(//textarea[@id='input-detail'])[2]", 'รายละเอียดประกัน');
|
||||
await page.fill("(//textarea[@id='input-remark'])[2]", 'หมายเหตุประกัน');
|
||||
|
||||
// บันทึกการสร้างกลุ่มสินค้นและบริการ
|
||||
await page.click('id=btn-form-submit');
|
||||
|
||||
// ตรวจสอบหลังทำการสร้างกลุ่มสินค้าและบริการ
|
||||
const newProductAndServiceLocator = page.locator(
|
||||
"//div[normalize-space(text())='ประกัน']",
|
||||
);
|
||||
await newProductAndServiceLocator.waitFor({ state: 'visible' });
|
||||
|
||||
// ดึงข้อความให้ตรงจาก XPath
|
||||
|
||||
const newProductAndServiceName =
|
||||
await newProductAndServiceLocator.textContent();
|
||||
|
||||
// ตรวจสอบความถูกต้องหลังทำการสร้างกลุ่มสินค้าและบริการ
|
||||
if (newProductAndServiceName !== null) {
|
||||
const trimmedName = newProductAndServiceName.trim();
|
||||
expect(trimmedName).toBe('ประกัน');
|
||||
console.log('การตรวจสอบสำเร็จ : ถูกต้อง');
|
||||
} else {
|
||||
throw new Error('ไม่พบข้อมูลที่บันทึก');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('เกิดข้อผิดการในการทดสอบ');
|
||||
throw error;
|
||||
}
|
||||
|
||||
await page.waitForTimeout(2000);
|
||||
});
|
||||
|
||||
test('ทดสอบการเพิ่มประเภท', async () => {
|
||||
// เข้าสู่หน้าหลุ่มสินค้าและบริการ
|
||||
await page.click("(//div[@id='tree-enter-ประกัน']//div)[1]");
|
||||
|
||||
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-form-submit');
|
||||
|
||||
// ตรวจสอบหลังทำการสร้างกลุ่มสินค้าและบริการ
|
||||
const newProductAndServiceLocator = page.locator(
|
||||
"//div[normalize-space(text())='ประกัน']",
|
||||
);
|
||||
await newProductAndServiceLocator.waitFor({ state: 'visible' });
|
||||
|
||||
// ดึงข้อความให้ตรงจาก XPath
|
||||
|
||||
const newProductAndServiceName =
|
||||
await newProductAndServiceLocator.textContent();
|
||||
|
||||
// ตรวจสอบความถูกต้องหลังทำการสร้างกลุ่มสินค้าและบริการ
|
||||
if (newProductAndServiceName !== null) {
|
||||
const trimmedName = newProductAndServiceName.trim();
|
||||
expect(trimmedName).toBe('ประกัน');
|
||||
console.log('การตรวจสอบสำเร็จ : ถูกต้อง');
|
||||
} else {
|
||||
throw new Error('ไม่พบข้อมูลที่บันทึก');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('เกิดข้อผิดการในการทดสอบ');
|
||||
throw error;
|
||||
}
|
||||
|
||||
await page.waitForTimeout(2000);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue