(userInput)
| 292 | */ |
| 293 | describe('full editor save/reload cycle', () => { |
| 294 | function simulateEditorCycle(userInput) { |
| 295 | // --- LOAD --- |
| 296 | // Step 1: escape XML tags to entities |
| 297 | const escaped = escapeXmlTags(userInput) |
| 298 | // Steps 2-3: marked creates text nodes with entities, then unescapeXmlEntities fixes them |
| 299 | const mockJson = { |
| 300 | type: 'doc', |
| 301 | content: [{ type: 'paragraph', content: [{ type: 'text', text: escaped }] }] |
| 302 | } |
| 303 | unescapeXmlEntities(mockJson) |
| 304 | // Step 4: verify editor would display proper angle brackets (no entities) |
| 305 | const editorDisplayText = mockJson.content[0].content[0].text |
| 306 | expect(editorDisplayText).not.toMatch(/<|>/) |
| 307 | |
| 308 | // --- SAVE --- |
| 309 | // Step 5: getMarkdown() outputs text node content as-is (no escaping) |
| 310 | const markdownOutput = editorDisplayText |
| 311 | // Step 6: unescape safety net |
| 312 | return unescapeXmlTags(markdownOutput) |
| 313 | } |
| 314 | |
| 315 | it('should preserve XML-tagged prompt', () => { |
| 316 | const userInput = '<question>What is the answer?</question>' |
no test coverage detected