diff options
| author | Joe Mou <dev@mou.fo> | 2026-08-11 17:41:01 -0400 |
|---|---|---|
| committer | Joe Mou <dev@mou.fo> | 2026-08-11 18:25:26 -0400 |
| commit | 21310d0366c0f21e73c1f4f78d38370edfb59445 (patch) | |
| tree | b65c6bb2bfea1036266e29c308bf1132277bb993 /cgithub/src/app.test.ts | |
| parent | 866f99c414cb3d102483ce21c68a0e62b394baaa (diff) | |
Read the About box and latest release from JSON
GitHub rebuilt the repository sidebar, so the selectors parseRepoInfo used
matched nothing and the About box rendered empty. Everything but the latest
release is in the page's embedded payload as sidebarAbout; the latest release
is only in the _sidebar JSON already fetched for languages, so it arrives with
that fragment and is moved beside the release count.
Diffstat (limited to 'cgithub/src/app.test.ts')
| -rw-r--r-- | cgithub/src/app.test.ts | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/cgithub/src/app.test.ts b/cgithub/src/app.test.ts index 6544f03..5474f8d 100644 --- a/cgithub/src/app.test.ts +++ b/cgithub/src/app.test.ts @@ -58,6 +58,40 @@ describe("branch picker", () => { }); }); +describe("sidebar fragment", () => { + const repo = { owner: "actions", name: "deploy-pages" }; + const languages = [{ name: "JavaScript", percentage: 100, color: "#f1e05a" }]; + const latestRelease = { tag: "v5.0.0", publishedAt: "2026-03-25T16:59:14Z" }; + + // The release replaces the empty element it names, beside the release count. + it("should render the latest release and the languages", () => { + const html = eta.render("_sidebar.eta", { repo, languages, latestRelease }); + + assert.match(html, /<span data-target="latest-release">\(<a href/); + assert.match(html, /href="\/actions\/deploy-pages\/releases\/tag\/v5.0.0"/); + assert.match(html, /<time class="timestamp" title="2026-03-25T16:59:14Z">2026-03-25<\/time>/); + assert.match(html, /<div class="languages box">/); + }); + + it("should name a spot the repo page holds open", () => { + const html = eta.render("repo.eta", { + repo, + branch: "main", + path: "/", + items: [], + info: { description: null, website: null, stars: null, forks: null, numReleases: 38 }, + }); + + assert.match(html, /<span id="latest-release"><\/span>/); + }); + + it("should render nothing when the repository has neither", () => { + const html = eta.render("_sidebar.eta", { repo, languages: [], latestRelease: null }); + + assert.strictEqual(html.trim(), ""); + }); +}); + describe("redirects to GitHub", () => { // An HTTP redirect would be caught by the extension's declarativeNetRequest // rules and bounced straight back here. |
