Skip to content

Commit 06f10f7

Browse files
committed
Add test
1 parent c48dafd commit 06f10f7

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

photon-client/tests/input.spec.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { expect } from "@playwright/test";
2+
import { test } from "./fixtures.ts";
3+
4+
test("Camera Gain Slider won't go past max or min", async ({ page }) => {
5+
await page.goto("http://localhost:5800/#/dashboard");
6+
await page.locator("div").filter({ hasText: "Set up some cameras to get started!" }).nth(2).press("Escape");
7+
8+
// Fill in Camera Gain text field with 1000
9+
await page.locator("#input-v-44").fill("1000");
10+
await page.locator("#input-v-44").press("Enter");
11+
await expect(page.locator("#input-v-44")).toHaveValue("100");
12+
13+
// Try using buttons to go past the max
14+
await page.getByRole("button", { name: "appended action" }).nth(2).click();
15+
await expect(page.locator("#input-v-44")).toHaveValue("100");
16+
17+
// Make sure the value is actually properly limited, not just visually
18+
await page.getByRole("button", { name: "prepended action" }).nth(2).click();
19+
await expect(page.locator("#input-v-44")).toHaveValue("99");
20+
21+
await page.locator("#input-v-44").fill("-10");
22+
await page.locator("#input-v-44").press("Enter");
23+
await expect(page.locator("#input-v-44")).toHaveValue("0");
24+
25+
await page.getByRole("button", { name: "prepended action" }).nth(2).click();
26+
await expect(page.locator("#input-v-44")).toHaveValue("0");
27+
28+
// Make sure the value is actually properly limited, not just visually
29+
await page.getByRole("button", { name: "appended action" }).nth(2).click();
30+
await expect(page.locator("#input-v-44")).toHaveValue("1");
31+
32+
// Make sure that the guard actually prevents value setting, instead of just reverting the value
33+
// This can be ensured by making sure the Camera Gain field doesn't disappear (disappears when the value is -1)
34+
await page.getByRole("button", { name: "prepended action" }).nth(2).click();
35+
await page.getByRole("button", { name: "prepended action" }).nth(2).click();
36+
await expect(page.locator("#input-v-44")).toHaveValue("0");
37+
38+
await expect(page.getByText("Camera Gain", { exact: true })).toBeVisible();
39+
});

0 commit comments

Comments
 (0)