Skip to content

Commit

Permalink
Clean up the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
simshaun committed Aug 29, 2024
1 parent 53e691b commit 920c9c2
Showing 1 changed file with 15 additions and 31 deletions.
46 changes: 15 additions & 31 deletions test/e2e/specs/monitor-form.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 920c9c2

Please sign in to comment.