Pre-launch — Gluecron is in final validation. Public signups and git hosting for non-owner users open after launch review.
CodeIssuesDiscussionsWikiPull RequestsProjectsCommitsActionsReleasesContributorsPulse● GatesSecuritySettingsDeploymentsPipelineInsightsAgents✨ Explain✨ Ask AI✨ Workspace✨ Spec✨ Tests▓ Debt Map✨ NL Search🏛 Archaeology
Blame · Line-by-line history

repo.spec.ts

Each line is annotated with the commit that last touched it. Click any SHA to jump to that commit and see the surrounding change.

repo.spec.tsBlame175 lines · 1 contributor
a014defClaude1/**
2 * E2E — Repository flows
3 *
4 * Covers: create repo, push first commit, file browser shows files,
5 * commit list populated, README renders.
6 */
7
8import { test, expect } from "@playwright/test";
9import {
10 uid,
11 TEST_PASSWORD,
12 pushTestCommit,
13 pushFeatureBranch,
14 cleanupDir,
15} from "./fixtures";
16
17// ---------------------------------------------------------------------------
18// Shared state — one user + one repo for the whole suite.
19// ---------------------------------------------------------------------------
20
21let owner: string;
22let repoName: string;
23let tmpDir: string;
24
25test.beforeAll(async ({ browser }) => {
26 owner = uid("repouser");
27 repoName = uid("myrepo");
28
29 const page = await browser.newPage();
30
31 // Register the test user
32 await page.goto("/register");
33 await page.fill('input[name="username"]', owner);
34 await page.fill('input[name="email"]', `${owner}@test.example`);
35 await page.fill('input[name="password"]', TEST_PASSWORD);
36 await page.click('button[type="submit"]');
37 await page.waitForURL(/\/(dashboard|[a-z])/);
38
39 // Create the repository via the web UI
40 await page.goto("/new");
41 await page.fill('input[name="name"]', repoName);
42 await page.click('button[type="submit"]');
43 await page.waitForURL(new RegExp(`/${owner}/${repoName}`));
44
45 await page.close();
46
47 // Push an initial commit via git CLI
48 tmpDir = await pushTestCommit({
49 owner,
50 repo: repoName,
51 username: owner,
52 password: TEST_PASSWORD,
53 fileName: "README.md",
54 fileContent: `# ${repoName}\n\nThis is the E2E test repo.\n`,
55 commitMsg: "Initial commit",
56 });
57});
58
59test.afterAll(async () => {
60 await cleanupDir(tmpDir);
61});
62
63// ---------------------------------------------------------------------------
64// Repository creation
65// ---------------------------------------------------------------------------
66
67test.describe("Repository creation", () => {
68 test("new repo page is accessible while logged in", async ({ page }) => {
69 // Log in fresh for this test
70 await page.goto("/login");
71 await page.fill('input[name="username"]', owner);
72 await page.fill('input[name="password"]', TEST_PASSWORD);
73 await page.click('button[type="submit"]');
74 await page.waitForURL(/\/(dashboard|[a-z])/);
75
76 await page.goto("/new");
77 await expect(page.locator('input[name="name"]')).toBeVisible();
78 });
79
80 test("created repo homepage is publicly accessible", async ({ page }) => {
81 await page.goto(`/${owner}/${repoName}`);
82 await expect(page).toHaveURL(new RegExp(`/${owner}/${repoName}`));
83 // Page should mention the repo name
84 await expect(page.locator("body")).toContainText(repoName);
85 });
86});
87
88// ---------------------------------------------------------------------------
89// File browser
90// ---------------------------------------------------------------------------
91
92test.describe("File browser", () => {
93 test("README.md appears in the file listing", async ({ page }) => {
94 await page.goto(`/${owner}/${repoName}`);
95 await expect(page.locator("body")).toContainText("README.md", {
96 timeout: 8_000,
97 });
98 });
99
100 test("README.md content is rendered on repo homepage", async ({ page }) => {
101 await page.goto(`/${owner}/${repoName}`);
102 // The repo README says "E2E test repo"
103 await expect(page.locator("body")).toContainText("E2E test repo", {
104 timeout: 8_000,
105 });
106 });
107
108 test("clicking a file opens the blob view", async ({ page }) => {
109 await page.goto(`/${owner}/${repoName}`);
110 // Click the README link in the file table
111 await page.click('a[href*="README.md"]');
112 await expect(page).toHaveURL(new RegExp(`/${owner}/${repoName}/blob`));
113 await expect(page.locator("body")).toContainText("E2E test repo");
114 });
115});
116
117// ---------------------------------------------------------------------------
118// Commit list
119// ---------------------------------------------------------------------------
120
121test.describe("Commit list", () => {
122 test("commits page lists the initial commit", async ({ page }) => {
123 await page.goto(`/${owner}/${repoName}/commits`);
124 await expect(page.locator("body")).toContainText("Initial commit", {
125 timeout: 8_000,
126 });
127 });
128
129 test("commit detail page loads", async ({ page }) => {
130 await page.goto(`/${owner}/${repoName}/commits`);
131 // Click the first commit link
132 const commitLink = page.locator('a[href*="/commit/"]').first();
133 await commitLink.click();
134 await expect(page).toHaveURL(new RegExp(`/${owner}/${repoName}/commit/`));
135 // Should show the diff or commit message
136 await expect(page.locator("body")).toContainText(/Initial commit|README/i);
137 });
138});
139
140// ---------------------------------------------------------------------------
141// Branch support
142// ---------------------------------------------------------------------------
143
144test.describe("Branches", () => {
145 test("branches page lists main branch", async ({ page }) => {
146 await page.goto(`/${owner}/${repoName}/branches`);
147 await expect(page.locator("body")).toContainText(/main|master/, {
148 timeout: 8_000,
149 });
150 });
151});
152
153// ---------------------------------------------------------------------------
154// Additional repo — invalid names
155// ---------------------------------------------------------------------------
156
157test.describe("Repo creation validation", () => {
158 test("invalid repo name shows error", async ({ page }) => {
159 // Log in
160 await page.goto("/login");
161 await page.fill('input[name="username"]', owner);
162 await page.fill('input[name="password"]', TEST_PASSWORD);
163 await page.click('button[type="submit"]');
164 await page.waitForURL(/\/(dashboard|[a-z])/);
165
166 await page.goto("/new");
167 // Put a name with spaces/special chars that the validator rejects
168 await page.fill('input[name="name"]', "invalid repo name!");
169 await page.click('button[type="submit"]');
170
171 // Server should send back an error
172 const body = page.locator("body");
173 await expect(body).toContainText(/invalid|error/i, { timeout: 5_000 });
174 });
175});