const test = require('node:test'); const assert = require('node:assert/strict'); const fs = require('node:fs'); const path = require('node:path'); const modal = fs.readFileSync(path.join(__dirname, '../js/core/service-modals.js'), 'utf8'); const flow = fs.readFileSync(path.join(__dirname, '../js/core/service-create.js'), 'utf8'); const bundle = fs.readFileSync(path.join(__dirname, '../dist/core.js'), 'utf8'); test('Add Service keeps Local and External tabs and adds Shipdeck fields', () => { for (const id of ['service-type-local', 'service-type-external', 'service-name-input', 'service-subdomain-input', 'service-port-input', 'service-source-url', 'service-sha256-input', 'service-git-token', 'service-ip-input', 'service-logo-input', 'shipdeckfile-preview']) { assert.match(modal, new RegExp(`id=["']${id}["']`), id); } assert.match(modal, /id="service-git-token"[^>]*type="password"|type="password"[^>]*id="service-git-token"/); }); test('Local deployment calls fleet route and renders lifecycle status', () => { assert.match(flow, /secureFetch\('\/api\/v1\/fleet\/from-git'/); assert.match(flow, /\/api\/v1\/fleet\/shipdeckfile\?id=/); assert.match(flow, /Building.*Deploying.*Live/s); assert.match(flow, /service-git-token'\)\.value = ''/); }); test('External service flow remains present and unchanged in the bundle', () => { assert.match(flow, /async function createExternalService/); assert.match(flow, /\/api\/v1\/site\/external/); assert.match(bundle, /\/api\/v1\/fleet\/from-git/); assert.match(bundle, /\/api\/v1\/site\/external/); });