From bb8fc1c5698852deca0f459ab780d1dfa37baba3 Mon Sep 17 00:00:00 2001 From: Steve Churchill Date: Fri, 27 Feb 2026 09:55:55 +0000 Subject: [PATCH] Add sub-pool sync waits and test fixes Add a subPoolAddIcon locator to PoolsPage and use it as an additional synchronization point after saving/editing pools (waitFor on the icon) to ensure the page has fully loaded. Add extra waitForAllProgressBarsToDisappear calls in several tests where needed. Update pools tests to fetch forecastThisMonth and branch assertions depending on whether forecast exceeds the organization limit (adjust colors and expected icons accordingly). Rename one test title for clarity and fix a comparison to use a 0.9 multiplier instead of division. Increase test timeouts from 90s to 120s in resources tests. Minor test stability and assertion improvements related to sub-pool limit editing and UI state. --- e2etests/pages/pools-page.ts | 5 +++++ e2etests/tests/pools-tests.spec.ts | 22 ++++++++++++++++------ e2etests/tests/resources-tests.spec.ts | 4 ++-- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/e2etests/pages/pools-page.ts b/e2etests/pages/pools-page.ts index 1cf67fcb9..d7d985168 100644 --- a/e2etests/pages/pools-page.ts +++ b/e2etests/pages/pools-page.ts @@ -54,6 +54,7 @@ export class PoolsPage extends BasePage { readonly poolActionsColumn: Locator; readonly poolExpandMoreIcon: Locator; readonly domainOutlinedIcon: Locator; + readonly subPoolAddIcon: Locator; readonly subPoolNameColumn: Locator; readonly subPoolColumn2: Locator; @@ -127,6 +128,7 @@ export class PoolsPage extends BasePage { this.poolColumn4 = this.table.locator('//td[4]'); this.column4TextSpan = this.poolColumn4.locator('xpath=/span'); this.poolActionsColumn = this.table.locator('//td').last(); + this.subPoolAddIcon = this.getByAnyTestId('AddCircleOutlineIcon', this.poolActionsColumn); this.subPoolNameColumn = this.table.locator('//tr[@data-test-id="row_0"]/following-sibling::tr/td[1]'); this.subPoolColumn2 = this.table.locator('//tr[@data-test-id="row_0"]/following-sibling::tr/td[2]'); @@ -303,6 +305,8 @@ export class PoolsPage extends BasePage { await this.sideModalSaveBtn.click(); await this.waitForAllProgressBarsToDisappear(); await this.waitForElementDetached(this.sideModal); + await this.waitForAllProgressBarsToDisappear(); + await this.subPoolAddIcon.first().waitFor({timeout: 10000}); // Wait for the sub-pool add icon to ensure the page has fully loaded after saving } /** @@ -330,6 +334,7 @@ export class PoolsPage extends BasePage { await this.waitForAllProgressBarsToDisappear(); await this.waitForElementDetached(this.sideModal); await this.waitForAllProgressBarsToDisappear(); + await this.subPoolAddIcon.first().waitFor({timeout: 10000}); } } diff --git a/e2etests/tests/pools-tests.spec.ts b/e2etests/tests/pools-tests.spec.ts index 619fc03c9..ee465d384 100644 --- a/e2etests/tests/pools-tests.spec.ts +++ b/e2etests/tests/pools-tests.spec.ts @@ -30,6 +30,7 @@ test.describe('[MPT-12743] Pools Tests', { tag: ['@ui', '@pools'] }, () => { if ((await poolsPage.getColumnBadgeText()) !== 'All') await poolsPage.selectAllColumns(); await poolsPage.toggleExpandPool(); await poolsPage.removeAllSubPoolMonthlyLimits(); + await poolsPage.waitForAllProgressBarsToDisappear(); await poolsPage.toggleExpandPool(); }); @@ -147,6 +148,7 @@ test.describe('[MPT-12743] Pools Tests', { tag: ['@ui', '@pools'] }, () => { if ((await poolsPage.getOrganizationLimitValue()) !== 0) { await poolsPage.editPoolMonthlyLimit(0); debugLog('Removed organization limit'); + await poolsPage.waitForAllProgressBarsToDisappear(); } }); @@ -197,6 +199,7 @@ test.describe('[MPT-12743] Pools Tests', { tag: ['@ui', '@pools'] }, () => { const expensesThisMonth = await poolsPage.getExpensesThisMonth(); const organizationLimit = Math.ceil(expensesThisMonth / 0.91); + const forecastThisMonth = await poolsPage.getForecastThisMonth(); await test.step('Set organization limit to an integer where the expenses is more than the 90% of the limit', async () => { await poolsPage.editPoolMonthlyLimit(organizationLimit); @@ -207,12 +210,18 @@ test.describe('[MPT-12743] Pools Tests', { tag: ['@ui', '@pools'] }, () => { await expect.soft(poolsPage.exceededLimitCard).toBeHidden(); expect.soft(await poolsPage.getColorFromElement(poolsPage.expensesCard)).toBe(poolsPage.warningColor); await expect.soft(poolsPage.expensesThisMonthWarningIcon).toBeVisible(); - expect.soft(await poolsPage.getColorFromElement(poolsPage.forecastCard)).toBe(poolsPage.errorColor || poolsPage.warningColor); - //TODO: Fix the line below as border colour is not always warning color, if at the end of the month. - // expect.soft(await poolsPage.poolTableRow.getAttribute('style')).toContain(`border-left: 4px solid ${poolsPage.warningColor};`); + if(forecastThisMonth > organizationLimit){ + expect.soft(await poolsPage.getColorFromElement(poolsPage.forecastCard)).toBe(poolsPage.errorColor); + await expect.soft(poolsPage.forecastThisMonthCancelIcon).toBeVisible(); + expect.soft(await poolsPage.poolTableRow.getAttribute('style')).toContain(`border-left: 4px solid ${poolsPage.warningColor};`); + expect.soft(await poolsPage.getColorFromElement(poolsPage.column4TextSpan)).toBe(poolsPage.warningColor); + } else { + expect.soft(await poolsPage.getColorFromElement(poolsPage.forecastCard)).toBe(poolsPage.warningColor); + await expect.soft(poolsPage.forecastThisMonthWarningIcon).toBeVisible(); + expect.soft(await poolsPage.getColorFromElement(poolsPage.column4TextSpan)).toBe(poolsPage.infoColor); + } expect.soft((await poolsPage.poolColumn2.textContent()).replace(/\D/g, '')).toBe(organizationLimit.toString()); expect.soft(await poolsPage.getColorFromElement(poolsPage.column3TextDiv)).toBe(poolsPage.successColor); - expect.soft(await poolsPage.getColorFromElement(poolsPage.column4TextSpan)).toBe(poolsPage.warningColor); }); }); @@ -249,7 +258,7 @@ test.describe('[MPT-12743] Pools Tests', { tag: ['@ui', '@pools'] }, () => { }); }); - test('[230917] Verify Organisation Limit functionality - limit set lower forecast', async ({ poolsPage }) => { + test('[230917] Verify Organisation Limit functionality - limit set lower than forecast', async ({ poolsPage }) => { const expensesThisMonth = await poolsPage.getExpensesThisMonth(); const forecastThisMonth = await poolsPage.getForecastThisMonth(); test.skip(expensesThisMonth <= 1, 'Skipping test as it requires expenses to be greater than 1'); @@ -263,7 +272,7 @@ test.describe('[MPT-12743] Pools Tests', { tag: ['@ui', '@pools'] }, () => { await test.step('Assert Pools page elements displayed correctly when limit set below forecast this month', async () => { await expect.soft(poolsPage.exceededLimitCard).toBeHidden(); expect.soft(await poolsPage.getColorFromElement(poolsPage.forecastCard)).toBe(poolsPage.errorColor); - if (expensesThisMonth >= Math.round(organizationLimit / 0.9)) { + if (expensesThisMonth >= Math.round(organizationLimit * 0.9)) { expect.soft(await poolsPage.getColorFromElement(poolsPage.expensesCard)).toBe(poolsPage.warningColor); await expect.soft(poolsPage.expensesThisMonthWarningIcon).toBeVisible(); } else { @@ -347,6 +356,7 @@ test.describe('[MPT-12743] Pools Tests', { tag: ['@ui', '@pools'] }, () => { await test.step('Assert pool is exceeded when sub-pool limit set below sub-pool expenses', async () => { subPoolLimit = Math.round(subPoolExpenses - 1); await poolsPage.editSubPoolMonthlyLimit(subPoolLimit, true, 1, true); + await poolsPage.waitForAllProgressBarsToDisappear(); expect.soft(await poolsPage.getExceededLimitValue()).toBe(1); expect.soft(await poolsPage.getColorFromElement(poolsPage.subPoolColumn3.first().locator('span'))).toBe(poolsPage.errorColor); expect.soft(await poolsPage.getColorFromElement(poolsPage.subPoolColumn4.first().locator('span'))).toBe(poolsPage.warningColor); diff --git a/e2etests/tests/resources-tests.spec.ts b/e2etests/tests/resources-tests.spec.ts index 42fc8a493..6cd722182 100644 --- a/e2etests/tests/resources-tests.spec.ts +++ b/e2etests/tests/resources-tests.spec.ts @@ -183,7 +183,7 @@ test.describe('[MPT-11957] Resources page tests', { tag: ['@ui', '@resources'] } }); test('[230788] Filtered Total expenses matches table itemised total', { tag: '@slow' }, async ({ resourcesPage }) => { - test.setTimeout(90000); + test.setTimeout(120000); let initialTotalExpensesValue: number; await test.step('Get unfiltered total expenses value', async () => { @@ -224,7 +224,7 @@ test.describe('[MPT-11957] Resources page tests', { tag: ['@ui', '@resources'] } '[230781] Total expenses matches table itemised total for date range set to last 7 days', { tag: '@slow' }, async ({ resourcesPage, datePicker }) => { - test.setTimeout(90000); + test.setTimeout(120000); await test.step('Get total expenses value for last 7 days', async () => { await datePicker.selectLast7DaysDateRange();