From 7df56adaf1b4b5a062b8f671797d5eb03beae931 Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Sun, 19 Jul 2026 21:16:33 -0700 Subject: [PATCH] fix(ui): restore spaces around orca.yaml in trust dialog (#9511) --- .../sidebar/OrcaYamlTrustDialog.test.tsx | 98 +++++++++++++++++++ .../sidebar/OrcaYamlTrustDialog.tsx | 9 +- src/renderer/src/i18n/locales/es.json | 4 +- 3 files changed, 104 insertions(+), 7 deletions(-) create mode 100644 src/renderer/src/components/sidebar/OrcaYamlTrustDialog.test.tsx diff --git a/src/renderer/src/components/sidebar/OrcaYamlTrustDialog.test.tsx b/src/renderer/src/components/sidebar/OrcaYamlTrustDialog.test.tsx new file mode 100644 index 000000000..65f937da4 --- /dev/null +++ b/src/renderer/src/components/sidebar/OrcaYamlTrustDialog.test.tsx @@ -0,0 +1,98 @@ +import { renderToStaticMarkup } from 'react-dom/server' +import type { ButtonHTMLAttributes, ReactNode } from 'react' +import { beforeEach, describe, expect, it, vi } from 'vitest' + +const mocks = vi.hoisted(() => ({ + state: { + activeModal: 'confirm-orca-yaml-hooks' as string | null, + modalData: {} as Record, + closeModal: vi.fn(), + markOrcaHookScriptConfirmed: vi.fn(), + markOrcaHookRepoAlwaysTrusted: vi.fn() + } +})) + +vi.mock('@/store', () => ({ + useAppStore: Object.assign( + (selector: (state: typeof mocks.state) => unknown) => selector(mocks.state), + { + getState: () => mocks.state + } + ) +})) + +vi.mock('@/components/ui/dialog', () => ({ + Dialog: ({ open, children }: { open: boolean; children: ReactNode }) => + open ?
{children}
: null, + DialogContent: ({ children }: { children: ReactNode }) =>
{children}
, + DialogDescription: ({ children }: { children: ReactNode }) =>
{children}
, + DialogFooter: ({ children }: { children: ReactNode }) =>
{children}
, + DialogHeader: ({ children }: { children: ReactNode }) =>
{children}
, + DialogTitle: ({ children }: { children: ReactNode }) =>
{children}
+})) + +vi.mock('@/components/ui/button', () => ({ + Button: ({ + children, + ...props + }: ButtonHTMLAttributes & { children: ReactNode }) => ( + + ) +})) + +// Why: fall back to English defaults so this test doesn't depend on locale files +// being loaded; the bug is missing JSX whitespace around those fragments. +vi.mock('@/i18n/i18n', () => ({ + translate: (_key: string, fallback: string) => fallback +})) + +function decodeHtml(html: string): string { + return html + .replace(/'/g, "'") + .replace(/"/g, '"') + .replace(/&/g, '&') + .replace(/</g, '<') + .replace(/>/g, '>') +} + +describe('OrcaYamlTrustDialog', () => { + beforeEach(() => { + vi.clearAllMocks() + mocks.state.activeModal = 'confirm-orca-yaml-hooks' + mocks.state.modalData = { + repoId: 'repo-1', + repoName: 'orca', + scriptKind: 'setup', + scriptContent: 'node config/scripts/run-internal-dev-setup.mjs\npnpm install', + contentHash: 'hash-1', + previouslyApproved: false + } + }) + + it('keeps spaces around orca.yaml and the repo name in the first-run copy', async () => { + const { default: OrcaYamlTrustDialog } = await import('./OrcaYamlTrustDialog') + const text = decodeHtml(renderToStaticMarkup()).replace(/<[^>]+>/g, '') + + expect(text).toContain("This repository's orca.yaml runs on your machine") + expect(text).toContain('Only run if you trust orca.') + expect(text).toContain('Always trust orca.yaml in orca') + expect(text).not.toContain("repository'sorca.yaml") + expect(text).not.toContain('trustorca') + expect(text).not.toContain('trustorca.yaml') + expect(text).not.toContain('inorca') + }) + + it('keeps spaces around orca.yaml when the script changed since last approval', async () => { + mocks.state.modalData = { + ...mocks.state.modalData, + previouslyApproved: true + } + const { default: OrcaYamlTrustDialog } = await import('./OrcaYamlTrustDialog') + const text = decodeHtml(renderToStaticMarkup()).replace(/<[^>]+>/g, '') + + expect(text).toContain('orca.yaml changed since you last approved') + expect(text).toContain('Always trust orca.yaml in orca') + expect(text).not.toContain('Always trustorca.yaml') + expect(text).not.toContain('inorca') + }) +}) diff --git a/src/renderer/src/components/sidebar/OrcaYamlTrustDialog.tsx b/src/renderer/src/components/sidebar/OrcaYamlTrustDialog.tsx index 63489c8b2..60ea9bcf9 100644 --- a/src/renderer/src/components/sidebar/OrcaYamlTrustDialog.tsx +++ b/src/renderer/src/components/sidebar/OrcaYamlTrustDialog.tsx @@ -136,7 +136,7 @@ const OrcaYamlTrustDialog = React.memo(function OrcaYamlTrustDialog() { {translate( 'auto.components.sidebar.OrcaYamlTrustDialog.aa3ffb33fb', "This repository's" - )} + )}{' '} {translate('auto.components.sidebar.OrcaYamlTrustDialog.79afc6772b', 'orca.yaml')} {' '} @@ -148,7 +148,7 @@ const OrcaYamlTrustDialog = React.memo(function OrcaYamlTrustDialog() { {translate( 'auto.components.sidebar.OrcaYamlTrustDialog.bf800b7e04', '. Only run if you trust' - )} + )}{' '} {repoName}. )} @@ -190,12 +190,11 @@ const OrcaYamlTrustDialog = React.memo(function OrcaYamlTrustDialog() { onChange={(event) => setAlwaysTrust(event.target.checked)} /> - {translate('auto.components.sidebar.OrcaYamlTrustDialog.531689199b', 'Always trust')} + {translate('auto.components.sidebar.OrcaYamlTrustDialog.531689199b', 'Always trust')}{' '} {translate('auto.components.sidebar.OrcaYamlTrustDialog.79afc6772b', 'orca.yaml')} {' '} - {translate('auto.components.sidebar.OrcaYamlTrustDialog.c494b3ccb1', 'in')} - {repoName} + {translate('auto.components.sidebar.OrcaYamlTrustDialog.c494b3ccb1', 'in')} {repoName} diff --git a/src/renderer/src/i18n/locales/es.json b/src/renderer/src/i18n/locales/es.json index 1565076a5..64f47a9c2 100644 --- a/src/renderer/src/i18n/locales/es.json +++ b/src/renderer/src/i18n/locales/es.json @@ -3903,9 +3903,9 @@ "c494b3ccb1": "en", "79afc6772b": "orca.yaml", "531689199b": "Confiar siempre", - "bf800b7e04": ". Ejecútalo solo si confías en ", + "bf800b7e04": ". Ejecútalo solo si confías en", "831f2cd9f0": "se ejecuta en tu máquina", - "aa3ffb33fb": "El archivo ", + "aa3ffb33fb": "El archivo", "c55beddbf8": "cambió desde la última vez que lo aprobaste. Revísalo de nuevo antes de que se ejecute", "95bf974a1a": "Script {{value0}}", "9e52effffd": "Nuevo script {{value0}}",