Skip to content

Commit

Permalink
removed moiraapi class (#560)
Browse files Browse the repository at this point in the history
  • Loading branch information
EduardZaydler authored Dec 4, 2024
1 parent 5dcf704 commit f3f75ed
Show file tree
Hide file tree
Showing 47 changed files with 933 additions and 1,682 deletions.
42 changes: 41 additions & 1 deletion playwright/e2eTests/triggerOperations.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ import { test as base, expect } from "@playwright/test";
import { TriggerInfoPage } from "../pages/triggerInfo.page";
import { TriggerForm } from "../pages/triggerForm";
import { MainPage } from "../pages/main.page";
import {
calculateMaintenanceTime,
getMaintenanceCaption,
Maintenance,
MaintenanceList,
} from "../../src/Domain/Maintenance";
import { humanizeDuration } from "../../src/helpers/DateUtil";
import { maintenanceDelta } from "../../src/Domain/Trigger";

const triggerName = "test trigger name";
const testTriggerDescription = "test trigger description";
Expand Down Expand Up @@ -48,7 +56,39 @@ test("Add trigger", async ({ triggerName, triggerDescription, page }) => {
await expect(page).toHaveURL(`/trigger/${responseJson.id}`);
await expect(page.getByText(triggerName)).toBeVisible();
await expect(page.getByText(triggerDescription)).toBeVisible();
await page.waitForTimeout(1000);
});

test("Set trigger maintenance for all intervals", async ({ triggerName, page }) => {
const mainPage = new MainPage(page);
await mainPage.gotoMainPage();
await page.getByText(triggerName).click();

const triggerInfoPage = new TriggerInfoPage(page);

for (const maintenance of MaintenanceList) {
await test.step(`Set maintenance to ${getMaintenanceCaption(maintenance)}`, async () => {
const setMaintenanceRequestPromise = page.waitForRequest("**/trigger/*/setMaintenance");

const expectedTriggerTime = calculateMaintenanceTime(maintenance);

await triggerInfoPage.triggerMaintenance.click();

await page.getByText(getMaintenanceCaption(maintenance)).click();

const setMaintenanceRequest = await setMaintenanceRequestPromise;

const requestBody = JSON.parse(setMaintenanceRequest.postData() || "{}");
expect(requestBody).not.toBeNull();
expect(requestBody.trigger).toEqual(expectedTriggerTime);

if (maintenance === Maintenance.off) {
await expect(page.getByText("Maintenance")).toBeVisible();
} else
await expect(
page.getByText(humanizeDuration(maintenanceDelta(expectedTriggerTime)))
).toBeVisible();
});
}
});

test("Duplicate trigger", async ({
Expand Down
2 changes: 2 additions & 0 deletions playwright/pages/triggerInfo.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export class TriggerInfoPage {
readonly menuListButton: Locator;
readonly duplicateButton: Locator;
readonly deleteButton: Locator;
readonly triggerMaintenance: Locator;

constructor(page: Page) {
this.page = page;
Expand All @@ -16,5 +17,6 @@ export class TriggerInfoPage {
this.menuListButton = page.getByText("Other");
this.duplicateButton = page.getByText("Duplicate");
this.deleteButton = page.getByText("Delete");
this.triggerMaintenance = page.locator("[data-tid='TriggerMaintenanceButton']");
}
}
Loading

0 comments on commit f3f75ed

Please sign in to comment.