Files
orca/tests/e2e/linear-url-workspace-entry.spec.ts
T
Simon ChoandNeil 13757d773d test(e2e): update four stale e2e specs to match intentional product changes (#30115)
* test(e2e): repair specs that missed intentional product changes

Align still-stale e2e expectations with shipped product behavior:
- the Cmd+J placeholder names workspaces and tasks
- the worktree meta dialog is titled "Workspace details"
- OS-opened CSV/TSV files are editable and render as an ARIA grid
- the delayed-save notice carries the app toaster's close button

Fixes #30114

Co-authored-by: Neil <neil@stably.ai>

* test(e2e): stub host Linear status in linear-url-workspace-entry spec

Since #33270, Create worktree reads Linear status from the repo's host
(linear:status IPC) instead of the store, so the store-only fixture left
Linear disconnected in the composer and the pasted URL was never looked up.
Stub the linear:status handler with the same connected status.

---------

Co-authored-by: Neil <neil@stably.ai>
2026-10-27 10:15:28 -07:00

250 lines
9.5 KiB
TypeScript

import { openSidebarWorkspaceComposer } from './helpers/sidebar-project-dialog'
import type { ElectronApplication, Page } from '@stablyai/playwright-test'
import { test, expect } from './helpers/orca-app'
import { waitForActiveWorktree, waitForSessionReady } from './helpers/store'
import type { LinearIssue } from '../../src/shared/linear/issue-types'
import type { LinearConnectionStatus } from '../../src/shared/linear/workspace-types'
const LINEAR_URL =
'https://linear.app/stably/issue/STA-4084/restore-osc-133-shell-integration-when-an-exec-in-user-rc-files-strips'
const EXPECTED_WORKSPACE_NAME = 'sta-4084-restore-osc-133-shell-integration-when'
const LINEAR_ISSUE: LinearIssue = {
id: 'linear-sta-4084',
workspaceId: 'workspace-1',
workspaceName: 'Stably',
identifier: 'STA-4084',
title: 'Restore OSC 133 shell integration when an exec in user rc files strips',
branchName: 'sta-4084-restore-osc-133-shell-integration',
url: LINEAR_URL,
state: { name: 'Todo', type: 'unstarted', color: '#999999' },
team: { id: 'team-sta', name: 'Stably', key: 'STA' },
labels: [],
labelIds: [],
priority: 2,
estimate: null,
updatedAt: '2026-08-12T00:00:00.000Z'
}
const LINEAR_STATUS: LinearConnectionStatus = {
connected: true,
viewer: null,
activeWorkspaceId: 'workspace-other',
selectedWorkspaceId: 'workspace-other',
workspaces: [
{
id: 'workspace-other',
displayName: 'Other User',
email: null,
organizationId: 'organization-other',
organizationName: 'Other',
organizationUrlKey: 'other'
},
{
id: 'workspace-1',
displayName: 'Stably User',
email: null,
organizationId: 'organization-stably',
organizationName: 'Stably',
organizationUrlKey: 'stably'
}
]
}
declare global {
// oxlint-disable-next-line typescript-eslint/consistent-type-definitions -- declaration merging requires interface
interface Window {
// Set by the fixture below while a Linear lookup is deliberately held open.
__orcaTestReleaseLinearLookup?: () => void
}
}
function pasteChord(): string {
return process.platform === 'darwin' ? 'Meta+V' : 'Control+V'
}
async function installLinearFixture(
page: Page,
issue: LinearIssue | null = LINEAR_ISSUE,
lookupDelayMs: number | null = 150
): Promise<void> {
await page.evaluate(
({ resolvedIssue, lookupDelayMs, status }) => {
Reflect.deleteProperty(window, '__orcaTestReleaseLinearLookup')
const store = window.__store
if (!store) {
throw new Error('window.__store is not available')
}
store.setState({
linearStatus: status,
linearStatusChecked: true,
checkLinearConnection: async () => {},
searchLinearIssues: async () => [],
listLinearIssues: async () => ({ items: [] }),
fetchLinearIssue: async (_identifier: string, workspaceId?: string | null) => {
await (lookupDelayMs === null
? new Promise<void>((resolve) => {
Reflect.set(window, '__orcaTestReleaseLinearLookup', resolve)
})
: new Promise<void>((resolve) => window.setTimeout(resolve, lookupDelayMs)))
return resolvedIssue && workspaceId === resolvedIssue.workspaceId ? resolvedIssue : null
}
})
},
{ resolvedIssue: issue, lookupDelayMs, status: LINEAR_STATUS }
)
}
async function releaseHeldLinearLookup(page: Page): Promise<void> {
await page.evaluate(() => {
const release = window.__orcaTestReleaseLinearLookup
if (typeof release !== 'function') {
throw new Error('Linear lookup is not held')
}
Reflect.deleteProperty(window, '__orcaTestReleaseLinearLookup')
release()
})
}
async function pasteLinearUrl(page: Page, input: ReturnType<Page['locator']>): Promise<void> {
await page.evaluate((text) => window.api.ui.writeClipboardText(text), LINEAR_URL)
// X selection ownership is async; pasting before it lands delivers stale text.
await expect
.poll(() => page.evaluate(() => window.api.ui.readClipboardText()), { timeout: 5_000 })
.toBe(LINEAR_URL)
await input.focus()
await page.keyboard.press(pasteChord())
}
async function openJumpPalette(electronApp: ElectronApplication): Promise<void> {
// Headless Playwright keys bypass Electron's before-input-event shortcut path.
await electronApp.evaluate(({ BrowserWindow }) => {
BrowserWindow.getAllWindows()[0]?.webContents.send('ui:toggleWorktreePalette')
})
}
test.describe('Linear URL workspace entry', () => {
test.beforeEach(async ({ electronApp, orcaPage }) => {
await waitForSessionReady(orcaPage)
await waitForActiveWorktree(orcaPage)
// Why: Create worktree reads Linear status from its repo's host, not the store.
await electronApp.evaluate(({ ipcMain }, status) => {
ipcMain.removeHandler('linear:status')
ipcMain.handle('linear:status', () => status)
}, LINEAR_STATUS)
await installLinearFixture(orcaPage)
})
test('pasting into the composer selects the Linear issue without ArrowDown', async ({
orcaPage
}, testInfo) => {
await installLinearFixture(orcaPage, LINEAR_ISSUE, null)
await openSidebarWorkspaceComposer(orcaPage)
const dialog = orcaPage.getByRole('dialog', { name: /Create (Workspace|Worktree)/i })
const input = dialog.locator('[data-workspace-name-input="true"]')
await expect(input).toBeVisible()
await pasteLinearUrl(orcaPage, input)
await expect
.poll(() =>
orcaPage.evaluate(() => typeof window.__orcaTestReleaseLinearLookup === 'function')
)
.toBe(true)
await input.press('Enter')
await expect(input).toHaveValue(LINEAR_URL)
await expect(dialog.locator('[data-workspace-source-pill="true"]')).toHaveCount(0)
await releaseHeldLinearLookup(orcaPage)
const issueRow = orcaPage.getByRole('option', {
name: `${LINEAR_ISSUE.identifier} ${LINEAR_ISSUE.title}`,
exact: true
})
const useNameRow = orcaPage.getByRole('option', {
name: `Use "${LINEAR_URL}" as workspace name`,
exact: true
})
await expect(useNameRow).toBeVisible()
await expect(useNameRow).not.toHaveAttribute('data-selected', 'true')
await expect(issueRow).toContainText(LINEAR_ISSUE.title)
await expect(issueRow).toHaveAttribute('data-selected', 'true')
await testInfo.attach('linear-url-smart-entry-selected.png', {
body: await dialog.screenshot(),
contentType: 'image/png'
})
await input.press('Enter')
const sourcePill = dialog.locator('[data-workspace-source-pill="true"]')
await expect(sourcePill).toContainText(LINEAR_ISSUE.title)
await expect(dialog.getByPlaceholder('Workspace name')).toHaveValue(EXPECTED_WORKSPACE_NAME)
await expect(dialog.getByRole('button', { name: /Create (Workspace|Worktree)/i })).toBeEnabled()
await testInfo.attach('linear-url-smart-entry-composer.png', {
body: await dialog.screenshot(),
contentType: 'image/png'
})
})
test('a Linear URL lookup miss falls back to an arbitrary workspace name', async ({
orcaPage
}) => {
await installLinearFixture(orcaPage, null)
await openSidebarWorkspaceComposer(orcaPage)
const dialog = orcaPage.getByRole('dialog', { name: /Create (Workspace|Worktree)/i })
const input = dialog.locator('[data-workspace-name-input="true"]')
await pasteLinearUrl(orcaPage, input)
const useNameRow = orcaPage.getByRole('option', {
name: `Use "${LINEAR_URL}" as workspace name`,
exact: true
})
await expect(useNameRow).toHaveAttribute('data-selected', 'true')
await expect(input).not.toHaveAttribute('aria-busy', 'true')
await input.press('Enter')
await expect(input).toHaveValue(LINEAR_URL)
await expect(dialog.locator('[data-workspace-source-pill="true"]')).toHaveCount(0)
const suggestions = dialog.locator('[data-workspace-source-suggestions="true"]')
if (await suggestions.isVisible()) {
await input.press('Escape')
}
await expect(input).not.toHaveAttribute('aria-busy', 'true')
await input.press('Enter')
await expect(dialog.locator('[data-agent-combobox-root="true"][role="combobox"]')).toBeFocused()
})
test('pasting into Cmd+J previews the Linear issue and opens the linked composer', async ({
electronApp,
orcaPage
}, testInfo) => {
await openJumpPalette(electronApp)
const palette = orcaPage.getByRole('dialog', { name: 'Jump to...' })
const input = palette.getByPlaceholder(
'Search chats, terminals, workspaces, tasks, settings, and actions...'
)
await expect(input).toBeVisible()
await pasteLinearUrl(orcaPage, input)
const preview = palette.locator(
'[data-cmd-j-linear-issue-preview="true"][data-cmd-j-linear-issue-state="resolved"]'
)
await expect(preview).toContainText(LINEAR_ISSUE.identifier)
await expect(preview).toContainText(LINEAR_ISSUE.title)
await expect(preview).toHaveAttribute('data-selected', 'true')
await testInfo.attach('linear-url-cmd-j-preview.png', {
body: await palette.screenshot(),
contentType: 'image/png'
})
await input.press('Enter')
const dialog = orcaPage.getByRole('dialog', { name: /Create (Workspace|Worktree)/i })
const sourcePill = dialog.locator('[data-workspace-source-pill="true"]')
await expect(sourcePill).toContainText(LINEAR_ISSUE.title)
await expect(dialog.getByPlaceholder('Workspace name')).toHaveValue(EXPECTED_WORKSPACE_NAME)
await expect(dialog.getByRole('button', { name: /Create (Workspace|Worktree)/i })).toBeEnabled()
await testInfo.attach('linear-url-cmd-j-composer.png', {
body: await dialog.screenshot(),
contentType: 'image/png'
})
})
})