mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 19:07:41 +00:00
test: remove low-value presentation and shortcut suites (#43134)
* test: remove narrow Markdown and browser presentation coverage * test: remove low-value scrolling, focus and gallery suites --------- Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
This commit is contained in:
@@ -52,7 +52,6 @@
|
||||
1 test-no-polling-loop:tests/e2e/browser-guest-crash-recovery.spec.ts
|
||||
1 test-no-polling-loop:tests/e2e/browser-tab.spec.ts
|
||||
1 test-no-polling-loop:tests/e2e/chinese-ime-chat-input-repro.spec.ts
|
||||
3 test-no-polling-loop:tests/e2e/combined-diff-scroll-restore.spec.ts
|
||||
1 test-no-polling-loop:tests/e2e/cross-version-wire/released-relay-daemon.ts
|
||||
1 test-no-polling-loop:tests/e2e/cross-version-wire/released-relay-transport.ts
|
||||
1 test-no-polling-loop:tests/e2e/daemon-lifecycle-retirement.spec.ts
|
||||
@@ -192,7 +191,6 @@
|
||||
9 test-no-real-time-wait:tests/e2e/chinese-ime-chat-input-repro.spec.ts
|
||||
2 test-no-real-time-wait:tests/e2e/cli-floating-file-open-position.spec.ts
|
||||
1 test-no-real-time-wait:tests/e2e/codex-ctrl-c-status.spec.ts
|
||||
4 test-no-real-time-wait:tests/e2e/combined-diff-scroll-restore.spec.ts
|
||||
1 test-no-real-time-wait:tests/e2e/cross-version-wire/legacy-relay-bridge.unit.test.ts
|
||||
1 test-no-real-time-wait:tests/e2e/cross-version-wire/released-relay-daemon.ts
|
||||
2 test-no-real-time-wait:tests/e2e/cross-version-wire/released-relay-transport.ts
|
||||
@@ -240,7 +238,6 @@
|
||||
1 test-no-real-time-wait:tests/e2e/large-file-count-fixtures.ts
|
||||
1 test-no-real-time-wait:tests/e2e/large-markdown-preview.spec.ts
|
||||
1 test-no-real-time-wait:tests/e2e/layout-stream-loss-reopen.spec.ts
|
||||
1 test-no-real-time-wait:tests/e2e/markdown-table-row-backspace.spec.ts
|
||||
3 test-no-real-time-wait:tests/e2e/notification-sound-replay.spec.ts
|
||||
4 test-no-real-time-wait:tests/e2e/orchestration-idle-mail-delivery.spec.ts
|
||||
1 test-no-real-time-wait:tests/e2e/orchestration-idle-mail-restore.spec.ts
|
||||
@@ -321,7 +318,6 @@
|
||||
1 test-no-real-time-wait:tests/e2e/unopened-workspace-agent-single-resume.spec.ts
|
||||
1 test-no-real-time-wait:tests/e2e/workspace-sleep-in-main.spec.ts
|
||||
3 test-no-real-time-wait:tests/e2e/workspace-sleep-main-resume.spec.ts
|
||||
1 test-no-real-time-wait:tests/e2e/worktree-active-delete-scroll-position.spec.ts
|
||||
2 test-no-real-time-wait:tests/e2e/worktree-card-downward-drag.spec.ts
|
||||
1 test-no-real-time-wait:tests/e2e/worktree-jump-sleep-focus.spec.ts
|
||||
1 test-no-real-time-wait:tests/e2e/worktree-parent-reorder.spec.ts
|
||||
|
||||
@@ -4837,13 +4837,10 @@
|
||||
"tests/e2e/browser-fedcm-fallback.spec.ts": 15100,
|
||||
"tests/e2e/browser-guest-attachment-validation.spec.ts": 16900,
|
||||
"tests/e2e/browser-guest-crash-recovery.spec.ts": 123200,
|
||||
"tests/e2e/browser-loading-surface.spec.ts": 49800,
|
||||
"tests/e2e/browser-local-https-certificate-trust.spec.ts": 19500,
|
||||
"tests/e2e/browser-split-shortcuts.spec.ts": 75000,
|
||||
"tests/e2e/browser-tab.spec.ts": 175700,
|
||||
"tests/e2e/chinese-ime-chat-input-repro.spec.ts": 49200,
|
||||
"tests/e2e/combined-diff-invalidation-freeze-repro.spec.ts": 101900,
|
||||
"tests/e2e/combined-diff-scroll-restore.spec.ts": 51900,
|
||||
"tests/e2e/completed-worker-retirement-resume.spec.ts": 40400,
|
||||
"tests/e2e/daemon-generation-legacy-close-safety.spec.ts": 5300,
|
||||
"tests/e2e/daemon-lifecycle-retirement.spec.ts": 222,
|
||||
@@ -4898,10 +4895,7 @@
|
||||
"tests/e2e/local-worktree-visibility-runtime-active.spec.ts": 14700,
|
||||
"tests/e2e/macos-press-and-hold-startup.spec.ts": 12700,
|
||||
"tests/e2e/manual-worktree-order-persistence.spec.ts": 36100,
|
||||
"tests/e2e/markdown-explorer-find-focus.spec.ts": 16300,
|
||||
"tests/e2e/markdown-nested-toggle.spec.ts": 50700,
|
||||
"tests/e2e/markdown-ordered-list-exit.spec.ts": 53200,
|
||||
"tests/e2e/markdown-table-row-backspace.spec.ts": 24600,
|
||||
"tests/e2e/mobile-banner.spec.ts": 89300,
|
||||
"tests/e2e/multi-client-navigation-isolation.spec.ts": 99900,
|
||||
"tests/e2e/native-chat-ask-user-question-card.spec.ts": 23600,
|
||||
@@ -5059,13 +5053,11 @@
|
||||
"tests/e2e/workspace-back-forward-navigation.spec.ts": 108500,
|
||||
"tests/e2e/workspace-board-lane-virtualization.spec.ts": 107700,
|
||||
"tests/e2e/workspace-session-corrupt-tab-salvage.spec.ts": 21100,
|
||||
"tests/e2e/worktree-active-delete-scroll-position.spec.ts": 59200,
|
||||
"tests/e2e/worktree-card-downward-drag.spec.ts": 60000,
|
||||
"tests/e2e/worktree-delete-shortcut.spec.ts": 20600,
|
||||
"tests/e2e/worktree-lifecycle.spec.ts": 44000,
|
||||
"tests/e2e/worktree-lineage.spec.ts": 96700,
|
||||
"tests/e2e/worktree-recent-sort.spec.ts": 28400,
|
||||
"tests/e2e/worktree-scroll-to-current.spec.ts": 62400,
|
||||
"tests/e2e/worktree-switch-responsiveness.spec.ts": 15100,
|
||||
"tests/e2e/worktree.spec.ts": 118100
|
||||
}
|
||||
|
||||
@@ -1,300 +0,0 @@
|
||||
import { createServer } from 'node:http'
|
||||
import { writeFile } from 'node:fs/promises'
|
||||
import type { AddressInfo } from 'node:net'
|
||||
import { expect, type Page } from '@stablyai/playwright-test'
|
||||
import { PNG } from 'pngjs'
|
||||
|
||||
// Hold the response, not a timer: every screenshot precedes the first document commit.
|
||||
export async function observeBrowserLoadingSurface(
|
||||
page: Page,
|
||||
outputPath: (name: string) => string,
|
||||
crashGuest?: (id: number) => Promise<void>
|
||||
) {
|
||||
const pendingResponses: (() => void)[] = []
|
||||
const release = (): void => {
|
||||
pendingResponses.splice(0).forEach((send) => send())
|
||||
}
|
||||
let requestCount = 0
|
||||
let flushPrefix: (() => void) | undefined
|
||||
let retryReady = false
|
||||
const server = createServer((request, response) => {
|
||||
if (request.url === '/fail' && !retryReady) {
|
||||
response.destroy()
|
||||
return
|
||||
}
|
||||
if (request.url !== '/held' && request.url !== '/fail') {
|
||||
response.writeHead(204).end()
|
||||
return
|
||||
}
|
||||
requestCount += 1
|
||||
let prefixSent = false
|
||||
flushPrefix = () => {
|
||||
prefixSent = true
|
||||
response.writeHead(200, { 'Content-Type': 'text/html' })
|
||||
response.write(
|
||||
`<!doctype html><head><title>Surface oracle</title></head><!--${'.'.repeat(4096)}-->`
|
||||
)
|
||||
}
|
||||
pendingResponses.push(() =>
|
||||
response.end(
|
||||
`${prefixSent ? '' : '<!doctype html><title>Surface oracle</title>'}<body><h1>Usable webpage</h1><input value="retained"></body>`
|
||||
)
|
||||
)
|
||||
})
|
||||
await new Promise<void>((resolve) => server.listen(0, '127.0.0.1', resolve))
|
||||
const url = `http://127.0.0.1:${(server.address() as AddressInfo).port}/held`
|
||||
const observations: Record<string, unknown>[] = []
|
||||
// Freezing attachment for a screenshot must also freeze the missing-guest watchdog.
|
||||
await page.clock.pauseAt(new Date())
|
||||
const attachGate = await page.evaluateHandle((heldUrl) => {
|
||||
const original = Element.prototype.setAttribute
|
||||
const pending: (() => void)[] = []
|
||||
Element.prototype.setAttribute = function (name, value) {
|
||||
if (this.tagName === 'WEBVIEW' && name === 'src' && value === heldUrl) {
|
||||
pending.push(() => original.call(this, name, value))
|
||||
return
|
||||
}
|
||||
original.call(this, name, value)
|
||||
}
|
||||
return () => {
|
||||
Element.prototype.setAttribute = original
|
||||
pending.splice(0).forEach((release) => release())
|
||||
}
|
||||
}, url)
|
||||
try {
|
||||
await page.evaluate(async () => {
|
||||
await window.__store!.getState().updateSettingsOrThrow({ theme: 'dark' })
|
||||
})
|
||||
await expect(page.locator('html')).toHaveClass(/dark/)
|
||||
const tab = await page.evaluate((url) => {
|
||||
const s = window.__store!.getState()
|
||||
return s.createBrowserTab(s.activeWorktreeId!, url, {
|
||||
activate: true,
|
||||
title: 'Surface oracle'
|
||||
})
|
||||
}, url)
|
||||
let guest = page.locator(`[data-browser-overlay-tab-id="${tab.id}"] webview`)
|
||||
await expect(guest).toHaveCount(1)
|
||||
const capture = async (phase: string, expected: 'theme' | 'white', loading = false) => {
|
||||
const state = await guest.evaluate((element) => {
|
||||
const webview = element as Electron.WebviewTag
|
||||
const rect = webview.closest('[data-browser-page-container]')!.getBoundingClientRect()
|
||||
let loading = false
|
||||
let url = ''
|
||||
let attached = false
|
||||
try {
|
||||
loading = webview.isLoading()
|
||||
url = webview.getURL()
|
||||
attached = webview.getWebContentsId() > 0
|
||||
} catch {
|
||||
/* Guest creation is held by the oracle. */
|
||||
}
|
||||
return {
|
||||
attached,
|
||||
background: getComputedStyle(webview).backgroundColor,
|
||||
theme: getComputedStyle(webview.closest('[data-browser-page-container]')!)
|
||||
.backgroundColor,
|
||||
visibility: getComputedStyle(webview).visibility,
|
||||
display: getComputedStyle(webview).display,
|
||||
loading,
|
||||
url,
|
||||
rect: { x: rect.x, y: rect.y, width: rect.width, height: rect.height }
|
||||
}
|
||||
})
|
||||
const target =
|
||||
expected === 'white' ? [255, 255, 255] : state.theme.match(/\d+/g)!.slice(0, 3).map(Number)
|
||||
let samples: number[][] = []
|
||||
const sampleSurface = async (): Promise<boolean> => {
|
||||
const screenshot = await page.screenshot({ path: outputPath(`${phase}.png`), scale: 'css' })
|
||||
const png = PNG.sync.read(screenshot)
|
||||
samples = [0.08, 0.92].flatMap((x) =>
|
||||
[0.08, 0.85, 0.92].map((y) => {
|
||||
const offset =
|
||||
(Math.floor(state.rect.y + state.rect.height * y) * png.width +
|
||||
Math.floor(state.rect.x + state.rect.width * x)) *
|
||||
4
|
||||
return [...png.data.subarray(offset, offset + 3)]
|
||||
})
|
||||
)
|
||||
return samples.every((rgb) => rgb.every((c, i) => Math.abs(c - target[i]) <= 2))
|
||||
}
|
||||
let pixelPass = await sampleSurface()
|
||||
if (expected === 'white' && !pixelPass) {
|
||||
// Loading can stop before the compositor presents the recovered guest's first frame.
|
||||
await expect.poll(async () => (pixelPass = await sampleSurface())).toBe(true)
|
||||
}
|
||||
const statePass =
|
||||
expected === 'theme'
|
||||
? state.background === state.theme ||
|
||||
state.visibility === 'hidden' ||
|
||||
state.display === 'none'
|
||||
: state.url.startsWith('http://127.0.0.1:')
|
||||
expect(state.loading).toBe(loading)
|
||||
observations.push({
|
||||
phase,
|
||||
...state,
|
||||
samples,
|
||||
pixelPass,
|
||||
statePass,
|
||||
pass: pixelPass && statePass
|
||||
})
|
||||
}
|
||||
const dismissDrawHint = page.getByRole('button', { name: 'Got it', exact: true })
|
||||
if (await dismissDrawHint.isVisible()) {
|
||||
await dismissDrawHint.click()
|
||||
await expect(dismissDrawHint).not.toBeVisible()
|
||||
}
|
||||
await page.keyboard.press('Escape')
|
||||
await page.mouse.move(0, 0)
|
||||
await capture('pre-attach', 'theme')
|
||||
await attachGate.evaluate((release) => release())
|
||||
await page.clock.resume()
|
||||
await expect.poll(() => requestCount).toBe(1)
|
||||
await capture('dark-held', 'theme', true)
|
||||
await page.evaluate(async () => {
|
||||
await window.__store!.getState().updateSettingsOrThrow({ theme: 'light' })
|
||||
})
|
||||
await expect(page.locator('html')).toHaveClass(/light/)
|
||||
await capture('light-held', 'theme', true)
|
||||
await page.evaluate(async () => {
|
||||
await window.__store!.getState().updateSettingsOrThrow({ theme: 'dark' })
|
||||
})
|
||||
await expect(page.locator('html')).toHaveClass(/dark/)
|
||||
await capture('dark-again-held', 'theme', true)
|
||||
await page.emulateMedia({ colorScheme: 'light' })
|
||||
await page.evaluate(async () => {
|
||||
await window.__store!.getState().updateSettingsOrThrow({ theme: 'system' })
|
||||
})
|
||||
await expect(page.locator('html')).toHaveClass(/light/)
|
||||
await capture('system-light-held', 'theme', true)
|
||||
await page.emulateMedia({ colorScheme: 'dark' })
|
||||
await expect(page.locator('html')).toHaveClass(/dark/)
|
||||
await capture('system-dark-held', 'theme', true)
|
||||
await page.emulateMedia({ colorScheme: null })
|
||||
await page.evaluate(async () => {
|
||||
await window.__store!.getState().updateSettingsOrThrow({ theme: 'dark' })
|
||||
})
|
||||
flushPrefix!()
|
||||
await expect
|
||||
.poll(() => guest.evaluate((e) => (e as Electron.WebviewTag).getTitle()))
|
||||
.toBe('Surface oracle')
|
||||
await capture('committed-empty', 'theme', true)
|
||||
release!()
|
||||
await expect
|
||||
.poll(() => guest.evaluate((e) => (e as Electron.WebviewTag).isLoading()))
|
||||
.toBe(false)
|
||||
expect(
|
||||
await guest.evaluate((e) =>
|
||||
(e as Electron.WebviewTag).executeJavaScript(
|
||||
'({ text: document.querySelector("h1").textContent, style: document.body.getAttribute("style") })'
|
||||
)
|
||||
)
|
||||
).toEqual({ text: 'Usable webpage', style: null })
|
||||
await capture('unstyled-painted', 'white')
|
||||
await page.evaluate(async () => {
|
||||
await window.__store!.getState().updateSettingsOrThrow({ theme: 'light' })
|
||||
})
|
||||
await expect(page.locator('html')).toHaveClass(/light/)
|
||||
await capture('unstyled-light', 'white')
|
||||
await page.evaluate(async () => {
|
||||
await window.__store!.getState().updateSettingsOrThrow({ theme: 'dark' })
|
||||
})
|
||||
await expect(page.locator('html')).toHaveClass(/dark/)
|
||||
const pane = page.locator(`[data-browser-overlay-tab-id="${tab.id}"]`)
|
||||
await pane.getByRole('button', { name: 'Reload', exact: true }).click()
|
||||
await expect.poll(() => requestCount).toBe(2)
|
||||
await capture('reload-retained', 'white', true)
|
||||
release!()
|
||||
await expect
|
||||
.poll(() => guest.evaluate((e) => (e as Electron.WebviewTag).isLoading()))
|
||||
.toBe(false)
|
||||
const guestId = await guest.evaluate((e) => (e as Electron.WebviewTag).getWebContentsId())
|
||||
const worktreeId = await page.evaluate(() => window.__store!.getState().activeWorktreeId!)
|
||||
await page.evaluate(() => window.__store!.getState().setActiveWorktree(null))
|
||||
await expect(pane).not.toBeVisible()
|
||||
await page.evaluate(
|
||||
({ worktreeId, tabId }) => {
|
||||
const s = window.__store!.getState()
|
||||
s.setActiveWorktree(worktreeId)
|
||||
s.setActiveBrowserTab(tabId)
|
||||
},
|
||||
{ worktreeId, tabId: tab.id }
|
||||
)
|
||||
await expect(pane).toBeVisible()
|
||||
expect(await guest.evaluate((e) => (e as Electron.WebviewTag).getWebContentsId())).toBe(guestId)
|
||||
await capture('unpark-retained', 'white')
|
||||
if (crashGuest) {
|
||||
await crashGuest(guestId)
|
||||
await expect.poll(() => requestCount).toBe(3)
|
||||
await capture('recovery-held', 'theme', true)
|
||||
release!()
|
||||
await expect
|
||||
.poll(() => guest.evaluate((e) => (e as Electron.WebviewTag).isLoading()))
|
||||
.toBe(false)
|
||||
await capture('recovery-painted', 'white')
|
||||
}
|
||||
const blank = await page.evaluate(() => {
|
||||
const s = window.__store!.getState()
|
||||
return s.createBrowserTab(s.activeWorktreeId!, 'about:blank', { activate: true })
|
||||
})
|
||||
guest = page.locator(`[data-browser-overlay-tab-id="${blank.id}"] webview`)
|
||||
await expect
|
||||
.poll(() =>
|
||||
guest.evaluate((e) => {
|
||||
try {
|
||||
return (e as Electron.WebviewTag).getURL()
|
||||
} catch {
|
||||
return ''
|
||||
}
|
||||
})
|
||||
)
|
||||
.toMatch(/about:blank|data:text\/html,/)
|
||||
await expect
|
||||
.poll(() => guest.evaluate((e) => (e as Electron.WebviewTag).isLoading()))
|
||||
.toBe(false)
|
||||
await page.keyboard.press('Escape')
|
||||
await capture('new-tab', 'theme')
|
||||
// Navigate through the real address input, retaining the blank document while the server waits.
|
||||
const address = page.locator(`[data-browser-overlay-tab-id="${blank.id}"] input`).first()
|
||||
await address.fill(url)
|
||||
await address.press('Enter')
|
||||
await expect.poll(() => requestCount).toBe(crashGuest ? 4 : 3)
|
||||
await capture('new-tab-first-navigation-held', 'theme', true)
|
||||
release!()
|
||||
await expect
|
||||
.poll(() => guest.evaluate((e) => (e as Electron.WebviewTag).isLoading()))
|
||||
.toBe(false)
|
||||
await capture('new-tab-painted', 'white')
|
||||
await address.fill(url.replace('/held', '/fail'))
|
||||
await address.press('Enter')
|
||||
const retry = page
|
||||
.locator(`[data-browser-overlay-tab-id="${blank.id}"]`)
|
||||
.getByRole('button', { name: 'Retry', exact: true })
|
||||
.filter({ hasText: 'Retry' })
|
||||
await expect(retry).toBeVisible()
|
||||
await expect
|
||||
.poll(() => guest.evaluate((e) => (e as Electron.WebviewTag).isLoading()))
|
||||
.toBe(false)
|
||||
await capture('network-error', 'theme')
|
||||
retryReady = true
|
||||
const countBeforeRetry = requestCount
|
||||
await retry.click()
|
||||
await expect.poll(() => requestCount).toBeGreaterThan(countBeforeRetry)
|
||||
await capture('network-retry-held', 'theme', true)
|
||||
release!()
|
||||
await expect(retry).not.toBeVisible()
|
||||
await expect
|
||||
.poll(() => guest.evaluate((e) => (e as Electron.WebviewTag).isLoading()))
|
||||
.toBe(false)
|
||||
await capture('network-retry-painted', 'white')
|
||||
await writeFile(outputPath('observations.json'), JSON.stringify(observations, null, 2))
|
||||
return observations
|
||||
} finally {
|
||||
await attachGate.evaluate((release) => release()).catch(() => {})
|
||||
await page.clock.resume().catch(() => {})
|
||||
await attachGate.dispose()
|
||||
release?.()
|
||||
server.closeAllConnections()
|
||||
await new Promise<void>((resolve) => server.close(() => resolve()))
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
import { expect, test } from './helpers/orca-app'
|
||||
import { ensureTerminalVisible, waitForActiveWorktree, waitForSessionReady } from './helpers/store'
|
||||
import { crashGuestRenderer } from './browser-guest-runtime-oracle'
|
||||
import { observeBrowserLoadingSurface } from './browser-loading-surface-oracle'
|
||||
|
||||
test('browser host follows the theme before content and preserves the webpage canvas', async ({
|
||||
orcaPage,
|
||||
electronApp
|
||||
}, testInfo) => {
|
||||
await waitForSessionReady(orcaPage)
|
||||
await ensureTerminalVisible(orcaPage)
|
||||
await waitForActiveWorktree(orcaPage)
|
||||
const observations = await observeBrowserLoadingSurface(
|
||||
orcaPage,
|
||||
(name) => testInfo.outputPath(name),
|
||||
async (id) => {
|
||||
await crashGuestRenderer(electronApp, id)
|
||||
}
|
||||
)
|
||||
expect(observations.filter((entry) => !entry.pass)).toEqual([])
|
||||
})
|
||||
@@ -32,12 +32,6 @@ import {
|
||||
} from './helpers/browser-split-page-server'
|
||||
|
||||
const copyChord = `${shortcutModifier}+c`
|
||||
// Default annotate chord: Cmd+Shift+C on macOS, Alt+Shift+N on Linux and Windows.
|
||||
const annotateGuestChord: { keyCode: string; modifiers: GuestModifier[] } =
|
||||
process.platform === 'darwin'
|
||||
? { keyCode: 'C', modifiers: [guestModifier, 'shift'] }
|
||||
: { keyCode: 'N', modifiers: ['alt', 'shift'] }
|
||||
|
||||
function grabBanner(page: Page, browserTabId: string) {
|
||||
return browserOverlay(page, browserTabId).getByText(/Click or hover an element|Grab failed/)
|
||||
}
|
||||
@@ -75,12 +69,6 @@ async function hoverGuestGrabTarget(page: Page, browserTabId: string, x: number,
|
||||
.toBe(true)
|
||||
}
|
||||
|
||||
function annotateBanner(page: Page, browserTabId: string) {
|
||||
return browserOverlay(page, browserTabId).getByText(
|
||||
'Click an element to add feedback for the agent.'
|
||||
)
|
||||
}
|
||||
|
||||
function reloadButton(page: Page, browserTabId: string) {
|
||||
return browserOverlay(page, browserTabId).getByRole('button', { name: 'Reload', exact: true })
|
||||
}
|
||||
@@ -210,49 +198,6 @@ test.describe('browser split grab shortcut', () => {
|
||||
await server.close()
|
||||
})
|
||||
|
||||
test('copy chord from one split toolbar arms grab only in that split', async ({ orcaPage }) => {
|
||||
const fixture = await createBrowserSplit(orcaPage, {
|
||||
first: server.pageUrl('a', 1),
|
||||
second: server.pageUrl('b', 1, 'localhost')
|
||||
})
|
||||
await waitForGuestUrl(orcaPage, fixture.firstBrowserTabId, server.pageUrl('a', 1))
|
||||
await waitForGuestUrl(orcaPage, fixture.secondBrowserTabId, server.pageUrl('b', 1, 'localhost'))
|
||||
|
||||
// Why: the active terminal refits a frame after the splits mount and can take focus back.
|
||||
const firstReloadButton = reloadButton(orcaPage, fixture.firstBrowserTabId)
|
||||
await expect(async () => {
|
||||
await firstReloadButton.focus()
|
||||
await waitForFocusedGroup(orcaPage, fixture.firstBrowserGroupId)
|
||||
await expect(firstReloadButton).toBeFocused({ timeout: 1_000 })
|
||||
}).toPass({ timeout: 30_000 })
|
||||
await orcaPage.keyboard.press(copyChord)
|
||||
|
||||
await expect(grabBanner(orcaPage, fixture.firstBrowserTabId)).toBeVisible()
|
||||
await expect(grabBanner(orcaPage, fixture.secondBrowserTabId)).toBeHidden()
|
||||
})
|
||||
|
||||
test('annotate chord typed in one guest arms annotate only in that split', async ({
|
||||
orcaPage
|
||||
}) => {
|
||||
const fixture = await createBrowserSplit(orcaPage, {
|
||||
first: server.pageUrl('a', 1),
|
||||
second: server.pageUrl('b', 1, 'localhost')
|
||||
})
|
||||
await waitForGuestUrl(orcaPage, fixture.firstBrowserTabId, server.pageUrl('a', 1))
|
||||
await waitForGuestUrl(orcaPage, fixture.secondBrowserTabId, server.pageUrl('b', 1, 'localhost'))
|
||||
|
||||
await pressKeyInBrowserGuest(
|
||||
orcaPage,
|
||||
fixture.firstBrowserTabId,
|
||||
fixture.firstBrowserPageId,
|
||||
annotateGuestChord.keyCode,
|
||||
annotateGuestChord.modifiers
|
||||
)
|
||||
|
||||
await expect(annotateBanner(orcaPage, fixture.firstBrowserTabId)).toBeVisible()
|
||||
await expect(annotateBanner(orcaPage, fixture.secondBrowserTabId)).toBeHidden()
|
||||
})
|
||||
|
||||
test('escape typed in the page exits grab, the copy toast and find', async ({ orcaPage }) => {
|
||||
const fixture = await createBrowserSplit(orcaPage, {
|
||||
first: server.pageUrl('a', 1),
|
||||
|
||||
@@ -5,7 +5,6 @@ import { expect, test } from './helpers/orca-app'
|
||||
import { focusActiveTerminalInput } from './helpers/terminal'
|
||||
import { ensureTerminalVisible, waitForActiveWorktree, waitForSessionReady } from './helpers/store'
|
||||
import {
|
||||
browserAddressBar,
|
||||
browserOverlay,
|
||||
createBrowserSplit,
|
||||
createTerminalBrowserSplit,
|
||||
@@ -160,15 +159,6 @@ test.describe('browser split navigation shortcuts', () => {
|
||||
expect(await secondZoom()).toBe(initialSecondZoom)
|
||||
})
|
||||
|
||||
test('Focus Address Bar typed in one guest focuses only that split', async ({ orcaPage }) => {
|
||||
const fixture = await createBrowserSplitWithHistory(orcaPage, server)
|
||||
|
||||
await pressInGuest(orcaPage, fixture, { guestKeyCode: 'L', guestModifiers: [guestModifier] })
|
||||
|
||||
await expect(browserAddressBar(orcaPage, fixture.firstBrowserTabId)).toBeFocused()
|
||||
await expect(browserAddressBar(orcaPage, fixture.secondBrowserTabId)).not.toBeFocused()
|
||||
})
|
||||
|
||||
test('Back and Reload pressed from one split toolbar act on only that split', async ({
|
||||
orcaPage
|
||||
}) => {
|
||||
|
||||
@@ -1,172 +0,0 @@
|
||||
import { expect, test } from './helpers/orca-app'
|
||||
import type { Page } from '@stablyai/playwright-test'
|
||||
import { focusActiveTerminalInput } from './helpers/terminal'
|
||||
import { ensureTerminalVisible, waitForActiveWorktree, waitForSessionReady } from './helpers/store'
|
||||
import {
|
||||
browserAddressBar,
|
||||
createBrowserSplit,
|
||||
createTerminalBrowserSplit,
|
||||
focusBrowserAddressBar,
|
||||
focusBrowserGroup,
|
||||
guestModifier,
|
||||
pressKeyInBrowserGuest,
|
||||
shortcutModifier as modifier,
|
||||
waitForFocusedGroup
|
||||
} from './helpers/browser-split-fixture'
|
||||
|
||||
function browserFindInput(page: Page) {
|
||||
return page.getByPlaceholder('Find in page...')
|
||||
}
|
||||
|
||||
function browserFindCloseButton(page: Page) {
|
||||
return browserFindInput(page).locator('xpath=..').getByTitle('Close')
|
||||
}
|
||||
|
||||
function browserSplitFindInput(page: Page, browserTabId: string) {
|
||||
return page
|
||||
.locator(`[data-browser-overlay-tab-id="${browserTabId}"]`)
|
||||
.getByPlaceholder('Find in page...')
|
||||
}
|
||||
|
||||
async function pressFindInBrowserGuest(
|
||||
page: Page,
|
||||
browserTabId: string,
|
||||
browserPageId: string
|
||||
): Promise<void> {
|
||||
await pressKeyInBrowserGuest(page, browserTabId, browserPageId, 'F', [guestModifier])
|
||||
}
|
||||
|
||||
function terminalFindInput(page: Page) {
|
||||
return page.locator('[data-terminal-search-root] input:visible')
|
||||
}
|
||||
|
||||
test.describe('browser split shortcuts', () => {
|
||||
test.beforeEach(async ({ orcaPage }) => {
|
||||
await waitForSessionReady(orcaPage)
|
||||
await waitForActiveWorktree(orcaPage)
|
||||
await ensureTerminalVisible(orcaPage)
|
||||
})
|
||||
|
||||
test('routes repeated Find shortcuts to the focused terminal or browser split', async ({
|
||||
orcaPage
|
||||
}) => {
|
||||
const fixture = await createTerminalBrowserSplit(orcaPage)
|
||||
|
||||
await orcaPage.evaluate(({ terminalGroupId }) => {
|
||||
const state = window.__store?.getState()
|
||||
const worktreeId = state?.activeWorktreeId
|
||||
if (state && worktreeId) {
|
||||
state.focusGroup(worktreeId, terminalGroupId)
|
||||
}
|
||||
}, fixture)
|
||||
await focusActiveTerminalInput(orcaPage)
|
||||
await waitForFocusedGroup(orcaPage, fixture.terminalGroupId)
|
||||
await orcaPage.keyboard.press(`${modifier}+f`)
|
||||
await expect(terminalFindInput(orcaPage)).toBeFocused()
|
||||
await expect(browserFindInput(orcaPage)).toBeHidden()
|
||||
await orcaPage.keyboard.press('Escape')
|
||||
|
||||
await focusBrowserGroup(orcaPage, fixture.browserGroupId)
|
||||
await focusBrowserAddressBar(orcaPage, fixture.browserTabId)
|
||||
await orcaPage.keyboard.press(`${modifier}+f`)
|
||||
await expect(browserFindInput(orcaPage)).toBeFocused()
|
||||
await expect(terminalFindInput(orcaPage)).toBeHidden()
|
||||
await browserFindCloseButton(orcaPage).click()
|
||||
await expect(browserFindInput(orcaPage)).toBeHidden()
|
||||
|
||||
await orcaPage.keyboard.press(`${modifier}+f`)
|
||||
await expect(browserFindInput(orcaPage)).toBeFocused()
|
||||
await browserFindCloseButton(orcaPage).click()
|
||||
|
||||
await orcaPage.evaluate(({ browserTabId }) => {
|
||||
window.__store?.getState().closeBrowserTab(browserTabId)
|
||||
}, fixture)
|
||||
await expect(
|
||||
orcaPage.locator(`[data-browser-overlay-tab-id="${fixture.browserTabId}"]`)
|
||||
).toHaveCount(0)
|
||||
|
||||
await focusActiveTerminalInput(orcaPage)
|
||||
await orcaPage.keyboard.press(`${modifier}+f`)
|
||||
await expect(terminalFindInput(orcaPage)).toBeFocused()
|
||||
await expect(browserFindInput(orcaPage)).toBeHidden()
|
||||
})
|
||||
|
||||
test('opens Find only in the browser split whose guest owns the shortcut', async ({
|
||||
orcaPage
|
||||
}) => {
|
||||
const fixture = await createBrowserSplit(orcaPage)
|
||||
|
||||
await pressFindInBrowserGuest(orcaPage, fixture.firstBrowserTabId, fixture.firstBrowserPageId)
|
||||
|
||||
await expect(browserSplitFindInput(orcaPage, fixture.firstBrowserTabId)).toBeVisible()
|
||||
await expect(browserSplitFindInput(orcaPage, fixture.secondBrowserTabId)).toBeHidden()
|
||||
await expect
|
||||
.poll(() =>
|
||||
orcaPage.evaluate(
|
||||
({ browserPageId, browserTabId }) =>
|
||||
window.__store
|
||||
?.getState()
|
||||
.browserPagesByWorkspace[browserTabId]?.find((page) => page.id === browserPageId)
|
||||
?.loadError?.code ?? null,
|
||||
{
|
||||
browserPageId: fixture.firstBrowserPageId,
|
||||
browserTabId: fixture.firstBrowserTabId
|
||||
}
|
||||
)
|
||||
)
|
||||
.toBeNull()
|
||||
})
|
||||
|
||||
test('keeps browser Find available when split focus state is temporarily missing', async ({
|
||||
orcaPage
|
||||
}) => {
|
||||
const fixture = await createTerminalBrowserSplit(orcaPage)
|
||||
await focusBrowserGroup(orcaPage, fixture.browserGroupId)
|
||||
const addressBar = browserAddressBar(orcaPage, fixture.browserTabId)
|
||||
await focusBrowserAddressBar(orcaPage, fixture.browserTabId)
|
||||
|
||||
await orcaPage.evaluate(() => {
|
||||
const store = window.__store
|
||||
const worktreeId = store?.getState().activeWorktreeId
|
||||
if (!store || !worktreeId) {
|
||||
throw new Error('Active worktree unavailable')
|
||||
}
|
||||
store.setState((state) => {
|
||||
const activeGroupIdByWorktree = { ...state.activeGroupIdByWorktree }
|
||||
delete activeGroupIdByWorktree[worktreeId]
|
||||
return { activeGroupIdByWorktree }
|
||||
})
|
||||
})
|
||||
await expect(addressBar).toBeFocused()
|
||||
|
||||
await orcaPage.keyboard.press(`${modifier}+f`)
|
||||
await expect(browserFindInput(orcaPage)).toBeFocused()
|
||||
await expect(terminalFindInput(orcaPage)).toBeHidden()
|
||||
})
|
||||
|
||||
test('keeps browser Find available when the focused split ID is stale', async ({ orcaPage }) => {
|
||||
const fixture = await createTerminalBrowserSplit(orcaPage)
|
||||
await focusBrowserGroup(orcaPage, fixture.browserGroupId)
|
||||
const addressBar = browserAddressBar(orcaPage, fixture.browserTabId)
|
||||
await focusBrowserAddressBar(orcaPage, fixture.browserTabId)
|
||||
|
||||
await orcaPage.evaluate(() => {
|
||||
const store = window.__store
|
||||
const worktreeId = store?.getState().activeWorktreeId
|
||||
if (!store || !worktreeId) {
|
||||
throw new Error('Active worktree unavailable')
|
||||
}
|
||||
store.setState((state) => ({
|
||||
activeGroupIdByWorktree: {
|
||||
...state.activeGroupIdByWorktree,
|
||||
[worktreeId]: 'removed-group'
|
||||
}
|
||||
}))
|
||||
})
|
||||
await expect(addressBar).toBeFocused()
|
||||
|
||||
await orcaPage.keyboard.press(`${modifier}+f`)
|
||||
await expect(browserFindInput(orcaPage)).toBeFocused()
|
||||
await expect(terminalFindInput(orcaPage)).toBeHidden()
|
||||
})
|
||||
})
|
||||
@@ -1,452 +0,0 @@
|
||||
import { execFileSync } from 'node:child_process'
|
||||
import { mkdirSync, mkdtempSync, realpathSync, rmSync, writeFileSync } from 'node:fs'
|
||||
import os from 'node:os'
|
||||
import path from 'node:path'
|
||||
import type { Page } from '@stablyai/playwright-test'
|
||||
import { test, expect } from './helpers/orca-app'
|
||||
import { waitForSessionReady } from './helpers/store'
|
||||
|
||||
type CombinedDiffScrollRepo = {
|
||||
repoPath: string
|
||||
}
|
||||
|
||||
type ViewportAnchor = {
|
||||
key: string
|
||||
index: number
|
||||
top: number
|
||||
bottom: number
|
||||
scrollTop: number
|
||||
scrollHeight: number
|
||||
clientHeight: number
|
||||
}
|
||||
|
||||
type ScrollProbeSample = {
|
||||
scrollHeight: number
|
||||
scrollTop: number
|
||||
}
|
||||
|
||||
const FILE_COUNT = 18
|
||||
const ADDED_LINES_PER_FILE = 180
|
||||
|
||||
function runGit(repoPath: string, args: string[]): void {
|
||||
execFileSync('git', args, { cwd: repoPath, stdio: 'pipe' })
|
||||
}
|
||||
|
||||
function buildBaseFile(fileIndex: number): string {
|
||||
return `${Array.from(
|
||||
{ length: 20 },
|
||||
(_, lineIndex) => `export const base_${fileIndex}_${lineIndex} = ${lineIndex}`
|
||||
).join('\n')}\n`
|
||||
}
|
||||
|
||||
function buildModifiedFile(fileIndex: number): string {
|
||||
const added = Array.from(
|
||||
{ length: ADDED_LINES_PER_FILE },
|
||||
(_, lineIndex) => `export const changed_${fileIndex}_${lineIndex} = ${fileIndex + lineIndex}`
|
||||
).join('\n')
|
||||
return `${buildBaseFile(fileIndex)}${added}\n`
|
||||
}
|
||||
|
||||
function createCombinedDiffScrollRepo(): CombinedDiffScrollRepo {
|
||||
const repoPath = realpathSync(mkdtempSync(path.join(os.tmpdir(), 'orca-combined-diff-scroll-')))
|
||||
runGit(repoPath, ['init'])
|
||||
runGit(repoPath, ['config', 'user.email', 'e2e@test.local'])
|
||||
runGit(repoPath, ['config', 'user.name', 'E2E Test'])
|
||||
|
||||
const srcDir = path.join(repoPath, 'src')
|
||||
mkdirSync(srcDir, { recursive: true })
|
||||
for (let index = 0; index < FILE_COUNT; index += 1) {
|
||||
writeFileSync(
|
||||
path.join(srcDir, `scroll-${String(index).padStart(2, '0')}.ts`),
|
||||
buildBaseFile(index)
|
||||
)
|
||||
}
|
||||
runGit(repoPath, ['add', '-A'])
|
||||
runGit(repoPath, ['commit', '-m', 'Initial combined diff scroll fixture'])
|
||||
|
||||
for (let index = 0; index < FILE_COUNT; index += 1) {
|
||||
writeFileSync(
|
||||
path.join(srcDir, `scroll-${String(index).padStart(2, '0')}.ts`),
|
||||
buildModifiedFile(index)
|
||||
)
|
||||
}
|
||||
|
||||
return { repoPath }
|
||||
}
|
||||
|
||||
async function addAndActivateRepo(page: Page, repoPath: string): Promise<string> {
|
||||
const repoId = await page.evaluate(async (pathToRepo: string) => {
|
||||
const store = window.__store
|
||||
if (!store) {
|
||||
throw new Error('window.__store is not available')
|
||||
}
|
||||
|
||||
const addedRepo = await store.getState().addRepoPath(pathToRepo)
|
||||
if (!addedRepo) {
|
||||
throw new Error(`isolated combined-diff repo not found: ${pathToRepo}`)
|
||||
}
|
||||
return addedRepo.id
|
||||
}, repoPath)
|
||||
|
||||
await expect
|
||||
.poll(
|
||||
() =>
|
||||
page.evaluate(async (targetRepoId: string) => {
|
||||
const store = window.__store
|
||||
if (!store) {
|
||||
return 0
|
||||
}
|
||||
await store.getState().fetchWorktrees(targetRepoId)
|
||||
return store.getState().worktreesByRepo[targetRepoId]?.length ?? 0
|
||||
}, repoId),
|
||||
{
|
||||
timeout: 30_000,
|
||||
message: 'isolated combined-diff worktree did not load'
|
||||
}
|
||||
)
|
||||
.toBeGreaterThan(0)
|
||||
|
||||
return page.evaluate(
|
||||
({ targetRepoId, pathToRepo }) => {
|
||||
const store = window.__store
|
||||
if (!store) {
|
||||
throw new Error('window.__store is not available')
|
||||
}
|
||||
|
||||
const state = store.getState()
|
||||
const worktrees = state.worktreesByRepo[targetRepoId] ?? []
|
||||
const worktree = worktrees.find((entry) => entry.path === pathToRepo) ?? worktrees[0]
|
||||
if (!worktree) {
|
||||
throw new Error(`isolated combined-diff worktree not found: ${pathToRepo}`)
|
||||
}
|
||||
state.setActiveRepo(targetRepoId)
|
||||
state.setActiveWorktree(worktree.id)
|
||||
return worktree.id
|
||||
},
|
||||
{ targetRepoId: repoId, pathToRepo: repoPath }
|
||||
)
|
||||
}
|
||||
|
||||
async function openCombinedDiff(page: Page, worktreeId: string, repoPath: string): Promise<string> {
|
||||
return page.evaluate(
|
||||
async ({ wId, pathToRepo }) => {
|
||||
const store = window.__store
|
||||
if (!store) {
|
||||
throw new Error('window.__store is not available')
|
||||
}
|
||||
const state = store.getState()
|
||||
const status = await window.api.git.status({ worktreePath: pathToRepo })
|
||||
const entries = status.entries.filter((entry) => entry.area === 'unstaged')
|
||||
if (entries.length < 2) {
|
||||
throw new Error(`expected multiple unstaged entries, received ${entries.length}`)
|
||||
}
|
||||
state.setGitStatus(wId, status)
|
||||
state.openAllDiffs(wId, pathToRepo, undefined, 'unstaged', entries)
|
||||
|
||||
const nextState = store.getState()
|
||||
const activeGroupId = nextState.activeGroupIdByWorktree[wId]
|
||||
const activeFileId = nextState.activeFileId
|
||||
const tab = (nextState.unifiedTabsByWorktree[wId] ?? []).find(
|
||||
(candidate) => candidate.groupId === activeGroupId && candidate.entityId === activeFileId
|
||||
)
|
||||
if (!tab) {
|
||||
throw new Error('combined diff tab was not created')
|
||||
}
|
||||
return tab.id
|
||||
},
|
||||
{ wId: worktreeId, pathToRepo: repoPath }
|
||||
)
|
||||
}
|
||||
|
||||
async function scrollCombinedDiffDeep(page: Page): Promise<void> {
|
||||
await page.evaluate(() => {
|
||||
const container = document.querySelector<HTMLElement>('.combined-diff-scroll-container')
|
||||
if (!container) {
|
||||
throw new Error('combined diff scroll container not found')
|
||||
}
|
||||
const target = Math.min(7_000, Math.max(0, container.scrollHeight - container.clientHeight - 1))
|
||||
container.dispatchEvent(
|
||||
new WheelEvent('wheel', { bubbles: true, cancelable: true, deltaY: target })
|
||||
)
|
||||
container.scrollTop = target
|
||||
container.dispatchEvent(new Event('scroll', { bubbles: true }))
|
||||
})
|
||||
}
|
||||
|
||||
async function readViewportAnchor(page: Page): Promise<ViewportAnchor | null> {
|
||||
return page.evaluate(() => {
|
||||
const container = document.querySelector<HTMLElement>('.combined-diff-scroll-container')
|
||||
if (!container) {
|
||||
return null
|
||||
}
|
||||
const containerRect = container.getBoundingClientRect()
|
||||
const visibleRows = Array.from(
|
||||
container.querySelectorAll<HTMLElement>('[data-combined-diff-section-row]')
|
||||
)
|
||||
.map((row) => {
|
||||
const rect = row.getBoundingClientRect()
|
||||
const key = row.dataset.combinedDiffSectionKey
|
||||
const index = Number(row.dataset.index)
|
||||
if (
|
||||
!key ||
|
||||
!Number.isFinite(index) ||
|
||||
rect.height <= 0 ||
|
||||
rect.bottom <= containerRect.top ||
|
||||
rect.top >= containerRect.bottom
|
||||
) {
|
||||
return null
|
||||
}
|
||||
return {
|
||||
key,
|
||||
index,
|
||||
top: rect.top - containerRect.top,
|
||||
bottom: rect.bottom - containerRect.top,
|
||||
scrollTop: container.scrollTop,
|
||||
scrollHeight: container.scrollHeight,
|
||||
clientHeight: container.clientHeight
|
||||
}
|
||||
})
|
||||
.filter((row): row is ViewportAnchor => row !== null)
|
||||
.sort((a, b) => a.top - b.top)
|
||||
return visibleRows[0] ?? null
|
||||
})
|
||||
}
|
||||
|
||||
async function waitForStableViewportAnchor(page: Page): Promise<ViewportAnchor> {
|
||||
const startedAt = Date.now()
|
||||
let lastSignature = ''
|
||||
let stableSamples = 0
|
||||
let lastAnchor: ViewportAnchor | null = null
|
||||
|
||||
while (Date.now() - startedAt < 15_000) {
|
||||
const anchor = await readViewportAnchor(page)
|
||||
if (anchor) {
|
||||
const signature = `${anchor.key}:${Math.round(anchor.top)}:${Math.round(
|
||||
anchor.bottom
|
||||
)}:${Math.round(anchor.scrollHeight)}`
|
||||
if (signature === lastSignature) {
|
||||
stableSamples += 1
|
||||
if (stableSamples >= 2) {
|
||||
return anchor
|
||||
}
|
||||
} else {
|
||||
lastSignature = signature
|
||||
stableSamples = 0
|
||||
}
|
||||
lastAnchor = anchor
|
||||
}
|
||||
await page.waitForTimeout(100)
|
||||
}
|
||||
|
||||
throw new Error(`combined diff viewport anchor did not settle: ${JSON.stringify(lastAnchor)}`)
|
||||
}
|
||||
|
||||
// Poll through Monaco’s layout passes until the restored anchor converges; return the last anchor on timeout so misses still fail.
|
||||
async function waitForRestoredViewportAnchor(
|
||||
page: Page,
|
||||
target: ViewportAnchor,
|
||||
tolerancePx = 80
|
||||
): Promise<ViewportAnchor> {
|
||||
// Start the restoration window after the up-to-15s anchor settle, or slow setup can consume it.
|
||||
let lastAnchor = await waitForStableViewportAnchor(page)
|
||||
const startedAt = Date.now()
|
||||
while (Date.now() - startedAt < 10_000) {
|
||||
if (lastAnchor.key === target.key && Math.abs(lastAnchor.top - target.top) < tolerancePx) {
|
||||
return lastAnchor
|
||||
}
|
||||
await page.waitForTimeout(100)
|
||||
const anchor = await readViewportAnchor(page)
|
||||
if (anchor) {
|
||||
lastAnchor = anchor
|
||||
}
|
||||
}
|
||||
return lastAnchor
|
||||
}
|
||||
|
||||
async function startCombinedDiffScrollProbe(page: Page): Promise<void> {
|
||||
await page.evaluate(() => {
|
||||
type CombinedDiffScrollProbe = {
|
||||
samples: ScrollProbeSample[]
|
||||
stop: () => void
|
||||
}
|
||||
const targetWindow = window as typeof window & {
|
||||
__combinedDiffScrollProbe?: CombinedDiffScrollProbe
|
||||
}
|
||||
targetWindow.__combinedDiffScrollProbe?.stop()
|
||||
|
||||
const container = document.querySelector<HTMLElement>('.combined-diff-scroll-container')
|
||||
if (!container) {
|
||||
throw new Error('combined diff scroll container not found')
|
||||
}
|
||||
|
||||
const samples: ScrollProbeSample[] = []
|
||||
const record = (): void => {
|
||||
samples.push({
|
||||
scrollHeight: container.scrollHeight,
|
||||
scrollTop: container.scrollTop
|
||||
})
|
||||
}
|
||||
container.addEventListener('scroll', record, { passive: true })
|
||||
record()
|
||||
targetWindow.__combinedDiffScrollProbe = {
|
||||
samples,
|
||||
stop: () => container.removeEventListener('scroll', record)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async function stopCombinedDiffScrollProbe(page: Page): Promise<ScrollProbeSample[]> {
|
||||
return page.evaluate(() => {
|
||||
type CombinedDiffScrollProbe = {
|
||||
samples: ScrollProbeSample[]
|
||||
stop: () => void
|
||||
}
|
||||
const targetWindow = window as typeof window & {
|
||||
__combinedDiffScrollProbe?: CombinedDiffScrollProbe
|
||||
}
|
||||
const probe = targetWindow.__combinedDiffScrollProbe
|
||||
if (!probe) {
|
||||
return []
|
||||
}
|
||||
probe.stop()
|
||||
delete targetWindow.__combinedDiffScrollProbe
|
||||
return probe.samples
|
||||
})
|
||||
}
|
||||
|
||||
async function wheelCombinedDiffDown(page: Page): Promise<ScrollProbeSample[]> {
|
||||
const container = page.locator('.combined-diff-scroll-container')
|
||||
const box = await container.boundingBox()
|
||||
if (!box) {
|
||||
throw new Error('combined diff scroll container bounds not found')
|
||||
}
|
||||
|
||||
await page.mouse.move(box.x + box.width / 2, box.y + box.height / 2)
|
||||
await startCombinedDiffScrollProbe(page)
|
||||
for (let index = 0; index < 12; index += 1) {
|
||||
await page.mouse.wheel(0, 520)
|
||||
await page.waitForTimeout(35)
|
||||
}
|
||||
await page.waitForTimeout(400)
|
||||
return stopCombinedDiffScrollProbe(page)
|
||||
}
|
||||
|
||||
function getLargestBackwardScrollJump(samples: readonly ScrollProbeSample[]): number {
|
||||
let largestBackwardJump = 0
|
||||
for (let index = 1; index < samples.length; index += 1) {
|
||||
// Count backward jumps only at stable content height; lazy Monaco measurement legitimately corrects scrollTop.
|
||||
if (samples[index].scrollHeight !== samples[index - 1].scrollHeight) {
|
||||
continue
|
||||
}
|
||||
largestBackwardJump = Math.max(
|
||||
largestBackwardJump,
|
||||
samples[index - 1].scrollTop - samples[index].scrollTop
|
||||
)
|
||||
}
|
||||
return largestBackwardJump
|
||||
}
|
||||
|
||||
async function clickVisibleDiffLine(page: Page): Promise<void> {
|
||||
// After tab switch, wait for asynchronously painted Monaco lines rather than treating a transient empty view as failure.
|
||||
let linePoint: { x: number; y: number } | null | undefined
|
||||
await expect
|
||||
.poll(
|
||||
async () => {
|
||||
linePoint = await page.evaluate(() => {
|
||||
const container = document.querySelector<HTMLElement>('.combined-diff-scroll-container')
|
||||
if (!container) {
|
||||
return null
|
||||
}
|
||||
const containerRect = container.getBoundingClientRect()
|
||||
for (const line of container.querySelectorAll<HTMLElement>(
|
||||
'.monaco-diff-editor .view-line'
|
||||
)) {
|
||||
const rect = line.getBoundingClientRect()
|
||||
const left = Math.max(rect.left, containerRect.left)
|
||||
const right = Math.min(rect.right, containerRect.right)
|
||||
const top = Math.max(rect.top, containerRect.top)
|
||||
const bottom = Math.min(rect.bottom, containerRect.bottom)
|
||||
if (left >= right || top >= bottom) {
|
||||
continue
|
||||
}
|
||||
const point = {
|
||||
x: left + Math.min(12, (right - left) / 2),
|
||||
y: (top + bottom) / 2
|
||||
}
|
||||
// Sticky headers can cover a line whose rectangle intersects the viewport.
|
||||
if (line.contains(document.elementFromPoint(point.x, point.y))) {
|
||||
return point
|
||||
}
|
||||
}
|
||||
return null
|
||||
})
|
||||
return linePoint !== null
|
||||
},
|
||||
{ timeout: 10_000, message: 'visible combined diff line not found' }
|
||||
)
|
||||
.toBe(true)
|
||||
|
||||
if (!linePoint) {
|
||||
throw new Error('visible combined diff line not found')
|
||||
}
|
||||
await page.mouse.click(linePoint.x, linePoint.y)
|
||||
}
|
||||
|
||||
test.describe('Combined diff scroll restore', () => {
|
||||
test.describe.configure({ mode: 'serial' })
|
||||
test.use({ seedTestRepo: false })
|
||||
|
||||
test('keeps the visible section anchored after switching tabs', async ({ orcaPage }) => {
|
||||
await waitForSessionReady(orcaPage)
|
||||
const fixture = createCombinedDiffScrollRepo()
|
||||
|
||||
try {
|
||||
const worktreeId = await addAndActivateRepo(orcaPage, fixture.repoPath)
|
||||
const diffTabId = await openCombinedDiff(orcaPage, worktreeId, fixture.repoPath)
|
||||
await expect(orcaPage.locator('.combined-diff-scroll-container')).toBeVisible()
|
||||
await expect(orcaPage.getByText(`${FILE_COUNT} changed files`)).toBeVisible()
|
||||
|
||||
await scrollCombinedDiffDeep(orcaPage)
|
||||
await waitForStableViewportAnchor(orcaPage)
|
||||
const activeScrollSamples = await wheelCombinedDiffDown(orcaPage)
|
||||
expect(activeScrollSamples.length).toBeGreaterThan(2)
|
||||
expect(
|
||||
getLargestBackwardScrollJump(activeScrollSamples),
|
||||
`backward scroll jump at a stable content height; samples=${JSON.stringify(
|
||||
activeScrollSamples
|
||||
)}`
|
||||
).toBeLessThan(120)
|
||||
|
||||
const beforeSwitch = await waitForStableViewportAnchor(orcaPage)
|
||||
expect(beforeSwitch.index).toBeGreaterThan(0)
|
||||
|
||||
await orcaPage.evaluate((wId) => {
|
||||
const store = window.__store
|
||||
if (!store) {
|
||||
throw new Error('window.__store is not available')
|
||||
}
|
||||
store.getState().createTab(wId)
|
||||
}, worktreeId)
|
||||
await expect(orcaPage.locator('.combined-diff-scroll-container')).toHaveCount(0)
|
||||
|
||||
await orcaPage.locator(`[data-tab-id="${diffTabId}"]`).click({ force: true })
|
||||
await expect(orcaPage.locator('.combined-diff-scroll-container')).toBeVisible()
|
||||
const afterSwitch = await waitForRestoredViewportAnchor(orcaPage, beforeSwitch)
|
||||
|
||||
expect(afterSwitch.key).toBe(beforeSwitch.key)
|
||||
expect(Math.abs(afterSwitch.top - beforeSwitch.top)).toBeLessThan(80)
|
||||
|
||||
await clickVisibleDiffLine(orcaPage)
|
||||
const afterLineClick = await waitForStableViewportAnchor(orcaPage)
|
||||
|
||||
// Cap viewport movement rather than exact anchor keys; subpixel focus scroll can change the top key without a meaningful jump.
|
||||
expect(Math.abs(afterLineClick.top - afterSwitch.top)).toBeLessThan(80)
|
||||
// Cap scrollTop drift only at stable content height; Chromium anchoring compensates when Monaco replaces estimated heights.
|
||||
if (afterLineClick.scrollHeight === afterSwitch.scrollHeight) {
|
||||
expect(Math.abs(afterLineClick.scrollTop - afterSwitch.scrollTop)).toBeLessThan(40)
|
||||
}
|
||||
} finally {
|
||||
rmSync(fixture.repoPath, { recursive: true, force: true })
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -26,22 +26,6 @@ export const NESTED_TOGGLE_MARKDOWN = [
|
||||
''
|
||||
].join('\n')
|
||||
|
||||
// Unsupported nested attributes require byte-preserving passthrough for the whole block.
|
||||
export const UNSUPPORTED_NESTED_TOGGLE_MARKDOWN = [
|
||||
'<details class="orca-details" open>',
|
||||
'<summary>outer</summary>',
|
||||
'',
|
||||
'<details id="not-a-toggle">',
|
||||
'<summary>inner</summary>',
|
||||
'',
|
||||
'Body',
|
||||
'',
|
||||
'</details>',
|
||||
'',
|
||||
'</details>',
|
||||
''
|
||||
].join('\n')
|
||||
|
||||
export type RenderedToggles = {
|
||||
toggleCount: number
|
||||
nestedToggleCount: number
|
||||
@@ -83,12 +67,6 @@ export async function expectEditableNestedToggles(page: Page): Promise<void> {
|
||||
})
|
||||
}
|
||||
|
||||
export async function expectPassthroughFallback(page: Page): Promise<void> {
|
||||
const passthrough = page.locator('.rich-markdown-editor [data-raw-markdown-html-block]')
|
||||
await expect(passthrough).toHaveCount(1, { timeout: TOGGLE_RENDER_TIMEOUT_MS })
|
||||
await expect(passthrough).toContainText('<details id="not-a-toggle">')
|
||||
}
|
||||
|
||||
async function selectionIsInsideNestedToggleBody(page: Page): Promise<boolean> {
|
||||
return page.evaluate(() => {
|
||||
const editor = document.querySelector('.rich-markdown-editor') as
|
||||
|
||||
@@ -1,226 +0,0 @@
|
||||
import type { Page } from '@stablyai/playwright-test'
|
||||
import { expect } from '@stablyai/playwright-test'
|
||||
import {
|
||||
createMarkdownFixture as createMarkdownFixtureIn,
|
||||
type ActiveWorktreeContext
|
||||
} from './markdown-editor-fixture'
|
||||
|
||||
const DRAFT_SERIALIZATION_TIMEOUT_MS = 10_000
|
||||
const FIXTURE_DIRECTORY = '.orca-e2e-markdown-ordered-list'
|
||||
|
||||
export {
|
||||
cleanupMarkdownFixture,
|
||||
getActiveWorktreeContext,
|
||||
openMarkdownFixture,
|
||||
waitForRichMarkdownEditor,
|
||||
type ActiveWorktreeContext
|
||||
} from './markdown-editor-fixture'
|
||||
|
||||
export type MatrixRow = {
|
||||
name: string
|
||||
slug: string
|
||||
sentinel: string
|
||||
initialMarkdown: string
|
||||
run: (page: Page, sentinel: string) => Promise<void>
|
||||
}
|
||||
|
||||
export async function createMarkdownFixture(
|
||||
context: ActiveWorktreeContext,
|
||||
slug: string,
|
||||
workerIndex: number,
|
||||
initialMarkdown: string
|
||||
): Promise<string> {
|
||||
return createMarkdownFixtureIn(context, FIXTURE_DIRECTORY, slug, workerIndex, initialMarkdown)
|
||||
}
|
||||
|
||||
export async function expectSentinelParagraphOutsideOrderedList(
|
||||
page: Page,
|
||||
sentinel: string
|
||||
): Promise<void> {
|
||||
await expect
|
||||
.poll(
|
||||
async () =>
|
||||
page.evaluate((sentinel) => {
|
||||
const editor = document.querySelector('.rich-markdown-editor')
|
||||
if (!editor) {
|
||||
return false
|
||||
}
|
||||
|
||||
return Array.from(editor.querySelectorAll('p')).some((paragraph) => {
|
||||
return (
|
||||
paragraph.textContent?.trim() === sentinel &&
|
||||
!paragraph.closest('ol') &&
|
||||
!paragraph.closest('li')
|
||||
)
|
||||
})
|
||||
}, sentinel),
|
||||
{
|
||||
timeout: 5_000,
|
||||
message: `${sentinel} did not render in a paragraph outside an ordered list`
|
||||
}
|
||||
)
|
||||
.toBe(true)
|
||||
}
|
||||
|
||||
export async function expectSerializedDraftOutsideOrderedList(
|
||||
page: Page,
|
||||
draftKey: string,
|
||||
sentinel: string
|
||||
): Promise<void> {
|
||||
await expect
|
||||
.poll(
|
||||
async () =>
|
||||
page.evaluate(
|
||||
({ draftKey, sentinel }) => {
|
||||
const draft = window.__store?.getState().editorDrafts[draftKey]
|
||||
if (typeof draft !== 'string') {
|
||||
return false
|
||||
}
|
||||
|
||||
const sentinelLines = draft
|
||||
.split(/\r\n|\r|\n/)
|
||||
.filter((line) => line.includes(sentinel))
|
||||
return {
|
||||
hasPlainLine: sentinelLines.some((line) => line.trim() === sentinel),
|
||||
appearsOnNumberedLine: sentinelLines.some((line) => /^\s*\d+\.\s+/.test(line))
|
||||
}
|
||||
},
|
||||
{ draftKey, sentinel }
|
||||
),
|
||||
{
|
||||
timeout: DRAFT_SERIALIZATION_TIMEOUT_MS,
|
||||
message: `${sentinel} did not serialize as a plain paragraph in editorDrafts[${draftKey}]`
|
||||
}
|
||||
)
|
||||
.toEqual({ hasPlainLine: true, appearsOnNumberedLine: false })
|
||||
}
|
||||
|
||||
export async function assertLoadedThirdEmptyOrderedListItem(page: Page): Promise<void> {
|
||||
await expect
|
||||
.poll(
|
||||
async () =>
|
||||
page.evaluate(() => {
|
||||
const editor = document.querySelector('.rich-markdown-editor')
|
||||
const listItems = Array.from(editor?.querySelectorAll('ol > li') ?? [])
|
||||
const thirdItem = listItems[2]
|
||||
const paragraph = thirdItem?.querySelector('p') ?? null
|
||||
const rect = paragraph?.getBoundingClientRect()
|
||||
return Boolean(
|
||||
thirdItem &&
|
||||
paragraph &&
|
||||
thirdItem.textContent?.trim() === '' &&
|
||||
rect &&
|
||||
rect.width > 0 &&
|
||||
rect.height > 0
|
||||
)
|
||||
}),
|
||||
{
|
||||
timeout: 5_000,
|
||||
message: 'Loaded markdown did not expose an editable empty third ordered-list item'
|
||||
}
|
||||
)
|
||||
.toBe(true)
|
||||
}
|
||||
|
||||
async function selectionIsInsideThirdEmptyOrderedListItem(page: Page): Promise<boolean> {
|
||||
return page.evaluate(() => {
|
||||
const editor = document.querySelector('.rich-markdown-editor')
|
||||
const thirdItem = editor?.querySelectorAll('ol > li')[2] as
|
||||
| (Element & {
|
||||
pmViewDesc?: {
|
||||
node?: { type?: { name?: string } }
|
||||
}
|
||||
})
|
||||
| undefined
|
||||
const paragraph = thirdItem?.querySelector('p') as
|
||||
| (Element & {
|
||||
pmViewDesc?: {
|
||||
posAtStart?: number
|
||||
posAtEnd?: number
|
||||
}
|
||||
})
|
||||
| null
|
||||
const tiptapEditor = (
|
||||
editor as
|
||||
| (Element & {
|
||||
editor?: {
|
||||
state?: {
|
||||
selection?: {
|
||||
empty?: boolean
|
||||
from?: number
|
||||
to?: number
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
| null
|
||||
)?.editor
|
||||
const selection = tiptapEditor?.state?.selection
|
||||
const selectionFrom = selection?.from
|
||||
const selectionTo = selection?.to
|
||||
const paragraphStart = paragraph?.pmViewDesc?.posAtStart
|
||||
const paragraphEnd = paragraph?.pmViewDesc?.posAtEnd
|
||||
|
||||
if (
|
||||
!thirdItem ||
|
||||
!paragraph ||
|
||||
!selection?.empty ||
|
||||
typeof selectionFrom !== 'number' ||
|
||||
typeof selectionTo !== 'number' ||
|
||||
typeof paragraphStart !== 'number' ||
|
||||
typeof paragraphEnd !== 'number'
|
||||
) {
|
||||
return false
|
||||
}
|
||||
|
||||
return (
|
||||
thirdItem.pmViewDesc?.node?.type?.name === 'listItem' &&
|
||||
thirdItem.textContent?.trim() === '' &&
|
||||
selectionFrom >= paragraphStart &&
|
||||
selectionTo <= paragraphEnd
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
export async function placeCaretInLoadedThirdEmptyItem(page: Page): Promise<void> {
|
||||
const thirdItemParagraph = page.locator('.rich-markdown-editor ol > li').nth(2).locator('p')
|
||||
await thirdItemParagraph.click()
|
||||
|
||||
if (!(await selectionIsInsideThirdEmptyOrderedListItem(page))) {
|
||||
await page.evaluate(() => {
|
||||
const editor = document.querySelector('.rich-markdown-editor') as
|
||||
| (Element & {
|
||||
editor?: {
|
||||
commands?: {
|
||||
focus?: () => boolean
|
||||
setTextSelection?: (position: number) => boolean
|
||||
}
|
||||
}
|
||||
})
|
||||
| null
|
||||
const thirdItem = editor?.querySelectorAll('ol > li')[2]
|
||||
const paragraph = thirdItem?.querySelector('p') as
|
||||
| (Element & {
|
||||
pmViewDesc?: {
|
||||
posAtStart?: number
|
||||
}
|
||||
})
|
||||
| null
|
||||
const selectionPosition = paragraph?.pmViewDesc?.posAtStart
|
||||
if (!editor?.editor?.commands || typeof selectionPosition !== 'number') {
|
||||
throw new Error('Cannot place caret in the loaded empty ordered-list item')
|
||||
}
|
||||
|
||||
// Set the caret explicitly: a headless click may precede ProseMirror’s selection commit.
|
||||
editor.editor.commands.setTextSelection?.(selectionPosition)
|
||||
editor.editor.commands.focus?.()
|
||||
})
|
||||
}
|
||||
|
||||
await expect
|
||||
.poll(async () => selectionIsInsideThirdEmptyOrderedListItem(page), {
|
||||
timeout: 3_000,
|
||||
message: 'Selection was not inside the loaded empty third ordered-list item'
|
||||
})
|
||||
.toBe(true)
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
import { test, expect } from './helpers/orca-app'
|
||||
import type { Editor } from '@tiptap/core'
|
||||
import {
|
||||
cleanupMarkdownFixture,
|
||||
createMarkdownFixture,
|
||||
getActiveWorktreeContext,
|
||||
openMarkdownFixture,
|
||||
waitForRichMarkdownEditor
|
||||
} from './helpers/markdown-editor-fixture'
|
||||
import { waitForSessionReady, waitForActiveWorktree } from './helpers/store'
|
||||
|
||||
type PageRichMarkdownLinkEditorElement = HTMLElement & {
|
||||
editor?: Editor
|
||||
}
|
||||
|
||||
test('collapses a selection beside a document link without rewriting the link', async ({
|
||||
orcaPage,
|
||||
registerPostElectronShutdownCleanup
|
||||
}, testInfo) => {
|
||||
await waitForSessionReady(orcaPage)
|
||||
await waitForActiveWorktree(orcaPage)
|
||||
const context = await getActiveWorktreeContext(orcaPage)
|
||||
const filePath = await createMarkdownFixture(
|
||||
context,
|
||||
'.orca-e2e-markdown-links',
|
||||
'selection',
|
||||
testInfo.workerIndex,
|
||||
'[[Guide]]after\n\nSelecting text beside a document link should keep the link intact.'
|
||||
)
|
||||
registerPostElectronShutdownCleanup(() => cleanupMarkdownFixture(filePath))
|
||||
await openMarkdownFixture(orcaPage, context, filePath)
|
||||
const editor = await waitForRichMarkdownEditor(orcaPage)
|
||||
await expect(editor.locator('[data-doc-link-target="Guide"]')).toHaveCount(1)
|
||||
await orcaPage.evaluate(() => {
|
||||
const editorElement =
|
||||
document.querySelector<PageRichMarkdownLinkEditorElement>('.rich-markdown-editor')
|
||||
const instance = editorElement?.editor
|
||||
if (!editorElement || !instance) {
|
||||
throw new Error('Editor unavailable')
|
||||
}
|
||||
editorElement.focus()
|
||||
if (!instance.commands.setTextSelection({ from: 2, to: 7 })) {
|
||||
throw new Error('Selection unavailable')
|
||||
}
|
||||
})
|
||||
await expect.poll(() => orcaPage.evaluate(() => window.getSelection()?.toString())).toBe('after')
|
||||
await expect
|
||||
.poll(() =>
|
||||
orcaPage.evaluate(() => {
|
||||
const selection =
|
||||
document.querySelector<PageRichMarkdownLinkEditorElement>('.rich-markdown-editor')?.editor
|
||||
?.state.selection
|
||||
return selection ? { from: selection.from, to: selection.to, empty: selection.empty } : null
|
||||
})
|
||||
)
|
||||
.toEqual({ from: 2, to: 7, empty: false })
|
||||
await expect(editor).toBeFocused()
|
||||
await orcaPage.keyboard.press('ArrowLeft')
|
||||
await expect(editor.locator('[data-doc-link-target="Guide"]')).toHaveCount(1)
|
||||
await expect(editor.locator('p').first()).toHaveText('Guideafter')
|
||||
await expect.poll(() => orcaPage.evaluate(() => window.getSelection()?.toString())).toBe('')
|
||||
await orcaPage.screenshot({ path: testInfo.outputPath('link-after-collapse.png') })
|
||||
})
|
||||
@@ -1,24 +0,0 @@
|
||||
import { expect, test } from './helpers/orca-app'
|
||||
import { openFileExplorer } from './helpers/file-explorer'
|
||||
import { pressShortcut } from './helpers/shortcuts'
|
||||
import { waitForActiveWorktree, waitForSessionReady } from './helpers/store'
|
||||
|
||||
test('Explorer-opened Markdown accepts the find shortcut without a document click', async ({
|
||||
orcaPage
|
||||
}) => {
|
||||
await waitForSessionReady(orcaPage)
|
||||
await waitForActiveWorktree(orcaPage)
|
||||
await openFileExplorer(orcaPage)
|
||||
|
||||
const readmeRow = orcaPage.locator('[data-file-explorer-row]').filter({ hasText: 'README.md' })
|
||||
await expect(readmeRow).toBeVisible({ timeout: 10_000 })
|
||||
await readmeRow.focus()
|
||||
await readmeRow.click()
|
||||
|
||||
await expect(orcaPage.locator('.rich-markdown-editor')).toBeVisible({ timeout: 25_000 })
|
||||
await pressShortcut(orcaPage, 'f')
|
||||
|
||||
await expect(
|
||||
orcaPage.getByRole('textbox', { name: 'Find in rich markdown editor' })
|
||||
).toBeVisible()
|
||||
})
|
||||
@@ -11,12 +11,10 @@ import {
|
||||
import {
|
||||
expectEditableNestedToggles,
|
||||
expectFileKeepsNesting,
|
||||
expectPassthroughFallback,
|
||||
expectSentinelInsideNestedToggle,
|
||||
NESTED_TOGGLE_FIXTURE_DIRECTORY,
|
||||
NESTED_TOGGLE_MARKDOWN,
|
||||
placeCaretInNestedToggleBody,
|
||||
UNSUPPORTED_NESTED_TOGGLE_MARKDOWN
|
||||
placeCaretInNestedToggleBody
|
||||
} from './helpers/markdown-nested-toggle'
|
||||
import { waitForActiveWorktree, waitForSessionReady } from './helpers/store'
|
||||
|
||||
@@ -65,27 +63,4 @@ test.describe('Markdown nested toggle regression', () => {
|
||||
await cleanupMarkdownFixture(filePath)
|
||||
}
|
||||
})
|
||||
|
||||
test('a nested toggle that cannot be represented stays raw passthrough', async ({
|
||||
orcaPage
|
||||
}, testInfo) => {
|
||||
const context = await getActiveWorktreeContext(orcaPage)
|
||||
let filePath: string | null = null
|
||||
|
||||
try {
|
||||
filePath = await createMarkdownFixture(
|
||||
context,
|
||||
NESTED_TOGGLE_FIXTURE_DIRECTORY,
|
||||
'nested-toggle-unsupported',
|
||||
testInfo.workerIndex,
|
||||
UNSUPPORTED_NESTED_TOGGLE_MARKDOWN
|
||||
)
|
||||
await openMarkdownFixture(orcaPage, context, filePath)
|
||||
await waitForRichMarkdownEditor(orcaPage)
|
||||
|
||||
await expectPassthroughFallback(orcaPage)
|
||||
} finally {
|
||||
await cleanupMarkdownFixture(filePath)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,92 +0,0 @@
|
||||
import { test, expect } from './helpers/orca-app'
|
||||
import { waitForActiveWorktree, waitForSessionReady } from './helpers/store'
|
||||
import {
|
||||
assertLoadedThirdEmptyOrderedListItem,
|
||||
cleanupMarkdownFixture,
|
||||
createMarkdownFixture,
|
||||
expectSentinelParagraphOutsideOrderedList,
|
||||
expectSerializedDraftOutsideOrderedList,
|
||||
getActiveWorktreeContext,
|
||||
openMarkdownFixture,
|
||||
placeCaretInLoadedThirdEmptyItem,
|
||||
type MatrixRow,
|
||||
waitForRichMarkdownEditor
|
||||
} from './helpers/markdown-ordered-list-exit'
|
||||
|
||||
const rows: MatrixRow[] = [
|
||||
{
|
||||
name: 'typed ordered-list marker exits to a paragraph',
|
||||
slug: 'typed-marker',
|
||||
sentinel: 'afterTypedMarkerExit',
|
||||
initialMarkdown: '',
|
||||
run: async (page, sentinel) => {
|
||||
const editor = await waitForRichMarkdownEditor(page)
|
||||
await editor.click()
|
||||
await page.keyboard.type('1. first')
|
||||
await page.keyboard.press('Enter')
|
||||
await page.keyboard.press('Enter')
|
||||
await page.keyboard.type(sentinel)
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'toolbar-created ordered list exits to a paragraph',
|
||||
slug: 'toolbar-list',
|
||||
sentinel: 'afterToolbarListExit',
|
||||
initialMarkdown: '',
|
||||
run: async (page, sentinel) => {
|
||||
const editor = await waitForRichMarkdownEditor(page)
|
||||
await editor.click()
|
||||
await page.getByRole('button', { name: 'Numbered list' }).click()
|
||||
await expect(editor.locator('ol')).toHaveCount(1, { timeout: 5_000 })
|
||||
await page.keyboard.type('first')
|
||||
await page.keyboard.press('Enter')
|
||||
await page.keyboard.press('Enter')
|
||||
await page.keyboard.type(sentinel)
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'loaded existing-note ordered-list continuation exits to a paragraph',
|
||||
slug: 'loaded-continuation',
|
||||
sentinel: 'afterLoadedContinuationExit',
|
||||
initialMarkdown: '1. Item 1\n2. Item 2\n3. \n\n## Next section\n',
|
||||
run: async (page, sentinel) => {
|
||||
await waitForRichMarkdownEditor(page)
|
||||
await assertLoadedThirdEmptyOrderedListItem(page)
|
||||
await placeCaretInLoadedThirdEmptyItem(page)
|
||||
await page.keyboard.press('Enter')
|
||||
await page.keyboard.type(sentinel)
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
test.describe('Markdown ordered-list exit regression', () => {
|
||||
test.beforeEach(async ({ orcaPage }) => {
|
||||
await waitForSessionReady(orcaPage)
|
||||
await waitForActiveWorktree(orcaPage)
|
||||
})
|
||||
|
||||
for (const row of rows) {
|
||||
test(row.name, async ({ orcaPage }, testInfo) => {
|
||||
const context = await getActiveWorktreeContext(orcaPage)
|
||||
let filePath: string | null = null
|
||||
|
||||
try {
|
||||
filePath = await createMarkdownFixture(
|
||||
context,
|
||||
row.slug,
|
||||
testInfo.workerIndex,
|
||||
row.initialMarkdown
|
||||
)
|
||||
const activeFile = await openMarkdownFixture(orcaPage, context, filePath)
|
||||
const draftKey = activeFile.filePath
|
||||
|
||||
await row.run(orcaPage, row.sentinel)
|
||||
|
||||
await expectSentinelParagraphOutsideOrderedList(orcaPage, row.sentinel)
|
||||
await expectSerializedDraftOutsideOrderedList(orcaPage, draftKey, row.sentinel)
|
||||
} finally {
|
||||
await cleanupMarkdownFixture(filePath)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
@@ -1,101 +0,0 @@
|
||||
import { writeFile, rm } from 'node:fs/promises'
|
||||
import path from 'node:path'
|
||||
import { test, expect } from './helpers/orca-app'
|
||||
import { waitForActiveWorktree, waitForSessionReady } from './helpers/store'
|
||||
import {
|
||||
cleanupMarkdownFixture,
|
||||
createMarkdownFixture,
|
||||
getActiveWorktreeContext,
|
||||
openMarkdownFixture,
|
||||
waitForRichMarkdownEditor
|
||||
} from './helpers/markdown-editor-fixture'
|
||||
|
||||
test('restores the Markdown viewport when an image gains height after a tab switch', async ({
|
||||
orcaPage,
|
||||
registerPostElectronShutdownCleanup
|
||||
}, testInfo) => {
|
||||
await waitForSessionReady(orcaPage)
|
||||
await waitForActiveWorktree(orcaPage)
|
||||
const context = await getActiveWorktreeContext(orcaPage)
|
||||
const directory = '.orca-e2e-markdown-scroll'
|
||||
let filePath: string | null = null
|
||||
let otherPath: string | null = null
|
||||
let imagePath: string | null = null
|
||||
|
||||
registerPostElectronShutdownCleanup(async () => {
|
||||
await cleanupMarkdownFixture(filePath)
|
||||
await cleanupMarkdownFixture(otherPath)
|
||||
if (imagePath) {
|
||||
await rm(imagePath, { force: true })
|
||||
}
|
||||
})
|
||||
|
||||
const sections = Array.from(
|
||||
{ length: 100 },
|
||||
(_, index) => `## Section ${index}\n\nParagraph ${index}. Scroll restoration testing text.`
|
||||
).join('\n\n')
|
||||
filePath = await createMarkdownFixture(
|
||||
context,
|
||||
directory,
|
||||
'image-scroll',
|
||||
testInfo.workerIndex,
|
||||
`# Image scroll\n\n\n\n${sections}`
|
||||
)
|
||||
imagePath = path.join(path.dirname(filePath), 'tall.svg')
|
||||
await writeFile(
|
||||
imagePath,
|
||||
'<svg xmlns="http://www.w3.org/2000/svg" width="400" height="1500"><rect width="400" height="1500" fill="gray"/></svg>'
|
||||
)
|
||||
otherPath = await createMarkdownFixture(
|
||||
context,
|
||||
directory,
|
||||
'other-tab',
|
||||
testInfo.workerIndex,
|
||||
'# Other tab'
|
||||
)
|
||||
await openMarkdownFixture(orcaPage, context, otherPath)
|
||||
await waitForRichMarkdownEditor(orcaPage)
|
||||
await openMarkdownFixture(orcaPage, context, filePath)
|
||||
const editor = await waitForRichMarkdownEditor(orcaPage)
|
||||
const image = editor.getByRole('img', { name: 'Scroll restoration image' })
|
||||
await expect
|
||||
.poll(() =>
|
||||
image.evaluate((element) => (element instanceof HTMLImageElement ? element.naturalHeight : 0))
|
||||
)
|
||||
.toBe(1500)
|
||||
const viewport = orcaPage.locator('.rich-markdown-editor-shell .overflow-auto')
|
||||
await viewport.evaluate((element) => {
|
||||
element.scrollTop = 4000
|
||||
})
|
||||
const heading = editor.getByRole('heading', { name: 'Section 45', exact: true })
|
||||
const originalTop = await heading.evaluate((element) => element.getBoundingClientRect().top)
|
||||
|
||||
await orcaPage
|
||||
.locator('[data-tab-id]')
|
||||
.filter({ hasText: path.basename(otherPath) })
|
||||
.click()
|
||||
// Model image dimensions arriving after restoration, independent of the host's decode speed.
|
||||
const pendingImage = await orcaPage.addStyleTag({
|
||||
content: '.rich-markdown-editor img[alt="Scroll restoration image"] { height: 1px !important; }'
|
||||
})
|
||||
await orcaPage
|
||||
.locator('[data-tab-id]')
|
||||
.filter({ hasText: path.basename(filePath) })
|
||||
.click()
|
||||
await expect.poll(() => viewport.evaluate((element) => element.scrollTop)).toBe(4000)
|
||||
await pendingImage.evaluate((element) => element.parentNode?.removeChild(element))
|
||||
await expect
|
||||
.poll(() => image.evaluate((element) => element.getBoundingClientRect().height))
|
||||
.toBeGreaterThan(500)
|
||||
// Let Chromium apply its scroll-anchor adjustment before checking the final viewport.
|
||||
await viewport.evaluate(
|
||||
() =>
|
||||
new Promise<void>((resolve) => {
|
||||
requestAnimationFrame(() => requestAnimationFrame(() => resolve()))
|
||||
})
|
||||
)
|
||||
await expect.poll(() => viewport.evaluate((element) => element.scrollTop)).toBe(4000)
|
||||
await expect
|
||||
.poll(() => heading.evaluate((element) => element.getBoundingClientRect().top))
|
||||
.toBeCloseTo(originalTop, 1)
|
||||
})
|
||||
@@ -1,146 +0,0 @@
|
||||
import path from 'node:path'
|
||||
import { test, expect } from './helpers/orca-app'
|
||||
import { waitForActiveWorktree, waitForSessionReady } from './helpers/store'
|
||||
import {
|
||||
cleanupMarkdownFixture,
|
||||
createMarkdownFixture,
|
||||
getActiveWorktreeContext,
|
||||
openMarkdownFixture,
|
||||
waitForRichMarkdownEditor
|
||||
} from './helpers/markdown-ordered-list-exit'
|
||||
|
||||
// Start with an empty middle row so Backspace can delete it without document-wide Meta+A.
|
||||
const TABLE_MARKDOWN = `| Name | Value |
|
||||
| --- | --- |
|
||||
| keep | a |
|
||||
| | |
|
||||
| stay | c |
|
||||
`
|
||||
|
||||
const SCRATCH_DIR =
|
||||
process.env.ORCA_TABLE_ROW_BACKSPACE_SCREENSHOT_DIR ??
|
||||
path.join(process.cwd(), 'test-results', 'table-row-backspace')
|
||||
|
||||
async function selectionCellText(page: {
|
||||
evaluate: (fn: () => string | null) => Promise<string | null>
|
||||
}): Promise<string | null> {
|
||||
return page.evaluate(() => {
|
||||
const selection = window.getSelection()
|
||||
if (!selection || selection.rangeCount === 0) {
|
||||
return null
|
||||
}
|
||||
const node = selection.anchorNode
|
||||
if (!node) {
|
||||
return null
|
||||
}
|
||||
const element = node.nodeType === Node.ELEMENT_NODE ? (node as Element) : node.parentElement
|
||||
const cell = element?.closest('td, th')
|
||||
return cell?.textContent?.trim() ?? null
|
||||
})
|
||||
}
|
||||
|
||||
async function tableRowCount(page: {
|
||||
evaluate: (fn: () => number) => Promise<number>
|
||||
}): Promise<number> {
|
||||
return page.evaluate(() => {
|
||||
const editorRoot = document.querySelector('.rich-markdown-editor')
|
||||
if (!editorRoot) {
|
||||
return -1
|
||||
}
|
||||
return editorRoot.querySelectorAll('tr').length
|
||||
})
|
||||
}
|
||||
|
||||
test.describe('Markdown table keyboard', () => {
|
||||
test.beforeEach(async ({ orcaPage }) => {
|
||||
await waitForSessionReady(orcaPage)
|
||||
await waitForActiveWorktree(orcaPage)
|
||||
})
|
||||
|
||||
test('Tab/Shift-Tab move between cells and empty-row Backspace deletes the row', async ({
|
||||
orcaPage
|
||||
}, testInfo) => {
|
||||
const context = await getActiveWorktreeContext(orcaPage)
|
||||
let filePath: string | null = null
|
||||
|
||||
try {
|
||||
filePath = await createMarkdownFixture(
|
||||
context,
|
||||
'table-row-backspace',
|
||||
testInfo.workerIndex,
|
||||
TABLE_MARKDOWN
|
||||
)
|
||||
await openMarkdownFixture(orcaPage, context, filePath)
|
||||
const editor = await waitForRichMarkdownEditor(orcaPage)
|
||||
|
||||
await expect(editor.locator('tr')).toHaveCount(4, { timeout: 10_000 })
|
||||
await expect(editor.getByText('keep')).toBeVisible()
|
||||
await expect(editor.getByText('stay')).toBeVisible()
|
||||
|
||||
await editor.getByText('keep').click()
|
||||
|
||||
await orcaPage.keyboard.press('Tab')
|
||||
await expect
|
||||
.poll(async () => selectionCellText(orcaPage), {
|
||||
timeout: 5_000,
|
||||
message: 'Tab should move from keep → a'
|
||||
})
|
||||
.toBe('a')
|
||||
|
||||
await orcaPage.keyboard.press('Tab')
|
||||
await expect
|
||||
.poll(async () => selectionCellText(orcaPage), {
|
||||
timeout: 5_000,
|
||||
message: 'Tab should wrap into the empty body row'
|
||||
})
|
||||
.toBe('')
|
||||
|
||||
await orcaPage.keyboard.press('Shift+Tab')
|
||||
await expect
|
||||
.poll(async () => selectionCellText(orcaPage), {
|
||||
timeout: 5_000,
|
||||
message: 'Shift-Tab should return to previous cell (a)'
|
||||
})
|
||||
.toBe('a')
|
||||
|
||||
await orcaPage.keyboard.press('Enter')
|
||||
await expect
|
||||
.poll(async () => selectionCellText(orcaPage), {
|
||||
timeout: 5_000,
|
||||
message: 'Enter should move down into the empty body row'
|
||||
})
|
||||
.toBe('')
|
||||
|
||||
await editor.screenshot({
|
||||
path: path.join(SCRATCH_DIR, 'electron-table-row-backspace-before.png')
|
||||
})
|
||||
await orcaPage.screenshot({
|
||||
path: path.join(SCRATCH_DIR, 'electron-table-row-backspace-before-window.png')
|
||||
})
|
||||
|
||||
await orcaPage.keyboard.press('Backspace')
|
||||
|
||||
await expect
|
||||
.poll(async () => tableRowCount(orcaPage), {
|
||||
timeout: 5_000,
|
||||
message: 'Empty body row should be removed after Backspace'
|
||||
})
|
||||
.toBe(3)
|
||||
|
||||
await expect(editor.getByText('keep')).toBeVisible()
|
||||
await expect(editor.getByText('stay')).toBeVisible()
|
||||
|
||||
await editor.screenshot({
|
||||
path: path.join(SCRATCH_DIR, 'electron-table-row-backspace-after.png')
|
||||
})
|
||||
await orcaPage.screenshot({
|
||||
path: path.join(SCRATCH_DIR, 'electron-table-row-backspace-after-window.png')
|
||||
})
|
||||
|
||||
// Hold a beat so the video recording captures the final table state.
|
||||
await orcaPage.waitForTimeout(800)
|
||||
} finally {
|
||||
await cleanupMarkdownFixture(filePath)
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -1,87 +0,0 @@
|
||||
/**
|
||||
* Invariant: the catalog 2 components draw with Orca's own controls and round-trip through the
|
||||
* hidden guest: tabs switch, a Table pages and sorts, a Tree loads children lazily, and an Image
|
||||
* shows a plugin file Orca read itself (an object URL, never a network or file URL).
|
||||
*/
|
||||
|
||||
import { cp, mkdtemp, rm } from 'node:fs/promises'
|
||||
import { tmpdir } from 'node:os'
|
||||
import { join } from 'node:path'
|
||||
import { expect, test } from './helpers/orca-app'
|
||||
import { disablePluginSystem, enableDevPlugins } from './helpers/plugin-smoke'
|
||||
import { ISOLATED_FRAMES_E2E } from './helpers/plugin-frame-guest'
|
||||
|
||||
test.use(ISOLATED_FRAMES_E2E)
|
||||
|
||||
const TITLE = 'Components Gallery'
|
||||
|
||||
test('the components gallery draws forms, data and content components', async ({ orcaPage }) => {
|
||||
const tempRoot = await mkdtemp(join(tmpdir(), 'orca-components-gallery-'))
|
||||
const pluginRoot = join(tempRoot, 'components-gallery')
|
||||
try {
|
||||
await cp(join(process.cwd(), 'examples', 'plugins', 'components-gallery'), pluginRoot, {
|
||||
recursive: true
|
||||
})
|
||||
await enableDevPlugins(orcaPage, [pluginRoot])
|
||||
await orcaPage.evaluate(async () => {
|
||||
const store = window.__store?.getState()
|
||||
if (store && !store.rightSidebarOpen) {
|
||||
store.toggleRightSidebar()
|
||||
}
|
||||
await window.api.plugins.refresh()
|
||||
})
|
||||
const panelButton = orcaPage.getByRole('button', { name: TITLE })
|
||||
await expect(panelButton).toBeVisible({ timeout: 15_000 })
|
||||
await panelButton.click()
|
||||
|
||||
const sections = orcaPage.getByRole('tablist', { name: 'Gallery sections' })
|
||||
await expect(sections).toBeVisible({ timeout: 15_000 })
|
||||
// Forms: the Field's error clears once the title is filled in.
|
||||
await expect(orcaPage.getByRole('alert')).toHaveText('Give the task a title')
|
||||
await orcaPage.getByRole('textbox', { name: 'Title' }).fill('Write docs')
|
||||
await expect(orcaPage.getByRole('alert')).toHaveCount(0)
|
||||
await orcaPage.getByRole('radio', { name: 'High' }).click()
|
||||
await expect(orcaPage.getByRole('radio', { name: 'High' })).toBeChecked()
|
||||
|
||||
// Data: the Table draws rows from the guest and asks for more as it scrolls.
|
||||
await orcaPage.getByRole('tab', { name: 'Data' }).click()
|
||||
const table = orcaPage.getByRole('grid', { name: 'Files' })
|
||||
await expect(table).toHaveAttribute('aria-rowcount', '51')
|
||||
await expect(table.getByText('doc-002.md')).toBeVisible()
|
||||
await table.getByText('doc-002.md').click()
|
||||
await expect(orcaPage.getByText('1 selected')).toBeVisible()
|
||||
await table
|
||||
.getByRole('row')
|
||||
.nth(1)
|
||||
.evaluate((row) => {
|
||||
row.parentElement?.parentElement?.scrollTo({ top: 10_000 })
|
||||
})
|
||||
await expect(table).toHaveAttribute('aria-rowcount', '101')
|
||||
await table.getByRole('button', { name: 'Bytes' }).click()
|
||||
await expect(table.getByRole('columnheader', { name: 'Bytes' })).toHaveAttribute(
|
||||
'aria-sort',
|
||||
'ascending'
|
||||
)
|
||||
|
||||
const tree = orcaPage.getByRole('tree', { name: 'Folders' })
|
||||
const src = tree.getByRole('treeitem', { name: 'src' })
|
||||
await src.focus()
|
||||
await orcaPage.keyboard.press('ArrowRight')
|
||||
await expect(tree.getByRole('treeitem', { name: 'main.ts' })).toBeVisible()
|
||||
await expect(src).toHaveAttribute('aria-expanded', 'true')
|
||||
|
||||
// Content: Markdown, code and a plugin image Orca read through main.
|
||||
await orcaPage.getByRole('tab', { name: 'Content' }).click()
|
||||
await expect(orcaPage.getByRole('toolbar', { name: 'Gallery actions' })).toBeVisible()
|
||||
await expect(orcaPage.getByRole('heading', { name: 'Components Gallery' })).toBeVisible()
|
||||
await expect(orcaPage.getByText('greet.ts')).toBeVisible()
|
||||
const logo = orcaPage.getByRole('img', { name: 'Gallery logo' })
|
||||
await expect(logo).toHaveAttribute('src', /^blob:/)
|
||||
await expect
|
||||
.poll(() => logo.evaluate((image: HTMLImageElement) => image.naturalWidth))
|
||||
.toBeGreaterThan(0)
|
||||
} finally {
|
||||
await disablePluginSystem(orcaPage).catch(() => undefined)
|
||||
await rm(tempRoot, { recursive: true, force: true })
|
||||
}
|
||||
})
|
||||
@@ -1,267 +0,0 @@
|
||||
import type { Page, TestInfo } from '@stablyai/playwright-test'
|
||||
import { expect, test } from './helpers/orca-app'
|
||||
import { evaluatePolled } from './helpers/page-evaluate-polled'
|
||||
import { addRepoWithWorkspaces, writeWorkspaceMeta } from './helpers/repo-with-workspaces'
|
||||
import { waitForSessionReady } from './helpers/store'
|
||||
|
||||
const TARGET_INDEX = 24
|
||||
const SYNTHETIC_COUNT = 40
|
||||
const VISUAL_PROOF_PAUSE_MS = 1_200
|
||||
const POST_REMOVAL_SAMPLE_FRAMES = 20
|
||||
// A real delete runs git, so wait by time: a frame count shrinks on high-refresh displays.
|
||||
const MAX_REMOVAL_WAIT_MS = 20_000
|
||||
|
||||
test.use({ seedTestRepo: false })
|
||||
|
||||
type RowRemovalFrame = {
|
||||
animationCount: number
|
||||
belowTop: number | null
|
||||
scrollTop: number
|
||||
targetExists: boolean
|
||||
}
|
||||
|
||||
declare global {
|
||||
// oxlint-disable-next-line typescript-eslint/consistent-type-definitions -- declaration merging requires interface
|
||||
interface Window {
|
||||
// Frame sampling started in the page and awaited once the removal animation settles.
|
||||
__activeDeleteRowRemovalFrames?: Promise<RowRemovalFrame[]>
|
||||
}
|
||||
}
|
||||
|
||||
async function pauseForVisualProof(page: Page): Promise<void> {
|
||||
if (process.env.ORCA_E2E_RECORD_VIDEO === '1') {
|
||||
await page.waitForTimeout(VISUAL_PROOF_PAUSE_MS)
|
||||
}
|
||||
}
|
||||
|
||||
async function seedActiveDeletionRows(
|
||||
page: Page,
|
||||
testInfo: TestInfo
|
||||
): Promise<{
|
||||
belowId: string
|
||||
successorId: string
|
||||
targetId: string
|
||||
}> {
|
||||
const repo = await addRepoWithWorkspaces(page, testInfo, SYNTHETIC_COUNT)
|
||||
await writeWorkspaceMeta(
|
||||
page,
|
||||
repo.ids.map((worktreeId, index) => ({
|
||||
worktreeId,
|
||||
updates: {
|
||||
displayName: `Active delete row ${String(index).padStart(2, '0')}`,
|
||||
sortOrder: SYNTHETIC_COUNT - index,
|
||||
manualOrder: SYNTHETIC_COUNT - index
|
||||
}
|
||||
}))
|
||||
)
|
||||
const targetId = repo.ids[TARGET_INDEX]!
|
||||
const belowId = repo.ids[TARGET_INDEX + 1]!
|
||||
const successorId = repo.ids[0]!
|
||||
await evaluatePolled(
|
||||
page,
|
||||
async ({ repoId, targetId, successorId }) => {
|
||||
const store = window.__store!
|
||||
const state = store.getState()
|
||||
await state.updateSettings({ skipDeleteWorktreeConfirm: true })
|
||||
// A setup script keeps the setup guide from opening over the sidebar.
|
||||
await state.updateRepo(repoId, {
|
||||
hookSettings: { mode: 'auto', scripts: { setup: 'true', archive: '' } }
|
||||
})
|
||||
store.setState({
|
||||
activeRepoId: repoId,
|
||||
activeView: 'terminal',
|
||||
activeWorktreeId: targetId,
|
||||
activeWorkspaceKey: `worktree:${targetId}`,
|
||||
filterRepoIds: [],
|
||||
groupBy: 'none',
|
||||
hideDefaultBranchWorkspace: false,
|
||||
lastVisitedAtByWorktreeId: { [successorId]: Date.now() + 1_000 },
|
||||
pendingRevealSidebarRow: null,
|
||||
pendingRevealWorktree: null,
|
||||
setupScriptPromptDismissedRepoIds: [`generation-v1:local\0${repoId}`],
|
||||
showActiveOnly: false,
|
||||
showSleepingWorkspaces: true,
|
||||
sidebarOpen: true,
|
||||
sortBy: 'manual'
|
||||
})
|
||||
},
|
||||
{ repoId: repo.repoId, targetId, successorId }
|
||||
)
|
||||
return { belowId, successorId, targetId }
|
||||
}
|
||||
|
||||
async function prepareScrolledActiveRow(page: Page, targetId: string): Promise<void> {
|
||||
const target = page.locator(
|
||||
`[data-worktree-sidebar] [data-worktree-id=${JSON.stringify(targetId)}]`
|
||||
)
|
||||
const scroller = page.locator('[data-worktree-sidebar]')
|
||||
await expect
|
||||
.poll(async () => {
|
||||
if ((await target.count()) > 0) {
|
||||
return true
|
||||
}
|
||||
await scroller.evaluate((element) => {
|
||||
element.scrollTop = Math.min(
|
||||
element.scrollHeight,
|
||||
element.scrollTop + Math.max(100, element.clientHeight / 2)
|
||||
)
|
||||
element.dispatchEvent(new Event('scroll', { bubbles: true }))
|
||||
})
|
||||
return false
|
||||
})
|
||||
.toBe(true)
|
||||
await target.evaluate((element) => element.scrollIntoView({ block: 'center' }))
|
||||
await target.evaluate((element) => {
|
||||
const scroller = element.closest<HTMLElement>('[data-worktree-sidebar]')
|
||||
if (!scroller) {
|
||||
throw new Error('Worktree sidebar is unavailable')
|
||||
}
|
||||
const targetOffset = element.getBoundingClientRect().top - scroller.getBoundingClientRect().top
|
||||
scroller.scrollTop += targetOffset - 160
|
||||
scroller.dispatchEvent(new Event('scroll', { bubbles: true }))
|
||||
})
|
||||
await expect(target).toBeVisible()
|
||||
await expect(target).toHaveAttribute('aria-current', 'page')
|
||||
}
|
||||
|
||||
async function startRowRemovalSampling(
|
||||
page: Page,
|
||||
targetId: string,
|
||||
belowId: string
|
||||
): Promise<void> {
|
||||
await page.evaluate(
|
||||
({ belowId, maxRemovalWaitMs, postRemovalSampleFrames, targetId }) => {
|
||||
const sample = async (): Promise<RowRemovalFrame[]> => {
|
||||
const readFrame = (): RowRemovalFrame => {
|
||||
const scroller = document.querySelector<HTMLElement>('[data-worktree-sidebar]')
|
||||
const below = document.querySelector<HTMLElement>(
|
||||
`[data-worktree-sidebar] [data-worktree-id=${JSON.stringify(belowId)}]`
|
||||
)
|
||||
const targetExists = Boolean(
|
||||
document.querySelector(
|
||||
`[data-worktree-sidebar] [data-worktree-id=${JSON.stringify(targetId)}]`
|
||||
)
|
||||
)
|
||||
return {
|
||||
animationCount:
|
||||
below?.closest('[data-worktree-virtual-row]')?.firstElementChild?.getAnimations()
|
||||
.length ?? 0,
|
||||
belowTop: below?.getBoundingClientRect().top ?? null,
|
||||
scrollTop: scroller?.scrollTop ?? 0,
|
||||
targetExists
|
||||
}
|
||||
}
|
||||
const frames: RowRemovalFrame[] = [readFrame()]
|
||||
let framesAfterRemoval = 0
|
||||
const deadline = performance.now() + maxRemovalWaitMs
|
||||
while (performance.now() < deadline) {
|
||||
await new Promise<void>((resolve) => requestAnimationFrame(() => resolve()))
|
||||
const frame = readFrame()
|
||||
frames.push(frame)
|
||||
framesAfterRemoval = frame.targetExists ? 0 : framesAfterRemoval + 1
|
||||
if (framesAfterRemoval >= postRemovalSampleFrames) {
|
||||
break
|
||||
}
|
||||
}
|
||||
return frames
|
||||
}
|
||||
Reflect.set(window, '__activeDeleteRowRemovalFrames', sample())
|
||||
},
|
||||
{
|
||||
belowId,
|
||||
maxRemovalWaitMs: MAX_REMOVAL_WAIT_MS,
|
||||
postRemovalSampleFrames: POST_REMOVAL_SAMPLE_FRAMES,
|
||||
targetId
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async function finishRowRemovalSampling(page: Page): Promise<RowRemovalFrame[]> {
|
||||
return page.evaluate(async () => {
|
||||
const pending = window.__activeDeleteRowRemovalFrames
|
||||
if (!(pending instanceof Promise)) {
|
||||
throw new Error('Row removal sampling was not started')
|
||||
}
|
||||
return pending
|
||||
})
|
||||
}
|
||||
|
||||
test('deleting the active scrolled worktree preserves position and closes the row gap', async ({
|
||||
orcaPage
|
||||
}, testInfo) => {
|
||||
await waitForSessionReady(orcaPage)
|
||||
await orcaPage.setViewportSize({ width: 1_200, height: 800 })
|
||||
const { belowId, successorId, targetId } = await seedActiveDeletionRows(orcaPage, testInfo)
|
||||
await prepareScrolledActiveRow(orcaPage, targetId)
|
||||
const target = orcaPage.locator(
|
||||
`[data-worktree-sidebar] [data-worktree-id=${JSON.stringify(targetId)}]`
|
||||
)
|
||||
const below = orcaPage.locator(
|
||||
`[data-worktree-sidebar] [data-worktree-id=${JSON.stringify(belowId)}]`
|
||||
)
|
||||
await pauseForVisualProof(orcaPage)
|
||||
const contextMenuScope = target.locator('[data-worktree-context-menu-scope="worktree"]')
|
||||
await expect(contextMenuScope).toBeVisible()
|
||||
await contextMenuScope.click({ button: 'right' })
|
||||
const deleteItem = orcaPage.getByRole('menuitem', { name: /^Delete(?:\s|$)/ })
|
||||
await expect(deleteItem).toBeVisible()
|
||||
await expect(deleteItem).toBeInViewport()
|
||||
await pauseForVisualProof(orcaPage)
|
||||
await startRowRemovalSampling(orcaPage, targetId, belowId)
|
||||
await deleteItem.click()
|
||||
|
||||
await expect(target).toHaveCount(0)
|
||||
await expect(below).toBeVisible()
|
||||
await expect
|
||||
.poll(() => orcaPage.evaluate(() => window.__store?.getState().activeWorktreeId ?? null))
|
||||
.toBe(successorId)
|
||||
const frames = await finishRowRemovalSampling(orcaPage)
|
||||
await pauseForVisualProof(orcaPage)
|
||||
const mountedTops = frames.flatMap((frame) => (frame.belowTop === null ? [] : [frame.belowTop]))
|
||||
const firstRemovedFrame = frames.findIndex((frame) => !frame.targetExists)
|
||||
const scrollTopBeforeDelete = frames[0]?.scrollTop
|
||||
if (scrollTopBeforeDelete === undefined) {
|
||||
throw new Error('Row removal sampler recorded no pre-delete frame')
|
||||
}
|
||||
|
||||
expect(firstRemovedFrame).toBeGreaterThan(0)
|
||||
expect(frames.slice(firstRemovedFrame).every((frame) => !frame.targetExists)).toBe(true)
|
||||
expect(Math.max(...frames.map((frame) => frame.animationCount))).toBeGreaterThan(0)
|
||||
expect(Math.max(...mountedTops) - Math.min(...mountedTops)).toBeGreaterThan(30)
|
||||
expect(Math.max(...frames.map((frame) => frame.scrollTop))).toBeLessThanOrEqual(
|
||||
scrollTopBeforeDelete + 1
|
||||
)
|
||||
expect(Math.min(...frames.map((frame) => frame.scrollTop))).toBeGreaterThanOrEqual(
|
||||
scrollTopBeforeDelete - 1
|
||||
)
|
||||
await expect(
|
||||
orcaPage.locator(`[data-worktree-sidebar] [data-worktree-id=${JSON.stringify(successorId)}]`)
|
||||
).toHaveCount(0)
|
||||
})
|
||||
|
||||
test('reduced motion removes the active row without animating its neighbor', async ({
|
||||
orcaPage
|
||||
}, testInfo) => {
|
||||
await orcaPage.emulateMedia({ reducedMotion: 'reduce' })
|
||||
await waitForSessionReady(orcaPage)
|
||||
const { belowId, targetId } = await seedActiveDeletionRows(orcaPage, testInfo)
|
||||
await prepareScrolledActiveRow(orcaPage, targetId)
|
||||
|
||||
await startRowRemovalSampling(orcaPage, targetId, belowId)
|
||||
await evaluatePolled(
|
||||
orcaPage,
|
||||
async (targetId) => {
|
||||
const removed = await window
|
||||
.__store!.getState()
|
||||
.removeWorktree({ id: targetId, executionHostId: 'local' })
|
||||
if (!removed.ok) {
|
||||
throw new Error(removed.error)
|
||||
}
|
||||
},
|
||||
targetId
|
||||
)
|
||||
const frames = await finishRowRemovalSampling(orcaPage)
|
||||
|
||||
expect(frames.some((frame) => !frame.targetExists)).toBe(true)
|
||||
expect(Math.max(...frames.map((frame) => frame.animationCount))).toBe(0)
|
||||
})
|
||||
@@ -1,358 +0,0 @@
|
||||
import { mkdirSync, realpathSync } from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import { runProcess } from '@orca/process-host'
|
||||
import type { Page } from '@stablyai/playwright-test'
|
||||
import { test, expect } from './helpers/orca-app'
|
||||
import { evaluatePolled } from './helpers/page-evaluate-polled'
|
||||
import {
|
||||
addRepoWithWorkspaces,
|
||||
bulkWriteTimeout,
|
||||
writeWorkspaceMeta
|
||||
} from './helpers/repo-with-workspaces'
|
||||
import { waitForActiveWorktree, waitForSessionReady } from './helpers/store'
|
||||
|
||||
async function prepareSidebarForScrollTest(page: Page): Promise<void> {
|
||||
await page.evaluate(() => {
|
||||
const store = window.__store
|
||||
if (!store) {
|
||||
throw new Error('window.__store is not available')
|
||||
}
|
||||
|
||||
const state = store.getState()
|
||||
state.setActiveView('terminal')
|
||||
state.setSidebarOpen(true)
|
||||
state.setGroupBy('none')
|
||||
state.setSortBy('recent')
|
||||
state.setShowActiveOnly(false)
|
||||
state.setShowSleepingWorkspaces(true)
|
||||
state.setHideDefaultBranchWorkspace(false)
|
||||
state.setFilterRepoIds([])
|
||||
})
|
||||
}
|
||||
|
||||
test.describe('Reveal active workspace button', () => {
|
||||
test.beforeEach(async ({ orcaPage }) => {
|
||||
// Reduced motion jumps reveal deterministically because hidden xvfb Electron never advances smooth-scroll animations.
|
||||
await orcaPage.emulateMedia({ reducedMotion: 'reduce' })
|
||||
await waitForSessionReady(orcaPage)
|
||||
await waitForActiveWorktree(orcaPage)
|
||||
})
|
||||
|
||||
// Use outside-virtual-window reveal coverage; a removed ~44px synthetic viewport/±1px containment test was unstable under saturated CI.
|
||||
|
||||
test('adjusts sidebar filters before revealing a hidden current workspace', async ({
|
||||
orcaPage,
|
||||
testRepoPath
|
||||
}, testInfo) => {
|
||||
const filterRepoPath = testInfo.outputPath('filter-repo')
|
||||
mkdirSync(filterRepoPath, { recursive: true })
|
||||
for (const args of [
|
||||
['init', filterRepoPath],
|
||||
[
|
||||
'-C',
|
||||
filterRepoPath,
|
||||
'-c',
|
||||
'user.name=E2E',
|
||||
'-c',
|
||||
'user.email=e2e@test.local',
|
||||
'commit',
|
||||
'--allow-empty',
|
||||
'-m',
|
||||
'Filter fixture'
|
||||
]
|
||||
]) {
|
||||
const result = await runProcess({ program: 'git', args })
|
||||
expect(result.code, result.stderr).toBe(0)
|
||||
}
|
||||
const filterRepoId = await orcaPage.evaluate(async (repoPath) => {
|
||||
const result = await window.api.repos.add({ path: repoPath })
|
||||
if ('error' in result) {
|
||||
throw new Error(result.error)
|
||||
}
|
||||
return result.repo.id
|
||||
}, filterRepoPath)
|
||||
await expect
|
||||
.poll(() =>
|
||||
orcaPage.evaluate(async (id) => {
|
||||
await window
|
||||
.__store!.getState()
|
||||
.fetchRepos({ runtimeEnvironmentId: null, throwOnError: true })
|
||||
return window.__store!.getState().repos.some((repo) => repo.id === id)
|
||||
}, filterRepoId)
|
||||
)
|
||||
.toBe(true)
|
||||
await prepareSidebarForScrollTest(orcaPage)
|
||||
|
||||
// Other specs can add worktrees to the shared repository before this test runs.
|
||||
const targetId = await orcaPage.evaluate((repoPath) => {
|
||||
const state = window.__store!.getState()
|
||||
const repo = state.repos.find((candidate) => candidate.path === repoPath)
|
||||
return repo
|
||||
? state.worktreesByRepo[repo.id]?.find(
|
||||
(worktree) => worktree.branch === 'refs/heads/e2e-secondary'
|
||||
)?.id
|
||||
: undefined
|
||||
}, testRepoPath)
|
||||
if (!targetId) {
|
||||
throw new Error('Seeded secondary worktree is missing')
|
||||
}
|
||||
const targetRepoId = await orcaPage.evaluate(
|
||||
(repoPath) => window.__store!.getState().repos.find((repo) => repo.path === repoPath)?.id,
|
||||
testRepoPath
|
||||
)
|
||||
if (!targetRepoId) {
|
||||
throw new Error('Seeded repository is missing')
|
||||
}
|
||||
|
||||
const targetRows = orcaPage.locator(
|
||||
`[data-worktree-sidebar] [data-worktree-id=${JSON.stringify(targetId)}]`
|
||||
)
|
||||
const targetRow = targetRows.first()
|
||||
await expect(targetRows.and(orcaPage.getByRole('option'))).toHaveCount(1)
|
||||
const revealButton = orcaPage.getByRole('button', { name: 'Reveal active workspace' })
|
||||
|
||||
await orcaPage.evaluate((targetId) => {
|
||||
const store = window.__store
|
||||
if (!store) {
|
||||
throw new Error('window.__store is not available')
|
||||
}
|
||||
const state = store.getState()
|
||||
const target = Object.values(state.worktreesByRepo)
|
||||
.flat()
|
||||
.find((worktree) => worktree.id === targetId)
|
||||
if (!target) {
|
||||
throw new Error(`Target workspace ${targetId} not found`)
|
||||
}
|
||||
store.setState({
|
||||
activeRepoId: target.repoId,
|
||||
activeWorktreeId: target.id,
|
||||
activeWorkspaceKey: `worktree:${target.id}`,
|
||||
pendingRevealWorktree: null
|
||||
})
|
||||
}, targetId)
|
||||
await expect(targetRow).toHaveAttribute('aria-current', 'page')
|
||||
|
||||
// Catalog refreshes prune nonexistent IDs, so use a real repo to keep the filter applied.
|
||||
await orcaPage.evaluate((repoId) => {
|
||||
window.__store!.getState().setFilterRepoIds([repoId])
|
||||
}, filterRepoId)
|
||||
await expect(targetRows).toHaveCount(0)
|
||||
|
||||
await revealButton.click()
|
||||
await orcaPage
|
||||
.getByRole('dialog', { name: 'Reveal hidden workspace?' })
|
||||
.getByRole('button', { name: 'Adjust filters and reveal' })
|
||||
.click()
|
||||
|
||||
await expect(targetRow).toBeVisible()
|
||||
await expect(targetRow).toHaveAttribute('data-scroll-reveal-highlight', 'true')
|
||||
await expect
|
||||
.poll(
|
||||
() =>
|
||||
orcaPage.evaluate(() => {
|
||||
const store = window.__store
|
||||
if (!store) {
|
||||
throw new Error('window.__store is not available')
|
||||
}
|
||||
return store.getState().filterRepoIds
|
||||
}),
|
||||
{
|
||||
timeout: 10_000,
|
||||
message:
|
||||
'Reveal button should preserve selected repos while revealing the current workspace'
|
||||
}
|
||||
)
|
||||
.toEqual([filterRepoId, targetRepoId])
|
||||
})
|
||||
|
||||
test('reveals the current workspace when it starts outside the virtualized window', async ({
|
||||
orcaPage
|
||||
}, testInfo) => {
|
||||
await prepareSidebarForScrollTest(orcaPage)
|
||||
|
||||
const repo = await addRepoWithWorkspaces(orcaPage, testInfo, 60)
|
||||
await writeWorkspaceMeta(
|
||||
orcaPage,
|
||||
repo.ids.map((worktreeId, index) => ({
|
||||
worktreeId,
|
||||
updates: {
|
||||
displayName: `Virtual reveal ${String(index).padStart(2, '0')}`,
|
||||
sortOrder: 10_000 - index,
|
||||
manualOrder: 10_000 - index
|
||||
}
|
||||
}))
|
||||
)
|
||||
const targetId = repo.ids.at(-1)!
|
||||
await orcaPage.evaluate(
|
||||
({ repoId, targetId }) => {
|
||||
window.__store!.setState({
|
||||
activeRepoId: repoId,
|
||||
activeWorktreeId: targetId,
|
||||
activeWorkspaceKey: `worktree:${targetId}`,
|
||||
pendingRevealWorktree: null,
|
||||
sortBy: 'manual'
|
||||
})
|
||||
},
|
||||
{ repoId: repo.repoId, targetId }
|
||||
)
|
||||
|
||||
const scroller = orcaPage.locator('[data-worktree-sidebar]')
|
||||
await expect
|
||||
.poll(
|
||||
() =>
|
||||
orcaPage.evaluate(() => {
|
||||
const scroller = document.querySelector<HTMLElement>('[data-worktree-sidebar]')
|
||||
return scroller?.scrollTop ?? null
|
||||
}),
|
||||
{ timeout: 10_000, message: 'sidebar scroller did not mount' }
|
||||
)
|
||||
.not.toBeNull()
|
||||
|
||||
await scroller.evaluate((element) => {
|
||||
element.scrollTop = 0
|
||||
element.dispatchEvent(new Event('scroll', { bubbles: true }))
|
||||
})
|
||||
await expect
|
||||
.poll(
|
||||
() =>
|
||||
orcaPage.evaluate((targetId) => {
|
||||
const scroller = document.querySelector<HTMLElement>('[data-worktree-sidebar]')
|
||||
const target = [...document.querySelectorAll<HTMLElement>('[data-worktree-id]')].find(
|
||||
(candidate) => candidate.dataset.worktreeId === targetId
|
||||
)
|
||||
if (!scroller || !target) {
|
||||
return false
|
||||
}
|
||||
const scrollerBounds = scroller.getBoundingClientRect()
|
||||
const targetBounds = target.getBoundingClientRect()
|
||||
return (
|
||||
targetBounds.top >= scrollerBounds.top - 1 &&
|
||||
targetBounds.bottom <= scrollerBounds.bottom + 1
|
||||
)
|
||||
}, targetId),
|
||||
{ timeout: 10_000, message: 'target workspace should start outside the sidebar viewport' }
|
||||
)
|
||||
.toBe(false)
|
||||
|
||||
const revealButton = orcaPage.getByRole('button', { name: 'Reveal active workspace' })
|
||||
await expect(revealButton).toBeVisible()
|
||||
await expect(revealButton).toBeEnabled()
|
||||
|
||||
await revealButton.click()
|
||||
const targetRow = orcaPage
|
||||
.locator(`[data-worktree-sidebar] [data-worktree-id=${JSON.stringify(targetId)}]`)
|
||||
.first()
|
||||
await expect(targetRow).toBeVisible()
|
||||
await expect(targetRow).toHaveAttribute('data-scroll-reveal-highlight', 'true')
|
||||
})
|
||||
|
||||
test('uses the active workspace key when the legacy active worktree id is not set', async ({
|
||||
orcaPage
|
||||
}, testInfo) => {
|
||||
await prepareSidebarForScrollTest(orcaPage)
|
||||
|
||||
// The oldest of 36 folder workspaces sorts last under Recent.
|
||||
const groupPath = testInfo.outputPath('reveal-folder-group')
|
||||
const folderPaths = Array.from({ length: 36 }, (_, index) => {
|
||||
const folderPath = path.join(groupPath, `folder-${String(index).padStart(2, '0')}`)
|
||||
mkdirSync(folderPath, { recursive: true })
|
||||
return realpathSync(folderPath)
|
||||
})
|
||||
const folderWorktreeId = await evaluatePolled(
|
||||
orcaPage,
|
||||
async ({ parentPath, folderPaths }) => {
|
||||
const store = window.__store!
|
||||
const group = await window.api.projectGroups.create({
|
||||
name: 'Reveal folder group',
|
||||
parentPath,
|
||||
createdFrom: 'manual'
|
||||
})
|
||||
await store
|
||||
.getState()
|
||||
.fetchProjectGroups({ runtimeEnvironmentId: null, throwOnError: true })
|
||||
const ids: string[] = []
|
||||
for (const [index, folderPath] of folderPaths.entries()) {
|
||||
const folder = await store.getState().createFolderWorkspace(
|
||||
{
|
||||
projectGroupId: group.id,
|
||||
name: `Reveal folder workspace ${String(index).padStart(2, '0')}`,
|
||||
folderPath
|
||||
},
|
||||
{ runtimeEnvironmentId: null }
|
||||
)
|
||||
if (!folder) {
|
||||
throw new Error(`Folder workspace ${index} was not created`)
|
||||
}
|
||||
ids.push(folder.folderWorkspace.id)
|
||||
}
|
||||
const targetKey = `folder:${ids[0]}` as const
|
||||
store.setState({
|
||||
activeRepoId: null,
|
||||
activeWorktreeId: null,
|
||||
activeWorkspaceKey: targetKey
|
||||
})
|
||||
store.getState().setGroupBy('repo')
|
||||
return targetKey
|
||||
},
|
||||
{ parentPath: realpathSync(groupPath), folderPaths },
|
||||
{ timeout: bulkWriteTimeout(folderPaths.length) }
|
||||
)
|
||||
|
||||
const scroller = orcaPage.locator('[data-worktree-sidebar]')
|
||||
await scroller.evaluate((element) => {
|
||||
element.scrollTop = 0
|
||||
element.dispatchEvent(new Event('scroll', { bubbles: true }))
|
||||
})
|
||||
await expect
|
||||
.poll(
|
||||
() =>
|
||||
orcaPage.evaluate((targetId) => {
|
||||
const scroller = document.querySelector<HTMLElement>('[data-worktree-sidebar]')
|
||||
const target = [...document.querySelectorAll<HTMLElement>('[data-worktree-id]')].find(
|
||||
(candidate) => candidate.dataset.worktreeId === targetId
|
||||
)
|
||||
if (!scroller || !target) {
|
||||
return false
|
||||
}
|
||||
const scrollerBounds = scroller.getBoundingClientRect()
|
||||
const targetBounds = target.getBoundingClientRect()
|
||||
return (
|
||||
targetBounds.top >= scrollerBounds.top - 1 &&
|
||||
targetBounds.bottom <= scrollerBounds.bottom + 1
|
||||
)
|
||||
}, folderWorktreeId),
|
||||
{ timeout: 10_000, message: 'target folder workspace should start outside the viewport' }
|
||||
)
|
||||
.toBe(false)
|
||||
|
||||
const revealButton = orcaPage.getByRole('button', { name: 'Reveal active workspace' })
|
||||
await expect(revealButton).toBeVisible()
|
||||
await expect(revealButton).toBeEnabled()
|
||||
await revealButton.click()
|
||||
|
||||
await expect
|
||||
.poll(
|
||||
() =>
|
||||
orcaPage.evaluate((targetId) => {
|
||||
const scroller = document.querySelector<HTMLElement>('[data-worktree-sidebar]')
|
||||
const target = [...document.querySelectorAll<HTMLElement>('[data-worktree-id]')].find(
|
||||
(candidate) => candidate.dataset.worktreeId === targetId
|
||||
)
|
||||
if (!scroller || !target) {
|
||||
return false
|
||||
}
|
||||
const scrollerBounds = scroller.getBoundingClientRect()
|
||||
const targetBounds = target.getBoundingClientRect()
|
||||
return (
|
||||
targetBounds.top >= scrollerBounds.top - 1 &&
|
||||
targetBounds.bottom <= scrollerBounds.bottom + 1
|
||||
)
|
||||
}, folderWorktreeId),
|
||||
{
|
||||
timeout: 10_000,
|
||||
message: 'Reveal button should scroll to the active folder workspace'
|
||||
}
|
||||
)
|
||||
.toBe(true)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user