diff --git a/packages/api-e2e/test/helpers/server.ts b/packages/api-e2e/test/helpers/server.ts index 204f74107..230d92df3 100644 --- a/packages/api-e2e/test/helpers/server.ts +++ b/packages/api-e2e/test/helpers/server.ts @@ -49,7 +49,9 @@ export interface FixtureServer { * - `ws /ws` — a WebSocket echo endpoint: text and binary messages are sent * back as-is, and {@link WEBSOCKET_CLOSE_REQUEST} makes the server close the * connection with {@link WEBSOCKET_CLOSE_CODE}. On `/ws/headers` the server - * first sends the upgrade request's headers as a JSON text message. + * answers the first message with the upgrade request's headers as a JSON + * text message instead (not sent on connect, where it could arrive before + * the client attached a listener). */ export function startFixtureServer(): Promise { const server = http.createServer((req, res) => { @@ -111,11 +113,12 @@ export function startFixtureServer(): Promise { return } wss.handleUpgrade(req, socket, head, (ws) => { - if (pathname === '/ws/headers') { - ws.send(JSON.stringify(req.headers)) - } + let sendHeaders = pathname === '/ws/headers' ws.on('message', (data, isBinary) => { - if ( + if (sendHeaders) { + sendHeaders = false + ws.send(JSON.stringify(req.headers)) + } else if ( !isBinary && Buffer.isBuffer(data) && data.toString('utf8') === WEBSOCKET_CLOSE_REQUEST diff --git a/packages/api-e2e/test/specs/opener.spec.ts b/packages/api-e2e/test/specs/opener.spec.ts index d5e1b733c..6e2265eaa 100644 --- a/packages/api-e2e/test/specs/opener.spec.ts +++ b/packages/api-e2e/test/specs/opener.spec.ts @@ -41,6 +41,7 @@ describePlugin('opener', () => { await api.path.join(await api.path.appDataDir(), 'does-not-exist-e2e') ) ) - expect(message).toMatch(/os error 2/) + // the `std::io` NotFound message on Unix, the shell path lookup's on Windows + expect(message).toMatch(/os error 2|path doesn't exist/) }) }) diff --git a/packages/api-e2e/test/specs/positioner.spec.ts b/packages/api-e2e/test/specs/positioner.spec.ts index f2cfadf9f..d0e7986d3 100644 --- a/packages/api-e2e/test/specs/positioner.spec.ts +++ b/packages/api-e2e/test/specs/positioner.spec.ts @@ -101,13 +101,21 @@ describePlugin('positioner', { desktopOnly: true }, () => { ) itWm('tray positions are relative to the reported tray rect', async () => { - // a tray "icon" in the middle of the window's monitor, far from any edge, - // so neither the OS-specific flips nor the constraint kick in + // The example's 1000x800 window barely fits the CI screens (1024x768 on + // Windows, 1280x1024 on Xvfb), so wherever the tray "icon" is it sticks out + // of the monitor and `moveWindowConstrained` clamps it back on both axes. + // The window is shrunk and the tray placed near the monitor's top left + // corner, far enough from the edges that both positions keep the window on + // screen and neither the OS-specific flips nor the constraint kick in. const tray = await tauri(async (api) => { + const win = api.window.getCurrentWindow() + await win.setSize(new api.dpi.LogicalSize(600, 400)) + await new Promise((resolve) => setTimeout(resolve, 500)) const monitor = await api.window.currentMonitor() + const size = await win.outerSize() const rect = { - x: monitor!.position.x + Math.trunc(monitor!.size.width / 2), - y: monitor!.position.y + Math.trunc(monitor!.size.height / 2), + x: monitor!.position.x + Math.trunc(size.width / 2) + 50, + y: monitor!.position.y + 50, width: 20, height: 20 } diff --git a/packages/api-e2e/test/specs/websocket.spec.ts b/packages/api-e2e/test/specs/websocket.spec.ts index cb01f55a7..474ad4ee0 100644 --- a/packages/api-e2e/test/specs/websocket.spec.ts +++ b/packages/api-e2e/test/specs/websocket.spec.ts @@ -73,6 +73,7 @@ describePlugin('websocket', () => { const message = await new Promise((resolve, reject) => { setTimeout(() => reject(new Error('headers not received')), 5000) ws.addListener(resolve) + ws.send('headers').catch(reject) }) await ws.disconnect() return JSON.parse(message.data as string) as Record