mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 19:07:41 +00:00
test: remove redundant Markdown and update Electron smoke suites (#42477)
Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
This commit is contained in:
@@ -1,42 +0,0 @@
|
||||
import { test, expect } from './helpers/orca-app'
|
||||
import { waitForActiveWorktree, waitForSessionReady } from './helpers/store'
|
||||
import {
|
||||
cleanupMarkdownFixture,
|
||||
createMarkdownFixture,
|
||||
getActiveWorktreeContext,
|
||||
openMarkdownFixture
|
||||
} from './helpers/markdown-editor-fixture'
|
||||
|
||||
test('source links stay outside mixed code fences', async ({ orcaPage }, testInfo) => {
|
||||
await waitForSessionReady(orcaPage)
|
||||
await waitForActiveWorktree(orcaPage)
|
||||
const context = await getActiveWorktreeContext(orcaPage)
|
||||
const file = await createMarkdownFixture(
|
||||
context,
|
||||
'markdown-fences',
|
||||
'links',
|
||||
testInfo.workerIndex,
|
||||
'# Fence boundaries\n\n~~~text\n```\n[[inside-code]]\n~~~\n\n[[outside-code]]\n'
|
||||
)
|
||||
try {
|
||||
await openMarkdownFixture(orcaPage, context, file)
|
||||
await orcaPage.evaluate(() => {
|
||||
const state = window.__store!.getState()
|
||||
if (!state.activeFileId) {
|
||||
throw new Error('missing active file')
|
||||
}
|
||||
state.setMarkdownViewMode(state.activeFileId, 'source')
|
||||
})
|
||||
const links = orcaPage.locator('.monaco-editor .view-line').filter({
|
||||
has: orcaPage.locator('.monaco-markdown-doc-link')
|
||||
})
|
||||
await expect(links).toHaveCount(1)
|
||||
await expect(links).toHaveText('[[outside-code]]')
|
||||
await testInfo.attach('fence-links', {
|
||||
body: await orcaPage.screenshot({ path: testInfo.outputPath('fence-links.png') }),
|
||||
contentType: 'image/png'
|
||||
})
|
||||
} finally {
|
||||
await cleanupMarkdownFixture(file)
|
||||
}
|
||||
})
|
||||
@@ -1,78 +0,0 @@
|
||||
import type { Locator, Page } from '@stablyai/playwright-test'
|
||||
import { test, expect } from './helpers/orca-app'
|
||||
import { waitForActiveWorktree, waitForSessionReady } from './helpers/store'
|
||||
import {
|
||||
cleanupMarkdownFixture,
|
||||
createMarkdownFixture,
|
||||
getActiveWorktreeContext,
|
||||
openMarkdownFixture,
|
||||
waitForRichMarkdownEditor
|
||||
} from './helpers/markdown-editor-fixture'
|
||||
|
||||
const MARKDOWN = `\`\`\`bash
|
||||
printf '%s\\n' "build complete" # bash-highlight-marker
|
||||
\`\`\`
|
||||
|
||||
\`\`\`sh
|
||||
printf '%s\\n' "build complete" # shell-control-marker
|
||||
\`\`\`
|
||||
`
|
||||
|
||||
async function switchToSourceMode(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()
|
||||
if (!state.activeFileId) {
|
||||
throw new Error('No active editor file')
|
||||
}
|
||||
state.setMarkdownViewMode(state.activeFileId, 'source')
|
||||
})
|
||||
}
|
||||
|
||||
async function distinctLeafTokenColors(line: Locator): Promise<number> {
|
||||
return line.locator('span').evaluateAll((spans) => {
|
||||
const colors = spans
|
||||
.filter((span) => span.childElementCount === 0 && span.textContent?.trim())
|
||||
.map((span) => window.getComputedStyle(span).color)
|
||||
return new Set(colors).size
|
||||
})
|
||||
}
|
||||
|
||||
test('highlights bash and sh fences in Markdown Source mode', async ({ orcaPage }, testInfo) => {
|
||||
await waitForSessionReady(orcaPage)
|
||||
await waitForActiveWorktree(orcaPage)
|
||||
|
||||
const context = await getActiveWorktreeContext(orcaPage)
|
||||
let filePath: string | null = null
|
||||
|
||||
try {
|
||||
filePath = await createMarkdownFixture(
|
||||
context,
|
||||
'.orca-e2e-markdown-source-highlighting',
|
||||
'bash-and-sh',
|
||||
testInfo.workerIndex,
|
||||
MARKDOWN
|
||||
)
|
||||
await openMarkdownFixture(orcaPage, context, filePath)
|
||||
await waitForRichMarkdownEditor(orcaPage)
|
||||
await switchToSourceMode(orcaPage)
|
||||
|
||||
const monaco = orcaPage.locator('.monaco-editor').first()
|
||||
await expect(monaco).toBeVisible({ timeout: 25_000 })
|
||||
|
||||
for (const marker of ['bash-highlight-marker', 'shell-control-marker']) {
|
||||
const line = monaco.locator('.view-line').filter({ hasText: marker })
|
||||
await expect(line).toHaveCount(1)
|
||||
await expect
|
||||
.poll(() => distinctLeafTokenColors(line), {
|
||||
message: `${marker} should render with distinct shell token colors`
|
||||
})
|
||||
.toBeGreaterThan(1)
|
||||
}
|
||||
} finally {
|
||||
await cleanupMarkdownFixture(filePath)
|
||||
}
|
||||
})
|
||||
@@ -1,67 +0,0 @@
|
||||
import { expect, test } from './helpers/orca-app'
|
||||
import { waitForSessionReady } from './helpers/store'
|
||||
|
||||
const CHECK_ERROR = 'E2E update check failed: connection refused'
|
||||
|
||||
test.use({ seedTestRepo: false })
|
||||
|
||||
for (const theme of ['dark', 'light'] as const) {
|
||||
test(`automatic update failure opens details from the status bar (${theme})`, async ({
|
||||
orcaPage
|
||||
}, testInfo) => {
|
||||
await waitForSessionReady(orcaPage)
|
||||
await orcaPage.setViewportSize({ width: 1200, height: 800 })
|
||||
await orcaPage.evaluate(async (theme) => {
|
||||
const state = window.__store!.getState()
|
||||
await state.updateSettingsOrThrow({ theme })
|
||||
state.setUpdateStatus({ state: 'checking', userInitiated: false })
|
||||
}, theme)
|
||||
await expect(orcaPage.locator('html')).toHaveClass(theme === 'dark' ? /\bdark\b/ : /\blight\b/)
|
||||
await orcaPage.evaluate((message) => {
|
||||
window.__store!.getState().setUpdateStatus({
|
||||
state: 'error',
|
||||
message,
|
||||
userInitiated: false
|
||||
})
|
||||
}, CHECK_ERROR)
|
||||
|
||||
const statusButton = orcaPage.getByRole('button', {
|
||||
name: 'Update failed. Click to expand.',
|
||||
exact: true
|
||||
})
|
||||
const card = orcaPage.getByRole('complementary', { name: 'Update error', exact: true })
|
||||
await expect(statusButton).toBeVisible()
|
||||
await expect(card).toBeHidden()
|
||||
|
||||
await statusButton.click()
|
||||
// Capture before the assertion so the broken build provides the same visual evidence.
|
||||
const statusClickScreenshot = testInfo.outputPath(
|
||||
`update-error-after-status-click-${theme}.png`
|
||||
)
|
||||
await orcaPage.screenshot({ path: statusClickScreenshot, animations: 'disabled' })
|
||||
await testInfo.attach(`update-error-after-status-click-${theme}`, {
|
||||
path: statusClickScreenshot,
|
||||
contentType: 'image/png'
|
||||
})
|
||||
await expect(card).toBeVisible()
|
||||
await expect(statusButton).toHaveAttribute('aria-expanded', 'true')
|
||||
await expect(card.getByRole('heading', { name: 'Update Check Failed' })).toBeVisible()
|
||||
await expect(card.getByRole('button', { name: 'Re-check', exact: true })).toBeVisible()
|
||||
|
||||
await card.getByRole('button', { name: 'Show details', exact: true }).click()
|
||||
await expect(card.getByText(CHECK_ERROR, { exact: true })).toBeVisible()
|
||||
const detailsScreenshot = testInfo.outputPath(`update-error-expanded-details-${theme}.png`)
|
||||
await orcaPage.screenshot({ path: detailsScreenshot, animations: 'disabled' })
|
||||
await testInfo.attach(`update-error-expanded-details-${theme}`, {
|
||||
path: detailsScreenshot,
|
||||
contentType: 'image/png'
|
||||
})
|
||||
|
||||
await card.getByRole('button', { name: 'Minimize to status bar', exact: true }).click()
|
||||
await expect(card).toBeHidden()
|
||||
await expect(statusButton).toHaveAttribute('aria-expanded', 'false')
|
||||
await statusButton.click()
|
||||
await expect(card).toBeVisible()
|
||||
await expect(statusButton).toHaveAttribute('aria-expanded', 'true')
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user