import test from 'node:test'; import assert from 'node:assert/strict'; import { buildFirstRunSetupHtml, createHandleFirstRunSetupNavigationHandler, createMaybeFocusExistingFirstRunSetupWindowHandler, createOpenFirstRunSetupWindowHandler, parseFirstRunSetupSubmissionUrl, } from './first-run-setup-window'; import type { CommandLineLauncherSnapshot } from './command-line-launcher'; function createCommandLineLauncherSnapshot( overrides: Partial = {}, ): CommandLineLauncherSnapshot { return { supported: true, bun: { status: 'missing', commandPath: null, version: null, installMethod: 'official-script', installCommand: ['bash', '-lc', 'curl -fsSL https://bun.com/install | bash'], message: null, }, launcher: { status: 'not_installed', commandPath: null, installPath: '/home/tester/.local/bin/subminer', pathDir: '/home/tester/.local/bin', shadowedBy: null, message: null, }, ...overrides, }; } test('buildFirstRunSetupHtml renders macchiato setup actions and disabled finish state', () => { const html = buildFirstRunSetupHtml({ configReady: true, dictionaryCount: 0, canFinish: false, externalYomitanConfigured: false, pluginStatus: 'required', pluginInstallPathSummary: null, mpvExecutablePath: '', mpvExecutablePathStatus: 'blank', windowsMpvShortcuts: { supported: false, startMenuEnabled: true, desktopEnabled: true, startMenuInstalled: false, desktopInstalled: false, status: 'optional', }, commandLineLauncher: createCommandLineLauncherSnapshot(), message: 'Waiting for dictionaries', }); assert.match(html, /SubMiner setup/); assert.doesNotMatch(html, /Install legacy mpv plugin/); assert.doesNotMatch(html, /action=install-plugin/); assert.doesNotMatch(html, /mpv runtime plugin/); assert.doesNotMatch(html, /Bundled ready/); assert.doesNotMatch(html, /Managed mpv launches use the bundled runtime plugin\./); assert.match(html, /Open Yomitan Settings/); assert.match(html, /Open SubMiner Settings/); assert.match( html, /action=open-yomitan-settings'">Open Yomitan Settings<\/button>\s*