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
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-sweepgatetest/auto-fix-1776586424172gatetest/auto-fix-1776586534814gatetest/auto-fix-1776590685143gatetest/auto-fix-1776590808199mainops/redeploy-retriggerstyle/dxt-cta-themeworktree-agent-a3377aad30d55da26worktree-agent-a7ef607b7ee1d6c74
atom-feed.test.ts7.7 KB · 231 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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
/**
 * Block J19 — Atom feed renderer. Pure XML + route smokes.
 */

import { describe, it, expect } from "bun:test";
import app from "../app";
import {
  escapeXml,
  toIsoUtc,
  renderAtomFeed,
  ATOM_CONTENT_TYPE,
  __internal,
  type AtomEntry,
} from "../lib/atom-feed";

describe("atom-feed — escapeXml", () => {
  it("escapes the five XML metacharacters", () => {
    expect(escapeXml("a < b & c > d")).toBe("a &lt; b &amp; c &gt; d");
    expect(escapeXml(`"single'`)).toBe("&quot;single&apos;");
  });

  it("returns '' for empty / falsy input", () => {
    expect(escapeXml("")).toBe("");
  });

  it("idempotent escape of already-escaped text", () => {
    // Double-escaping is expected — this is a serialiser, not a re-encoder.
    // We just need it not to throw or drop content.
    const once = escapeXml("&");
    const twice = escapeXml(once);
    expect(twice).toBe("&amp;amp;");
  });
});

describe("atom-feed — toIsoUtc", () => {
  it("converts valid ISO strings to ISO-UTC", () => {
    const out = toIsoUtc("2026-04-15T12:00:00Z");
    expect(out).toBe("2026-04-15T12:00:00.000Z");
  });

  it("accepts Date instances", () => {
    const out = toIsoUtc(new Date("2026-04-15T12:00:00Z"));
    expect(out).toBe("2026-04-15T12:00:00.000Z");
  });

  it("falls back to epoch on garbage", () => {
    expect(toIsoUtc("not-a-date")).toBe("1970-01-01T00:00:00.000Z");
    expect(toIsoUtc(null)).toBe("1970-01-01T00:00:00.000Z");
    expect(toIsoUtc(undefined)).toBe("1970-01-01T00:00:00.000Z");
    expect(toIsoUtc("")).toBe("1970-01-01T00:00:00.000Z");
  });
});

describe("atom-feed — renderAtomFeed", () => {
  const entry: AtomEntry = {
    id: "tag:gluecron,2026:alice/repo/commit/abc",
    title: "Fix bug",
    href: "https://gluecron.com/alice/repo/commit/abc",
    updatedAt: "2026-04-15T12:00:00Z",
    summary: "Fix a bug",
    author: { name: "Alice", email: "a@x" },
  };

  it("prefixes with the XML declaration + feed root", () => {
    const xml = renderAtomFeed({
      id: "tag:feed",
      title: "Test",
      selfHref: "https://gluecron.com/feed",
      entries: [],
    });
    expect(xml.startsWith('<?xml version="1.0" encoding="utf-8"?>\n')).toBe(
      true
    );
    expect(xml).toContain('<feed xmlns="http://www.w3.org/2005/Atom">');
    expect(xml.trim().endsWith("</feed>")).toBe(true);
  });

  it("emits required feed-level elements", () => {
    const xml = renderAtomFeed({
      id: "tag:feed",
      title: "Test Feed",
      subtitle: "Sub",
      selfHref: "https://g.c/feed",
      alternateHref: "https://g.c/",
      entries: [],
    });
    expect(xml).toContain("<id>tag:feed</id>");
    expect(xml).toContain("<title>Test Feed</title>");
    expect(xml).toContain("<subtitle>Sub</subtitle>");
    expect(xml).toContain('<link rel="self" href="https://g.c/feed"/>');
    expect(xml).toContain('<link rel="alternate" href="https://g.c/"/>');
    expect(xml).toMatch(/<updated>.+<\/updated>/);
  });

  it("renders entry title, id, link, updated, published, author, summary", () => {
    const xml = renderAtomFeed({
      id: "tag:feed",
      title: "Test",
      selfHref: "https://g.c/feed",
      entries: [entry],
    });
    expect(xml).toContain("<entry>");
    expect(xml).toContain("</entry>");
    expect(xml).toContain(`<id>${entry.id}</id>`);
    expect(xml).toContain(`<title>${entry.title}</title>`);
    expect(xml).toContain(`<link rel="alternate" href="${entry.href}"/>`);
    expect(xml).toContain("<updated>2026-04-15T12:00:00.000Z</updated>");
    expect(xml).toContain("<published>2026-04-15T12:00:00.000Z</published>");
    expect(xml).toContain("<name>Alice</name>");
    expect(xml).toContain("<email>a@x</email>");
    expect(xml).toContain('<summary type="text">Fix a bug</summary>');
  });

  it("escapes entry text fields", () => {
    const xml = renderAtomFeed({
      id: "tag:feed",
      title: "Test & Ampersand",
      selfHref: "https://g.c/feed?x=1&y=2",
      entries: [
        {
          id: "tag:e",
          title: "<script>bad</script>",
          href: "https://g.c/x?a=1&b=2",
          updatedAt: "2026-04-15T12:00:00Z",
          summary: 'She said "hi"',
        },
      ],
    });
    expect(xml).toContain("Test &amp; Ampersand");
    expect(xml).toContain("x=1&amp;y=2");
    expect(xml).toContain("&lt;script&gt;bad&lt;/script&gt;");
    expect(xml).toContain("&quot;hi&quot;");
    // Must not contain the raw unescaped forms.
    expect(xml).not.toContain("<script>bad</script>");
  });

  it("picks feed updated from the newest entry when not set explicitly", () => {
    const xml = renderAtomFeed({
      id: "tag:feed",
      title: "Test",
      selfHref: "https://g.c/feed",
      entries: [
        { id: "a", title: "A", href: "h", updatedAt: "2026-04-10T00:00:00Z" },
        { id: "b", title: "B", href: "h", updatedAt: "2026-04-14T00:00:00Z" },
        { id: "c", title: "C", href: "h", updatedAt: "2026-04-12T00:00:00Z" },
      ],
    });
    // The feed `<updated>` should pick the newest entry (Apr 14)
    expect(xml).toContain("<updated>2026-04-14T00:00:00.000Z</updated>");
  });

  it("respects explicit feed updatedAt", () => {
    const xml = renderAtomFeed({
      id: "tag:feed",
      title: "Test",
      selfHref: "https://g.c/feed",
      updatedAt: "2026-01-01T00:00:00Z",
      entries: [
        { id: "a", title: "A", href: "h", updatedAt: "2026-04-14T00:00:00Z" },
      ],
    });
    expect(xml).toContain("<updated>2026-01-01T00:00:00.000Z</updated>");
  });

  it("produces a well-formed document even with zero entries", () => {
    const xml = renderAtomFeed({
      id: "tag:empty",
      title: "Empty",
      selfHref: "https://g.c/empty.atom",
      entries: [],
    });
    expect(xml).toContain("<id>tag:empty</id>");
    expect(xml).not.toContain("<entry>");
  });

  it("falls back to (untitled) when a title is empty", () => {
    const xml = renderAtomFeed({
      id: "tag:feed",
      title: "Test",
      selfHref: "https://g.c/feed",
      entries: [
        { id: "a", title: "", href: "h", updatedAt: "2026-04-14T00:00:00Z" },
      ],
    });
    expect(xml).toContain("<title>(untitled)</title>");
  });
});

describe("atom-feed — ATOM_CONTENT_TYPE", () => {
  it("is the canonical Atom mime with charset", () => {
    expect(ATOM_CONTENT_TYPE).toBe("application/atom+xml; charset=utf-8");
  });
});

describe("atom-feed — __internal", () => {
  it("re-exports the helpers for parity", () => {
    expect(__internal.escapeXml).toBe(escapeXml);
    expect(__internal.toIsoUtc).toBe(toIsoUtc);
    expect(__internal.renderAtomFeed).toBe(renderAtomFeed);
    expect(__internal.ATOM_CONTENT_TYPE).toBe(ATOM_CONTENT_TYPE);
  });
});

describe("atom-feed — routes", () => {
  it("GET /:o/:r/commits.atom returns 200 with Atom content-type", async () => {
    const res = await app.request("/alice/nope/commits.atom");
    expect(res.status).toBe(200);
    expect(res.headers.get("content-type")).toBe(ATOM_CONTENT_TYPE);
    const body = await res.text();
    expect(body).toContain('<feed xmlns="http://www.w3.org/2005/Atom">');
  });

  it("GET /:o/:r/releases.atom returns 200 Atom", async () => {
    const res = await app.request("/alice/nope/releases.atom");
    expect(res.status).toBe(200);
    expect(res.headers.get("content-type")).toBe(ATOM_CONTENT_TYPE);
  });

  it("GET /:o/:r/issues.atom returns 200 Atom", async () => {
    const res = await app.request("/alice/nope/issues.atom");
    expect(res.status).toBe(200);
    expect(res.headers.get("content-type")).toBe(ATOM_CONTENT_TYPE);
  });

  it("cache headers set for feed reader friendliness", async () => {
    const res = await app.request("/alice/nope/commits.atom");
    const cc = res.headers.get("cache-control") || "";
    expect(cc).toContain("max-age");
    expect(cc).toContain("stale-while-revalidate");
  });
});