From 2ecd7af89bb8056ebdf200f40b6babd287551a31 Mon Sep 17 00:00:00 2001 From: Ionys <9364594+Ionys320@users.noreply.github.com> Date: Fri, 20 Dec 2024 07:55:13 +0100 Subject: [PATCH] feat(monitor condition): Remove the empty default condition creation (#5354) --- src/components/EditMonitorConditions.vue | 6 ------ test/e2e/specs/monitor-form.spec.js | 14 +++++++++----- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/components/EditMonitorConditions.vue b/src/components/EditMonitorConditions.vue index 60f7c6589..1827cfe27 100644 --- a/src/components/EditMonitorConditions.vue +++ b/src/components/EditMonitorConditions.vue @@ -73,12 +73,6 @@ export default { } }, - created() { - if (this.model.length === 0) { - this.addCondition(); - } - }, - methods: { getNewGroup() { return { diff --git a/test/e2e/specs/monitor-form.spec.js b/test/e2e/specs/monitor-form.spec.js index 7a84f3c93..b41f6ceb9 100644 --- a/test/e2e/specs/monitor-form.spec.js +++ b/test/e2e/specs/monitor-form.spec.js @@ -28,16 +28,16 @@ test.describe("Monitor Form", () => { await selectMonitorType(page); await page.getByTestId("add-condition-button").click(); - expect(await page.getByTestId("condition").count()).toEqual(2); // 1 added by default + 1 explicitly added + expect(await page.getByTestId("condition").count()).toEqual(1); // 1 explicitly added 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 + expect(await page.getByTestId("condition").count()).toEqual(2); // 1 solo conditions + 1 condition in group await screenshot(testInfo, page); await page.getByTestId("remove-condition").first().click(); - expect(await page.getByTestId("condition").count()).toEqual(2); // 1 solo condition + 1 condition in group + expect(await page.getByTestId("condition").count()).toEqual(1); // 0 solo condition + 1 condition in group await page.getByTestId("remove-condition-group").first().click(); expect(await page.getByTestId("condition-group").count()).toEqual(0); @@ -60,7 +60,10 @@ test.describe("Monitor Form", () => { await resolveTypeSelect.getByRole("option", { name: "NS" }).click(); await page.getByTestId("add-condition-button").click(); - expect(await page.getByTestId("condition").count()).toEqual(2); // 1 added by default + 1 explicitly added + expect(await page.getByTestId("condition").count()).toEqual(1); // 1 explicitly added + + await page.getByTestId("add-condition-button").click(); + expect(await page.getByTestId("condition").count()).toEqual(2); // 2 explicitly added await page.getByTestId("condition-value").nth(0).fill("a.iana-servers.net"); await page.getByTestId("condition-and-or").nth(0).selectOption("or"); @@ -89,7 +92,8 @@ test.describe("Monitor Form", () => { await resolveTypeSelect.click(); await resolveTypeSelect.getByRole("option", { name: "NS" }).click(); - expect(await page.getByTestId("condition").count()).toEqual(1); // 1 added by default + await page.getByTestId("add-condition-button").click(); + expect(await page.getByTestId("condition").count()).toEqual(1); // 1 explicitly added await page.getByTestId("condition-value").nth(0).fill("definitely-not.net");