Skip to content

Commit ab35a00

Browse files
test(e2e): Add non-admin machine create access test (#904)
Verify non-admin users cannot access /m/new page: - "Add Machine" button hidden on /m page for members - Direct navigation to /m/new redirects to /m - Create form heading not visible after redirect Closes #875 Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 3c7d29c commit ab35a00

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

e2e/smoke/machines-crud.spec.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,27 @@ test.describe("Machines CRUD", () => {
6262
});
6363
});
6464

65+
test("non-admin cannot access /m/new page", async ({ page }) => {
66+
// Default login is member (non-admin) from beforeEach
67+
68+
// Verify "Add Machine" button is NOT visible to non-admin on /m page
69+
await page.goto("/m");
70+
await expect(page.getByRole("heading", { name: "Machines" })).toBeVisible();
71+
await expect(
72+
page.getByRole("link", { name: /Add Machine/i })
73+
).not.toBeVisible();
74+
75+
// Attempt direct navigation to /m/new - should redirect to /m
76+
await page.goto("/m/new");
77+
await expect(page).toHaveURL("/m");
78+
79+
// Verify we're back on machines list, not the create form
80+
await expect(page.getByRole("heading", { name: "Machines" })).toBeVisible();
81+
await expect(
82+
page.getByRole("heading", { name: "Add New Machine" })
83+
).not.toBeVisible();
84+
});
85+
6586
test("should display seeded test machines with correct statuses", async ({
6687
page,
6788
}) => {

0 commit comments

Comments
 (0)