Repository navigation
Expand file tree
/
Copy pathAccounts.test.tsx
More file actions
749 lines (738 loc) · 22.2 KB
/
Copy pathAccounts.test.tsx
File metadata and controls
749 lines (738 loc) · 22.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
import { useState } from "react";
import {
cleanup,
fireEvent,
render,
screen,
waitFor,
within,
} from "@testing-library/react";
import { afterEach, expect, it, vi } from "vitest";
import Accounts from "./views/Accounts";
import Workspace from "./views/Workspace";
import AccountSelection, {
deviceAccount,
SessionAccountControls,
} from "./AccountSelection";
import AccountAttempts from "./AccountAttempts";
import { accountError, resetCountdown } from "./accountDisplay";
import type {
Account,
AccountSettings,
Agent,
DockState,
Mutate,
Session,
} from "./types";
const t = (zh: string) => zh;
const account: Account = {
id: "personal",
label: "Personal",
provider: "codex",
environment_id: "local",
status: "ready",
priority: 0,
generation: 1,
};
const remote: Account = {
...account,
id: "remote",
label: "Remote",
environment_id: "devbox",
};
const claude: Account = {
...account,
id: "claude",
label: "Work",
provider: "claude",
};
const state: DockState = {
projects: [],
agents: [],
sessions: [],
messages: [],
runs: [],
memories: [],
proposals: [],
events: [],
quotas: [],
approvals: [],
subscriptions: [],
runtime: { enabled: true, version: "0.3.0" },
accounts: [account, remote, claude],
environments: [
{ id: "devbox", name: "Devbox", kind: "ssh", status: "connected" },
],
};
afterEach(() => {
cleanup();
vi.unstubAllGlobals();
vi.restoreAllMocks();
});
function setup(extra: Partial<DockState> = {}) {
const mutate = vi.fn<Mutate>(async (_path, _data, success) => {
success?.({});
return true;
});
const changed = vi.fn();
render(
<Accounts
state={{ ...state, ...extra }}
token="test"
busy={false}
mutate={mutate}
onChanged={changed}
t={t}
/>,
);
return { mutate, changed };
}
it("creates a subscription bound to the user's selected device and supports closing the form twice", async () => {
const { mutate } = setup();
const add = screen.getByRole("button", { name: "添加账号" });
fireEvent.click(add);
fireEvent.click(add);
expect(screen.queryByLabelText("账号名称")).toBeNull();
fireEvent.click(add);
fireEvent.change(screen.getByLabelText("账号名称"), {
target: { value: " Dev work " },
});
const form = screen.getByLabelText("账号名称").closest("form")!;
fireEvent.change(within(form).getByLabelText("服务"), {
target: { value: "claude" },
});
fireEvent.change(within(form).getByLabelText("设备"), {
target: { value: "devbox" },
});
fireEvent.click(within(form).getByRole("button", { name: "添加" }));
await waitFor(() =>
expect(mutate).toHaveBeenCalledWith("/api/accounts", {
label: "Dev work",
provider: "claude",
environment_id: "devbox",
priority: 0,
}),
);
});
it("filters removed accounts and device/provider independently", () => {
setup({
accounts: [
...state.accounts!,
{ ...account, id: "removed", label: "Old", status: "removed" },
],
});
expect(screen.queryByRole("heading", { name: "Old" })).toBeNull();
fireEvent.change(screen.getByLabelText("设备"), {
target: { value: "devbox" },
});
expect(screen.queryByRole("heading", { name: "Personal" })).toBeNull();
expect(screen.getByRole("heading", { name: "Remote" })).toBeTruthy();
fireEvent.change(screen.getByLabelText("服务"), {
target: { value: "claude" },
});
expect(screen.getByText("暂无订阅账号")).toBeTruthy();
});
it("starts native device login, shows the code, and cancels without altering another account", async () => {
const fetch = vi.fn(async () => ({
ok: true,
json: async () => ({
status: "waiting",
url: "https://auth.example.test/device",
device_code: "ABCD-1234",
}),
}));
vi.stubGlobal("fetch", fetch);
const { mutate } = setup({ accounts: [remote] });
expect(screen.queryByRole("button", { name: "重新登录" })).toBeNull();
fireEvent.click(screen.getByRole("button", { name: "设备码登录" }));
await waitFor(() => expect(screen.getByText("ABCD-1234")).toBeTruthy());
expect(mutate).toHaveBeenCalledWith("/api/accounts/remote/login", {
method: "device",
});
expect(
screen.getByRole("link", { name: /打开登录页面/ }).getAttribute("href"),
).toBe("https://auth.example.test/device");
fireEvent.click(screen.getByRole("button", { name: "取消登录" }));
await waitFor(() =>
expect(mutate).toHaveBeenCalledWith(
"/api/accounts/remote/cancel",
{},
expect.any(Function),
),
);
});
it("never renders an unsafe login URL, and can submit an explicit Claude callback code", async () => {
vi.stubGlobal(
"fetch",
vi.fn(async () => ({
ok: true,
json: async () => ({ status: "waiting", url: "javascript:alert(1)" }),
})),
);
const { mutate } = setup({ accounts: [claude] });
fireEvent.click(screen.getByRole("button", { name: "重新登录" }));
const input = await screen.findByLabelText("授权码(仅登录页面提供时填写)");
expect(screen.queryByRole("link", { name: /打开登录页面/ })).toBeNull();
fireEvent.change(input, { target: { value: "code-from-browser" } });
fireEvent.click(screen.getByRole("button", { name: "提交验证码" }));
await waitFor(() =>
expect(mutate).toHaveBeenCalledWith("/api/accounts/claude/input", {
code: "code-from-browser",
}),
);
});
it("edits, disables and explicitly deletes an account while preserving a missing quota as unknown", async () => {
const { mutate } = setup({
accounts: [
{
...account,
quota: {
windows: [{ label: "Weekly", remaining_percent: null }],
status: "unknown",
source: "cli",
},
},
],
});
expect(screen.getByText("未知")).toBeTruthy();
expect(screen.getByRole("button", { name: "删除账号" })).toBeTruthy();
fireEvent.click(screen.getByRole("button", { name: "设置" }));
fireEvent.change(screen.getByLabelText("名称"), {
target: { value: "Personal 2" },
});
fireEvent.click(screen.getByRole("button", { name: "保存" }));
await waitFor(() =>
expect(mutate).toHaveBeenCalledWith("/api/accounts/personal", {
label: "Personal 2",
priority: 0,
}),
);
fireEvent.click(screen.getByRole("button", { name: "设置" }));
fireEvent.click(screen.getByRole("button", { name: "停用账号" }));
expect(mutate).toHaveBeenCalledWith("/api/accounts/personal", {
enabled: false,
});
fireEvent.click(screen.getByRole("button", { name: "设置" }));
expect(screen.queryByLabelText("名称")).toBeNull();
fireEvent.click(screen.getByRole("button", { name: "删除账号" }));
fireEvent.click(screen.getByRole("button", { name: "删除账号" }));
expect(screen.queryByRole("button", { name: "确认删除账号" })).toBeNull();
fireEvent.click(screen.getByRole("button", { name: "删除账号" }));
fireEvent.click(screen.getByRole("button", { name: "关闭删除确认" }));
expect(screen.queryByRole("button", { name: "确认删除账号" })).toBeNull();
fireEvent.click(screen.getByRole("button", { name: "删除账号" }));
expect(mutate).not.toHaveBeenCalledWith("/api/accounts/personal/delete", {});
fireEvent.click(screen.getByRole("button", { name: "确认删除账号" }));
expect(mutate).toHaveBeenCalledWith("/api/accounts/personal/delete", {});
});
it("only offers accounts for the exact service and device and submits an explicit failover pool", () => {
let latest: AccountSettings = {};
function Harness() {
const [value, setValue] = useState<AccountSettings>(deviceAccount);
return (
<AccountSelection
accounts={state.accounts!}
provider="codex"
environment="local"
value={value}
onChange={(next) => {
latest = next;
setValue(next);
}}
t={t}
/>
);
}
render(<Harness />);
expect(screen.queryByRole("option", { name: /Remote|Work/ })).toBeNull();
fireEvent.change(screen.getByLabelText("账号使用方式"), {
target: { value: "failover" },
});
fireEvent.click(screen.getByRole("checkbox", { name: /Personal/ }));
expect(latest).toEqual({
account_id: null,
account_policy: "failover",
account_ids: ["personal"],
});
});
it("changes only the current session and keeps a removed account explicit instead of falling back", async () => {
const agent: Agent = {
id: "agent",
name: "Codex",
provider: "codex",
role: "",
project_id: null,
};
const session: Session = {
id: "session",
agent_id: "agent",
title: "One",
project_id: null,
status: "idle",
created_at: "2026-01-01",
updated_at: "2026-01-01",
account_id: "deleted",
};
const mutate = vi.fn<Mutate>(async () => true);
render(
<SessionAccountControls
accounts={[account]}
agent={agent}
session={session}
busy={false}
demo={false}
mutate={mutate}
t={t}
/>,
);
fireEvent.click(screen.getByRole("button", { name: /账号不可用/ }));
expect((screen.getByLabelText("订阅账号") as HTMLSelectElement).value).toBe(
"deleted",
);
fireEvent.change(screen.getByLabelText("订阅账号"), {
target: { value: "personal" },
});
fireEvent.click(screen.getByRole("button", { name: "保存账号设置" }));
await waitFor(() =>
expect(mutate).toHaveBeenCalledWith("/api/sessions/session/account", {
account_id: "personal",
account_policy: "manual",
account_ids: [],
}),
);
});
it("opens account settings outside the clipped conversation, traps focus, and restores the trigger", () => {
const agent: Agent = {
id: "agent",
name: "Codex",
provider: "codex",
role: "",
project_id: null,
};
const session: Session = {
id: "session",
agent_id: agent.id,
title: "One",
project_id: null,
status: "idle",
created_at: "2026-01-01",
updated_at: "2026-01-01",
account_id: null,
};
const mutate = vi.fn<Mutate>(async () => true);
const { container } = render(
<div style={{ height: 200, overflow: "hidden" }}>
<SessionAccountControls
accounts={[account]}
agent={agent}
session={session}
busy={false}
demo={false}
mutate={mutate}
t={t}
/>
</div>,
);
const trigger = screen.getByRole("button", { name: "沿用设备登录" });
fireEvent.click(trigger);
const dialog = screen.getByRole("dialog", { name: "会话账号" });
expect(container.contains(dialog)).toBe(false);
expect(document.activeElement).toBe(dialog);
const save = screen.getByRole("button", { name: "保存账号设置" });
save.focus();
fireEvent.keyDown(save, { key: "Tab" });
expect(document.activeElement).toBe(
screen.getByRole("button", { name: "关闭账号设置" }),
);
fireEvent.keyDown(dialog, { key: "Escape" });
expect(screen.queryByRole("dialog")).toBeNull();
expect(document.activeElement).toBe(trigger);
expect(mutate).not.toHaveBeenCalled();
});
it("shows account switch and wait events without printing raw payloads", () => {
render(
<AccountAttempts
accounts={[account]}
attempts={[]}
events={[
{
id: "switch",
seq: 1,
session_id: "s",
project_id: null,
kind: "account_switched",
payload: { to_account_id: "personal", secret: "must-not-render" },
created_at: "2026-01-01",
},
{
id: "wait",
seq: 2,
session_id: "s",
project_id: null,
kind: "account_waiting",
payload: { account_id: "personal" },
created_at: "2026-01-01",
},
]}
t={t}
/>,
);
expect(screen.getByText("已切换账号")).toBeTruthy();
expect(screen.getByRole("status").textContent).toContain("等待");
expect(screen.queryByText("must-not-render")).toBeNull();
});
it("hides legacy device-login attempts while retaining removed managed account history", () => {
const attempt = {
id: "attempt",
run_id: "run",
account_id: null,
status: "completed",
created_at: "2026-01-01",
};
const event = {
id: "event",
seq: 1,
session_id: "s",
project_id: null,
kind: "account_attempt",
payload: { account_id: null },
created_at: "2026-01-01",
};
const { container, rerender } = render(
<AccountAttempts attempts={[attempt]} events={[event]} t={t} />,
);
expect(container.textContent).toBe("");
rerender(
<AccountAttempts
attempts={[{ ...attempt, account_id: "removed" }]}
events={[]}
accounts={[{ ...account, id: "removed", status: "removed" }]}
t={t}
/>,
);
expect(screen.getByText("账号使用记录")).toBeTruthy();
expect(screen.getByText("Personal")).toBeTruthy();
});
it("opens manual account selection after a failed run with preserved progress", () => {
const configure = vi.fn();
render(
<AccountAttempts
accounts={[account]}
active={false}
events={[
{
id: "required",
seq: 1,
session_id: "s",
project_id: null,
kind: "account_action_required",
payload: {
account_id: "personal",
reason: "progress_recorded",
error_code: "quota_exhausted",
},
created_at: "2026-01-01",
},
]}
t={t}
onConfigureAccount={configure}
/>,
);
expect(screen.getByRole("status").textContent).toContain("已保留执行现场");
fireEvent.click(screen.getByRole("button", { name: "选择账号后继续" }));
expect(configure).toHaveBeenCalledOnce();
expect(screen.queryByText("progress_recorded")).toBeNull();
});
it("opens the requested account panel and retains the explicit account if saving fails", async () => {
const agent: Agent = {
id: "agent",
name: "Codex",
provider: "codex",
role: "",
project_id: null,
};
const session: Session = {
id: "session",
agent_id: "agent",
title: "One",
project_id: null,
status: "failed",
created_at: "2026-01-01",
updated_at: "2026-01-01",
account_id: "removed",
};
const mutate = vi.fn<Mutate>(async () => false);
const props = {
accounts: [account],
agent,
session,
busy: false,
demo: false,
mutate,
t,
};
const { rerender } = render(
<SessionAccountControls {...props} openRequest={0} />,
);
expect(screen.queryByLabelText("订阅账号")).toBeNull();
rerender(<SessionAccountControls {...props} openRequest={1} />);
const selector = screen.getByLabelText("订阅账号") as HTMLSelectElement;
expect(selector.value).toBe("removed");
fireEvent.click(screen.getByRole("button", { name: "保存账号设置" }));
await waitFor(() =>
expect(mutate).toHaveBeenCalledWith("/api/sessions/session/account", {
account_id: "removed",
account_policy: "manual",
account_ids: [],
}),
);
await waitFor(() =>
expect(screen.getByRole("button", { name: "保存账号设置" })).toBeTruthy(),
);
expect(selector.value).toBe("removed");
fireEvent.change(selector, { target: { value: "personal" } });
fireEvent.click(screen.getByRole("button", { name: "保存账号设置" }));
await waitFor(() =>
expect(mutate).toHaveBeenLastCalledWith("/api/sessions/session/account", {
account_id: "personal",
account_policy: "manual",
account_ids: [],
}),
);
expect(selector.value).toBe("personal");
expect(
mutate.mock.calls.every(
([, data]) => (data as AccountSettings).account_id !== null,
),
).toBe(true);
});
it("shows exact app usage, quota reset countdowns and safe account errors", () => {
vi.spyOn(Date, "now").mockReturnValue(Date.parse("2026-01-01T00:00:00Z"));
setup({
accounts: [
{
...account,
status: "cooldown",
error: "quota_exhausted",
usage: { input_tokens: 1200, output_tokens: 0, total_tokens: 1200 },
quota: {
status: "ready",
fetched_at: "2026-01-01T00:00:00Z",
windows: [
{
name: "weekly",
remaining_percent: 0,
reset_at: "2026-01-01T01:30:00Z",
},
],
},
},
],
});
const usage = screen.getByLabelText("AgentDock 用量");
expect(within(usage).getAllByText("1,200")).toHaveLength(2);
expect(within(usage).getByText("0")).toBeTruthy();
expect(screen.getByText("0% 剩余")).toBeTruthy();
expect(screen.getByText("1 小时 30 分钟后恢复")).toBeTruthy();
expect(
screen.getByText("当前额度已用完,请等待恢复或选择其他账号。"),
).toBeTruthy();
expect(screen.queryByText(/上次数据/)).toBeNull();
expect(screen.queryByText("quota_exhausted")).toBeNull();
});
it("keeps unknown usage distinct from zero and empty quota distinct from exhausted", () => {
setup({
accounts: [
{
...account,
usage: { input_tokens: null, output_tokens: 0, total_tokens: null },
quota: { status: "unknown", windows: [] },
},
],
});
expect(
within(screen.getByLabelText("AgentDock 用量")).getAllByText("—"),
).toHaveLength(2);
expect(screen.getByText("额度暂未读取")).toBeTruthy();
expect(screen.queryByRole("meter")).toBeNull();
});
it("explains native login failure without rendering a raw backend error", async () => {
vi.stubGlobal(
"fetch",
vi.fn(async () => ({
ok: true,
json: async () => ({
status: "failed",
error_code: "login_timeout",
error: "secret-error-output",
}),
})),
);
setup({ accounts: [account] });
fireEvent.click(screen.getByRole("button", { name: "重新登录" }));
expect(
await screen.findByText("登录等待已超时,请重新发起登录。"),
).toBeTruthy();
expect(screen.queryByText("secret-error-output")).toBeNull();
});
it("handles passed or invalid quota reset times without inventing availability", () => {
const now = Date.parse("2026-01-01T00:00:00Z");
expect(resetCountdown("invalid", now, t)).toBe("恢复时间未知");
expect(resetCountdown("2026-01-01T00:00:00Z", now, t)).toBe(
"已到恢复时间,可刷新确认",
);
expect(resetCountdown("2026-01-02T01:00:00Z", now, t)).toBe(
"1 天 1 小时后恢复",
);
expect(accountError("unexpected-secret-value", t)).toBe(
"账号操作暂未成功,请检查设备连接和登录状态后重试。",
);
});
it("uses managed account quotas on Agent cards and never falls back to device quota", () => {
const base: Agent = {
id: "fixed",
name: "Fixed helper",
provider: "codex",
project_id: null,
role: "",
account_id: "personal",
account_policy: "manual",
};
const agents: Agent[] = [
base,
{ ...base, id: "zero", name: "Exhausted helper", account_id: "exhausted" },
{ ...base, id: "removed", name: "Removed helper", account_id: "removed" },
{
...base,
id: "remote",
name: "Wrong device helper",
account_id: "remote",
},
{
...base,
id: "auto",
name: "Automatic helper",
account_id: null,
account_policy: "auto",
},
{ ...base, id: "legacy", name: "Legacy helper", account_id: null },
];
render(
<Workspace
t={t}
lang="zh"
state={{
...state,
agents,
accounts: [
{
...account,
quota: { status: "ready", windows: [{ remaining_percent: 27 }] },
},
{
...account,
id: "exhausted",
status: "cooldown",
quota: { status: "exhausted", windows: [{ remaining_percent: 0 }] },
},
{
...account,
id: "removed",
status: "removed",
quota: { status: "ready", windows: [{ remaining_percent: 32 }] },
},
{
...remote,
quota: { status: "ready", windows: [{ remaining_percent: 44 }] },
},
],
quotas: [
{
provider: "codex",
status: "ok",
source: "device",
windows: [{ label: "Device", remaining_percent: 89 }],
},
],
}}
agents={agents}
sessions={[]}
approvals={[]}
token="test"
demo
runtimeEnabled
busy={false}
mutate={async () => true}
/>,
);
expect(
within(screen.getByRole("button", { name: /^Fixed helper/ })).getByText(
"当前额度: 27% 剩余",
),
).toBeTruthy();
expect(
within(screen.getByRole("button", { name: /^Exhausted helper/ })).getByText(
"当前额度: 0% 剩余",
),
).toBeTruthy();
for (const name of [
"Removed helper",
"Wrong device helper",
"Automatic helper",
]) {
expect(
within(
screen.getByRole("button", { name: new RegExp(`^${name}`) }),
).getByText("当前额度: 未知"),
).toBeTruthy();
}
expect(
within(screen.getByRole("button", { name: /^Legacy helper/ })).getByText(
"当前额度: 89% 剩余",
),
).toBeTruthy();
});
it("shows passive Claude quota provenance and does not offer an active quota refresh", () => {
setup({
accounts: [
{
...claude,
quota: {
source: "cli_event",
status: "ok",
fetched_at: "2026-10-09T08:00:00Z",
windows: [{ name: "session", remaining_percent: 30 }],
},
},
],
});
expect(screen.getByText("来源:上次运行")).toBeTruthy();
expect(screen.getByText(/30%/)).toBeTruthy();
expect(screen.queryByRole("button", { name: "刷新额度" })).toBeNull();
expect(screen.queryByRole("button", { name: "本机客户端" })).toBeNull();
expect(screen.getByRole("button", { name: "检查登录" })).toBeTruthy();
});
it("distinguishes unknown Claude quota from an unchanged pre-upgrade sample", () => {
setup({
accounts: [
claude,
{
...claude,
id: "legacy",
label: "Legacy",
quota: {
source: "legacy_snapshot",
status: "stale",
fetched_at: "2026-10-01T08:00:00Z",
windows: [{ name: "weekly", remaining_percent: 25 }],
},
},
],
});
expect(
screen.getByText("额度未知,等待运行中的 CLI 返回数据。"),
).toBeTruthy();
expect(screen.getByText("来源:升级前记录")).toBeTruthy();
expect(screen.getByText(/25%/)).toBeTruthy();
expect(screen.queryByText("Claude 订阅额度查询")).toBeNull();
});