Pre-launch — Gluecron is in final validation. Public signups and git hosting for non-owner users open after launch review.
CodeIssuesPull RequestsActionsSecurityInsightsSettings
✨ AI
More
claude/adoring-hopper-5x74bqclaude/affectionate-feynman-ykrf1hclaude/architecture-audit-design-wxprenclaude/build-status-update-3MXsfclaude/charming-meitner-mllb5rclaude/compare-gate-gluecron-s4mFQclaude/confident-faraday-tikcwbclaude/continue-work-XMTlIclaude/crontech-gluecron-deploy-7MIECclaude/crontech-platform-setup-SeKfwclaude/design-2026claude/ecstatic-ptolemy-jMdigclaude/enhance-github-integration-QNHdGclaude/fix-aa-loop-issue-PonMQclaude/fix-actions-and-processclaude/fix-desktop-errors-XqoW8claude/fix-red-workflowsclaude/fix-website-access-6FKJNclaude/gatetest-integration-hardeningclaude/github-audit-improvements-bDFr9claude/gluecron-launch-status-FoMRlclaude/hopeful-lamport-olfCTclaude/issue-to-pr-and-protectionsclaude/jolly-heisenberg-2sg1Qclaude/launch-preparation-QmTb6claude/new-session-xk1l7claude/plan-platform-architecture-kkN4yclaude/platform-analysis-roadmap-1nUGLclaude/platform-launch-assessment-8dWV8claude/polish-platform-release-AeDrUclaude/resume-previous-work-KzyLwclaude/review-crontech-handoff-qYEVqclaude/review-project-completeness-lHhS2claude/review-readme-docs-ulqPKclaude/serene-edison-rj87weclaude/setup-multi-repo-dev-BCwNQclaude/ship-fixes-and-tests-Jvz1cclaude/site-audit-competitive-pctlwgclaude/site-migration-vercel-XstpKclaude/standalone-product-repos-XHFTDcopilot/feat-smart-empty-states-keyboard-first-enhancementcopilot/feat-smart-morning-digest-review-context-restorecopilot/fix-and-process-workflowscopilot/update-ai-powered-code-reviewfeat/debt-mapfeat/push-policy-codeowners-hardeningfeat/smart-digest-contextfeat/stage-impactfeat/t1-secret-migrationfeat/u-polishfeat/w-self-hostfeat/w2-claude-configfix/agent-journey-orphan-sweepfix/audit-sweep-2026-07-26gatetest/auto-fix-1776586424172gatetest/auto-fix-1776586534814gatetest/auto-fix-1776590685143gatetest/auto-fix-1776590808199mainops/redeploy-retriggerstyle/dxt-cta-themeworktree-agent-a3377aad30d55da26worktree-agent-a7ef607b7ee1d6c74
web-routes.test.ts5.8 KB · 164 lines
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
import { describe, it, expect, beforeAll, afterAll } from "bun:test";
import { join } from "path";
import { rm, mkdir } from "fs/promises";
import app from "../app";
import { initBareRepo, getRepoPath } from "../git/repository";

const TEST_REPOS = join(import.meta.dir, "../../.test-repos-web-" + Date.now());

beforeAll(async () => {
  await rm(TEST_REPOS, { recursive: true, force: true });
  await mkdir(TEST_REPOS, { recursive: true });
  process.env.GIT_REPOS_PATH = TEST_REPOS;

  // Create a test repo with content
  await initBareRepo("testuser", "myrepo");
  const cloneDir = join(TEST_REPOS, "_clone");
  await mkdir(cloneDir, { recursive: true });
  const repoPath = getRepoPath("testuser", "myrepo");
  const workDir = join(cloneDir, "work");

  // Must throw on failure — see the note in week3.test.ts. A silently failed
  // clone leaves `cwd` inside the real repository and the subsequent git
  // config/add/commit calls then mutate it.
  const run = async (cmd: string[], cwd: string) => {
    const proc = Bun.spawn(cmd, { cwd, stdout: "pipe", stderr: "pipe" });
    const [exitCode, stderr] = await Promise.all([
      proc.exited,
      new Response(proc.stderr).text(),
    ]);
    if (exitCode !== 0) {
      throw new Error(
        `[web-routes fixture] ${cmd.join(" ")} failed in ${cwd} (exit ${exitCode}): ${stderr}`
      );
    }
  };

  await run(["git", "clone", repoPath, workDir], TEST_REPOS);
  await run(["git", "config", "user.email", "test@test.com"], workDir);
  await run(["git", "config", "user.name", "Test"], workDir);

  await mkdir(join(workDir, "src"), { recursive: true });
  await Bun.write(join(workDir, "README.md"), "# My Repo\nHello");
  await Bun.write(
    join(workDir, "src/index.ts"),
    'const x: number = 42;\nconsole.log(x);'
  );

  await run(["git", "add", "-A"], workDir);
  await run(["git", "commit", "-m", "Initial commit"], workDir);
  await run(["git", "branch", "-M", "main"], workDir);
  await run(["git", "push", "-u", "origin", "main"], workDir);

  // Create a second branch
  await run(["git", "checkout", "-b", "feature"], workDir);
  await Bun.write(join(workDir, "src/feature.ts"), "export const y = 1;");
  await run(["git", "add", "-A"], workDir);
  await run(["git", "commit", "-m", "Add feature"], workDir);
  await run(["git", "push", "-u", "origin", "feature"], workDir);

  await rm(cloneDir, { recursive: true, force: true });
});

afterAll(async () => {
  await rm(TEST_REPOS, { recursive: true, force: true });
});

describe("web routes", () => {
  it("GET / returns landing page", async () => {
    const res = await app.request("/");
    expect(res.status).toBe(200);
    const html = await res.text();
    expect(html).toContain("gluecron");
  });

  it("GET /login returns login form", async () => {
    const res = await app.request("/login");
    expect(res.status).toBe(200);
    const html = await res.text();
    expect(html).toContain("Sign in");
    expect(html).toContain("Continue with GitHub");
    expect(html).toContain("Email me a link");
  });

  it("GET /register returns registration form", async () => {
    const res = await app.request("/register");
    expect(res.status).toBe(200);
    const html = await res.text();
    expect(html).toContain("Create account");
    expect(html).toContain('name="username"');
    expect(html).toContain('name="email"');
  });

  it("GET /new redirects to login without auth", async () => {
    const res = await app.request("/new", { redirect: "manual" });
    expect(res.status).toBe(302);
    expect(res.headers.get("location")).toContain("/login");
  });

  it("GET /settings redirects to login without auth", async () => {
    const res = await app.request("/settings", { redirect: "manual" });
    expect(res.status).toBe(302);
    expect(res.headers.get("location")).toContain("/login");
  });

  it("GET /:owner/:repo shows repo page", async () => {
    const res = await app.request("/testuser/myrepo");
    expect(res.status).toBe(200);
    const html = await res.text();
    expect(html).toContain("testuser");
    expect(html).toContain("myrepo");
    expect(html).toContain("README.md");
    expect(html).toContain("src");
  });

  it("GET /:owner/:repo returns 404 for missing repo", async () => {
    const res = await app.request("/nobody/nope");
    expect(res.status).toBe(404);
  });

  it("GET /:owner/:repo/tree/:ref shows tree", async () => {
    const res = await app.request("/testuser/myrepo/tree/main/src");
    expect(res.status).toBe(200);
    const html = await res.text();
    expect(html).toContain("index.ts");
  });

  it("GET /:owner/:repo/blob/:ref/:path shows file with syntax highlighting", async () => {
    const res = await app.request("/testuser/myrepo/blob/main/src/index.ts");
    expect(res.status).toBe(200);
    const html = await res.text();
    // Should contain highlighted code
    expect(html).toContain("hljs-");
    expect(html).toContain("42");
  });

  it("GET /:owner/:repo/commits shows commits", async () => {
    const res = await app.request("/testuser/myrepo/commits");
    expect(res.status).toBe(200);
    const html = await res.text();
    expect(html).toContain("Initial commit");
  });

  it("supports branch switching — feature branch", async () => {
    const res = await app.request("/testuser/myrepo/tree/feature");
    expect(res.status).toBe(200);
    const html = await res.text();
    expect(html).toContain("feature");
  });

  it("feature branch has feature.ts", async () => {
    const res = await app.request("/testuser/myrepo/tree/feature/src");
    expect(res.status).toBe(200);
    const html = await res.text();
    expect(html).toContain("feature.ts");
  });

  it("shows branch dropdown when multiple branches", async () => {
    const res = await app.request("/testuser/myrepo");
    const html = await res.text();
    expect(html).toContain("branch-dropdown");
    expect(html).toContain("main");
    expect(html).toContain("feature");
  });
});