Skip to content
File

Blob: tests/e2e/specs/03-project-crud.spec.ts

typescript56 lines
1import { test, expect, loginViaUi } from "../fixtures/anvil-test";
2 
3test.describe("Project CRUD", () => {
4 test("can create a project", async ({ livePage, e2eContext, operatorIdentity }) => {
5 await loginViaUi(livePage, e2eContext, operatorIdentity);
6 await livePage.goto("/app/projects/new");
7 
8 await livePage.getByLabel("Project name").fill("CI Test Project");
9 
10 // Slug auto-generates from the name — just verify it has a value.
11 await expect(livePage.getByLabel("Project slug")).not.toHaveValue("");
12 
13 await livePage.getByLabel("Repository URL").fill("https://github.com/miragespace/ci-test");
14 
15 // "Default branch" and "Config path" are pre-filled; leave them.
16 
17 await livePage.getByRole("button", { name: "Create Project" }).click();
18 
19 await livePage.waitForURL("**/app/projects");
20 await expect(livePage.getByText("CI Test Project")).toBeVisible();
21 });
22 
23 test("can view project detail", async ({ livePage, e2eContext, operatorIdentity }) => {
24 await loginViaUi(livePage, e2eContext, operatorIdentity);
25 await livePage.goto("/app/projects");
26 
27 // Click the project card link — use role to avoid matching nested text nodes.
28 await livePage.getByRole("link").filter({ hasText: "CI Test Project" }).first().click();
29 
30 await expect(livePage.getByRole("navigation", { name: "Breadcrumb" })).toContainText("CI Test Project");
31 await expect(livePage.getByText("github.com")).toBeVisible();
32 await expect(livePage.getByText("Run history")).toBeVisible();
33 await expect(livePage.getByRole("button", { name: "Trigger Run" })).toBeVisible();
34 });
35 
36 test("can edit project settings", async ({ livePage, e2eContext, operatorIdentity }) => {
37 await loginViaUi(livePage, e2eContext, operatorIdentity);
38 await livePage.goto("/app/projects");
39 
40 await livePage.getByRole("link").filter({ hasText: "CI Test Project" }).first().click();
41 
42 await livePage.getByRole("link", { name: /Settings/ }).click();
43 
44 await expect(livePage.getByRole("heading", { name: "Update project" })).toBeVisible();
45 
46 const nameInput = livePage.getByLabel("Project name");
47 await nameInput.clear();
48 await nameInput.fill("CI Test Project Updated");
49 
50 await livePage.getByRole("button", { name: "Save Changes" }).click();
51 
52 // Redirect back to project detail page.
53 await expect(livePage.getByRole("navigation", { name: "Breadcrumb" })).toContainText("CI Test Project Updated");
54 });
55});