Skip to content

Commit 9da1688

Browse files
committed
test(web): 测试断言同步「上游→渠道」用词
上轮提交遗漏的两个测试文件(Dashboard/Playground),本地工作树全绿但 CI 用提交内容失败。
1 parent f7aab88 commit 9da1688

2 files changed

Lines changed: 21 additions & 21 deletions

File tree

‎web/src/pages/__tests__/DashboardPage.test.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ describe("DashboardPage", () => {
7878
expect(list).toHaveTextContent("plan 权益不足");
7979
});
8080

81-
it("凭证池单列表展示,行内标注所属上游", async () => {
81+
it("凭证池单列表展示,行内标注所属渠道", async () => {
8282
mockFetch({
8383
"/api/credentials": {
8484
credentials: [
@@ -92,7 +92,7 @@ describe("DashboardPage", () => {
9292
renderPage(<DashboardPage />);
9393
await settle();
9494

95-
// 不再按上游分组成两个列表,而是单一列表 + 行内渠道标注
95+
// 不再按渠道分组成两个列表,而是单一列表 + 行内渠道标注
9696
expect(screen.getByTestId("credential-list")).toBeInTheDocument();
9797
expect(screen.queryByTestId("provider-group-trae")).not.toBeInTheDocument();
9898
expect(screen.getByTestId("credential-t1")).toHaveAttribute("data-provider", "trae");

‎web/src/pages/__tests__/PlaygroundPage.test.tsx‎

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ describe("PlaygroundPage(会话鉴权,无需 API Key)", () => {
5353
expect(screen.queryByTestId("playground-key")).not.toBeInTheDocument();
5454
});
5555

56-
it("选中模型后展示渠道与元数据,双上游倍率按渠道显示", async () => {
56+
it("选中模型后展示渠道与元数据,双渠道倍率按渠道显示", async () => {
5757
const META_MODELS = {
5858
object: "list",
5959
data: [
@@ -76,10 +76,10 @@ describe("PlaygroundPage(会话鉴权,无需 API Key)", () => {
7676
await waitForModelLoaded();
7777

7878
const meta = screen.getByTestId("model-meta");
79-
// 渠道前置 icon 标注:双上游全部显示(icon + 名称)
79+
// 渠道前置 icon 标注:双渠道全部显示(icon + 名称)
8080
expect(meta).toHaveTextContent("CodeBuddy");
8181
expect(meta).toHaveTextContent("TRAE");
82-
// 双上游倍率按渠道分别显示
82+
// 双渠道倍率按渠道分别显示
8383
expect(meta).toHaveTextContent("x0.29");
8484
expect(meta).toHaveTextContent("x0.17");
8585
// 合并字段照常展示;勾/叉用 icon(svg)而非文本符号
@@ -89,29 +89,29 @@ describe("PlaygroundPage(会话鉴权,无需 API Key)", () => {
8989
expect(meta.querySelector("svg.lucide-x")).toBeInTheDocument();
9090
expect(meta).not.toHaveTextContent("✓");
9191

92-
// 切到单上游模型:倍率不按渠道拆分,显示合并值
92+
// 切到单渠道模型:倍率不按渠道拆分,显示合并值
9393
await userEvent.selectOptions(screen.getByTestId("model-select"),
9494
"DeepSeek-V4-Flash-Official@trae");
9595
const meta2 = screen.getByTestId("model-meta");
9696
expect(meta2).toHaveTextContent("x0.08");
9797
expect(meta2).not.toHaveTextContent("x0.29");
9898
});
9999

100-
it("自动载入模型列表并展示可选上游,请求走会话端点", async () => {
100+
it("自动载入模型列表并展示可选渠道,请求走会话端点", async () => {
101101
const spy = mockFetch({ "/api/playground/models": MODELS });
102102
renderPage(<PlaygroundPage />, { username: "root", is_admin: true });
103103
await waitForModelLoaded();
104104

105105
const select = screen.getByTestId("model-select");
106-
// 双上游模型出现在「自动路由」分组
106+
// 双渠道模型出现在「自动路由」分组
107107
expect(select).toHaveTextContent("glm-5.2");
108108
const groups = [...select.querySelectorAll("optgroup")].map((g) => g.label);
109-
expect(groups).toContain("双上游(自动调度)");
109+
expect(groups).toContain("双渠道(自动调度)");
110110
expect(spy.mock.calls.some(([url]) => String(url).includes("/api/playground/models"))).toBe(true);
111111
expect(spy.mock.calls.some(([url]) => String(url).includes("/v1/models"))).toBe(false);
112112
});
113113

114-
it("模型 option 文本带消耗倍率(双上游按渠道标注)", async () => {
114+
it("模型 option 文本带消耗倍率(双渠道按渠道标注)", async () => {
115115
const RATED_MODELS = {
116116
object: "list",
117117
data: [
@@ -134,19 +134,19 @@ describe("PlaygroundPage(会话鉴权,无需 API Key)", () => {
134134
const options = [...screen.getByTestId("model-select").querySelectorAll("option")];
135135
const textOf = (value: string) =>
136136
options.find((o) => o.value === value)?.textContent ?? "";
137-
// 双上游:渠道缩写 + 各自倍率
137+
// 双渠道:渠道缩写 + 各自倍率
138138
expect(textOf("glm-5.2")).toBe("glm-5.2(自动路由 · CB x0.29/TR x0.17)");
139-
// 单上游:optgroup 已标渠道,仍带渠道缩写 + 倍率
139+
// 单渠道:optgroup 已标渠道,仍带渠道缩写 + 倍率
140140
expect(textOf("DeepSeek-V4-Flash-Official@trae")).toBe(
141141
"DeepSeek-V4-Flash-Official · TR x0.08");
142142
// 无倍率数据:不追加任何标记
143143
expect(textOf("no-rate@trae")).toBe("no-rate");
144144

145-
// 双上游倍率相同:两个渠道都要写出来
146-
// 双上游只有一个渠道返回倍率:只标那个渠道,不裸显数字
145+
// 双渠道倍率相同:两个渠道都要写出来
146+
// 双渠道只有一个渠道返回倍率:只标那个渠道,不裸显数字
147147
});
148148

149-
it("双上游倍率相同或缺失时,渠道标注规则", async () => {
149+
it("双渠道倍率相同或缺失时,渠道标注规则", async () => {
150150
const EDGE_MODELS = {
151151
object: "list",
152152
data: [
@@ -179,7 +179,7 @@ describe("PlaygroundPage(会话鉴权,无需 API Key)", () => {
179179
expect(await screen.findByTestId("playground-error")).toHaveTextContent("模型列表加载失败");
180180
});
181181

182-
it("强制指定上游生成 model@provider,恢复自动路由去掉后缀", async () => {
182+
it("强制指定渠道生成 model@provider,恢复自动路由去掉后缀", async () => {
183183
mockFetch({ "/api/playground/models": MODELS });
184184
renderPage(<PlaygroundPage />, { username: "root", is_admin: true });
185185
await waitForModelLoaded();
@@ -233,15 +233,15 @@ describe("PlaygroundPage(会话鉴权,无需 API Key)", () => {
233233
vi.fn(async (input: RequestInfo | URL) => {
234234
const url = String(input);
235235
if (url.includes("/api/playground/models")) return jsonResponse(MODELS);
236-
return jsonResponse({ error: { message: "上游不可用" } }, 503);
236+
return jsonResponse({ error: { message: "渠道不可用" } }, 503);
237237
}),
238238
);
239239

240240
renderPage(<PlaygroundPage />, { username: "root", is_admin: true });
241241
await waitForModelLoaded();
242242
await userEvent.click(screen.getByTestId("stream-toggle"));
243243
await fillPromptAndSend("hi");
244-
expect(await screen.findByTestId("playground-error")).toHaveTextContent("上游不可用");
244+
expect(await screen.findByTestId("playground-error")).toHaveTextContent("渠道不可用");
245245
});
246246

247247
it("会话过期时跳回登录页", async () => {
@@ -338,7 +338,7 @@ describe("PlaygroundPage(会话鉴权,无需 API Key)", () => {
338338
expect(screen.getByText(/计入 alice/)).toBeInTheDocument();
339339
});
340340

341-
it("仅单一上游可用的模型按分组展示(避免淹没在长列表里)", async () => {
341+
it("仅单一渠道可用的模型按分组展示(避免淹没在长列表里)", async () => {
342342
const mixed = {
343343
object: "list",
344344
data: [
@@ -359,8 +359,8 @@ describe("PlaygroundPage(会话鉴权,无需 API Key)", () => {
359359
);
360360
expect(groups).toContainEqual(["仅 CodeBuddy", ["deepseek-v4-pro@codebuddy"]]);
361361
expect(groups).toContainEqual(["仅 TRAE", ["kimi-k3@trae"]]);
362-
// 双上游模型保留原值(不带 @),走自动路由
363-
const dualGroup = select.querySelector('optgroup[label="双上游(自动调度)"]');
362+
// 双渠道模型保留原值(不带 @),走自动路由
363+
const dualGroup = select.querySelector('optgroup[label="双渠道(自动调度)"]');
364364
expect(dualGroup).not.toBeNull();
365365
expect(dualGroup!.querySelector("option")?.value).toBe("glm-5.2");
366366
});

0 commit comments

Comments
 (0)