A local-first multi-agent app development platform, built on PenguinHarness
fix(web): 新增分组的导入被拒时,原因留在对话框里,不再只活六秒
lmliheng153a99a054a1
diff --git a/changelog/unreleased/2026-11-08-models-group-import-refusal.md b/changelog/unreleased/2026-11-08-models-group-import-refusal.mdnew file mode 100644index 00000000..3330e2e2--- /dev/null+++ b/changelog/unreleased/2026-11-08-models-group-import-refusal.md@@ -0,0 +1,58 @@+# A refused group import says why in the dialog, not in a six-second toast++- **Date:** 2026-11-08+- **Type:** fix+- **Scope:** `web`+- **Breaking:** no++[中文](2026-11-08-models-group-import-refusal.zh.md)++The model library's "Add group" dialog has an import mode: point it at an endpoint, the server+lists the models it serves, and one press appends them all as a new user-defined group. That press+is one whole-table write, so a refusal writes nothing at all — the group the reader just named is+not there, nothing from the listing landed, and the dialog stays open (it closes only on a written+save) over a page that still shows no such group.++The reason used to be raised as a notification, which sits over the dialog and dismisses itself+after six seconds: once it left, the dialog looked exactly as it had before the press and the page+behind it had not changed either, so nothing on screen said why. It now renders in the dialog's own+error line, under the base URL field and above the buttons — the same slot the listing's own+failures use — and stays until the form is edited, the mode is switched, or another attempt starts.+The import button is the retry, and the fields it will send are the ones on screen.++The sentence names both facts the reader needs before retrying: which group was not created, and+that the table behind the dialog did not move. "Saving failed" alone would leave open whether half+the listing had landed.++## Details++- `packages/web/src/features/models/group-import-refusal.ts` (new): `groupImportRefusal(name,+ outcome)` answers the line or `null` for a written save (which closes the dialog, so there is+ nothing to say).+- `packages/web/src/features/models/models-page.tsx`: `importGroup` hands `persist`'s verdict back+ to the dialog instead of toasting it (the docstring claiming "the dialog closes the moment the+ import lands, so there is no card here" was wrong — it closes only on a written save, which is+ exactly why the verdict travels back); `runImport` draws the refusal in the dialog; switching mode+ clears the previous answer.+- `packages/web/src/lib/strings{,-en}.ts`: `models.groupImportRefused(name, reason)`.+- `packages/web/src/features/models/write-outcome.ts`: the header now names the import path among+ the call sites that hand the words to a card.++## Tests++- `packages/web/test/group-import-refusal.test.ts` (new, 4 cases): a written save says nothing; a+ refusal names the group and keeps the server's words; it also says the table did not move; both+ languages.+- `packages/web/e2e/models-group-import-refusal.spec.mjs` (new, real server + real browser; both+ routes the flow uses — `models/list` and the table `PUT` — are stubbed, so nothing depends on a+ provider): a refused import puts the whole sentence in the dialog, records the write attempt and+ the listing, leaves the notification region empty, keeps the dialog and its fields, and the line+ is **still there seven seconds later** with the server table unchanged; the second case shows the+ mode switch retiring the sentence and the same button, once the write is allowed, closing the+ dialog and writing both models.++## Compatibility++No interface change, no new dependency, no Project config change. The dialog's other failures+(invalid URL, a listing that failed or was empty), the create-only path and every other model-library+write are untouched.diff --git a/changelog/unreleased/2026-11-08-models-group-import-refusal.zh.md b/changelog/unreleased/2026-11-08-models-group-import-refusal.zh.mdnew file mode 100644index 00000000..f34cc922--- /dev/null+++ b/changelog/unreleased/2026-11-08-models-group-import-refusal.zh.md@@ -0,0 +1,46 @@+# 新增分组里导入被拒时,原因留在对话框里,不再只活六秒++- **日期:** 2026-11-08+- **类型:** 修复+- **范围:** `web`+- **破坏性变更:** 无++[English](2026-11-08-models-group-import-refusal.md)++模型库的「新增分组」对话框带一个导入模式:填一个端点,服务端列出它提供的模型,一次按下就把它们+全部作为新的自建分组写进表。那一次按下就是一整张表的写入,所以被拒的时候什么都没写 —— 读者刚起+好的那个分组不存在,列表里的条目一个都没进去,而对话框留着(它只在写入成功时关闭),身后那个页+面上也没有这个分组。++这条原因此前只能用一条通知说,而通知浮在对话框上方、六秒后自己消失:它一走,对话框与按下之前一+模一样,身后的页面也没有任何变化,屏幕上再没有一句解释。现在它画在对话框自己的报错那一行:base+URL 字段下面、按钮上面,也就是「获取模型列表失败」这类答复占的同一个位置,一直留到改表单、切换+模式或下一次尝试为止。导入按钮自己就是重试,它要发出去的就是屏幕上这几个字段。++这句话把重试之前必须知道的两件事都说清:哪个分组没有建成,以及对话框身后的那张表没有动。只说+「保存失败」会留一个疑问 —— 列表是不是已经进去了一半。++## 细节++- 新增 `packages/web/src/features/models/group-import-refusal.ts`:`groupImportRefusal(name,+ outcome)` —— 写入成功时答 `null`(那时对话框已经关了,没有要画的东西),被拒时给整句。+- `packages/web/src/features/models/models-page.tsx`:`importGroup` 把 `persist` 的判定交还给对话+ 框(原来那段注释写「导入一落地对话框就关,这里没有卡片可承接」,是错的 —— 它只在写入成功时关,+ 判定要交回去正是因为它没关);`runImport` 把拒绝画进对话框;切换模式清掉上一次的答复。+- `packages/web/src/lib/strings{,-en}.ts`:`models.groupImportRefused(name, reason)`。+- `packages/web/src/features/models/write-outcome.ts`:文件头那份「哪些调用点把话交给卡片」的清单+ 补上导入这条路。++## 测试++- 新增 `packages/web/test/group-import-refusal.test.ts`(4 条):写入成功不语;被拒时点出分组名并+ 保留服务端原话;同时说明表没有动;中英两种界面语言。+- 新增 `packages/web/e2e/models-group-import-refusal.spec.mjs`(真服务端 + 真浏览器;这条流程的两+ 个路由 —— `models/list` 与整表 `PUT` —— 都桩掉,不依赖任何厂商):导入被拒时整句在对话框里、+ 这次写入与列表各只发生一次、通知区是空的、对话框与字段原样,**七秒后**那句话仍在、服务端表里+ 一条也没有;第二条:切换模式把那句话一并退掉,而放行后重按同一个按钮会关掉对话框并写进两个模型。++## 兼容性++不改接口、不引入新依赖、不改 Project 配置。对话框自己的其它失败(URL 无效、列表失败或为空)、+「仅新增分组」那条路、模型库其它写入都没动。diff --git a/packages/web/e2e/models-group-import-refusal.spec.mjs b/packages/web/e2e/models-group-import-refusal.spec.mjsnew file mode 100644index 00000000..326e583b--- /dev/null+++ b/packages/web/e2e/models-group-import-refusal.spec.mjs@@ -0,0 +1,204 @@+/**+ * Regression: the add-group dialog's bulk import keeps a refused save's reason in the dialog, with+ * the fields the retry sends — not in a six-second notification over it.+ *+ * The import is one whole-table PUT (every model the endpoint listed, appended), so a refusal+ * writes nothing: the dialog stays open (it closes only on a written save) and the page behind it+ * still has no such group. That reason used to be raised as a toast alone, which sits over the+ * dialog and dismisses itself — leaving a dialog that looked exactly as it had before the press+ * and a page that had not changed, with nothing saying why.+ *+ * The endpoint is stubbed on both routes the flow uses (`models/list` for the listing, `models` for+ * the table write), so nothing here depends on a real provider or on the built-in catalog.+ */+import { test, expect } from "@playwright/test";+import { provisionAndLogin } from "./auth.mjs";++const BASE = process.env.BASE_URL;+const P = "password123";++/** The group the tests create; unique enough to appear nowhere else. */+const GROUP = "probeimport";++/** What the stubbed endpoint lists: two ids no catalog knows, so the import is the only source. */+const LISTED = ["probe-import-a", "probe-import-b"];++/** The table entry a `ModelInfo` came from: every field the response reports, sent back as-is. */+function toEntry(m) {+ const entry = { provider: m.provider, modelId: m.modelId };+ for (const key of [+ "displayName",+ "contextWindow",+ "clientType",+ "vision",+ "maxTokens",+ "fastMode",+ "pricing",+ ]) {+ if (m[key] !== undefined) entry[key] = m[key];+ }+ if (m.credential?.baseUrl !== undefined) entry.baseUrl = m.credential.baseUrl;+ return entry;+}++/**+ * Provision the user and seed their Project without the group under test: a rerun on the same data+ * root drops the group an earlier run left, so its name is free for the dialog.+ */+async function projectWithoutGroup(page, userId) {+ await provisionAndLogin(page.request, userId, P);+ const { projects } = await (await page.request.get(`${BASE}/api/projects`)).json();+ const projectId = projects[0].projectId;+ const read = async () =>+ (await page.request.get(`${BASE}/api/projects/${projectId}/models`)).json();++ const table = await read();+ if (table.models.some((m) => m.provider === GROUP)) {+ const put = await page.request.put(`${BASE}/api/projects/${projectId}/models`, {+ data: {+ defaultModel: table.defaultModel,+ models: table.models.filter((m) => m.provider !== GROUP).map(toEntry),+ },+ });+ expect(put.ok(), "drop the group an earlier run left").toBeTruthy();+ }+ expect((await read()).models.some((m) => m.provider === GROUP)).toBe(false);+ return { projectId, read };+}++/** Supply the endpoint's listing: the one request the import runs before it saves. */+async function listModels(page, seen) {+ await page.route("**/api/projects/*/models/list", async (route) => {+ seen.push(route.request().url());+ await route.fulfill({+ status: 200,+ contentType: "application/json",+ body: JSON.stringify({ ok: true, models: LISTED }),+ });+ });+}++/** Refuse the table write with a code the interface has no local copy for, so the server's words show. */+async function refuseWrites(page, puts, refused) {+ await page.route("**/api/projects/*/models", async (route) => {+ if (route.request().method() !== "PUT") return route.fallback();+ puts.push(route.request().url());+ if (!refused()) return route.fallback();+ await route.fulfill({+ status: 500,+ contentType: "application/json",+ body: JSON.stringify({+ error: { code: "models_store_closed", message: "models store is closed" },+ }),+ });+ });+}++/**+ * Open the add-group dialog on its import side, with everything the import button needs already+ * filled in: the protocol is hand-picked from the in-field menu (nothing depends on a detect run),+ * so the press is the save itself.+ */+async function openImportDialog(page) {+ await page.goto("/models");+ await page+ .getByRole("button", { name: /新增分组/ })+ .first()+ .click();+ const dialog = page.getByRole("dialog");+ await expect(dialog).toBeVisible();+ await dialog.getByRole("button", { name: "导入模型" }).click();+ await dialog.locator('input[placeholder*="小写字母"]').fill(GROUP);+ await dialog.locator('input[placeholder*="该端点的 API key"]').fill("sk-probe");+ await dialog.locator('input[aria-label="自定义 base URL"]').fill("http://127.0.0.1:9/v1");+ await dialog.getByRole("button", { name: /选择协议/ }).click();+ await page.getByRole("menuitemradio", { name: /OpenAI Chat Completions/ }).click();+ await expect(dialog.getByRole("button", { name: "批量导入模型" })).toBeVisible();+ return dialog;+}++/** The line the dialog draws for a refused save — the whole sentence, in the server's words. */+function refusalLine(dialog) {+ return dialog.getByText(/models store is closed/);+}++test("a refused import leaves the reason in the dialog, over a table that did not move", async ({+ page,+}) => {+ const { read } = await projectWithoutGroup(page, "r210import");+ const before = await read();+ const listed = [];+ await listModels(page, listed);++ const dialog = await openImportDialog(page);+ const puts = [];+ await refuseWrites(page, puts, () => true);+ await dialog.getByRole("button", { name: "批量导入模型" }).click();++ // The reason is in the dialog, whole, and says what the reader has to know before retrying:+ // which group was not created, and that nothing from the listing went in.+ const line = refusalLine(dialog);+ await expect(line).toBeVisible();+ expect(await line.innerText()).toBe(+ `分组「${GROUP}」没有建成,导入的模型一个都没写进表:models store is closed`,+ );+ // Not in a notification, which would sit over the dialog and dismiss itself.+ await expect(page.getByRole("region", { name: "通知" }).getByRole("button")).toHaveCount(0);++ // The listing ran once and the save was attempted once; the dialog and its fields are intact,+ // so the same button is the retry.+ expect(listed).toHaveLength(1);+ expect(puts).toHaveLength(1);+ await expect(dialog).toBeVisible();+ await expect(dialog.locator('input[placeholder*="小写字母"]')).toHaveValue(GROUP);+ await expect(dialog.locator('input[aria-label="自定义 base URL"]')).toHaveValue(+ "http://127.0.0.1:9/v1",+ );++ // Seven seconds later it is still there: the sentence outlives any toast.+ await page.waitForTimeout(7000);+ await expect(line).toBeVisible();++ // And the server holds exactly what it held before: no group, no half-imported rows.+ const after = await read();+ expect(after.models.some((m) => m.provider === GROUP)).toBe(false);+ expect(after.models).toHaveLength(before.models.length);+});++test("the retry is the same button, and switching modes retires the sentence", async ({ page }) => {+ const { read } = await projectWithoutGroup(page, "r210importretry");+ const listed = [];+ await listModels(page, listed);++ const dialog = await openImportDialog(page);+ const puts = [];+ let refuse = true;+ await refuseWrites(page, puts, () => refuse);++ await dialog.getByRole("button", { name: "批量导入模型" }).click();+ const line = refusalLine(dialog);+ await expect(line).toBeVisible();+ expect(puts).toHaveLength(1);++ // The mode switch leaves the flow the sentence described, so it goes with it — and does not come+ // back when the reader returns to the import side.+ await dialog.getByRole("button", { name: "仅新增分组" }).click();+ await expect(refusalLine(dialog)).toHaveCount(0);+ await dialog.getByRole("button", { name: "导入模型" }).click();+ await expect(refusalLine(dialog)).toHaveCount(0);++ // Letting the write through: the retry is the same button, and it closes the dialog.+ refuse = false;+ await dialog.getByRole("button", { name: "批量导入模型" }).click();+ await expect(page.getByRole("dialog")).toHaveCount(0);+ expect(puts).toHaveLength(2);++ const table = await read();+ expect(+ table.models+ .filter((m) => m.provider === GROUP)+ .map((m) => m.modelId)+ .sort(),+ ).toEqual(LISTED);+ await expect(page.getByText("probe-import-a", { exact: true }).first()).toBeVisible();+});diff --git a/packages/web/src/features/models/group-import-refusal.ts b/packages/web/src/features/models/group-import-refusal.tsnew file mode 100644index 00000000..55c75aca--- /dev/null+++ b/packages/web/src/features/models/group-import-refusal.ts@@ -0,0 +1,29 @@+/**+ * The add-group dialog's import landing: the sentence a refused save leaves inside that dialog,+ * and why that sentence is a line in the dialog rather than a notification.+ *+ * Importing a group is one whole-table PUT (every row the endpoint listed, appended), so a+ * refusal writes nothing at all and the table goes back to what it was — the dialog is all the+ * reader has left: the name, the key and the base URL the retry sends. It also stays open (that+ * is why the caller hands the verdict back), and it already draws its own failures — an invalid+ * URL, a listing that failed — under the import button. A save that was refused used to be the+ * only one of those answers that went to a notification instead: a box over the dialog, six+ * seconds and gone, after which the dialog looked exactly as it had before the press and said+ * nothing about why the group was still missing from the page behind it.+ *+ * So the refusal is drawn in the dialog's own error slot, under the button that retries it, and+ * stays until the form is edited or another attempt starts. The sentence names the group and+ * says the table still holds what it held: the retry has to be read against something that did+ * not move, and "not created" on its own leaves the reader unsure whether half the listing+ * landed.+ */+import { S } from "../../lib/strings";+import type { WriteOutcome } from "./write-outcome";++/**+ * The line the dialog draws when the import's save did not land, or `null` when it did — a+ * written import closes the dialog, so only the refused one has a line to show.+ */+export function groupImportRefusal(name: string, outcome: WriteOutcome): string | null {+ return outcome.ok ? null : S.models.groupImportRefused(name, outcome.reason);+}diff --git a/packages/web/src/features/models/models-page.tsx b/packages/web/src/features/models/models-page.tsxindex 4e98707c..eb0c1310 100644--- a/packages/web/src/features/models/models-page.tsx+++ b/packages/web/src/features/models/models-page.tsx@@ -147,6 +147,7 @@ import { dismissTodo } from "../../lib/todo-dismissals";import { noticeCounts } from "../../lib/bulk-update";import { refreshProjectTodos } from "../../lib/use-project-todos";import { buildImportedRows } from "./group-import";+import { groupImportRefusal } from "./group-import-refusal";import { tpsTone, ttftTone } from "./speed-test";import type { SpeedResult, SpeedTone } from "./speed-test";import { toneDot, toneInk } from "../../lib/tone";@@ -1105,24 +1106,29 @@ export function ModelsPage() {/*** Import-mode landing from the add-group dialog: one table PUT with the appended rows,- * then the new group is opened so the result is visible immediately. Returns persist's- * verdict so the dialog stays up (fields intact) when saving failed.+ * then the new group is opened so the result is visible immediately. The answer is+ * persist's own verdict, not a boolean: the dialog stays up with its fields when the save+ * was refused, so it is also the card that carries the reason (see `groupImportRefusal`).** A failed save is rolled back to the table as it stood: persist otherwise keeps the* attempted rows on screen (right for a field edit the user is still holding), which* here would show the whole group as if it existed and make the dialog's own name check* report the name as taken on the retry.*- * The refusal is raised as a toast: the add-group dialog closes the moment the import lands- * and keeps its own fields, so there is no card here to carry the server's words.+ * The refusal is deliberately not raised as a toast: the dialog that asked is still on+ * screen, with the fields the retry sends, and a notification sits over it and leaves after+ * six seconds — leaving that dialog looking exactly as it did before the press, with no+ * account of why the group is still missing from the page behind it.*/const importGroup = async (nextRows: RowState[],name: string,added: number,skipped: number,- ): Promise<boolean> => {- if (!projectId) return false;+ ): Promise<WriteOutcome> => {+ // Unreachable through the page (it renders nothing without a Project, and the dialog is+ // behind that gate). The generic sentence is what a write that never left would report.+ if (!projectId) return { ok: false, reason: S.common.unknownError };const before = rows;const outcome = await persist(nextRows,@@ -1131,9 +1137,8 @@ export function ModelsPage() {S.models.groupImported(added, skipped),);if (!outcome.ok) {- toastError(outcome.reason);setRows(before);- return false;+ return outcome;}if (!expanded.has(name)) {const next = new Set(expanded);@@ -1142,7 +1147,7 @@ export function ModelsPage() {saveExpandedProviders(projectId, next);}setAddGroupOpen(false);- return true;+ return outcome;};const editingRow =editing !== null ? rows?.find((r) => sameModelRef(rowRef(r), editing)) : undefined;@@ -2047,13 +2052,16 @@ function AddGroupDialog({onClose: () => void;/** Create-only confirm: open the add-model dialog for the named group. */onManual: (name: string) => void;- /** Import landing: persist the appended rows; resolves false when saving failed (the dialog stays open). */+ /**+ * Import landing: persist the appended rows. A refused save answers `ok: false` and leaves the+ * dialog open, so its reason has somewhere to be drawn (`groupImportRefusal`).+ */onImport: (nextRows: RowState[],name: string,added: number,skipped: number,- ) => Promise<boolean>;+ ) => Promise<WriteOutcome>;}) {const [name, setName] = useState("");const [nameError, setNameError] = useState<string | null>(null);@@ -2175,7 +2183,12 @@ function AddGroupDialog({return;}setImporting(S.models.groupImportSaving(built.added));- await onImport([...rows, ...built.rows], n, built.added, built.skipped);+ // The verdict decides the dialog's fate: a written import closes it (the landing above+ // does that), a refused one keeps it up, so the reason goes into the slot this dialog+ // already uses for its own failures — under the button that retries it.+ const outcome = await onImport([...rows, ...built.rows], n, built.added, built.skipped);+ const refusal = groupImportRefusal(n, outcome);+ if (refusal !== null) setError(refusal);} catch (e) {setError(apiErrorText(e));} finally {@@ -2244,7 +2257,12 @@ function AddGroupDialog({{ value: "import", label: S.models.groupModeImport },]}value={mode}- onChange={setMode}+ // The mode switch retires the previous answer: a refused import's sentence, or a+ // failed listing's, described the flow the reader just left.+ onChange={(next) => {+ setMode(next);+ setError(null);+ }}/>{mode === "import" && (<>diff --git a/packages/web/src/features/models/write-outcome.ts b/packages/web/src/features/models/write-outcome.tsindex b1ad38d7..c43207c8 100644--- a/packages/web/src/features/models/write-outcome.ts+++ b/packages/web/src/features/models/write-outcome.ts@@ -8,8 +8,10 @@* while retrying was also the first thing to leave.** The words are the caller's to place: a call site with a card still on screen hands them to that- * card, and the two that have none (a group key written from a dialog that closes on submit, the- * presets sync started from the toolbar) keep the toast.+ * card, and the ones with none (a group key written from a dialog that closes on submit, the+ * presets sync started from the toolbar) keep the toast. The add-group dialog's import is the+ * other way round — it closes only on a written save — so its refusal goes back into that dialog+ * (`groupImportRefusal`).*/export type WriteOutcome = { ok: true } | { ok: false; reason: string };diff --git a/packages/web/src/lib/strings-en.ts b/packages/web/src/lib/strings-en.tsindex f4c751d1..90a14d9a 100644--- a/packages/web/src/lib/strings-en.ts+++ b/packages/web/src/lib/strings-en.ts@@ -2118,6 +2118,13 @@ export const en: Strings = {skipped > 0? `Imported ${added} models, skipped ${skipped} entries`: `Imported ${added} models`,+ /**+ * A refused import save, drawn in the dialog that asked (group-import-refusal.ts): the group is+ * not there and neither is anything from the listing — the table is one write, so it is all or+ * nothing, and the reader has to know which of the two they are looking at before retrying.+ */+ groupImportRefused: (name: string, reason: string): string =>+ `The group “${name}” was not created — none of the imported models were written: ${reason}`,groupNameLabel: "Group name",groupNameHint: "Starts with a lowercase letter / digit; may contain - and _",groupNameInvalid:diff --git a/packages/web/src/lib/strings.ts b/packages/web/src/lib/strings.tsindex 96f34513..f171906a 100644--- a/packages/web/src/lib/strings.ts+++ b/packages/web/src/lib/strings.ts@@ -2150,6 +2150,13 @@ export const zh = {groupImportEmpty: "该端点没有可导入的模型",groupImported: (added: number, skipped: number): string =>skipped > 0 ? `已导入 ${added} 个模型,跳过 ${skipped} 个条目` : `已导入 ${added} 个模型`,+ /**+ * A refused import save, drawn in the dialog that asked (group-import-refusal.ts): the group is+ * not there and neither is anything from the listing — the table is one write, so it is all or+ * nothing, and the reader has to know which of the two they are looking at before retrying.+ */+ groupImportRefused: (name: string, reason: string): string =>+ `分组「${name}」没有建成,导入的模型一个都没写进表:${reason}`,groupNameLabel: "分组名",groupNameHint: "小写字母 / 数字开头,可含 - 与 _",groupNameInvalid: "分组名只能用小写字母、数字、- 与 _(首字符为字母或数字),长度不超过 32",diff --git a/packages/web/test/group-import-refusal.test.ts b/packages/web/test/group-import-refusal.test.tsnew file mode 100644index 00000000..59c1a128--- /dev/null+++ b/packages/web/test/group-import-refusal.test.ts@@ -0,0 +1,52 @@+/**+ * The add-group dialog's import line (src/features/models/group-import-refusal.ts): which answer+ * gets a sentence, and what that sentence has to say.+ *+ * The import is one whole-table write, so a refusal writes nothing and the dialog stays up with+ * the fields the retry sends — this line is the only account of the press once the six-second+ * notification is gone. That is why it has to name the two facts a reader needs before retrying:+ * which group was not created, and that the table behind the dialog did not move either.+ */+import { afterEach, describe, expect, it } from "vitest";+import { en as EN } from "../src/lib/strings-en";+import { S, setActiveStrings, zh as ZH } from "../src/lib/strings";+import { groupImportRefusal } from "../src/features/models/group-import-refusal";++afterEach(() => {+ setActiveStrings(ZH);+});++describe("groupImportRefusal", () => {+ it("says nothing for a written import", () => {+ // A written import closes the dialog, so there is no line for it to draw.+ expect(groupImportRefusal("probegroup", { ok: true })).toBeNull();+ });++ it("names the group and keeps the server's words for a refused one", () => {+ const line = groupImportRefusal("probeimport", {+ ok: false,+ reason: "models store is closed",+ });+ expect(line).toContain("probeimport");+ expect(line).toContain("models store is closed");+ });++ it("says the table did not move, not just that the write failed", () => {+ // The dialog stays open over a page that still has no such group: the reader has to know the+ // listing did not half-land, which is the one thing a bare "saving failed" leaves open.+ const line = groupImportRefusal("probeimport", {+ ok: false,+ reason: "服务器内部错误,请稍后重试。",+ });+ expect(line).toBe(S.models.groupImportRefused("probeimport", "服务器内部错误,请稍后重试。"));+ expect(line).toContain("一个都没写进表");+ });++ it("follows the interface language", () => {+ setActiveStrings(EN);+ const line = groupImportRefusal("probeimport", { ok: false, reason: "models store is closed" });+ expect(line).toContain("probeimport");+ expect(line).toContain("not created");+ expect(line).toContain("models store is closed");+ });+});