This commit is contained in:
@@ -44,15 +44,72 @@ describe('Editor view modes', () => {
|
||||
expect(c.querySelector('.editor .ln-row')).toBeTruthy()
|
||||
})
|
||||
|
||||
it('Split opens a full-screen two-pane overlay and Esc collapses it', async () => {
|
||||
it('a git row opens the file in Actual, not in the full-screen Diff', async () => {
|
||||
const c = await openChanged()
|
||||
fireEvent.click(c.querySelector('.split-btn')!)
|
||||
expect(c.querySelector('.split-overlay')).toBeNull()
|
||||
expect(find(c, '.seg button.on', 'Actual')).toBeTruthy()
|
||||
await waitFor(() => expect(c.querySelector('.ce-ta')).toBeTruthy())
|
||||
})
|
||||
|
||||
it('Actual bands every changed line, over a buffer that stays editable', async () => {
|
||||
const c = await openChanged()
|
||||
// The mock rewrites six lines of UserController.php and removes none.
|
||||
await waitFor(() => expect(c.querySelectorAll('.ce-band')).toHaveLength(6))
|
||||
expect(c.querySelector('.ce-gaprule')).toBeNull()
|
||||
expect(c.querySelectorAll('.ce-gutter .chg')).toHaveLength(6)
|
||||
expect(c.querySelector('.ln-sign')).toBeNull()
|
||||
expect((c.querySelector('.ce-ta') as HTMLTextAreaElement).readOnly).toBe(false)
|
||||
})
|
||||
|
||||
it('the Diff segment opens the full-screen view, and Esc puts back the mode it covered', async () => {
|
||||
const c = await openChanged()
|
||||
fireEvent.click(find(c, '.seg button', 'Original')!)
|
||||
await waitFor(() => expect(c.querySelector('.ce-ta')).toBeNull())
|
||||
|
||||
fireEvent.click(find(c, '.seg button', 'Diff')!)
|
||||
await waitFor(() => expect(c.querySelector('.split-overlay')).toBeTruthy())
|
||||
expect(c.querySelector('.split-pane.left')).toBeTruthy()
|
||||
expect(c.querySelector('.split-pane.right')).toBeTruthy()
|
||||
|
||||
act(() => { window.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape' })) })
|
||||
await waitFor(() => expect(c.querySelector('.split-overlay')).toBeNull())
|
||||
expect(find(c, '.seg button.on', 'Original')).toBeTruthy()
|
||||
})
|
||||
|
||||
it('hovering a band in Actual reveals the original, leaving the editor hides it', async () => {
|
||||
const c = await openChanged()
|
||||
const scroll = await waitFor(() => {
|
||||
const el = c.querySelector<HTMLElement>('.ce-scroll')
|
||||
if (!el || !c.querySelector('.ce-band')) throw new Error('bands not ready')
|
||||
return el
|
||||
})
|
||||
// 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.mouseMove(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,")
|
||||
|
||||
fireEvent.mouseLeave(scroll)
|
||||
await waitFor(() => expect(c.querySelector('.peek')).toBeNull())
|
||||
})
|
||||
|
||||
it('⌘M cycles Actual → Original → Diff, and nothing else', async () => {
|
||||
const c = await openChanged()
|
||||
const seen: string[] = []
|
||||
for (let i = 0; i < 3; i++) {
|
||||
act(() => { window.dispatchEvent(new KeyboardEvent('keydown', { key: 'm', metaKey: true })) })
|
||||
await waitFor(() => {
|
||||
const on = c.querySelector('.seg button.on')?.textContent ?? ''
|
||||
if (seen[seen.length - 1] === on) throw new Error('mode not changed')
|
||||
seen.push(on)
|
||||
})
|
||||
}
|
||||
// A tab opens in Actual, so the first ⌘M already leaves it.
|
||||
expect(seen).toEqual(['Original', 'Diff', 'Actual'])
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user