Commit 251bebb2 by 胡悦

fix(channel-codes): 渠道活码停用失败时优先展示后端错误信息

更新渠道活码列表页的停用操作错误处理逻辑,优先展示后端返回的错误信息而非统一兜底文案;补充并更新了相关单元测试与OpenSpec文档。
1 parent b5770e43
...@@ -58,6 +58,8 @@ ...@@ -58,6 +58,8 @@
2026-05-24:用户补充岗位标签删除二次弹窗需要提示具体哪些 Agent 将失去该标签。已更新 `workspace/agent-admin/web/openspec/changes/fix-position-tag-delete-references/` 的 design、spec 和 tasks,要求弹窗展示 `agent_references` 中每个引用项的 `name`,并补充对应测试与浏览器验证任务;已通过 `openspec validate "fix-position-tag-delete-references" --strict`。 2026-05-24:用户补充岗位标签删除二次弹窗需要提示具体哪些 Agent 将失去该标签。已更新 `workspace/agent-admin/web/openspec/changes/fix-position-tag-delete-references/` 的 design、spec 和 tasks,要求弹窗展示 `agent_references` 中每个引用项的 `name`,并补充对应测试与浏览器验证任务;已通过 `openspec validate "fix-position-tag-delete-references" --strict`。
2026-05-24:用户确认渠道活码点击停用时,非 `200` 接口响应应提示对应 `message`。已更新 `workspace/agent-admin/web/openspec/changes/real-api-integration/` 的 proposal、spec 和 tasks,补充渠道活码停用失败透传后端 message 的规则;随后按 TDD 修改 `ChannelCodeListPage`,让停用失败时优先展示 `ApiError.message`,并新增/更新回归测试。已通过 `npm test -- src/routes/channel-codes/ChannelCodeStatusOperations.test.tsx`、`npm run typecheck`、`npm run build`,并在浏览器中验证停用失败后弹出的提示文本为后端返回的 message。
## 下一步 ## 下一步
1. 等待用户确认 `official-site-agent-display-config` OpenSpec artifacts。 1. 等待用户确认 `official-site-agent-display-config` OpenSpec artifacts。
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
- 修复真实接口列表项缺少 mock `operations` 字段时状态操作按钮消失的问题:渠道活码列表的 `启用`/`停用`、岗位展示配置列表的 `上架`/`下架` 必须由当前行状态派生。 - 修复真实接口列表项缺少 mock `operations` 字段时状态操作按钮消失的问题:渠道活码列表的 `启用`/`停用`、岗位展示配置列表的 `上架`/`下架` 必须由当前行状态派生。
- 保留现有 mock 契约文件,但限定为测试 fixture;测试可继续引用,业务运行时代码不得依赖 mock 数据源。 - 保留现有 mock 契约文件,但限定为测试 fixture;测试可继续引用,业务运行时代码不得依赖 mock 数据源。
- 所有用户触发的后端操作必须给出反馈信息,包括查询、保存、删除、启用、停用、上传、批量更新等成功提示,以及失败时展示后端返回的错误信息。 - 所有用户触发的后端操作必须给出反馈信息,包括查询、保存、删除、启用、停用、上传、批量更新等成功提示,以及失败时展示后端返回的错误信息。
- 渠道活码停用失败时,页面必须优先展示后端返回的 `message`,而不是统一兜底文案。
## Capabilities ## Capabilities
......
...@@ -27,6 +27,12 @@ ...@@ -27,6 +27,12 @@
- **AND** `display_status=disable` 的行 MUST 展示 `上架` 按钮 - **AND** `display_status=disable` 的行 MUST 展示 `上架` 按钮
- **AND** 页面 MUST NOT 因缺少 `operations` 字段隐藏对应状态切换按钮 - **AND** 页面 MUST NOT 因缺少 `operations` 字段隐藏对应状态切换按钮
#### Scenario: 渠道活码停用失败时展示后端错误信息
- **WHEN** 用户在渠道活码列表页点击某行 `停用`
- **AND** 停用接口返回非 `200` 响应且包含 `message`
- **THEN** 页面 MUST 展示后端返回的 `message`
- **AND** 页面 MUST NOT 仅展示统一兜底文案 `操作失败,请重试`
#### Scenario: 方法论步骤图标上传遵循官网素材接口 #### Scenario: 方法论步骤图标上传遵循官网素材接口
- **WHEN** 用户在方法论配置页选择步骤图标图片上传 - **WHEN** 用户在方法论配置页选择步骤图标图片上传
- **THEN** 页面 MUST 向当前环境基础路径下的 `/official-site-upload/upload` 提交包含真实 `file` 字段和 `usage_type=methodology_icon` 的 multipart 请求 - **THEN** 页面 MUST 向当前环境基础路径下的 `/official-site-upload/upload` 提交包含真实 `file` 字段和 `usage_type=methodology_icon` 的 multipart 请求
......
...@@ -61,7 +61,8 @@ ...@@ -61,7 +61,8 @@
## 4. 用户反馈与 fixture 边界 ## 4. 用户反馈与 fixture 边界
- [ ] 4.1 为所有用户触发的查询、保存、删除、启用、停用、上传、批量更新操作补齐成功提示。 - [ ] 4.1 为所有用户触发的查询、保存、删除、启用、停用、上传、批量更新操作补齐成功提示。
- [ ] 4.2 为所有后端失败路径补齐错误提示,优先展示后端 `message` 或 API client 归一化错误信息。 - [ ] 4.2 为所有后端失败路径补齐错误提示,优先展示后端 `message` 或 API client 归一化错误信息,包含渠道活码停用失败时透传后端 message。
- [x] 4.2.1 渠道活码停用失败时优先展示后端 `message`,不再仅显示统一兜底文案。
- [ ] 4.3 保留 mock 契约文件作为测试 fixture,并移除受影响页面运行时代码对 mock 契约、mock local store 和模拟延迟的依赖。 - [ ] 4.3 保留 mock 契约文件作为测试 fixture,并移除受影响页面运行时代码对 mock 契约、mock local store 和模拟延迟的依赖。
- [ ] 4.4 增加测试或静态检查,证明受影响页面运行时代码不再依赖 mock 数据源。 - [ ] 4.4 增加测试或静态检查,证明受影响页面运行时代码不再依赖 mock 数据源。
......
...@@ -331,8 +331,9 @@ export function ChannelCodeListPage() { ...@@ -331,8 +331,9 @@ export function ChannelCodeListPage() {
...routeState, ...routeState,
refreshToken: String(Date.now()), refreshToken: String(Date.now()),
})); }));
} catch { } catch (error) {
message.error('操作失败,请重试'); const errorMessage = error instanceof Error && error.message ? error.message : '操作失败,请重试';
message.error(errorMessage);
} }
}} }}
> >
......
...@@ -3,6 +3,7 @@ import { MemoryRouter } from 'react-router-dom'; ...@@ -3,6 +3,7 @@ import { MemoryRouter } from 'react-router-dom';
import { beforeEach, describe, expect, it, vi } from 'vitest'; import { beforeEach, describe, expect, it, vi } from 'vitest';
import { App } from '../../App'; import { App } from '../../App';
import { ApiError } from '../../api/client';
import { getChannelQRCodeList, enableChannelQRCode, disableChannelQRCode, type ChannelQRCodeListItem, type ChannelQRCodeStatus } from '../../api/channelCode'; import { getChannelQRCodeList, enableChannelQRCode, disableChannelQRCode, type ChannelQRCodeListItem, type ChannelQRCodeStatus } from '../../api/channelCode';
import { getPositionTagList } from '../../api/positionTag'; import { getPositionTagList } from '../../api/positionTag';
...@@ -208,7 +209,7 @@ describe('Channel code enable/disable operations', () => { ...@@ -208,7 +209,7 @@ describe('Channel code enable/disable operations', () => {
}); });
it('blocks disable with business error message', async () => { it('blocks disable with business error message', async () => {
vi.mocked(disableChannelQRCode).mockRejectedValueOnce(new Error('该渠道活码正在官网展示中,请先从官网配置中移除后再停用')); vi.mocked(disableChannelQRCode).mockRejectedValueOnce(new ApiError('该渠道活码正在官网展示中,请先从官网配置中移除后再停用', 400));
renderChannelCodes(); renderChannelCodes();
await screen.findByText('店销顾问渠道活码'); await screen.findByText('店销顾问渠道活码');
...@@ -220,7 +221,7 @@ describe('Channel code enable/disable operations', () => { ...@@ -220,7 +221,7 @@ describe('Channel code enable/disable operations', () => {
// The error message should be shown // The error message should be shown
await waitFor(() => { await waitFor(() => {
const alert = screen.getByRole('alert'); const alert = screen.getByRole('alert');
expect(alert).toHaveTextContent('操作失败,请重试'); expect(alert).toHaveTextContent('该渠道活码正在官网展示中,请先从官网配置中移除后再停用');
}); });
// Status should remain enabled // Status should remain enabled
expect(within(enabledRow).getByText('启用')).toBeInTheDocument(); expect(within(enabledRow).getByText('启用')).toBeInTheDocument();
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!