Improve the git diff preview from the file viewer
CI / check (push) Waiting to run

This commit is contained in:
2026-09-21 06:47:46 +02:00
parent a2d1c5df83
commit dbb7e40c6c
10 changed files with 98 additions and 221 deletions
+8 -12
View File
@@ -74,7 +74,7 @@ describe('Editor view modes', () => {
expect(find(c, '.seg button.on', 'Original')).toBeTruthy()
})
it('clicking a band in Actual reveals the original, clicking it again hides it', async () => {
it('clicking a band in Actual opens the full-screen Diff on that line', async () => {
const c = await openChanged()
const scroll = await waitFor(() => {
const el = c.querySelector<HTMLElement>('.ce-scroll')
@@ -84,18 +84,14 @@ describe('Editor view modes', () => {
// Line 30 is the first rewritten line. Unwrapped, its band is arithmetic:
// a 10px top pad plus 20px per line, and the hit test reads clientY.
fireEvent.click(scroll, { clientY: 10 + 29 * 20 + 5 })
const peek = await waitFor(() => {
const p = c.querySelector<HTMLElement>('.peek')
if (!p) throw new Error('peek not ready')
return p
})
const removed = Array.from(peek.querySelectorAll('.ln-row.del'))
expect(removed).toHaveLength(1)
expect(removed[0].textContent).toContain("'plan' => $user->plan,")
await waitFor(() => expect(c.querySelector('.split-overlay')).toBeTruthy())
const right = Array.from(c.querySelectorAll('.split-pane.right .ln-row'))
expect(right.some((el) => el.textContent?.includes("'plan'"))).toBe(true)
// A second click on the same band drops it.
fireEvent.click(scroll, { clientY: 10 + 29 * 20 + 5 })
await waitFor(() => expect(c.querySelector('.peek')).toBeNull())
// Esc puts the pane back in Actual.
act(() => { window.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape' })) })
await waitFor(() => expect(c.querySelector('.split-overlay')).toBeNull())
expect(c.querySelector('.seg button.on')?.textContent).toBe('Actual')
})
it('⌘M cycles Actual → Original → Diff, and nothing else', async () => {