Files
whats-that-music/desktop-client/tests/server.test.js
shadowdaoandClaude Sonnet 5.5 e49078ee03 Fix now-playing scraper, quit hang, tray icon, and tray race (v1.0.1)
- Read the track from the Media Session API, falling back to the legacy
  ytmusic-player-bar scrape. Current YT Music layouts render no player bar,
  so the API and tray stayed empty while music played. Artist is also clean
  now (no "• views • likes" suffix).
- Terminate connected WebSocket clients before closing the server. ws's
  close() waits for every client to disconnect, so quitting with an overlay
  open hung forever, leaving the window playing and the port bound.
- Replace the tray icon with a valid PNG (the old one had a bad IDAT CRC and
  decoded to an empty image) and test that its chunks are well formed.
- Create the tray before the window so early state updates are not dropped.
- Bump version to 1.0.1.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-04 11:37:38 -07:00

21 lines
711 B
JavaScript

const { test } = require('node:test');
const assert = require('node:assert');
const WebSocket = require('ws');
const { startServer } = require('../server');
test('stop() resolves even while an overlay WebSocket client is connected', async () => {
const handle = await startServer({ port: 9300 });
const client = new WebSocket(`ws://127.0.0.1:${handle.port}`);
client.on('error', () => {});
await new Promise((resolve) => client.on('open', resolve));
let timer;
const result = await Promise.race([
handle.stop().then(() => 'stopped'),
new Promise((resolve) => { timer = setTimeout(() => resolve('hung'), 2000); }),
]);
clearTimeout(timer);
assert.strictEqual(result, 'stopped');
});