From d7e2512cba427357905447c81a7d18e9cafc0810 Mon Sep 17 00:00:00 2001 From: Lukin Date: Mon, 6 Jul 2026 22:21:18 +0800 Subject: [PATCH] Fix admin i18n sync coverage Co-Authored-By: Codex --- .../lib/components/CreateKeyDialog.test.ts | 9 ++- .../src/lib/components/KeyCapsForm.svelte | 34 ++++----- apps/admin/src/lib/i18n/mcp-locales.test.ts | 7 +- .../lib/i18n/request-detail-locales.test.ts | 43 ++++++++++++ apps/admin/src/locales/en.json | 38 +++++++--- apps/admin/src/locales/ja.json | 68 +++++++++++------- apps/admin/src/locales/ko.json | 70 ++++++++++++------- apps/admin/src/locales/zh-hans.json | 68 +++++++++++------- apps/admin/src/locales/zh-hant.json | 68 +++++++++++------- apps/admin/src/routes/keys/keys.test.ts | 3 +- apps/admin/tools/keep-english.mjs | 34 --------- apps/admin/tools/translate-all.sh | 9 --- package.json | 4 ++ 13 files changed, 271 insertions(+), 184 deletions(-) create mode 100644 apps/admin/src/lib/i18n/request-detail-locales.test.ts delete mode 100644 apps/admin/tools/keep-english.mjs diff --git a/apps/admin/src/lib/components/CreateKeyDialog.test.ts b/apps/admin/src/lib/components/CreateKeyDialog.test.ts index 9861fe1b..7e7e59f5 100644 --- a/apps/admin/src/lib/components/CreateKeyDialog.test.ts +++ b/apps/admin/src/lib/components/CreateKeyDialog.test.ts @@ -41,18 +41,18 @@ describe('CreateKeyDialog', () => { // Tick a subset of lanes; the whitelist is the only lane cap (no max-lane field). await fireEvent.click(screen.getByLabelText('economy')); await fireEvent.click(screen.getByLabelText('balanced')); + await fireEvent.click(screen.getByLabelText('allow custom model')); await fireEvent.input(screen.getByLabelText('Blocked models'), { target: { value: 'gpt-4o\nanthropic/claude-sonnet-4-6' }, }); await fireEvent.click(screen.getByLabelText('allow client-requested Fast mode')); - // allow_custom_model defaults to false; leave that checkbox unchecked. await fireEvent.click(screen.getByRole('button', { name: /create key/i })); await waitFor(() => expect(createKey).toHaveBeenCalledTimes(1)); const input = createKey.mock.calls[0][0]; expect(input.allowed_lanes).toEqual(['economy', 'balanced']); expect(input.blocked_models).toEqual(['gpt-4o', 'anthropic/claude-sonnet-4-6']); - expect(input.allow_custom_model).toBe(false); + expect(input.allow_custom_model).toBe(true); expect(input.allow_fast_mode).toBe(true); }); @@ -78,12 +78,15 @@ describe('CreateKeyDialog', () => { expect(input.rate_limit_tpm).toBeUndefined(); }); - it('collapses the optional cap sections by default, basics stay visible', () => { + it('collapses the optional cap sections by default, basics stay visible', async () => { setup(); // Basics (lanes + passthrough) are immediately visible — not inside a section. expect(screen.getByLabelText('economy')).toBeInTheDocument(); expect(screen.getByLabelText('allow custom model')).toBeInTheDocument(); expect(screen.getByLabelText('allow client-requested Fast mode')).toBeInTheDocument(); + expect(screen.queryByLabelText('Blocked models')).not.toBeInTheDocument(); + await fireEvent.click(screen.getByLabelText('allow custom model')); + expect(screen.getByLabelText('Blocked models')).toBeInTheDocument(); // The three optional groups render as
sections, all closed. const sections = document.querySelectorAll('details'); expect(sections).toHaveLength(3); diff --git a/apps/admin/src/lib/components/KeyCapsForm.svelte b/apps/admin/src/lib/components/KeyCapsForm.svelte index 2cfb0335..a509513b 100644 --- a/apps/admin/src/lib/components/KeyCapsForm.svelte +++ b/apps/admin/src/lib/components/KeyCapsForm.svelte @@ -219,22 +219,24 @@ > - +{#if form.allowCustomModel} + +{/if}