import assert from 'node:assert/strict'; import { afterEach, beforeEach, describe, it } from 'node:test'; import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'; import { join } from 'node:path'; import { tmpdir } from 'node:os'; import { createLiveSessionStore } from '../skill/scripts/live/session-store.mjs'; import { prepareGenerationArtifact, publishGenerationArtifact, } from '../skill/scripts/live/generation-publisher.mjs'; import { inlineVueComponentAccept, nuxtViteFsModulePath, removeAllVueComponentSessions, scaffoldVueComponentSession, } from '../skill/scripts/live/vue-component.mjs'; describe('Nuxt Vue component preview', () => { let tmp; let source; beforeEach(() => { tmp = mkdtempSync(join(tmpdir(), 'impeccable-vue-component-')); source = join(tmp, 'app', 'pages', 'index.vue'); mkdirSync(join(tmp, 'app', 'pages'), { recursive: true }); writeFileSync(join(tmp, 'nuxt.config.ts'), 'export default defineNuxtConfig({ ssr: false });\n'); writeFileSync(source, [ '', '', '', '', ].join('\n')); }); afterEach(() => rmSync(tmp, { recursive: true, force: true })); it('stages real Vue SFCs without rewriting the active route', () => { const before = readFileSync(source, 'utf-8'); const result = scaffoldVueComponentSession({ id: 'vue12345', count: 3, sourceFile: 'app/pages/index.vue', sourceStartLine: 3, sourceEndLine: 3, originalLines: ['

Hello {{ user.name }}

'], cwd: tmp, }); assert.equal(readFileSync(source, 'utf-8'), before); assert.equal(result.manifest.previewMode, 'vue-component'); assert.equal(result.manifest.componentExtension, 'vue'); assert.match(result.manifestFile, /^app\/\.impeccable-live\/vue12345\/manifest\.json$/); const variant = readFileSync(join(tmp, result.componentDir, 'v1.vue'), 'utf-8'); assert.match(variant, /