Skip to content

Commit 269d01d

Browse files
authored
feat: add timezone (#1409)
## Description ## Linear Ticket UI-1940 ## What type of PR is this? (check all applicable) - [x] 💡 (feat) - A new feature (non-breaking change which adds functionality) Add timezone to trigger of type scheduler
1 parent 070c8f7 commit 269d01d

File tree

19 files changed

+648
-457
lines changed

19 files changed

+648
-457
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import type { Page } from "@playwright/test";
2+
3+
import { expect, test } from "../../fixtures";
4+
5+
const TRIGGER_NAME = "timezone_trigger";
6+
const DEFAULT_TIMEZONE = "Etc/GMT";
7+
8+
async function createTrigger(page: Page, name: string, cronExpression: string, fileName: string, functionName: string) {
9+
await page.getByRole("button", { name: "Add Triggers" }).click();
10+
await page.getByRole("textbox", { name: "Name", exact: true }).fill(name);
11+
await page.getByTestId("select-trigger-type").click();
12+
await page.getByRole("option", { name: "Scheduler" }).click();
13+
await page.getByRole("textbox", { name: "Cron expression" }).fill(cronExpression);
14+
await page.getByTestId("select-file").click();
15+
await page.getByRole("option", { name: fileName }).click();
16+
await page.getByRole("textbox", { name: "Function name" }).fill(functionName);
17+
await page.getByRole("button", { name: "Save", exact: true }).click();
18+
}
19+
20+
async function returnToTriggersList(page: Page) {
21+
await page.getByRole("button", { name: "Return back" }).click();
22+
}
23+
24+
async function hoverTriggerInfo(page: Page, triggerName: string) {
25+
await page.locator(`button[aria-label='Trigger information for "${triggerName}"']`).hover();
26+
}
27+
28+
async function selectTimezone(page: Page, searchTerm: string, optionName: RegExp) {
29+
await page.getByRole("combobox", { name: DEFAULT_TIMEZONE }).click();
30+
await page.keyboard.type(searchTerm);
31+
await page.getByRole("option", { name: optionName }).click();
32+
}
33+
34+
test.describe("Trigger Timezone Features", () => {
35+
test.beforeEach(async ({ dashboardPage }) => {
36+
await dashboardPage.createProjectFromMenu();
37+
});
38+
39+
test("Trigger shows default UTC timezone in info popover", async ({ page }) => {
40+
await createTrigger(page, TRIGGER_NAME, "5 4 * * *", "program.py", "on_trigger");
41+
await returnToTriggersList(page);
42+
43+
await hoverTriggerInfo(page, TRIGGER_NAME);
44+
45+
await expect(page.getByTestId("trigger-detail-timezone")).toHaveText("UTC");
46+
});
47+
48+
test("Edit trigger timezone and verify change in info popover", async ({ page }) => {
49+
await createTrigger(page, TRIGGER_NAME, "5 4 * * *", "program.py", "on_trigger");
50+
await returnToTriggersList(page);
51+
52+
await page.getByText(TRIGGER_NAME).click();
53+
await selectTimezone(page, "jeru", /Jerusalem/);
54+
await page.getByRole("button", { name: "Save", exact: true }).click();
55+
56+
await hoverTriggerInfo(page, TRIGGER_NAME);
57+
58+
await expect(page.getByTestId("trigger-detail-timezone")).toHaveText("Asia/Jerusalem");
59+
});
60+
61+
test("Invalid timezone input retains original value", async ({ page }) => {
62+
await createTrigger(page, TRIGGER_NAME, "5 4 * * *", "program.py", "on_trigger");
63+
64+
await page.getByRole("combobox", { name: DEFAULT_TIMEZONE }).fill("invalid_timezone");
65+
await page.getByRole("textbox", { name: "Cron expression" }).click();
66+
67+
await expect(page.getByRole("combobox", { name: DEFAULT_TIMEZONE })).toBeVisible();
68+
});
69+
});

0 commit comments

Comments
 (0)