From 81564025b485d824ecfdcb8e0699d98bfaaef939 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A5=BA=E5=AD=90w=20=28Yumechi=29?= <35571479+eternal-flame-AD@users.noreply.github.com> Date: Sun, 3 Nov 2024 04:22:54 -0600 Subject: [PATCH] test: Wait for some time for the client list to update (#722) Signed-off-by: eternal-flame-AD --- ui/src/tests/application.test.ts | 16 ++++++++-------- ui/src/tests/client.test.ts | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/ui/src/tests/application.test.ts b/ui/src/tests/application.test.ts index ee99b6b..00e1523 100644 --- a/ui/src/tests/application.test.ts +++ b/ui/src/tests/application.test.ts @@ -28,10 +28,10 @@ const hiddenToken = '•••••••••••••••'; const $table = selector.table('#app-table'); const $dialog = selector.form('#app-dialog'); -const hasApp = +const waitforApp = (name: string, description: string, row: number): (() => Promise) => async () => { - expect(await innerText(page, $table.cell(row, Col.Name))).toBe(name); + await waitForExists(page, $table.cell(row, Col.Name), name); expect(await innerText(page, $table.cell(row, Col.Token))).toBe(hiddenToken); expect(await innerText(page, $table.cell(row, Col.Description))).toBe(description); }; @@ -87,9 +87,9 @@ describe('Application', () => { await page.waitForSelector($table.row(3)); expect(await count(page, $table.rows())).toBe(3); }); - it('has server app', hasApp('server', '#1', 1)); - it('has desktop app', hasApp('desktop', '#2', 2)); - it('has raspberry app', hasApp('raspberry', '#3', 3)); + it('has server app', waitforApp('server', '#1', 1)); + it('has desktop app', waitforApp('desktop', '#2', 2)); + it('has raspberry app', waitforApp('raspberry', '#3', 3)); it('shows token', async () => { await page.click($table.cell(3, Col.Token, '.toggle-visibility')); const token = await innerText(page, $table.cell(3, Col.Token)); @@ -103,9 +103,9 @@ describe('Application', () => { await updateApp(3, {name: 'raspberry_pi', description: 'home_pi'})(); }); it('has updated application', async () => { - await hasApp('server_linux', '#1', 1)(); - await hasApp('desktop', 'kitchen_computer', 2)(); - await hasApp('raspberry_pi', 'home_pi', 3)(); + await waitforApp('server_linux', '#1', 1)(); + await waitforApp('desktop', 'kitchen_computer', 2)(); + await waitforApp('raspberry_pi', 'home_pi', 3)(); }); it('deletes application', async () => { await page.click($table.cell(2, Col.EditDelete, '.delete')); diff --git a/ui/src/tests/client.test.ts b/ui/src/tests/client.test.ts index 6f08b00..8c6be56 100644 --- a/ui/src/tests/client.test.ts +++ b/ui/src/tests/client.test.ts @@ -22,10 +22,10 @@ enum Col { Delete = 5, } -const hasClient = +const waitForClient = (name: string, row: number): (() => Promise) => async () => { - expect(await innerText(page, $table.cell(row, Col.Name))).toBe(name); + await waitForExists(page, $table.cell(row, Col.Name), name); }; const updateClient = @@ -79,7 +79,7 @@ describe('Client', () => { expect(await innerText(page, $table.cell(3, Col.Name))).toBe('desktop app'); }); it('updates client', updateClient(1, {name: 'firefox'})); - it('has updated client name', hasClient('firefox', 1)); + it('has updated client name', waitForClient('firefox', 1)); it('shows token', async () => { await page.click($table.cell(3, Col.Token, '.toggle-visibility')); expect((await innerText(page, $table.cell(3, Col.Token))).startsWith('C')).toBeTruthy();