Status: ready-for-dev
作为测试开发者, 我想要编写创建渠道的 E2E 测试(可选), 以便验证渠道创建功能(如需要)。
注意: 此 Story 标记为"可选",原因:
AC1: 基本创建渠道测试
web/tests/e2e/specs/admin/channel-create.spec.tsAC2: 完整表单字段测试
AC3: 表单验证测试
AC4: 对话框元素验证
AC5: 数据唯一性测试
[ ] 任务 1: 创建测试文件和基础结构 (AC: 1, 5)
web/tests/e2e/specs/admin/channel-create.spec.tstest-users.jsontest.describe('渠道创建功能', () => { ... })[ ] 任务 2: 基本创建流程测试 (AC: 1, 5)
[ ] 任务 3: 完整表单字段测试 (AC: 2)
[ ] 任务 4: 表单验证测试 (AC: 3)
[ ] 任务 5: 对话框元素验证 (AC: 4)
[ ] 任务 6: 数据唯一性测试 (AC: 5)
[ ] 任务 7: 运行测试并验证 (AC: 全部)
pnpm test:e2e:chromium channel-createEpic 11: 基础配置管理测试 (Epic F)
为平台、公司、渠道配置管理编写 E2E 测试,为后续用户管理和跨端测试提供必要的测试数据。
实体关系链:
Platform (平台)
↓ 1:N
Company (公司) - 必须 platformId
↓ 1:N
Order (订单) - 必须 companyId
↓
Channel (渠道) - 订单的可选条件
Story 11.8 可选性的原因:
Channel 是订单的可选字段
channelId 是可选的(optional())优先级较低
实现时机
idx_channel_name)Story 11.7 已完成的工作:
ChannelManagementPage 类goto(), expectToBeVisible()openCreateDialog(), cancelDialog(), waitForDialogClosed()fillChannelForm(), submitForm()createChannel(), deleteChannel()searchByName(), channelExists()从 platform-create.spec.ts 中学习的测试模式:
1. 测试文件结构:
import { test, expect } from '../../utils/test-setup';
import { readFileSync } from 'fs';
import { join, dirname } from 'path';
import { fileURLToPath } from 'url';
const testUsers = JSON.parse(readFileSync(...));
test.describe('平台创建功能', () => {
test.beforeEach(async ({ adminLoginPage, platformManagementPage }) => {
// 登录 + 导航
});
test.describe('基本创建流程测试', () => {
// 测试用例
});
});
2. 数据唯一性策略:
const timestamp = Date.now();
const platformName = `测试平台_${timestamp}`;
3. 基本创建测试流程:
4. 测试清理:
deleteChannel() 方法删除测试数据| 特性 | Platform | Company | Channel |
|---|---|---|---|
| 外键依赖 | 无 | 需要 platformId | 无 |
| 名称唯一性 | 全局 | 同平台下唯一 | 全局 |
| 必填字段 | platformName | companyName | channelName |
| 可选字段 | 联系人信息 | 地址 + platformId | channelType, description |
Channel 特有的特点:
测试文件: web/tests/e2e/specs/admin/channel-create.spec.ts
测试套件结构:
基本创建流程测试
完整表单字段测试
表单验证测试
对话框元素验证
数据唯一性测试
测试后清理验证
export interface ChannelData {
/** 渠道名称(必填) */
channelName: string;
/** 渠道类型(可选) */
channelType?: string;
/** 联系人(可选) */
contactPerson?: string;
/** 联系电话(可选) */
contactPhone?: string;
/** 描述(可选) */
description?: string;
}
// 创建渠道
POST /api/v1/channel/createChannel
Body: { channelName, channelType?, contactPerson?, contactPhone?, description? }
// 获取所有渠道
GET /api/v1/channel/getAllChannels?skip=0&take=10
// 删除渠道
POST /api/v1/channel/deleteChannel
Body: { id: number }
遵循项目测试标准:
docs/standards/testing-standards.mddocs/standards/web-ui-testing-standards.md关键测试原则:
使用时间戳确保唯一性:
const timestamp = Date.now();
const uniqueId = `channel_${timestamp}`;
const channelName = `测试渠道_${uniqueId}`;
测试数据清理:
deleteChannel() 方法删除测试数据test-setup.ts 中的 fixture(已在 Story 11.7 添加):
export const test = test.extend<{
adminLoginPage: AdminLoginPage;
channelManagementPage: ChannelManagementPage;
}>({
adminLoginPage: async ({ page }, use) => {
await use(new AdminLoginPage(page));
},
channelManagementPage: async ({ page }, use) => {
await use(new ChannelManagementPage(page));
},
});
Epic 11 内部依赖:
外部依赖:
@d8d/e2e-test-utils 包(已存在)web/tests/e2e/utils/test-setup.ts: channelManagementPage fixture 已添加从 Story 11.1-11.7 中学到的关键经验:
Toast 检测不可靠:
表格列顺序:
nth(1) 检查渠道名称列测试数据要求:
页面刷新:
page.reload() 或 goto() 刷新选择器优先级:
编辑表单 data-testid 缺失:
getByRole('form') + getByLabel() 组合定位页面路由:
/admin/channels(已确认)data-testid 不完整:
role + label 组合定位渠道名称全局唯一:
删除限制:
deleteChannel() 使用 API 直接删除,绕过 UI 限制状态显示:
由于此 Story 是可选的,实现前需要确认:
是否需要渠道管理测试?
优先级评估:
实现范围:
标记为"可选"的原因总结:
何时应该实现此 Story:
测试文件存放路径:
web/tests/e2e/
├── pages/admin/
│ ├── platform-management.page.ts # 平台管理 Page Object(已完成)
│ ├── company-management.page.ts # 公司管理 Page Object(已完成)
│ └── channel-management.page.ts # 渠道管理 Page Object(已完成)
├── specs/admin/
│ ├── platform-create.spec.ts # 平台创建测试(已完成)- 参考模式
│ ├── platform-list.spec.ts # 平台列表测试(已完成)
│ ├── company-create.spec.ts # 公司创建测试(待实现)
│ ├── company-list.spec.ts # 公司列表测试(已完成)
│ └── channel-create.spec.ts # 渠道创建测试(当前,可选)
└── utils/
└── test-setup.ts # 测试夹具配置(已添加 channelManagementPage)
claude-opus-4-5-20251101
无特殊问题需要记录。Story 创建过程顺利。
已完成的工作:
11-8-channel-create-test.mdready-for-dev文档包含内容:
注意事项:
新增文件:
_bmad-output/implementation-artifacts/11-8-channel-create-test.md - 本 story 文件计划创建文件(实施时):
web/tests/e2e/specs/admin/channel-create.spec.ts - 渠道创建测试修改文件(实施时):
_bmad-output/implementation-artifacts/sprint-status.yaml - 更新 Story 11.8 状态为 ready-for-dev2026-01-12