Skip to content

Commit

Permalink
added e2e test for date range
Browse files Browse the repository at this point in the history
  • Loading branch information
nalin-patidar committed Jan 24, 2025
1 parent 2b7ae69 commit 2b66481
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 1 deletion.
67 changes: 67 additions & 0 deletions thirdeye-ui/e2e/pages/alert-detail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,41 @@ export class AlertDetailsPage extends BasePage {
this.alertsApiResponseData = await alertsApiResponse.json();
}

async resolveDetailsPageApis() {
await Promise.all([
this.page.waitForResponse(
(response) =>
response.url().includes("/api/alerts/insights") &&
response.status() === 200
),
this.page.waitForResponse(
(response) =>
response.url().includes("/api/alerts") &&
response.status() === 200
),
this.page.waitForResponse(
(response) =>
response.url().includes("/api/enumeration-items") &&
response.status() === 200
),
this.page.waitForResponse(
(response) =>
response.url().includes("/api/anomalies") &&
response.status() === 200
),
this.page.waitForResponse(
(response) =>
response.url().includes("/stats") &&
response.status() === 200
),
this.page.waitForResponse(
(response) =>
response.url().includes("/api/alerts/evaluate") &&
response.status() === 200
),
]);
}

async resolveAnomaliesApis() {
const [anomaliesApiResponse] = await Promise.all([
this.page.waitForResponse(
Expand Down Expand Up @@ -277,4 +312,36 @@ export class AlertDetailsPage extends BasePage {
.filter({ hasText: "Heatmap & Dimension Drills" })
).toBeDefined();
}

async applyDateChange() {
const calnedarButton = this.page.getByTestId("open-calendar-button");
await calnedarButton.click();
const availableDates = this.page.locator(
".MuiPickersDay-day:not(.MuiPickersDay-daySelected):not(.MuiPickersDay-dayDisabled)"
);
const count = await availableDates.count();
const newStartDate = availableDates.nth(1);
const newEndDate = availableDates.nth(count - 2);
newStartDate.click();
newEndDate.click();
const applyDateBtn = this.page.getByTestId("apply-button");
applyDateBtn.click();
await Promise.all([
this.page.waitForResponse(
(response) =>
response.url().includes(`/api/anomalies`) &&
response.status() === 200
),
this.page.waitForResponse(
(response) =>
response.url().includes(`/stats`) &&
response.status() === 200
),
this.page.waitForResponse(
(response) =>
response.url().includes(`/api/alerts/evaluate`) &&
response.status() === 200
),
]);
}
}
9 changes: 9 additions & 0 deletions thirdeye-ui/e2e/tests/alert-details.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,12 @@ test("Active and Deactivate alerts", async ({ page }) => {
await alertDetailsPage.resolveApis();
await alertDetailsPage.checkAlertIsActiveOrDeactive(true);
});

test("User can select date range for anomalies", async ({ page }) => {
const alertDetailsPage = new AlertDetailsPage(page);
await alertDetailsPage.goToAlertDetailsPage();
await alertDetailsPage.resolveApis();
await alertDetailsPage.openFirstAlert();
await alertDetailsPage.resolveDetailsPageApis();
await alertDetailsPage.applyDateChange();
});
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export interface TimeRangeSelectorProps {

export const TIME_SELECTOR_TEST_IDS = {
TIME_RANGE_SELECTOR: "time-range-selector",
OPEN_BUTTON: "open-button",
OPEN_BUTTON: "open-calendar-button",
APPLY_BUTTON: "apply-button",
MONTH_LINK: "month-link",
DATE_LINK: "date-link",
Expand Down

0 comments on commit 2b66481

Please sign in to comment.