fix(profile): stabilize binding compatibility and frontend checks
This commit is contained in:
@@ -46,6 +46,8 @@ const {
|
||||
showSuccess: vi.fn(),
|
||||
}));
|
||||
|
||||
const localeRef = vi.hoisted(() => ({ value: "zh-CN" }));
|
||||
|
||||
vi.mock("@/api", () => ({
|
||||
adminAPI: {
|
||||
settings: {
|
||||
@@ -149,6 +151,8 @@ vi.mock("vue-i18n", async () => {
|
||||
"admin.settings.paymentVisibleMethods.sourceLabel": "支付来源",
|
||||
"admin.settings.paymentVisibleMethods.sourceHint": "启用后必须明确选择一个来源;未配置状态不会对外展示该支付方式。",
|
||||
"admin.settings.paymentVisibleMethods.sourceRequiredError": "{title} 已启用,请先选择支付来源。",
|
||||
"admin.settings.payment.configGuide": "查看支付配置说明",
|
||||
"admin.settings.payment.findProvider": "查看支持的支付方式",
|
||||
"admin.settings.openaiExperimentalScheduler.title": "OpenAI 实验调度策略",
|
||||
"admin.settings.openaiExperimentalScheduler.description": "默认关闭。开启后仅影响本网关在 OpenAI 账号间的实验性调度选择逻辑,不代表上游 OpenAI 官方能力。",
|
||||
};
|
||||
@@ -157,7 +161,7 @@ vi.mock("vue-i18n", async () => {
|
||||
useI18n: () => ({
|
||||
t: (key: string, params?: Record<string, string>) =>
|
||||
(translations[key] ?? key).replace(/\{(\w+)\}/g, (_, token) => params?.[token] ?? `{${token}}`),
|
||||
locale: ref("zh-CN"),
|
||||
locale: localeRef,
|
||||
}),
|
||||
};
|
||||
});
|
||||
@@ -429,6 +433,7 @@ describe("admin SettingsView payment visible method controls", () => {
|
||||
adminSettingsFetch.mockReset();
|
||||
showError.mockReset();
|
||||
showSuccess.mockReset();
|
||||
localeRef.value = "zh-CN";
|
||||
|
||||
getSettings.mockResolvedValue({ ...baseSettingsResponse });
|
||||
updateSettings.mockImplementation(async (payload) => ({
|
||||
@@ -489,6 +494,30 @@ describe("admin SettingsView payment visible method controls", () => {
|
||||
expect(wrapper.text()).not.toContain("支付来源");
|
||||
});
|
||||
|
||||
it("links payment guidance to README sections instead of removed payment docs", async () => {
|
||||
const wrapper = mountView();
|
||||
|
||||
await flushPromises();
|
||||
await openPaymentTab(wrapper);
|
||||
|
||||
const paymentLinks = wrapper
|
||||
.findAll("a")
|
||||
.filter((node) =>
|
||||
["查看支付配置说明", "查看支持的支付方式"].includes(node.text()),
|
||||
);
|
||||
|
||||
expect(paymentLinks).toHaveLength(2);
|
||||
expect(paymentLinks[0]?.attributes("href")).toBe(
|
||||
"https://github.com/Wei-Shaw/sub2api/blob/main/README_CN.md#%E6%94%AF%E4%BB%98",
|
||||
);
|
||||
expect(paymentLinks[1]?.attributes("href")).toBe(
|
||||
"https://github.com/Wei-Shaw/sub2api/blob/main/README_CN.md#%E6%94%AF%E4%BB%98",
|
||||
);
|
||||
for (const link of paymentLinks) {
|
||||
expect(link.attributes("href")).not.toContain("docs/PAYMENT");
|
||||
}
|
||||
});
|
||||
|
||||
it("does not submit legacy visible payment method settings", async () => {
|
||||
const wrapper = mountView();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user