import assert from 'node:assert/strict';
import fs from 'node:fs';
import path from 'node:path';
import test from 'node:test';
import { fileURLToPath } from 'node:url';

const here = path.dirname(fileURLToPath(import.meta.url));

function readBootWindow(): string {
  return fs.readFileSync(path.join(here, 'bootWindow.ts'), 'utf8');
}

void test('bootWindow: экран загрузки без preload, статус из main', () => {
  const src = readBootWindow();
  assert.ok(src.includes('createBootWindow'));
  assert.ok(src.includes('destroyBootWindow'));
  assert.ok(src.includes('setBootWindowStatus'));
  assert.ok(src.includes('waitForBootWindowReady'));
  assert.ok(src.includes('executeJavaScript'));
});

void test('createWindows: отложенный показ редактора для boot', () => {
  const src = fs.readFileSync(path.join(here, 'createWindows.ts'), 'utf8');
  assert.ok(src.includes('deferVisibility'));
  assert.ok(src.includes('createEditorWindowDeferred'));
  assert.ok(src.includes('waitForEditorWindowReady'));
  assert.ok(src.includes('getBootSplashWindow'));
});
