mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-09-26 21:41:48 +02:00
tests(e2e): fix e2e failures on Linux and Windows (#3642)
This commit is contained in:
@@ -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<FixtureServer> {
|
||||
const server = http.createServer((req, res) => {
|
||||
@@ -111,11 +113,12 @@ export function startFixtureServer(): Promise<FixtureServer> {
|
||||
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
|
||||
|
||||
@@ -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/)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -73,6 +73,7 @@ describePlugin('websocket', () => {
|
||||
const message = await new Promise<Message>((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<string, string>
|
||||
|
||||
Reference in New Issue
Block a user