const assert = require('assert'); const fs = require('fs'); const path = require('path'); const root = path.resolve(__dirname, '..'); const canvasHtml = fs.readFileSync(path.join(root, 'frontend', 'canvas.html'), 'utf8'); assert( canvasHtml.includes('buildInstancesYaml'), 'canvas.html should use buildInstancesYaml for layout instance export' ); assert( canvasHtml.includes('buildCanvasPortsYaml(activePage.nodes)'), 'canvas.html should export ports from active canvas port nodes' ); assert( canvasHtml.includes('buildPageComponentPorts(page.port, page.nodes)'), 'canvas library entries should expose ports from their page-port data' ); assert( !canvasHtml.includes("activePage.nodes.filter(n => n.type === 'rotatableNode' && n.data?.type === 'composite')"), 'project layout export should not filter out regular PDK instances' ); assert( canvasHtml.includes('Elements: {'), 'library tree should add an Elements folder' ); assert( canvasHtml.includes("__name__: 'Port'") && canvasHtml.includes("__name__: 'Anchor'"), 'Elements folder should expose Port and Anchor as separate virtual components' ); assert( canvasHtml.includes('const isElementComponentGrid = isComponentGrid && entries.every(([, childData]) => childData.__element__ === true);'), 'Elements folder should bypass category-card grouping and render separate virtual component leaves' ); assert( canvasHtml.includes('element-card-icon port-icon') && canvasHtml.includes('element-card-icon anchor-icon'), 'virtual element cards should render distinct generated icons for Port and Anchor' ); assert( canvasHtml.includes('const selectedIsVirtualElement = selectedNode?.data?.elementType ==='), 'right inspector should classify virtual elements separately from PDK/forge components' ); assert( canvasHtml.includes('const canChooseComponent = !selectedIsVirtualElement && availableComponentsFromNode.length > 0;'), 'virtual elements should not show PDK or generate_with_forge component selection' ); assert( canvasHtml.includes('buildElementsYaml(activePage.nodes)'), 'canvas layout export should include an elements section' ); assert( !canvasHtml.includes("activePage.nodes.filter(n => n.selected && n.id !== 'page-port')"), 'copy/delete should not exclude port nodes' );