Commit 3e54b8e47ee5f96d474ff06d3edf54198b143b64

Authored by 李玉霞
1 parent bbe2eb88

新增供应商分组用例,修改供应商管理用例

fixtures/testFixture.ts
@@ -5,6 +5,7 @@ import { SalePage } from '../pages/salePage'; @@ -5,6 +5,7 @@ import { SalePage } from '../pages/salePage';
5 import { ConsignmentPage } from '../pages/consignmentPage'; 5 import { ConsignmentPage } from '../pages/consignmentPage';
6 import { CustomerPage } from '../pages/customerPage'; 6 import { CustomerPage } from '../pages/customerPage';
7 import { SupplierPage } from '../pages/supplierPage'; 7 import { SupplierPage } from '../pages/supplierPage';
  8 +import { SupplierGroupingPage } from '../pages/supplierGroupingPage';
8 9
9 /** 10 /**
10 * 页面对象夹具类型定义 11 * 页面对象夹具类型定义
@@ -39,6 +40,11 @@ export type PageFixtures = { @@ -39,6 +40,11 @@ export type PageFixtures = {
39 * 供应商管理页面 40 * 供应商管理页面
40 */ 41 */
41 supplierPage: SupplierPage; 42 supplierPage: SupplierPage;
  43 +
  44 + /**
  45 + * 供应商分组页面
  46 + */
  47 + supplierGroupingPage: SupplierGroupingPage;
42 }; 48 };
43 49
44 /** 50 /**
@@ -74,6 +80,11 @@ export const test = base.extend<PageFixtures>({ @@ -74,6 +80,11 @@ export const test = base.extend<PageFixtures>({
74 supplierPage: async ({ page }, use) => { 80 supplierPage: async ({ page }, use) => {
75 await use(new SupplierPage(page)); 81 await use(new SupplierPage(page));
76 }, 82 },
  83 +
  84 + // 供应商分组页面
  85 + supplierGroupingPage: async ({ page }, use) => {
  86 + await use(new SupplierGroupingPage(page));
  87 + },
77 }); 88 });
78 89
79 /** 90 /**
@@ -114,5 +125,9 @@ export const fullTest = authTest.extend<PageFixtures>({ @@ -114,5 +125,9 @@ export const fullTest = authTest.extend<PageFixtures>({
114 supplierPage: async ({authenticatedPage }, use) => { 125 supplierPage: async ({authenticatedPage }, use) => {
115 await use(new SupplierPage(authenticatedPage)); 126 await use(new SupplierPage(authenticatedPage));
116 }, 127 },
117 - 128 +
  129 + supplierGroupingPage: async ({authenticatedPage }, use) => {
  130 + await use(new SupplierGroupingPage(authenticatedPage));
  131 + },
  132 +
118 }); 133 });
119 \ No newline at end of file 134 \ No newline at end of file
pages/supplierGroupingPage.ts 0 → 100644
  1 +import { Page, Locator } from '@playwright/test';
  2 +import { BasePage } from './basePage';
  3 +
  4 +/**
  5 + * 供应商分组选择器
  6 + */
  7 +const selectors = {
  8 + // 导航
  9 + moreMenu: 'text=更多 >',
  10 + supplierGroupingMenu: 'text=供应商分组',
  11 + addButton: 'text=新建',
  12 +
  13 + // 表单字段
  14 + groupNameInput: 'uni-input:filter([placeholder*="分组名称"]) input',
  15 + remarkInput: 'uni-input:filter([placeholder*="备注"]) input',
  16 +
  17 + // 操作按钮
  18 + confirmButton: 'text=确定',
  19 + saveButton: 'text=确定',
  20 +
  21 + // 供应商分组列表
  22 + supplierGroupingList: '.supplier-grouping-list',
  23 + supplierGroupingItem: '.supplier-grouping-list .item',
  24 +};
  25 +
  26 +/**
  27 + * 供应商分组页面类
  28 + * 处理供应商分组相关操作
  29 + */
  30 +export class SupplierGroupingPage extends BasePage {
  31 + // 导航定位器
  32 + readonly moreMenu!: Locator;
  33 + readonly supplierGroupingMenu: Locator;
  34 + readonly addButton: Locator;
  35 +
  36 + // 表单字段
  37 + readonly groupNameInput: Locator;
  38 + readonly remarkInput: Locator;
  39 +
  40 + // 操作按钮
  41 + readonly confirmButton: Locator;
  42 + readonly saveButton: Locator;
  43 +
  44 + constructor(page: Page) {
  45 + super(page);
  46 +
  47 + // 导航
  48 + this.moreMenu = page.getByText('更多 >');
  49 + this.supplierGroupingMenu = page.getByText('供应商分组').first();
  50 + this.addButton = page.getByText('新建');
  51 +
  52 + // 表单字段
  53 + this.groupNameInput = page.locator('uni-input').filter({ hasText: '请输入分组名称' }).getByRole('textbox');
  54 + this.remarkInput = page.locator('uni-input').filter({ hasText: '请输入备注' }).getByRole('textbox');
  55 +
  56 + // 操作按钮
  57 + this.confirmButton = page.getByText('确定');
  58 + this.saveButton = page.getByText('确定');
  59 + }
  60 +
  61 + /**
  62 + * 打开更多菜单
  63 + */
  64 + async openMoreMenu(): Promise<void> {
  65 + await this.moreMenu.click();
  66 + await this.wait(500);
  67 + }
  68 +
  69 + /**
  70 + * 打开供应商分组页面
  71 + */
  72 + async openSupplierGrouping(): Promise<void> {
  73 + await this.supplierGroupingMenu.click({ force: true });
  74 + await this.waitForPageLoad();
  75 + await this.wait(500);
  76 + }
  77 +
  78 + /**
  79 + * 点击新建分组按钮
  80 + */
  81 + async clickAddButton(): Promise<void> {
  82 + await this.addButton.click();
  83 + await this.waitForPageLoad();
  84 + }
  85 +
  86 + /**
  87 + * 填写分组名称
  88 + * @param name 分组名称
  89 + */
  90 + async fillGroupName(name: string): Promise<void> {
  91 + await this.groupNameInput.click();
  92 + await this.groupNameInput.fill(name);
  93 + }
  94 +
  95 + /**
  96 + * 填写备注
  97 + * @param remark 备注内容
  98 + */
  99 + async fillRemark(remark: string): Promise<void> {
  100 + await this.remarkInput.click();
  101 + await this.remarkInput.fill(remark);
  102 + }
  103 +
  104 + /**
  105 + * 保存分组
  106 + */
  107 + async saveGrouping(): Promise<void> {
  108 + await this.saveButton.click();
  109 + await this.waitForPageLoad();
  110 + await this.wait(500);
  111 + }
  112 +
  113 + /**
  114 + * 搜索分组
  115 + * @param groupName 分组名称
  116 + */
  117 + async searchGrouping(groupName: string): Promise<void> {
  118 + await this.page.getByRole('textbox').click();
  119 + await this.wait(300);
  120 + await this.page.getByRole('textbox').fill(groupName);
  121 + await this.wait(1500);
  122 + await this.page.getByRole('textbox').press('Enter');
  123 + await this.wait(1000);
  124 + }
  125 +
  126 + /**
  127 + * 验证分组是否创建成功
  128 + * @param groupName 分组名称
  129 + */
  130 + async verifyGroupingCreated(groupName: string): Promise<boolean> {
  131 + try {
  132 + await this.navigateToSupplierGrouping();
  133 + await this.searchGrouping(groupName);
  134 + await this.page.waitForSelector(`uni-view:has-text("${groupName}")`, { timeout: 10000 });
  135 + return true;
  136 + } catch {
  137 + return false;
  138 + }
  139 + }
  140 +
  141 + /**
  142 + * 进入供应商分组页面(完整流程)
  143 + */
  144 + async navigateToSupplierGrouping(): Promise<void> {
  145 + await this.navigate('/');
  146 + await this.openMoreMenu();
  147 + await this.openSupplierGrouping();
  148 + }
  149 +
  150 + /**
  151 + * 点击编辑分组按钮
  152 + */
  153 + async clickEditButton(): Promise<void> {
  154 + await this.page.getByText('编辑').click();
  155 + await this.waitForPageLoad();
  156 + }
  157 +
  158 + /**
  159 + * 修改分组
  160 + * @param groupName 新的分组名称
  161 + * @param remark 新的备注
  162 + */
  163 + async updateGrouping(groupName: string, remark: string): Promise<void> {
  164 + await this.fillGroupName(groupName);
  165 + await this.fillRemark(remark);
  166 + await this.saveGrouping();
  167 + }
  168 +
  169 + /**
  170 + * 验证分组是否修改成功
  171 + * @param groupName 分组名称
  172 + */
  173 + async verifyGroupingUpdated(groupName: string): Promise<boolean> {
  174 + try {
  175 + await this.navigateToSupplierGrouping();
  176 + await this.searchGrouping(groupName);
  177 + await this.page.waitForSelector(`uni-view:has-text("${groupName}")`, { timeout: 10000 });
  178 + return true;
  179 + } catch {
  180 + return false;
  181 + }
  182 + }
  183 +
  184 + /**
  185 + * 点击删除分组按钮
  186 + */
  187 + async clickDeleteButton(): Promise<void> {
  188 + await this.page.getByText('删除', { exact: true }).click();
  189 + }
  190 +
  191 + /**
  192 + * 点击分组项
  193 + * @param groupName 分组名称
  194 + */
  195 + async clickGroupingItem(groupName: string): Promise<void> {
  196 + await this.page.locator('uni-view').filter({ hasText: new RegExp(`^${groupName}$`) }).first().click();
  197 + await this.waitForPageLoad();
  198 + }
  199 +
  200 + /**
  201 + * 确认删除分组
  202 + */
  203 + async confirmDelete(): Promise<void> {
  204 + await this.page.getByText('确定', { exact: true }).click();
  205 + await this.waitForPageLoad();
  206 + await this.wait(500);
  207 + }
  208 +
  209 + /**
  210 + * 验证分组是否删除成功
  211 + * @param groupName 分组名称
  212 + */
  213 + async verifyGroupingDeleted(groupName: string): Promise<boolean> {
  214 + try {
  215 + await this.navigateToSupplierGrouping();
  216 + await this.searchGrouping(groupName);
  217 + // 删除成功后,列表会显示"没有数据哦~"
  218 + await this.page.waitForSelector(`uni-view:has-text("No data")`, { timeout: 10000 });
  219 + return true;
  220 + } catch {
  221 + return false;
  222 + }
  223 + }
  224 +}
pages/supplierPage.ts
@@ -276,7 +276,7 @@ export class SupplierPage extends BasePage { @@ -276,7 +276,7 @@ export class SupplierPage extends BasePage {
276 */ 276 */
277 async searchSupplier(supplierName: string): Promise<void> { 277 async searchSupplier(supplierName: string): Promise<void> {
278 await this.page.getByRole('textbox').click(); 278 await this.page.getByRole('textbox').click();
279 - const input = this.page.locator('uni-input').filter({ hasText: '供应商名称' }).getByRole('textbox'); 279 + const input = this.page.locator('uni-input').filter({ hasText: '供应商名称/联系电话' }).getByRole('textbox');
280 await input.fill(supplierName); 280 await input.fill(supplierName);
281 await this.page.waitForTimeout(1500); 281 await this.page.waitForTimeout(1500);
282 await input.press('Enter'); 282 await input.press('Enter');
@@ -372,8 +372,8 @@ export class SupplierPage extends BasePage { @@ -372,8 +372,8 @@ export class SupplierPage extends BasePage {
372 await this.wait(300); 372 await this.wait(300);
373 373
374 await this.page.getByText('1', { exact: true }).click(); 374 await this.page.getByText('1', { exact: true }).click();
375 - await this.page.getByText('0', { exact: true }).nth(1).click();  
376 - await this.page.getByText('0', { exact: true }).nth(1).click(); 375 + await this.page.getByText('0', { exact: true }).nth(0).click();
  376 + await this.page.getByText('0', { exact: true }).nth(0).click();
377 await this.page.getByText('完成').click(); 377 await this.page.getByText('完成').click();
378 } 378 }
379 379
@@ -495,7 +495,7 @@ export class SupplierPage extends BasePage { @@ -495,7 +495,7 @@ export class SupplierPage extends BasePage {
495 // 检查所有金额是否都是'¥ 0' 495 // 检查所有金额是否都是'¥ 0'
496 const allZero = yuanTexts.every(text => { 496 const allZero = yuanTexts.every(text => {
497 const trimmed = text.trim(); 497 const trimmed = text.trim();
498 - return trimmed === '¥ 0' || trimmed === '¥0'; 498 + return trimmed === '¥ 0.00' || trimmed === '¥0.00';
499 }); 499 });
500 500
501 // 如果全为0,返回true(保持在当前页面继续删除流程) 501 // 如果全为0,返回true(保持在当前页面继续删除流程)
tests/supplier.spec.ts 0 → 100644
  1 +import { test, expect } from '../fixtures';
  2 +import * as allure from 'allure-js-commons';
  3 +
  4 +/**
  5 + * 供应商管理测试
  6 + */
  7 +test.describe('供应商管理', () => {
  8 + // 使用已保存的认证状态
  9 + test.use({ storageState: 'auth.json' });
  10 +
  11 + // 强制测试串行执行,避免并行测试之间的干扰
  12 + test.describe.configure({ mode: 'serial' });
  13 +
  14 + test('新建供应商并绑定园区卡', async ({ supplierPage }, testInfo) => {
  15 + await allure.epic('供应商管理');
  16 + await allure.feature('供应商信息');
  17 + await allure.story('新建供应商');
  18 +
  19 + // 步骤1:生成随机供应商信息
  20 + const supplierInfo = await allure.step('生成随机供应商信息', async () => {
  21 + const info = await supplierPage.generateRandomSupplierInfo();
  22 +
  23 + console.log('供应商名称:', info.name);
  24 + console.log('负责人:', info.managerName);
  25 + console.log('手机号:', info.phone);
  26 + console.log('备注:', info.remark);
  27 +
  28 + return info;
  29 + });
  30 +
  31 + // 步骤2:填写并提交供应商表单
  32 + await allure.step('填写并提交供应商表单', async () => {
  33 + await supplierPage.navigateToSupplierManagement();
  34 + await supplierPage.clickAddSupplier();
  35 + await supplierPage.fillFormField(supplierPage.supplierNameInput, supplierInfo.name);
  36 + await supplierPage.selectGroup();
  37 + await supplierPage.fillFormField(supplierPage.managerNameInput, supplierInfo.managerName);
  38 + await supplierPage.fillFormField(supplierPage.phoneInput, supplierInfo.phone);
  39 + await supplierPage.selectParkCard('888810046477', '地利');
  40 + await supplierPage.fillFormField(supplierPage.remarkInput, supplierInfo.remark || '');
  41 + await supplierPage.saveButton.click();
  42 + await supplierPage.attachScreenshot(testInfo, '新建供应商成功截图');
  43 + });
  44 +
  45 + // 步骤3:验证供应商创建成功
  46 + await allure.step('验证供应商创建成功', async () => {
  47 + const isCreated = await supplierPage.verifySupplierCreated(supplierInfo.name);
  48 + expect(isCreated).toBeTruthy();
  49 + });
  50 + });
  51 +
  52 + test('编辑供应商并绑定园区卡', async ({ supplierPage }, testInfo) => {
  53 + await allure.epic('供应商管理');
  54 + await allure.feature('供应商信息');
  55 + await allure.story('编辑供应商');
  56 +
  57 + // 步骤1:生成新的供应商信息
  58 + const supplierInfo = await allure.step('生成新的供应商信息', async () => {
  59 + const namePrefixes = ['修改', '更新', '调整', '变更'];
  60 + const namePrefix = namePrefixes[Math.floor(Math.random() * namePrefixes.length)];
  61 + const info = await supplierPage.generateRandomSupplierInfo({
  62 + namePrefix: namePrefix,
  63 + });
  64 +
  65 + console.log('新供应商名称:', info.name);
  66 + console.log('新负责人:', info.managerName);
  67 + console.log('新手机号:', info.phone);
  68 + console.log('新备注:', info.remark);
  69 +
  70 + return info;
  71 + });
  72 +
  73 + // 步骤2:填写并提交供应商表单
  74 + await allure.step('填写并提交供应商表单', async () => {
  75 + await supplierPage.navigateToSupplierManagement();
  76 + await supplierPage.clickSupplierItemByIndex(0);
  77 + await supplierPage.clickEditButton();
  78 + await supplierPage.clearAndFillFormField(supplierPage.supplierNameInput, supplierInfo.name);
  79 + await supplierPage.clearAndFillFormField(supplierPage.managerNameInput, supplierInfo.managerName);
  80 + await supplierPage.clearAndFillFormField(supplierPage.phoneInput, supplierInfo.phone);
  81 + await supplierPage.selectSupplierType();
  82 + await supplierPage.selectParkCard('888800010617');
  83 + await supplierPage.clearAndFillFormField(supplierPage.remarkInput, supplierInfo.remark || '');
  84 + await supplierPage.clickConfirmButton();
  85 + await supplierPage.attachScreenshot(testInfo, '编辑供应商成功截图');
  86 + });
  87 +
  88 + // 步骤3:验证供应商修改成功
  89 + await allure.step('验证供应商修改成功', async () => {
  90 + const isUpdated = await supplierPage.verifySupplierCreated(supplierInfo.name);
  91 + expect(isUpdated).toBeTruthy();
  92 + });
  93 + });
  94 +
  95 + test('删除供应商(金额都为0)', async ({ supplierPage }, testInfo) => {
  96 + await allure.epic('供应商管理');
  97 + await allure.feature('供应商信息');
  98 + await allure.story('删除供应商');
  99 +
  100 + // 步骤1:进入供应商管理页面
  101 + await allure.step('进入供应商管理页面', async () => {
  102 + await supplierPage.navigateToSupplierManagement();
  103 + });
  104 +
  105 + // 步骤2:查找并点击金额都为0的供应商
  106 + await allure.step('查找并点击金额都为0的供应商', async () => {
  107 + const found = await supplierPage.clickSupplierWithZeroAmounts();
  108 + expect(found).toBeTruthy();
  109 + });
  110 +
  111 + // 步骤3:点击删除按钮
  112 + await allure.step('点击删除按钮', async () => {
  113 + await supplierPage.clickDeleteButton();
  114 + });
  115 +
  116 + // 步骤4:确认删除
  117 + await allure.step('确认删除', async () => {
  118 + await supplierPage.confirmDelete();
  119 + await supplierPage.attachScreenshot(testInfo, '删除供应商成功截图');
  120 + });
  121 + });
  122 +
  123 + test('录入欠款并验证应付金额增加', async ({ supplierPage }, testInfo) => {
  124 + await allure.epic('供应商管理');
  125 + await allure.feature('供应商信息');
  126 + await allure.story('录入欠款');
  127 +
  128 + // 录入的欠款金额
  129 + const debtAmount = '100';
  130 + const remark = '测试录入欠款';
  131 +
  132 + // 步骤1:进入供应商管理页面并选择第2个供应商,记录原始应付金额和供应商名称
  133 + let supplierName = '';
  134 + const originalAmount = await allure.step('记录原始应付金额', async () => {
  135 + await supplierPage.navigateToSupplierManagement();
  136 + await supplierPage.clickSupplierItemByIndex(1);
  137 + await supplierPage.waitForPageLoad();
  138 + await supplierPage.wait(300);
  139 + supplierName = await supplierPage.getSupplierName();
  140 + return await supplierPage.parsePayableAmount();
  141 + });
  142 + console.log('录入前应付金额:', originalAmount);
  143 +
  144 + // 步骤2:点击录入欠款
  145 + await allure.step('点击录入欠款', async () => {
  146 + await supplierPage.clickRecordDebt();
  147 + });
  148 +
  149 + // 步骤3:选择欠款方向(我方欠供应商)
  150 + await allure.step('选择欠款方向', async () => {
  151 + await supplierPage.selectDebtDirection('oweSupplier');
  152 + });
  153 +
  154 + // 步骤4:选择赊欠日期(今日)
  155 + await allure.step('选择赊欠日期', async () => {
  156 + await supplierPage.selectDebtDate();
  157 + });
  158 +
  159 + // 步骤5:填写赊欠金额
  160 + await allure.step('填写赊欠金额', async () => {
  161 + await supplierPage.fillDebtAmount(debtAmount);
  162 + });
  163 +
  164 + // 步骤6:填写备注
  165 + await allure.step('填写备注', async () => {
  166 + await supplierPage.fillRemark(remark);
  167 + });
  168 +
  169 + // 步骤7:保存欠款记录
  170 + await allure.step('保存欠款记录', async () => {
  171 + await supplierPage.saveDebt();
  172 + });
  173 +
  174 + // 步骤8:验证欠款录入成功 - 搜索同一供应商查看应付金额
  175 + const currentAmount = await allure.step('验证欠款录入成功', async () => {
  176 + await supplierPage.navigateToSupplierManagement();
  177 + await supplierPage.clickSupplierItemByIndex(1);
  178 + await supplierPage.page.waitForLoadState('networkidle');
  179 + await supplierPage.page.waitForTimeout(300);
  180 + const amount = await supplierPage.parsePayableAmount();
  181 + console.log('录入后应付金额:', amount);
  182 + return amount;
  183 + });
  184 +
  185 + // 验证应付金额增加了录入的金额
  186 + expect(currentAmount).toBeCloseTo(originalAmount + parseFloat(debtAmount), 1);
  187 +
  188 + await supplierPage.attachScreenshot(testInfo, '录入欠款成功截图');
  189 + });
  190 +});
tests/supplier_add.spec.ts deleted 100644 → 0
1 -import { test, expect } from '../fixtures';  
2 -import * as allure from 'allure-js-commons';  
3 -  
4 -/**  
5 - * 供应商管理测试  
6 - */  
7 -// 新增供应商  
8 -test.describe('供应商管理', () => {  
9 - // 使用已保存的认证状态  
10 - test.use({ storageState: 'auth.json' });  
11 -  
12 - // 强制测试串行执行,避免并行测试之间的干扰  
13 - test.describe.configure({ mode: 'serial' });  
14 -  
15 - test('新建供应商并绑定园区卡', async ({ supplierPage }, testInfo) => {  
16 - // 添加allure元素  
17 - await allure.epic('供应商管理');  
18 - await allure.feature('供应商信息');  
19 - await allure.story('新建供应商');  
20 -  
21 - // 步骤1:生成随机供应商信息  
22 - const supplierInfo = await allure.step('生成随机供应商信息', async () => {  
23 - const info = await supplierPage.generateRandomSupplierInfo();  
24 -  
25 - console.log('供应商名称:', info.name);  
26 - console.log('负责人:', info.managerName);  
27 - console.log('手机号:', info.phone);  
28 - console.log('备注:', info.remark);  
29 -  
30 - return info;  
31 - });  
32 -  
33 - // 步骤2:填写并提交供应商表单  
34 - await allure.step('填写并提交供应商表单', async () => {  
35 - // 进入供应商管理页面  
36 - await supplierPage.navigateToSupplierManagement();  
37 -  
38 - // 点击新建供应商  
39 - await supplierPage.clickAddSupplier();  
40 -  
41 - // 填写供应商名称  
42 - await supplierPage.fillFormField(supplierPage.supplierNameInput, supplierInfo.name);  
43 -  
44 - // 选择供应商分组  
45 - await supplierPage.selectGroup();  
46 -  
47 - // 填写负责人名称  
48 - await supplierPage.fillFormField(supplierPage.managerNameInput, supplierInfo.managerName);  
49 -  
50 - // 填写手机号  
51 - await supplierPage.fillFormField(supplierPage.phoneInput, supplierInfo.phone);  
52 -  
53 - // 绑定园区卡  
54 - await supplierPage.selectParkCard('888810046477', '地利');  
55 -  
56 - // 填写备注  
57 - await supplierPage.fillFormField(supplierPage.remarkInput, supplierInfo.remark || '');  
58 -  
59 - // 保存  
60 - await supplierPage.saveButton.click();  
61 -  
62 - await supplierPage.attachScreenshot(testInfo, '新建供应商成功截图');  
63 - });  
64 -  
65 - // 步骤3:验证供应商创建成功  
66 - await allure.step('验证供应商创建成功', async () => {  
67 - const isCreated = await supplierPage.verifySupplierCreated(supplierInfo.name);  
68 - expect(isCreated).toBeTruthy();  
69 - });  
70 - });  
71 -});  
tests/supplier_bill.spec.ts deleted 100644 → 0
1 -import { test, expect } from '../fixtures';  
2 -import * as allure from 'allure-js-commons';  
3 -  
4 -/**  
5 - * 供应商管理测试 - 录入欠款  
6 - */  
7 -test.describe('供应商管理-录入欠款', () => {  
8 - // 使用已保存的认证状态  
9 - test.use({ storageState: 'auth.json' });  
10 -  
11 - // 强制测试串行执行  
12 - test.describe.configure({ mode: 'serial' });  
13 -  
14 - test('录入欠款并验证应付金额增加', async ({ supplierPage }, testInfo) => {  
15 - // 添加allure元素  
16 - await allure.epic('供应商管理');  
17 - await allure.feature('供应商信息');  
18 - await allure.story('录入欠款');  
19 -  
20 - // 录入的欠款金额  
21 - const debtAmount = '100';  
22 - const remark = '测试录入欠款';  
23 -  
24 - // 步骤1:进入供应商管理页面并选择第2个供应商,记录原始应付金额和供应商名称  
25 - let supplierName = '';  
26 - const originalAmount = await allure.step('记录原始应付金额', async () => {  
27 - await supplierPage.navigateToSupplierManagement();  
28 - await supplierPage.clickSupplierItemByIndex(1);  
29 - await supplierPage.page.waitForLoadState('networkidle');  
30 - await supplierPage.page.waitForTimeout(300);  
31 - return await supplierPage.parsePayableAmount();  
32 - });  
33 - console.log('录入前应付金额:', originalAmount);  
34 -  
35 - // 步骤2:点击录入欠款  
36 - await allure.step('点击录入欠款', async () => {  
37 - await supplierPage.clickRecordDebt();  
38 - });  
39 -  
40 - // 步骤3:选择欠款方向(我方欠供应商)  
41 - await allure.step('选择欠款方向', async () => {  
42 - await supplierPage.selectDebtDirection('oweSupplier');  
43 - });  
44 -  
45 - // 步骤4:选择赊欠日期(今日)  
46 - await allure.step('选择赊欠日期', async () => {  
47 - await supplierPage.selectDebtDate();  
48 - });  
49 -  
50 - // 步骤5:填写赊欠金额  
51 - await allure.step('填写赊欠金额', async () => {  
52 - await supplierPage.fillDebtAmount(debtAmount);  
53 - });  
54 -  
55 - // 步骤6:填写备注  
56 - await allure.step('填写备注', async () => {  
57 - await supplierPage.fillRemark(remark);  
58 - });  
59 -  
60 - // 步骤7:保存欠款记录  
61 - await allure.step('保存欠款记录', async () => {  
62 - await supplierPage.saveDebt();  
63 - });  
64 -  
65 - // 步骤8:验证欠款录入成功 - 搜索同一供应商查看应付金额  
66 - const currentAmount = await allure.step('验证欠款录入成功', async () => {  
67 - await supplierPage.navigateToSupplierManagement();  
68 - await supplierPage.clickSupplierItemByIndex(1);  
69 - await supplierPage.page.waitForLoadState('networkidle');  
70 - await supplierPage.page.waitForTimeout(300);  
71 - const amount = await supplierPage.parsePayableAmount();  
72 - console.log('录入后应付金额:', amount);  
73 - return amount;  
74 - });  
75 -  
76 - // 验证应付金额增加了录入的金额  
77 - expect(currentAmount).toBeCloseTo(originalAmount + parseFloat(debtAmount), 1);  
78 -  
79 - await supplierPage.attachScreenshot(testInfo, '录入欠款成功截图');  
80 - });  
81 -});  
82 \ No newline at end of file 0 \ No newline at end of file
tests/supplier_delete.spec.ts deleted 100644 → 0
1 -import { test, expect } from '../fixtures';  
2 -import * as allure from 'allure-js-commons';  
3 -  
4 -/**  
5 - * 供应商管理测试 - 删除供应商  
6 - */  
7 -test.describe('供应商管理-删除', () => {  
8 - // 使用已保存的认证状态  
9 - test.use({ storageState: 'auth.json' });  
10 -  
11 - // 强制测试串行执行  
12 - test.describe.configure({ mode: 'serial' });  
13 -  
14 - test('删除供应商(金额都为0)', async ({ supplierPage }, testInfo) => {  
15 - // 添加allure元素  
16 - await allure.epic('供应商管理');  
17 - await allure.feature('供应商信息');  
18 - await allure.story('删除供应商');  
19 -  
20 - // 步骤1:进入供应商管理页面  
21 - await allure.step('进入供应商管理页面', async () => {  
22 - await supplierPage.navigateToSupplierManagement();  
23 - });  
24 -  
25 - // 步骤2:查找并点击金额都为0的供应商  
26 - await allure.step('查找并点击金额都为0的供应商', async () => {  
27 - const found = await supplierPage.clickSupplierWithZeroAmounts();  
28 - expect(found).toBeTruthy();  
29 - });  
30 -  
31 - // 步骤3:点击删除按钮  
32 - await allure.step('点击删除按钮', async () => {  
33 - await supplierPage.clickDeleteButton();  
34 - });  
35 -  
36 - // 步骤4:确认删除  
37 - await allure.step('确认删除', async () => {  
38 - await supplierPage.confirmDelete();  
39 - await supplierPage.attachScreenshot(testInfo, '删除供应商成功截图');  
40 - });  
41 - });  
42 -});  
43 \ No newline at end of file 0 \ No newline at end of file
tests/supplier_grouping.spec.ts 0 → 100644
  1 +import { test, expect } from '../fixtures';
  2 +import * as allure from 'allure-js-commons';
  3 +
  4 +/**
  5 + * 供应商分组管理测试
  6 + */
  7 +test.describe('供应商分组管理', () => {
  8 + // 使用已保存的认证状态
  9 + test.use({ storageState: 'auth.json' });
  10 +
  11 + // 强制测试串行执行,避免并行测试之间的干扰
  12 + test.describe.configure({ mode: 'serial' });
  13 +
  14 + test('新增供应商分组', async ({ supplierGroupingPage }, testInfo) => {
  15 + await allure.epic('供应商管理');
  16 + await allure.feature('供应商分组');
  17 + await allure.story('新增供应商分组');
  18 +
  19 + // 步骤1:生成随机分组信息
  20 + const groupName = `自动${Date.now().toString().slice(-3)}`;
  21 + const remark = '自动化测试';
  22 +
  23 + // 步骤2:进入供应商分组页面并点击新建
  24 + await allure.step('进入供应商分组页面', async () => {
  25 + await supplierGroupingPage.navigateToSupplierGrouping();
  26 + await supplierGroupingPage.clickAddButton();
  27 + });
  28 +
  29 + // 步骤3:填写分组信息
  30 + await allure.step('填写分组信息', async () => {
  31 + await supplierGroupingPage.fillGroupName(groupName);
  32 + await supplierGroupingPage.fillRemark(remark);
  33 + });
  34 +
  35 + // 步骤4:保存分组
  36 + await allure.step('保存分组', async () => {
  37 + await supplierGroupingPage.saveGrouping();
  38 + await supplierGroupingPage.attachScreenshot(testInfo, '新增供应商分组成功截图');
  39 + });
  40 +
  41 + // 步骤5:验证分组创建成功
  42 + await allure.step('验证分组创建成功', async () => {
  43 + const isCreated = await supplierGroupingPage.verifyGroupingCreated(groupName);
  44 + expect(isCreated).toBeTruthy();
  45 + });
  46 + });
  47 +
  48 + test('修改供应商分组', async ({ supplierGroupingPage }, testInfo) => {
  49 + await allure.epic('供应商管理');
  50 + await allure.feature('供应商分组');
  51 + await allure.story('修改供应商分组');
  52 +
  53 + // 步骤1:生成新的分组信息
  54 + const newGroupName = `修改${Date.now().toString().slice(-2)}`;
  55 + const newRemark = '自动化测试修改';
  56 +
  57 + // 步骤2:进入供应商分组页面
  58 + await allure.step('进入供应商分组页面', async () => {
  59 + await supplierGroupingPage.navigateToSupplierGrouping();
  60 + });
  61 +
  62 + // 步骤3:点击编辑分组
  63 + await allure.step('点击编辑分组', async () => {
  64 + await supplierGroupingPage.clickEditButton();
  65 + });
  66 +
  67 + // 步骤4:修改分组信息
  68 + await allure.step('修改分组信息', async () => {
  69 + await supplierGroupingPage.updateGrouping(newGroupName, newRemark);
  70 + await supplierGroupingPage.attachScreenshot(testInfo, '修改供应商分组成功截图');
  71 + });
  72 +
  73 + // 步骤5:验证分组修改成功
  74 + await allure.step('验证分组修改成功', async () => {
  75 + const isUpdated = await supplierGroupingPage.verifyGroupingUpdated(newGroupName);
  76 + expect(isUpdated).toBeTruthy();
  77 + });
  78 + });
  79 +
  80 + test('删除供应商分组', async ({ supplierGroupingPage }, testInfo) => {
  81 + await allure.epic('供应商管理');
  82 + await allure.feature('供应商分组');
  83 + await allure.story('删除供应商分组');
  84 +
  85 + // 步骤1:生成待删除的分组名称
  86 + const groupName = `删除${Date.now().toString().slice(-2)}`;
  87 +
  88 + // 步骤2:先创建一个分组用于删除
  89 + await allure.step('创建待删除的分组', async () => {
  90 + await supplierGroupingPage.navigateToSupplierGrouping();
  91 + await supplierGroupingPage.clickAddButton();
  92 + await supplierGroupingPage.fillGroupName(groupName);
  93 + await supplierGroupingPage.fillRemark('自动化测试');
  94 + await supplierGroupingPage.saveGrouping();
  95 + });
  96 +
  97 + // 步骤3:删除分组
  98 + await allure.step('删除分组', async () => {
  99 + await supplierGroupingPage.navigateToSupplierGrouping();
  100 + await supplierGroupingPage.clickGroupingItem(groupName);
  101 + await supplierGroupingPage.clickDeleteButton();
  102 + await supplierGroupingPage.confirmDelete();
  103 + await supplierGroupingPage.attachScreenshot(testInfo, '删除供应商分组成功截图');
  104 + });
  105 +
  106 + // 步骤4:验证分组删除成功
  107 + await allure.step('验证分组删除成功', async () => {
  108 + const isDeleted = await supplierGroupingPage.verifyGroupingDeleted(groupName);
  109 + expect(isDeleted).toBeTruthy();
  110 + });
  111 + });
  112 +});
tests/supplier_update.spec.ts deleted 100644 → 0
1 -import { test, expect } from '../fixtures';  
2 -import * as allure from 'allure-js-commons';  
3 -  
4 -/**  
5 - * 供应商管理测试 - 编辑供应商  
6 - */  
7 -test.describe('供应商管理-编辑', () => {  
8 - // 使用已保存的认证状态  
9 - test.use({ storageState: 'auth.json' });  
10 -  
11 - // 强制测试串行执行  
12 - test.describe.configure({ mode: 'serial' });  
13 -  
14 - test('编辑供应商并绑定园区卡', async ({ supplierPage }, testInfo) => {  
15 - // 添加allure元素  
16 - await allure.epic('供应商管理');  
17 - await allure.feature('供应商信息');  
18 - await allure.story('编辑供应商');  
19 -  
20 - // 步骤1:生成新的供应商信息  
21 - const supplierInfo = await allure.step('生成新的供应商信息', async () => {  
22 - // 随机生成供应商名称前缀  
23 - const namePrefixes = ['修改', '更新', '调整', '变更'];  
24 - const namePrefix = namePrefixes[Math.floor(Math.random() * namePrefixes.length)];  
25 -  
26 - const info = await supplierPage.generateRandomSupplierInfo({  
27 - namePrefix: namePrefix,  
28 - });  
29 -  
30 - console.log('新供应商名称:', info.name);  
31 - console.log('新负责人:', info.managerName);  
32 - console.log('新手机号:', info.phone);  
33 - console.log('新备注:', info.remark);  
34 -  
35 - return info;  
36 - });  
37 -  
38 - // 步骤2:填写并提交供应商表单  
39 - await allure.step('填写并提交供应商表单', async () => {  
40 - // 进入供应商管理页面  
41 - await supplierPage.navigateToSupplierManagement();  
42 -  
43 - // 选择供应商列表项(点击第一个)  
44 - await supplierPage.clickSupplierItemByIndex(0);  
45 -  
46 - // 点击编辑按钮  
47 - await supplierPage.clickEditButton();  
48 -  
49 - // 修改供应商名称  
50 - await supplierPage.clearAndFillFormField(supplierPage.supplierNameInput, supplierInfo.name);  
51 -  
52 - // 修改负责人名称  
53 - await supplierPage.clearAndFillFormField(supplierPage.managerNameInput, supplierInfo.managerName);  
54 -  
55 - // 修改手机号  
56 - await supplierPage.clearAndFillFormField(supplierPage.phoneInput, supplierInfo.phone);  
57 -  
58 - // 选择供应商类型(必选字段)  
59 - await supplierPage.selectSupplierType();  
60 -  
61 - // 绑定园区卡  
62 - await supplierPage.selectParkCard('888800010617');  
63 -  
64 - // 修改备注  
65 - await supplierPage.clearAndFillFormField(supplierPage.remarkInput, supplierInfo.remark || '');  
66 -  
67 - // 保存  
68 - await supplierPage.clickConfirmButton();  
69 -  
70 - await supplierPage.attachScreenshot(testInfo, '编辑供应商成功截图');  
71 - });  
72 -  
73 - // 步骤3:验证供应商修改成功  
74 - await allure.step('验证供应商修改成功', async () => {  
75 - const isUpdated = await supplierPage.verifySupplierCreated(supplierInfo.name);  
76 - expect(isUpdated).toBeTruthy();  
77 - });  
78 - });  
79 -});  
80 \ No newline at end of file 0 \ No newline at end of file