feat!: release v2 (#6545)
Co-authored-by: Artur <145776561+arturict@users.noreply.github.com> Co-authored-by: arturict <arturict@users.noreply.github.com> Co-authored-by: Thomas <thomas@ajnart.fr> Co-authored-by: Afonso Jorge Ramos <afonsojorgeramos@gmail.com> Co-authored-by: Danura30082 <danura30082+github@gmail.com> Co-authored-by: Kushie <122986913+kushiemoon-dev@users.noreply.github.com> Co-authored-by: ajnart <thomas@ajnart.fr> Co-authored-by: ajnart <thomas@ajnart.dev> Co-authored-by: chenjun <chenjun@foxmail.com> Co-authored-by: Wikibear <wikibear@users.noreply.github.com> Co-authored-by: Bergasha <bergasha@gmail.com> Co-authored-by: leafyelin <43306196+leafyelin@users.noreply.github.com> Co-authored-by: Lucas Araujo <lucas.lra@gmail.com> Co-authored-by: GreenMonito <86085570+GreenMonito@users.noreply.github.com> Co-authored-by: Nerdy-Technician <roffo@nerdy-technician.social> Co-authored-by: Jun <34545896+jcstrong@users.noreply.github.com> Co-authored-by: Edmond Abraham <54119952+gitedmond@users.noreply.github.com> Co-authored-by: thrawnx <tight.bulb9384@fastmail.com> Co-authored-by: Chris <58918656+nordada@users.noreply.github.com> Co-authored-by: yi111 <153097222+Yi-111-a@users.noreply.github.com> Co-authored-by: Yanis <naamaneyanis@gmail.com> Co-authored-by: Wikibear <me@sej.de> Co-authored-by: alessiottavo <93441886+alessiottavo@users.noreply.github.com>
This commit is contained in:
3286 files changed
+284386
-139176
No files matched your search
@@ -0,0 +1,61 @@
|
||||
import { afterEach, describe, expect, test } from "vitest";
|
||||
|
||||
import { getDemoStatsValues, getStatsSnapshotAsync } from "./stats";
|
||||
|
||||
const previousDemoMode = process.env.DEMO_MODE;
|
||||
|
||||
afterEach(() => {
|
||||
if (previousDemoMode === undefined) delete process.env.DEMO_MODE;
|
||||
else process.env.DEMO_MODE = previousDemoMode;
|
||||
});
|
||||
|
||||
describe("demo integration statistics", () => {
|
||||
test("returns showcase values only for seeded demo sources", () => {
|
||||
process.env.DEMO_MODE = "true";
|
||||
|
||||
expect(getDemoStatsValues({ kind: "sonarr", url: "https://demo.homarr.dev" })).toMatchObject({
|
||||
shows: 74,
|
||||
episodes: 3_986,
|
||||
});
|
||||
expect(getDemoStatsValues({ kind: "mealie", url: "https://demo.homarr.dev" })).toEqual({
|
||||
recipes: 318,
|
||||
users: 14,
|
||||
categories: 28,
|
||||
tags: 76,
|
||||
});
|
||||
expect(getDemoStatsValues({ kind: "spoolman", url: "https://demo.homarr.dev" })).toEqual({
|
||||
spools: 24,
|
||||
remainingWeight: 8_120,
|
||||
});
|
||||
expect(getDemoStatsValues({ kind: "sonarr", url: "https://sonarr.example.com" })).toBeUndefined();
|
||||
expect(getDemoStatsValues({ kind: "mock", url: "https://demo.homarr.dev" })).toBeUndefined();
|
||||
});
|
||||
|
||||
test("serves seeded values through the read-only snapshot path", async () => {
|
||||
process.env.DEMO_MODE = "true";
|
||||
|
||||
const snapshot = await getStatsSnapshotAsync({
|
||||
id: "demo-spoolman",
|
||||
appId: null,
|
||||
kind: "spoolman",
|
||||
name: "Spoolman",
|
||||
url: "https://demo.homarr.dev",
|
||||
externalUrl: null,
|
||||
decryptedSecrets: [],
|
||||
});
|
||||
|
||||
expect(snapshot).toMatchObject({
|
||||
values: { spools: 24, remainingWeight: 8_120 },
|
||||
retryAt: 0,
|
||||
error: false,
|
||||
stale: false,
|
||||
});
|
||||
expect(snapshot.updatedAt).not.toBeNull();
|
||||
});
|
||||
|
||||
test("does not replace live statistics outside demo mode", () => {
|
||||
process.env.DEMO_MODE = "false";
|
||||
|
||||
expect(getDemoStatsValues({ kind: "sonarr", url: "https://demo.homarr.dev" })).toBeUndefined();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user