consignmentOrder.spec.ts 3.14 KB
import { test, expect } from '../fixtures';
import { generateOtherName } from '../utils/dataGenerator';
import * as allure from 'allure-js-commons';

/**
 * 代销入库测试
 */
test.describe('代销入库', () => {
  // 使用已保存的认证状态
  test.use({ storageState: 'auth.json' });

  test('新增代销入库 - 完整流程', async ({ consignmentPage },testInfo) => {
    // 添加allure元素
    await allure.epic('代销管理');
    await allure.feature('代销入库'); 
    await allure.story('创建代销入库订单'); 
    // 步骤1,生成批次别名
    const batchAlias = await allure.step('生成唯一批次别名',async(step)=>{
      const alias = generateOtherName('自代卖');
      console.log('生成的批次别名:', alias);
      return alias;
    });
    // 生成唯一批次别名
    // const batchAlias = generateOtherName('代卖');
    // console.log('生成的批次别名:', batchAlias);

    // 步骤2.执行代销入库
    await allure.step('填写并提交代销入库表单',async()=>{
      await consignmentPage.createConsignmentOrder(
        batchAlias,           // 批次别名
        '娃娃菜',        // 商品名称
        '10',                 // 数量
        '1'                   // 费用金额
      );
      await consignmentPage.attachScreenshot(testInfo,'代销入库成功截图');
    })
    // 使用页面对象创建代销入库
    // await consignmentPage.createConsignmentOrder(
    //   batchAlias,           // 批次别名
    //   '娃娃菜',        // 商品名称
    //   '10',                 // 数量
    //   '1'                   // 费用金额
    // );
  });

  // test('新增代销入库 - 简化流程(无费用)', async ({ consignmentPage }) => {
  //   // 生成唯一批次别名
  //   const batchAlias = generateOtherName('代卖');
  //   console.log('生成的批次别名:', batchAlias);

  //   // 使用简化流程创建代销入库
  //   await consignmentPage.createSimpleConsignmentOrder(
  //     batchAlias,           // 批次别名
  //     '娃娃菜'         // 商品名称
  //   );

  //   // 验证批次创建成功
  //   await consignmentPage.expectBatchCreated(batchAlias);
  // });

  // test('新增代销入库 - 分步操作示例', async ({ consignmentPage }) => {
  //   // 生成唯一批次别名
  //   const batchAlias = generateOtherName('代卖');
  //   console.log('生成的批次别名:', batchAlias);

  //   // 导航到新增页面
  //   await consignmentPage.navigateToNewConsignment();

  //   // 选择仓库
  //   await consignmentPage.selectWarehouse();
  //   await consignmentPage.selectSecondWarehouse();

  //   // 输入批次别名
  //   await consignmentPage.enterBatchAlias(batchAlias);

  //   // 选择商品并输入数量
  //   await consignmentPage.selectProductWithQuantity('娃娃菜', '10');

  //   // 添加费用
  //   await consignmentPage.addExpense(0, '1');
  //   await consignmentPage.selectPaymentMethod(0);

  //   // 点击创建
  //   await consignmentPage.clickCreate();
  //   await consignmentPage.waitForCreationComplete();

  //   // 验证
  //   await consignmentPage.expectBatchCreated(batchAlias);
  // });
});