From d8e0975f974f94fb1b674ec42ba69358970bf245 Mon Sep 17 00:00:00 2001 From: SamTV12345 <40429738+SamTV12345@users.noreply.github.com> Date: Mon, 11 Mar 2024 08:00:16 +0100 Subject: [PATCH] Fixed admin tests * Increased timeout. * Wait for disconnect only if no admintest. --- src/node/hooks/express.ts | 2 +- src/node/hooks/express/socketio.ts | 2 +- src/tests/frontend-new/admin-spec/adminsettings.spec.ts | 1 + src/tests/frontend-new/admin-spec/adminupdateplugins.spec.ts | 1 + 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/node/hooks/express.ts b/src/node/hooks/express.ts index b273887d6..29da71ac3 100644 --- a/src/node/hooks/express.ts +++ b/src/node/hooks/express.ts @@ -46,7 +46,7 @@ const closeServer = async () => { for (const socket of sockets) socket.destroy(new Error('HTTP server is closing')); }, 5000); let lastLogged = 0; - while (sockets.size > 0) { + while (sockets.size > 0 && !settings.enableAdminUITests) { if (Date.now() - lastLogged > 1000) { // Rate limit to avoid filling logs. logger.info(`Waiting for ${sockets.size} HTTP clients to disconnect...`); lastLogged = Date.now(); diff --git a/src/node/hooks/express/socketio.ts b/src/node/hooks/express/socketio.ts index e64a16847..bbdec1c1c 100644 --- a/src/node/hooks/express/socketio.ts +++ b/src/node/hooks/express/socketio.ts @@ -38,7 +38,7 @@ export const expressCloseServer = async () => { // not appear to be a way to get all clients across all namespaces without tracking them // ourselves, so that is what we do. let lastLogged = 0; - while (sockets.size > 0) { + while (sockets.size > 0 && !settings.enableAdminUITests) { if (Date.now() - lastLogged > 1000) { // Rate limit to avoid filling logs. logger.info(`Waiting for ${sockets.size} socket.io clients to disconnect...`); lastLogged = Date.now(); diff --git a/src/tests/frontend-new/admin-spec/adminsettings.spec.ts b/src/tests/frontend-new/admin-spec/adminsettings.spec.ts index 8794eef90..ad3a0c441 100644 --- a/src/tests/frontend-new/admin-spec/adminsettings.spec.ts +++ b/src/tests/frontend-new/admin-spec/adminsettings.spec.ts @@ -55,5 +55,6 @@ test.describe('admin settings',()=> { const settings = page.locator('.settings'); await expect(settings).not.toBeEmpty(); await page.waitForSelector('.menu') + await page.waitForTimeout(5000) }); }) diff --git a/src/tests/frontend-new/admin-spec/adminupdateplugins.spec.ts b/src/tests/frontend-new/admin-spec/adminupdateplugins.spec.ts index 591448636..c1121d41b 100644 --- a/src/tests/frontend-new/admin-spec/adminupdateplugins.spec.ts +++ b/src/tests/frontend-new/admin-spec/adminupdateplugins.spec.ts @@ -66,6 +66,7 @@ test.describe('Plugins page', ()=> { await expect(installedPluginsRows).toHaveCount(1, { timeout: 15000 }) + await page.waitForTimeout(5000) }) })