From 76713201ec5ce9e7dd6a90a74aa102ec0cae8b88 Mon Sep 17 00:00:00 2001
From: Neil <4138956+nwparker@users.noreply.github.com>
Date: Mon, 10 Aug 2026 12:11:19 -0700
Subject: [PATCH] test(editor): cover commit-time visibility
---
...EditorPanelVisibilityContentState.test.tsx | 37 ++++++++++++++++++-
1 file changed, 36 insertions(+), 1 deletion(-)
diff --git a/src/renderer/src/components/editor/useEditorPanelVisibilityContentState.test.tsx b/src/renderer/src/components/editor/useEditorPanelVisibilityContentState.test.tsx
index 93ba2482bf0..eacc6c8fec3 100644
--- a/src/renderer/src/components/editor/useEditorPanelVisibilityContentState.test.tsx
+++ b/src/renderer/src/components/editor/useEditorPanelVisibilityContentState.test.tsx
@@ -1,6 +1,6 @@
// @vitest-environment happy-dom
-import { act, useMemo } from 'react'
+import { act, useLayoutEffect, useMemo } from 'react'
import { createRoot, type Root } from 'react-dom/client'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import type { OpenFile } from '@/store/slices/editor'
@@ -124,6 +124,21 @@ function dispatchExternalChange(file: OpenFile): void {
})
}
+function ExternalChangeLayoutEmitter({ file }: { file: OpenFile }): null {
+ useLayoutEffect(() => {
+ window.dispatchEvent(
+ new CustomEvent(ORCA_EDITOR_EXTERNAL_FILE_CHANGE_EVENT, {
+ detail: {
+ worktreeId: file.worktreeId,
+ worktreePath: '/repo',
+ relativePath: file.relativePath
+ }
+ })
+ )
+ }, [file])
+ return null
+}
+
function textDiff(modifiedContent: string): DiffContent {
return {
kind: 'text',
@@ -202,6 +217,26 @@ describe('useEditorPanelContentState visibility', () => {
)
})
+ it('publishes hidden visibility before a watcher event in the same commit', async () => {
+ const file = makeFile('commit-visibility')
+ mocks.readRuntimeFileContent.mockResolvedValue({ content: 'old', isBinary: false })
+
+ await act(async () => root.render())
+ await vi.waitFor(() => expect(mocks.readRuntimeFileContent).toHaveBeenCalledOnce())
+
+ await act(async () =>
+ root.render(
+ <>
+
+
+ >
+ )
+ )
+
+ expect(mocks.readRuntimeFileContent).toHaveBeenCalledOnce()
+ expect(snapshots.get('main')?.fileContents[file.id]).toBeUndefined()
+ })
+
it('shares one post-change read between visible source and preview panels', async () => {
const source = makeFile('source', {
filePath: '/repo/readme.md',