supplier_bill.spec.ts
2.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import { test, expect } from '../fixtures';
import * as allure from 'allure-js-commons';
/**
* 供应商管理测试 - 录入欠款
*/
test.describe('供应商管理-录入欠款', () => {
// 使用已保存的认证状态
test.use({ storageState: 'auth.json' });
// 强制测试串行执行
test.describe.configure({ mode: 'serial' });
test('录入欠款并验证应付金额增加', async ({ supplierPage }, testInfo) => {
// 添加allure元素
await allure.epic('供应商管理');
await allure.feature('供应商信息');
await allure.story('录入欠款');
// 录入的欠款金额
const debtAmount = '100';
const remark = '测试录入欠款';
// 步骤1:进入供应商管理页面并选择第2个供应商,记录原始应付金额和供应商名称
let supplierName = '';
const originalAmount = await allure.step('记录原始应付金额', async () => {
await supplierPage.navigateToSupplierManagement();
await supplierPage.clickSupplierItemByIndex(1);
await supplierPage.page.waitForLoadState('networkidle');
await supplierPage.page.waitForTimeout(300);
return await supplierPage.parsePayableAmount();
});
console.log('录入前应付金额:', originalAmount);
// 步骤2:点击录入欠款
await allure.step('点击录入欠款', async () => {
await supplierPage.clickRecordDebt();
});
// 步骤3:选择欠款方向(我方欠供应商)
await allure.step('选择欠款方向', async () => {
await supplierPage.selectDebtDirection('oweSupplier');
});
// 步骤4:选择赊欠日期(今日)
await allure.step('选择赊欠日期', async () => {
await supplierPage.selectDebtDate();
});
// 步骤5:填写赊欠金额
await allure.step('填写赊欠金额', async () => {
await supplierPage.fillDebtAmount(debtAmount);
});
// 步骤6:填写备注
await allure.step('填写备注', async () => {
await supplierPage.fillRemark(remark);
});
// 步骤7:保存欠款记录
await allure.step('保存欠款记录', async () => {
await supplierPage.saveDebt();
});
// 步骤8:验证欠款录入成功 - 搜索同一供应商查看应付金额
const currentAmount = await allure.step('验证欠款录入成功', async () => {
await supplierPage.navigateToSupplierManagement();
await supplierPage.clickSupplierItemByIndex(1);
await supplierPage.page.waitForLoadState('networkidle');
await supplierPage.page.waitForTimeout(300);
const amount = await supplierPage.parsePayableAmount();
console.log('录入后应付金额:', amount);
return amount;
});
// 验证应付金额增加了录入的金额
expect(currentAmount).toBeCloseTo(originalAmount + parseFloat(debtAmount), 1);
await supplierPage.attachScreenshot(testInfo, '录入欠款成功截图');
});
});