Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: harden changelog dialog for null fields
  • Loading branch information
hearsilent committed Mar 18, 2026
commit 2e531636cd7527493d5dd6d32cb939d05697281a
24 changes: 24 additions & 0 deletions src/components/changelog-dialog.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,30 @@ describe("ChangelogDialog", () => {
expect(screen.getByText("v1.0.0")).toBeInTheDocument()
})

it("handles null published_at gracefully", () => {
changelogState.releases = [
{
id: 1,
tag_name: "v1.0.1",
name: "v1.0.1",
body: "body",
published_at: null,
html_url: "https://github.com/robinebers/openusage/releases/tag/v1.0.1",
},
]

render(
<ChangelogDialog
currentVersion="1.0.1"
onBack={() => {}}
onClose={() => {}}
/>,
)

expect(screen.getByText("v1.0.1")).toBeInTheDocument()
expect(screen.getByText("Unpublished release")).toBeInTheDocument()
})

it("shows link to full changelog when multiple releases exist", async () => {
changelogState.releases = [
{
Expand Down
17 changes: 9 additions & 8 deletions src/components/changelog-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,14 +223,15 @@ export function ChangelogDialog({ currentVersion, onBack, onClose }: ChangelogDi
<div>
<h3 className="font-bold text-lg">{currentRelease.name || currentRelease.tag_name}</h3>
<p className="text-[10px] text-muted-foreground mt-0.5">
Released on{" "}
{(() => {
const d = new Date(currentRelease.published_at)
const year = d.getUTCFullYear()
const month = String(d.getUTCMonth() + 1).padStart(2, "0")
const day = String(d.getUTCDate()).padStart(2, "0")
return `${year}/${month}/${day}`
})()}
{currentRelease.published_at
? (() => {
const d = new Date(currentRelease.published_at)
const year = d.getUTCFullYear()
const month = String(d.getUTCMonth() + 1).padStart(2, "0")
const day = String(d.getUTCDate()).padStart(2, "0")
return `Released on ${year}/${month}/${day}`
})()
: "Unpublished release"}
</p>
</div>
<button
Expand Down
6 changes: 3 additions & 3 deletions src/hooks/use-changelog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { useState, useEffect } from "react"
export interface Release {
id: number
tag_name: string
name: string
body: string
published_at: string
name: string | null
body: string | null
published_at: string | null
html_url: string
}

Expand Down