guanghu/tests/smoke/persist-editor-mode.spec.ts
Guanghu Domestic Migration 9b41d51231
Some checks are pending
Auto-update PR branches / Update open PR branches (push) Waiting to run
CI / Frontend Static Quality Checks (push) Waiting to run
CI / Frontend Tests & Coverage (push) Waiting to run
CI / Rust Tests & Quality Checks (push) Waiting to run
CI / Linux build verification (push) Waiting to run
Deploy docs / Build VitePress site (push) Waiting to run
Deploy docs / Deploy to GitHub Pages (push) Blocked by required conditions
Release (Alpha) / Compute alpha version (push) Waiting to run
Release (Alpha) / Build release artifacts (push) Blocked by required conditions
Release (Alpha) / GitHub Release (alpha) (push) Blocked by required conditions
Release (Alpha) / Update docs and release pages (push) Blocked by required conditions
chore: import sanitized domestic snapshot for REPO-004
Source snapshot: 514ab1975951d94342ea38e64101d5a0f1c51c77
2026-07-17 15:55:28 +08:00

59 lines
2.3 KiB
TypeScript

import { test, expect } from '@playwright/test'
import { openCommandPalette, executeCommand } from './helpers'
const RAW_EDITOR = '[data-testid="raw-editor-codemirror"]'
const BLOCKNOTE_EDITOR = '.bn-editor'
test.describe('Persist editor mode (raw/preview) across note switches', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/')
await page.waitForLoadState('networkidle')
const noteList = page.locator('[data-testid="note-list-container"]')
await noteList.waitFor({ timeout: 5_000 })
})
test('raw mode persists when switching to a different note', async ({ page }) => {
const noteItems = page.locator('[data-testid="note-list-container"] .cursor-pointer')
// Open first note
await noteItems.nth(0).click()
await page.waitForTimeout(500)
await expect(page.locator(BLOCKNOTE_EDITOR).first()).toBeVisible({ timeout: 5_000 })
// Toggle raw mode on
await openCommandPalette(page)
await executeCommand(page, 'Toggle Raw')
await page.waitForTimeout(500)
await expect(page.locator(RAW_EDITOR)).toBeVisible({ timeout: 5_000 })
// Switch to second note — raw mode should persist
await noteItems.nth(1).click()
await page.waitForTimeout(500)
await expect(page.locator(RAW_EDITOR)).toBeVisible({ timeout: 5_000 })
})
test('preview mode persists when switching notes', async ({ page }) => {
const noteItems = page.locator('[data-testid="note-list-container"] .cursor-pointer')
// Open first note
await noteItems.nth(0).click()
await page.waitForTimeout(500)
await expect(page.locator(BLOCKNOTE_EDITOR).first()).toBeVisible({ timeout: 5_000 })
// Toggle raw on then off to ensure preview is explicitly set
await openCommandPalette(page)
await executeCommand(page, 'Toggle Raw')
await page.waitForTimeout(300)
await openCommandPalette(page)
await executeCommand(page, 'Toggle Raw')
await page.waitForTimeout(300)
await expect(page.locator(BLOCKNOTE_EDITOR).first()).toBeVisible({ timeout: 5_000 })
// Switch to second note — should still be in preview mode
await noteItems.nth(1).click()
await page.waitForTimeout(500)
await expect(page.locator(BLOCKNOTE_EDITOR).first()).toBeVisible({ timeout: 5_000 })
await expect(page.locator(RAW_EDITOR)).not.toBeVisible()
})
})