forked from qodo-benchmark/prefect
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrigger-step.test.tsx
More file actions
112 lines (87 loc) · 3.58 KB
/
trigger-step.test.tsx
File metadata and controls
112 lines (87 loc) · 3.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import { zodResolver } from "@hookform/resolvers/zod";
import { render, screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { mockPointerEvents } from "@tests/utils/browser";
import { useForm } from "react-hook-form";
import { beforeAll, describe, expect, it } from "vitest";
import { AutomationWizardSchema } from "@/components/automations/automations-wizard/automation-schema";
import { Form } from "@/components/ui/form";
import { TriggerStep } from "./trigger-step";
const TriggerStepFormContainer = () => {
const form = useForm({
resolver: zodResolver(AutomationWizardSchema),
defaultValues: {
actions: [{ type: undefined }],
trigger: {
type: "event" as const,
posture: "Reactive" as const,
threshold: 1,
within: 0,
},
},
});
return (
<Form {...form}>
<form>
<TriggerStep />
</form>
</Form>
);
};
describe("TriggerStep", () => {
beforeAll(() => {
mockPointerEvents();
});
it("renders trigger template select", () => {
render(<TriggerStepFormContainer />);
expect(screen.getByLabelText("Trigger Template")).toBeVisible();
});
it("can select deployment-status template and shows trigger fields", async () => {
const user = userEvent.setup();
render(<TriggerStepFormContainer />);
await user.click(screen.getByLabelText("Trigger Template"));
await user.click(screen.getByRole("option", { name: "Deployment status" }));
// Should show the DeploymentStatusTriggerFields component
expect(screen.getByLabelText("select posture")).toBeVisible();
expect(screen.getByLabelText("Threshold")).toBeVisible();
});
it("can select flow-run-state template and shows trigger fields", async () => {
const user = userEvent.setup();
render(<TriggerStepFormContainer />);
await user.click(screen.getByLabelText("Trigger Template"));
await user.click(screen.getByRole("option", { name: "Flow run state" }));
// Should show the FlowRunStateTriggerFields component
expect(screen.getByLabelText("select posture")).toBeVisible();
expect(screen.getByLabelText("Threshold")).toBeVisible();
});
it("can select work-pool-status template and shows trigger fields", async () => {
const user = userEvent.setup();
render(<TriggerStepFormContainer />);
await user.click(screen.getByLabelText("Trigger Template"));
await user.click(screen.getByRole("option", { name: "Work pool status" }));
// Should show the WorkPoolStatusTriggerFields component
expect(screen.getByLabelText("select posture")).toBeVisible();
expect(screen.getByLabelText("Threshold")).toBeVisible();
});
it("can select work-queue-status template and shows trigger fields", async () => {
const user = userEvent.setup();
render(<TriggerStepFormContainer />);
await user.click(screen.getByLabelText("Trigger Template"));
await user.click(screen.getByRole("option", { name: "Work queue status" }));
// Should show the WorkQueueStatusTriggerFields component
expect(screen.getByLabelText("select posture")).toBeVisible();
expect(screen.getByLabelText("Threshold")).toBeVisible();
});
it("can select custom template and shows trigger fields", async () => {
const user = userEvent.setup();
render(<TriggerStepFormContainer />);
await user.click(screen.getByLabelText("Trigger Template"));
await user.click(screen.getByRole("option", { name: "Custom" }));
// Should show the CustomTriggerFields component
expect(screen.getByLabelText("select posture")).toBeVisible();
expect(screen.getByLabelText("Threshold")).toBeVisible();
expect(
screen.getByLabelText("Expected Events (one per line)"),
).toBeVisible();
});
});