From 6884ea0731a77ef96118a520d76cbfd3f3c3bd0f Mon Sep 17 00:00:00 2001 From: Rado Date: Mon, 30 Sep 2024 19:26:46 +0300 Subject: [PATCH 1/2] test: only use the Database select filter if more than 7 dbs Signed-off-by: Rado --- e2e/instances.spec.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/e2e/instances.spec.ts b/e2e/instances.spec.ts index f8731ae6..ec6f67dd 100644 --- a/e2e/instances.spec.ts +++ b/e2e/instances.spec.ts @@ -35,7 +35,12 @@ test.describe('new instance', () => { await page.getByRole('textbox', { name: 'Description' }).fill('This is an e2e test instance.') await page.getByTestId('dhis2-uiwidgets-singleselectfield').filter({ hasText: 'Database' }).getByTestId('dhis2-uicore-select-input').click() - await page.locator('#filter').fill(dbFileName) + + // If there are more than 7 databases uploaded, we need to interact with the conditional #filter field. + const numberOfDatabases = await page.$$eval('[data-test="dhis2-uicore-singleselectoption"]', (options) => options.length) + if (numberOfDatabases > 7) { + await page.locator('#filter').fill(dbFileName) + } await page.getByText(dbFileName).click() await expect(page.getByRole('button', { name: 'Create instance' })).toBeEnabled() From 0db0c6690b6a5d57a11107732c2e940b564b0a59 Mon Sep 17 00:00:00 2001 From: Rado Date: Tue, 1 Oct 2024 08:58:16 +0300 Subject: [PATCH 2/2] chore: don't use eval for counting DB select options Signed-off-by: Rado --- e2e/instances.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/instances.spec.ts b/e2e/instances.spec.ts index ec6f67dd..b82b0e9b 100644 --- a/e2e/instances.spec.ts +++ b/e2e/instances.spec.ts @@ -37,7 +37,7 @@ test.describe('new instance', () => { await page.getByTestId('dhis2-uiwidgets-singleselectfield').filter({ hasText: 'Database' }).getByTestId('dhis2-uicore-select-input').click() // If there are more than 7 databases uploaded, we need to interact with the conditional #filter field. - const numberOfDatabases = await page.$$eval('[data-test="dhis2-uicore-singleselectoption"]', (options) => options.length) + const numberOfDatabases = await page.getByTestId('dhis2-uicore-singleselectoption').count() if (numberOfDatabases > 7) { await page.locator('#filter').fill(dbFileName) }