Files
orca/tests/e2e/markdown-nested-toggle.spec.ts
OrcaWinandOrcaWin e8a497e995 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>
2026-11-16 05:34:17 -08:00

67 lines
2.4 KiB
TypeScript

import { readFileSync } from 'node:fs'
import { test, expect } from './helpers/orca-app'
import {
cleanupMarkdownFixture,
closeActiveEditorTab,
createMarkdownFixture,
getActiveWorktreeContext,
openMarkdownFixture,
waitForRichMarkdownEditor
} from './helpers/markdown-editor-fixture'
import {
expectEditableNestedToggles,
expectFileKeepsNesting,
expectSentinelInsideNestedToggle,
NESTED_TOGGLE_FIXTURE_DIRECTORY,
NESTED_TOGGLE_MARKDOWN,
placeCaretInNestedToggleBody
} from './helpers/markdown-nested-toggle'
import { waitForActiveWorktree, waitForSessionReady } from './helpers/store'
test.describe('Markdown nested toggle regression', () => {
test.beforeEach(async ({ orcaPage }) => {
await waitForSessionReady(orcaPage)
await waitForActiveWorktree(orcaPage)
})
test('editing a nested toggle survives save and reopen', async ({ orcaPage }, testInfo) => {
const context = await getActiveWorktreeContext(orcaPage)
const sentinel = `editedInsideNestedToggle${Date.now()}`
let filePath: string | null = null
try {
filePath = await createMarkdownFixture(
context,
NESTED_TOGGLE_FIXTURE_DIRECTORY,
'nested-toggle-edit',
testInfo.workerIndex,
NESTED_TOGGLE_MARKDOWN
)
await openMarkdownFixture(orcaPage, context, filePath)
await waitForRichMarkdownEditor(orcaPage)
await expectEditableNestedToggles(orcaPage)
await placeCaretInNestedToggleBody(orcaPage)
await orcaPage.keyboard.type(` ${sentinel}`)
await expectSentinelInsideNestedToggle(orcaPage, sentinel)
// Save through the real shortcut and assert the bytes that landed on disk.
await orcaPage.keyboard.press('ControlOrMeta+S')
const savedPath = filePath
await expect
.poll(() => readFileSync(savedPath, 'utf8'), { timeout: 10_000 })
.toContain(sentinel)
expectFileKeepsNesting(readFileSync(savedPath, 'utf8'), sentinel)
// Reopen the saved bytes from scratch; the reported bug appeared only after reparsing.
await closeActiveEditorTab(orcaPage, savedPath)
await openMarkdownFixture(orcaPage, context, savedPath)
await waitForRichMarkdownEditor(orcaPage)
await expectEditableNestedToggles(orcaPage)
await expectSentinelInsideNestedToggle(orcaPage, sentinel)
} finally {
await cleanupMarkdownFixture(filePath)
}
})
})