From c43911a75e8a8a04f89ea081cefba7903f1b88e3 Mon Sep 17 00:00:00 2001 From: George Raduta Date: Tue, 19 May 2026 16:13:29 +0200 Subject: [PATCH] Use element ID instead of path in element page for test robustness --- .../test/public/page-new-environment-mocha.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Control/test/public/page-new-environment-mocha.js b/Control/test/public/page-new-environment-mocha.js index 42105d1f0..90ee7e88b 100644 --- a/Control/test/public/page-new-environment-mocha.js +++ b/Control/test/public/page-new-environment-mocha.js @@ -390,21 +390,29 @@ describe('`pageNewEnvironment` test-suite', async () => { }); it('should not select a detector that is not locked', async () => { - await page.evaluate(() => document.querySelector('.m1 > div:nth-child(1) > div > a:nth-child(2)').click()); // second element is for detector, first for lock + await page.evaluate(() => document.querySelector('#detectorSelectionButtonForMID').click()); const selectedDet = await page.evaluate(() => window.model.workflow.flpSelection.selectedDetectors); assert.ok(selectedDet.length == 0, 'Detector selected without lock'); }); it('should successfully lock, select a detector and request a list of hosts for that detector', async () => { - await page.locator('.m1 > div:nth-child(1) > div > div:nth-child(1)') - .setTimeout(1000) + await page.waitForSelector('#detectorLockButtonForMID', {timeout: 5000}); + await page.locator('#detectorLockButtonForMID') + .setTimeout(5000) .click(); - await page.locator('.m1 > div:nth-child(1) > div > a:nth-child(2)') - .setTimeout(1000) + await page.waitForFunction(() => { + const detectorButton = document.querySelector('#detectorSelectionButtonForMID'); + return detectorButton && !detectorButton.classList.contains('disabled-item'); + }, {timeout: 5000}); + + await page.locator('#detectorSelectionButtonForMID') + .setTimeout(5000) .click(); + await page.waitForFunction(() => window.model.workflow.flpSelection.selectedDetectors.includes('MID'), {timeout: 5000}); + const selectedDet = await page.evaluate(() => window.model.workflow.flpSelection.selectedDetectors); assert.deepStrictEqual(selectedDet, ['MID'], 'Missing detector selection'); });