built-worker.e2e.ts 1.6 KB

12345678910111213141516171819202122232425262728293031323334
  1. /**
  2. * Keyless built-artifact guard (the `dsh-workflow-worker-thread` built-worker
  3. * shape): plain `node` runs `lib/worker.cjs` and the bundle reaches its
  4. * real koffi requires. POSIX hosts prove the load path end to end through
  5. * the deterministic ole32 rejection; win32 skips (a real dialog would
  6. * open), where the win32-only smoke in win32-dialog.spec.ts covers the
  7. * source plane instead. Skips until a build produces the artifact.
  8. */
  9. import { spawn } from 'node:child_process'
  10. import { existsSync } from 'node:fs'
  11. import { fileURLToPath } from 'node:url'
  12. import { describe, expect, it } from 'vitest'
  13. import type { Win32DialogWorkerMessage } from '../src/win32-dialog-worker.ts'
  14. const builtWorker = fileURLToPath(new URL('../lib/worker.cjs', import.meta.url))
  15. describe.skipIf(!existsSync(builtWorker) || process.platform === 'win32')('built dialog worker (lib/worker.cjs)', () => {
  16. it('loads under plain node and reports the native-surface failure', async () => {
  17. const message = await new Promise<Win32DialogWorkerMessage>((resolve, reject) => {
  18. const child = spawn(process.execPath, [builtWorker], {
  19. env: { ...process.env, DSH_DIALOG_TITLE: 'Built-artifact guard' },
  20. stdio: ['ignore', 'inherit', 'inherit', 'ipc'],
  21. })
  22. child.on('message', resolve)
  23. child.on('error', reject)
  24. child.on('exit', (code) => {
  25. reject(new Error(`worker exited (${code}) before reporting`))
  26. })
  27. })
  28. expect(message.kind).toBe('error')
  29. expect((message as { kind: 'error'; message: string }).message).toMatch(/ole32|koffi/i)
  30. }, 30_000)
  31. })