From 920c9c2d127bba3b22eff852e38148983bb42228 Mon Sep 17 00:00:00 2001 From: Shaun Date: Thu, 29 Aug 2024 06:27:17 -0400 Subject: [PATCH] Clean up the tests --- test/e2e/specs/monitor-form.spec.js | 46 ++++++++++------------------- 1 file changed, 15 insertions(+), 31 deletions(-) diff --git a/test/e2e/specs/monitor-form.spec.js b/test/e2e/specs/monitor-form.spec.js index 40ba4813ba..1d1b5ef27f 100644 --- a/test/e2e/specs/monitor-form.spec.js +++ b/test/e2e/specs/monitor-form.spec.js @@ -19,28 +19,23 @@ test.describe("Monitor Form", () => { const selectedValue = await monitorTypeSelect.evaluate(select => select.value); expect(selectedValue).toBe("dns"); - const addConditionButton = page.getByTestId("add-condition-button"); - await expect(addConditionButton).toBeVisible(); - - // Add 2 conditions & ensure they show in the UI - await addConditionButton.click(); - await addConditionButton.click(); + // Add Conditions & verify: + await page.getByTestId("add-condition-button").click(); + await page.getByTestId("add-condition-button").click(); expect(await page.getByTestId("condition").count()).toEqual(2); - // Add a condition group & ensure it shows in the UI - const addGroupButton = page.getByTestId("add-group-button"); - await expect(addGroupButton).toBeVisible(); - await addGroupButton.click(); + // Add a Condition Group & verify: + await page.getByTestId("add-group-button").click(); expect(await page.getByTestId("condition-group").count()).toEqual(1); expect(await page.getByTestId("condition").count()).toEqual(3); // 2 solo conditions + 1 condition in group await screenshot(testInfo, page); - // Remove a condition & ensure it dissappears: + // Remove a condition & verify: await page.getByTestId("remove-condition").first().click(); expect(await page.getByTestId("condition").count()).toEqual(2); // 1 solo condition + 1 condition in group - // Remove the condition group & ensure it dissappears: + // Remove a condition group & verify: await page.getByTestId("remove-condition-group").first().click(); expect(await page.getByTestId("condition-group").count()).toEqual(0); @@ -68,21 +63,15 @@ test.describe("Monitor Form", () => { await resolveTypeSelect.click(); await resolveTypeSelect.getByRole("option", { name: "NS" }).click(); - const addConditionButton = page.getByTestId("add-condition-button"); - await expect(addConditionButton).toBeVisible(); - - await addConditionButton.click(); - await addConditionButton.click(); - - expect(await page.getByTestId("condition").count()).toBeGreaterThan(0); + await page.getByTestId("add-condition-button").click(); + await page.getByTestId("add-condition-button").click(); + expect(await page.getByTestId("condition").count()).toEqual(2); await page.getByTestId("condition-value").nth(0).fill("a.iana-servers.net"); - await page.getByTestId("condition-value").nth(1).fill("b.iana-servers.net"); await page.getByTestId("condition-and-or").nth(0).selectOption("or"); + await page.getByTestId("condition-value").nth(1).fill("b.iana-servers.net"); await screenshot(testInfo, page); - const saveButton = page.getByTestId("save-button"); - await saveButton.click(); - + await page.getByTestId("save-button").click(); await page.waitForURL("/dashboard/*"); // wait for the monitor to be created await expect(page.getByTestId("monitor-status")).toHaveText("up", { ignoreCase: true }); await screenshot(testInfo, page); @@ -109,17 +98,12 @@ test.describe("Monitor Form", () => { await resolveTypeSelect.click(); await resolveTypeSelect.getByRole("option", { name: "NS" }).click(); - const addConditionButton = page.getByTestId("add-condition-button"); - await expect(addConditionButton).toBeVisible(); - - await addConditionButton.click(); - expect(await page.getByTestId("condition").count()).toBeGreaterThan(0); + await page.getByTestId("add-condition-button").click(); + expect(await page.getByTestId("condition").count()).toEqual(1); await page.getByTestId("condition-value").nth(0).fill("definitely-not.net"); await screenshot(testInfo, page); - const saveButton = page.getByTestId("save-button"); - await saveButton.click(); - + await page.getByTestId("save-button").click(); await page.waitForURL("/dashboard/*"); // wait for the monitor to be created await expect(page.getByTestId("monitor-status")).toHaveText("down", { ignoreCase: true }); await screenshot(testInfo, page);