From 253b30d2de70bd15dd9579b1bf722f75f0faa12e Mon Sep 17 00:00:00 2001 From: MartinBraquet Date: Mon, 25 May 2026 15:43:55 +0200 Subject: [PATCH] Refactor sign-in test to improve profile count validation and asynchronous handling --- tests/e2e/web/specs/signIn.spec.ts | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/tests/e2e/web/specs/signIn.spec.ts b/tests/e2e/web/specs/signIn.spec.ts index a94e89c3..0b596b2d 100644 --- a/tests/e2e/web/specs/signIn.spec.ts +++ b/tests/e2e/web/specs/signIn.spec.ts @@ -1,5 +1,3 @@ -import {sleep} from 'common/util/time' - import {expect, test} from '../fixtures/signInFixture' test.describe('when given valid input', () => { @@ -19,19 +17,20 @@ test.describe('when given valid input', () => { await app.signinWithEmail(account) await app.home.clickPeopleLink() await app.people.getProfileInfo() + const totalProfiles = await app.people.profileCountLocator.textContent() + expect(totalProfiles).toBeTruthy() + const totalCount = Number.parseInt(totalProfiles!, 10) + expect(Number.isNaN(totalCount)).toBe(false) + await app.people.setConnectionTypeFilter(['Collaboration', 'collaboration']) - const filteredProfiles = await app.people.profileCountLocator.textContent() - - expect(totalProfiles).toBeTruthy() - expect(filteredProfiles).toBeTruthy() - const totalCount = Number.parseInt(totalProfiles!, 10) - const filteredCount = Number.parseInt(filteredProfiles!, 10) - expect(Number.isNaN(totalCount)).toBe(false) - expect(Number.isNaN(filteredCount)).toBe(false) - await sleep(1000) - await expect(filteredCount).not.toEqual(totalCount) + // The count updates asynchronously after the filter is applied, so poll until it changes. + await expect + .poll(async () => + Number.parseInt((await app.people.profileCountLocator.textContent())!, 10), + ) + .not.toEqual(totalCount) }) })