test(editor): skip source-mode HTML validation probes

This commit is contained in:
Neil
2026-09-19 00:56:39 -07:00
parent cb0e9336fc
commit ebbf1d11a2
@@ -1,10 +1,14 @@
import { describe, expect, it } from 'vitest'
import { afterEach, describe, expect, it, vi } from 'vitest'
import * as htmlValidation from './markdown-rich-html-validation'
import * as roundTrip from './markdown-round-trip'
import type { OpenFile } from '@/store/slices/editor'
import { RICH_MARKDOWN_MAX_SIZE_BYTES } from '../../../../shared/constants'
import type { GitStatusEntry } from '../../../../shared/git-status-types'
import type { FileContent } from './editor-panel-content-types'
import { getEditorPanelRenderModel } from './editor-panel-render-model'
afterEach(() => vi.restoreAllMocks())
function markdownFile(overrides: Partial<OpenFile> = {}): OpenFile {
return {
id: '/repo/README.md',
@@ -63,6 +67,23 @@ function htmlFile(overrides: Partial<OpenFile> = {}): OpenFile {
}
describe('getEditorPanelRenderModel rich-mode fallback toggle', () => {
it('skips HTML validation round trips for source mode', () => {
const htmlValidationSpy = vi.spyOn(htmlValidation, 'getRichMarkdownHtmlValidationOutput')
const roundTripSpy = vi.spyOn(roundTrip, 'getRichMarkdownRoundTripOutput')
const model = renderModel({
markdownViewMode: { '/repo/README.md': 'source' },
fileContents: {
'/repo/README.md': textContent({ content: '<span>source-mode-only</span>\n' })
}
})
expect(model.mdViewMode).toBe('source')
expect(model.inlineMarkdownRenderState?.renderMode).toBe('source')
expect(htmlValidationSpy).not.toHaveBeenCalled()
expect(roundTripSpy).not.toHaveBeenCalled()
})
it('offers Preview once rich mode falls back for this content', () => {
const model = renderModel({
fileContents: {