Revert "test: simplify main entrypoint setup"

This reverts commit 4ad32faa7b.
This commit is contained in:
lucaronin
2026-04-23 22:14:11 +02:00
parent 4ad32faa7b
commit 4ed0289989
2 changed files with 9 additions and 69 deletions

View File

@@ -1,8 +1,6 @@
import { describe, expect, it, vi, beforeAll, beforeEach } from 'vitest'
import { describe, expect, it, vi, beforeEach } from 'vitest'
import { createElement, type ReactNode } from 'react'
const MAIN_ENTRYPOINT_TEST_TIMEOUT_MS = 30_000
type ReactRootErrorInfo = { componentStack?: string }
type ReactRootOptions = {
onCaughtError?: (error: unknown, errorInfo: ReactRootErrorInfo) => void
@@ -54,17 +52,15 @@ function rootOptions(): ReactRootOptions {
}
describe('main entrypoint', () => {
beforeAll(async () => {
beforeEach(() => {
vi.resetModules()
vi.clearAllMocks()
document.body.innerHTML = '<div id="root"></div>'
await importEntrypoint()
}, MAIN_ENTRYPOINT_TEST_TIMEOUT_MS)
beforeEach(() => {
mocks.sentryHandler.mockClear()
})
it('captures React root errors through Sentry with component stack context', () => {
it('captures React root errors through Sentry with component stack context', async () => {
await importEntrypoint()
expect(mocks.reactErrorHandler).toHaveBeenCalledOnce()
expect(mocks.createRoot).toHaveBeenCalledWith(
document.getElementById('root'),
@@ -81,7 +77,9 @@ describe('main entrypoint', () => {
expect(mocks.sentryHandler).toHaveBeenCalledWith(error, { componentStack: '\n in App' })
})
it('normalizes missing React component stacks before handing errors to Sentry', () => {
it('normalizes missing React component stacks before handing errors to Sentry', async () => {
await importEntrypoint()
const error = new Error('recoverable render error')
rootOptions().onRecoverableError?.(error, {})

View File

@@ -1,58 +0,0 @@
import { test, expect, type Page } from '@playwright/test'
import { executeCommand, openCommandPalette } from './helpers'
const AI_AGENTS_ONBOARDING_DISMISSED_KEY = 'tolaria:ai-agents-onboarding-dismissed'
const CLAUDE_CODE_ONBOARDING_DISMISSED_KEY = 'tolaria:claude-code-onboarding-dismissed'
async function createNote(page: Page) {
await page.waitForSelector('[data-testid="sidebar-top-nav"]', { timeout: 10000 })
await page.locator('button[title="Create new note"]').first().click()
await expect(page.getByTestId('breadcrumb-filename-trigger')).toContainText(/untitled-note-\d+/i, {
timeout: 5_000,
})
await expect(page.locator('.bn-editor')).toBeVisible({ timeout: 5_000 })
await page.waitForTimeout(500)
await page.keyboard.press('Enter')
}
async function toggleRawEditor(page: Page) {
await openCommandPalette(page)
await executeCommand(page, 'Toggle Raw')
}
async function getRawEditorContent(page: Page) {
return page.locator('[data-testid="raw-editor-codemirror"]').evaluate((element) => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const view = (element as any).__cmView
return view?.state?.doc?.toString?.() ?? element.textContent ?? ''
})
}
test('typing keeps arrow ligatures aligned between rich and raw editors', async ({ page }) => {
await page.setViewportSize({ width: 1600, height: 900 })
await page.addInitScript(({ aiAgentsKey, claudeKey }: { aiAgentsKey: string; claudeKey: string }) => {
localStorage.clear()
localStorage.setItem(aiAgentsKey, '1')
localStorage.setItem(claudeKey, '1')
}, {
aiAgentsKey: AI_AGENTS_ONBOARDING_DISMISSED_KEY,
claudeKey: CLAUDE_CODE_ONBOARDING_DISMISSED_KEY,
})
await page.goto(process.env.BASE_URL ?? 'http://localhost:5201', { waitUntil: 'domcontentloaded' })
await createNote(page)
await page.keyboard.type('-> <- <-> \\<->')
await expect(page.locator('.bn-editor')).toContainText('→ ← ↔ <->', { timeout: 5_000 })
await toggleRawEditor(page)
await expect(page.locator('[data-testid="raw-editor-codemirror"]')).toBeVisible({ timeout: 5_000 })
await expect.poll(() => getRawEditorContent(page)).toContain('→ ← ↔ <->')
await page.locator('[data-testid="raw-editor-codemirror"]').click()
await page.keyboard.type('\n-> <- <-> \\<->')
await expect.poll(() => getRawEditorContent(page)).toMatch(/ <->\s+ <->/u)
await toggleRawEditor(page)
await expect(page.locator('.bn-editor')).toContainText('→ ← ↔ <->', { timeout: 5_000 })
})