mirror of
https://github.com/stablyai/orca.git
synced 2026-09-22 08:02:28 +00:00
test(editor): cover saved preview and destination repairs
This commit is contained in:
@@ -95,6 +95,7 @@ function openFile(
|
||||
|
||||
function renderEditPath({
|
||||
content,
|
||||
savedContent = '# Saved',
|
||||
language = 'markdown',
|
||||
viewMode = 'rich',
|
||||
mode = 'edit',
|
||||
@@ -102,6 +103,7 @@ function renderEditPath({
|
||||
onOpenMarkdownPreview
|
||||
}: {
|
||||
content: string
|
||||
savedContent?: string
|
||||
language?: 'markdown' | 'typescript'
|
||||
viewMode?: 'source' | 'rich' | 'preview'
|
||||
mode?: 'edit' | 'markdown-preview'
|
||||
@@ -110,7 +112,7 @@ function renderEditPath({
|
||||
}) {
|
||||
const activeFile = openFile(language, mode)
|
||||
const fileContents = {
|
||||
[activeFile.id]: { content: '# Saved', isBinary: false }
|
||||
[activeFile.id]: { content: savedContent, isBinary: false }
|
||||
}
|
||||
const editorDrafts = { [activeFile.id]: content }
|
||||
const model = getEditorPanelRenderModel({
|
||||
@@ -310,7 +312,10 @@ describe('inline Markdown render classification', () => {
|
||||
})
|
||||
|
||||
it('offers the Preview toggle once rich mode falls back to source for this content', () => {
|
||||
const fallback = renderEditPath({ content: '[reference]: https://example.com' })
|
||||
const fallback = renderEditPath({
|
||||
content: '[reference]: https://example.com',
|
||||
savedContent: '[reference]: https://example.com'
|
||||
})
|
||||
expect(fallback.model.availableEditorToggleModes).toEqual([
|
||||
'source',
|
||||
'rich',
|
||||
@@ -326,6 +331,7 @@ describe('inline Markdown render classification', () => {
|
||||
const content = '[reference]: https://example.com'
|
||||
const result = renderEditPath({
|
||||
content,
|
||||
savedContent: content,
|
||||
viewMode: 'source',
|
||||
markdownRichModeFaultedContent: { [openFile().id]: content }
|
||||
})
|
||||
|
||||
@@ -841,3 +841,17 @@ it('preserves code spacing inside a table across repeated saves', () => {
|
||||
expect(once).toContain('`a b`')
|
||||
expect(roundTripMarkdown(once)).toBe(once)
|
||||
})
|
||||
|
||||
it('retains an unchanged raw destination while repairing nearby attributes', () => {
|
||||
const source = '[a](b\\)c) and '
|
||||
expect(roundTripMarkdown(source)).toBe(source)
|
||||
})
|
||||
|
||||
it('encodes spaces in edited destinations', () => {
|
||||
expect(markdownAfterDestinationEdit('[a](old)', 'link', 'docs/My File.md')).toBe(
|
||||
'[a](docs/My%20File.md)'
|
||||
)
|
||||
expect(markdownAfterDestinationEdit('', 'image', 'My Image.png')).toBe(
|
||||
''
|
||||
)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user