- {repo.name}
+ {#if $canAccess('settings', 'edit')}
+
+ {:else}
+ {repo.name}
+ {/if}
{repo.url}
diff --git a/tests/changelog-filter.test.ts b/tests/changelog-filter.test.ts
index 56be0f001..69b564be6 100644
--- a/tests/changelog-filter.test.ts
+++ b/tests/changelog-filter.test.ts
@@ -1,5 +1,7 @@
import { describe, test, expect } from 'bun:test';
import { releasedEntries } from '../src/lib/utils/changelog-filter';
+import { latestReleasedVersion } from '../scripts/generate-changelog-page';
+import changelogJson from '../src/lib/data/changelog.json';
describe('releasedEntries', () => {
test('drops coming-soon (unreleased) entries', () => {
@@ -29,3 +31,40 @@ describe('releasedEntries', () => {
expect(releasedEntries(entries)[0].version).toBe('1.0.47');
});
});
+
+describe('latestReleasedVersion (landing page JSON-LD softwareVersion)', () => {
+ test('skips a coming-soon top entry and resolves to the newest shipped one', () => {
+ // The distinguishing case: reading entries[0] here would advertise a version
+ // nobody can download.
+ expect(
+ latestReleasedVersion([
+ { version: '1.0.50', comingSoon: true },
+ { version: '1.0.49' },
+ { version: '1.0.48' }
+ ] as never)
+ ).toBe('1.0.49');
+ });
+
+ test('resolves to the first entry when nothing is coming-soon', () => {
+ expect(
+ latestReleasedVersion([{ version: '1.0.49' }, { version: '1.0.48' }] as never)
+ ).toBe('1.0.49');
+ });
+
+ test('returns null when every entry is coming-soon, so the caller leaves the schema alone', () => {
+ expect(latestReleasedVersion([{ version: '1.0.50', comingSoon: true }] as never)).toBeNull();
+ });
+
+ test('returns null for an empty changelog', () => {
+ expect(latestReleasedVersion([])).toBeNull();
+ });
+
+ test('the shipped changelog resolves to a version that is not the coming-soon top entry', () => {
+ const changelog = changelogJson as { version: string; comingSoon?: boolean }[];
+ const resolved = latestReleasedVersion(changelog as never);
+ expect(resolved).toBe(changelog.find((e) => !e.comingSoon)!.version);
+ if (changelog[0].comingSoon) {
+ expect(resolved).not.toBe(changelog[0].version);
+ }
+ });
+});
diff --git a/tests/merge-partial-stats.test.ts b/tests/merge-partial-stats.test.ts
index 00cc0378a..fd3d553fc 100644
--- a/tests/merge-partial-stats.test.ts
+++ b/tests/merge-partial-stats.test.ts
@@ -124,6 +124,41 @@ describe('mergePartialStats - skeleton placeholders never blank a populated tile
});
});
+describe('mergePartialStats - event-triggered refresh keeps lists the non-stream endpoint omits', () => {
+ // The non-streaming /api/dashboard/stats does not compute topContainers/recentEvents
+ // (only the SSE stream does). An event-triggered refresh must MERGE its response so the
+ // richer lists a tile already got from the stream survive, instead of being blanked.
+ it('undefined topContainers/recentEvents in the refresh keep the stream-provided lists', () => {
+ // existing = what the SSE stream delivered
+ const existing: any = {
+ id: 8,
+ containers: { total: 8, running: 8, stopped: 0 },
+ topContainers: [{ id: 'a' }, { id: 'b' }, { id: 'c' }, { id: 'd' }, { id: 'e' }, { id: 'f' }, { id: 'g' }, { id: 'h' }],
+ recentEvents: Array.from({ length: 10 }, (_, i) => ({ action: 'start', container_name: `c${i}` })),
+ events: { today: 400, total: 700 }
+ };
+ // partial = the non-stream refresh: correct counts, no lists (fields omitted)
+ mergePartialStats(existing, {
+ id: 8,
+ containers: { total: 8, running: 8, stopped: 0 },
+ topContainers: undefined,
+ recentEvents: undefined,
+ events: { today: 488, total: 712 }
+ });
+ expect(existing.topContainers.length).toBe(8); // preserved, not blanked
+ expect(existing.recentEvents.length).toBe(10); // preserved, not blanked
+ expect(existing.events).toEqual({ today: 488, total: 712 }); // fresh counts applied
+ expect(existing.containers.running).toBe(8);
+ });
+
+ it('a genuine empty topContainers array (present, no loading flag) DOES replace', () => {
+ // If the endpoint ever explicitly sends [] (real "no running containers"), honour it.
+ const existing: any = { id: 8, topContainers: [{ id: 'a' }] };
+ mergePartialStats(existing, { id: 8, topContainers: [] });
+ expect(existing.topContainers).toEqual([]);
+ });
+});
+
describe('definedPartialForStore - store payload drops placeholder sections but keeps loading', () => {
it('drops a loading section, keeps loading + ready sections', () => {
const partial: any = {