MCPcopy Create free account
hub / github.com/FlowiseAI/Flowise / simulateEditorCycle

Function simulateEditorCycle

packages/ui/src/utils/xmlTagUtils.test.js:294–313  ·  view source on GitHub ↗
(userInput)

Source from the content-addressed store, hash-verified

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>'

Callers 1

Calls 3

escapeXmlTagsFunction · 0.90
unescapeXmlEntitiesFunction · 0.90
unescapeXmlTagsFunction · 0.90

Tested by

no test coverage detected