import { expect, tap } from '@git.zone/tstest/tapbundle';
import { Lw12wifiIntegration, lw12wifiProfile } from '../../ts/integrations/lw12wifi/index.js';

tap.test('documents LW-12 UDP blocker and avoids advertised native control', async () => {
  const metadata = lw12wifiProfile.metadata as {
    runtime: { blocker: string; controls: boolean };
    localApi: { explicitUnsupported: string[] };
  };

  expect(lw12wifiProfile.status).toEqual('read-only-runtime');
  expect(lw12wifiProfile.controlServices).toEqual([]);
  expect(metadata.runtime.controls).toBeFalse();
  expect(metadata.runtime.blocker.includes('binary UDP datagrams')).toBeTrue();
  expect(metadata.localApi.explicitUnsupported.some((itemArg) => itemArg.includes('not an HTTP/TCP/TLS/file protocol'))).toBeTrue();

  const runtime = await new Lw12wifiIntegration().setup({ name: 'LW-12' }, {});
  const result = await runtime.callService?.({ domain: 'lw12wifi', service: 'turn_on', target: {} });
  expect(result?.success).toBeFalse();
  expect(result?.error?.includes('requires an injected client.execute() or commandExecutor')).toBeTrue();
  await runtime.destroy();
});

export default tap.start();
