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
@@ -1,7 +1,7 @@
|
||||
import type { QueryKey } from "@tanstack/react-query";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { widgetIntegrationSupport, widgetKinds as definedWidgetKinds } from "@homarr/definitions";
|
||||
import { widgetIntegrationSupport, widgetKinds as declaredWidgetKinds } from "@homarr/definitions";
|
||||
|
||||
import {
|
||||
createRetryableLoader,
|
||||
@@ -14,7 +14,16 @@ import {
|
||||
widgetKinds,
|
||||
} from "./manifest";
|
||||
import { widgetQueryRefetchIntervals } from "./refetch-intervals";
|
||||
import { widgetCatalogIcons } from "./catalog";
|
||||
import { widgetCatalogIcons } from "@homarr/ui/widget-icons";
|
||||
import { getWidgetQueryKeys } from "./definition";
|
||||
|
||||
const serializePollingPolicy = ({
|
||||
queryKey,
|
||||
intervalSeconds,
|
||||
}: {
|
||||
queryKey: QueryKey;
|
||||
intervalSeconds: number | null;
|
||||
}) => JSON.stringify({ queryKey, intervalSeconds });
|
||||
|
||||
describe("widget manifest promise stability", () => {
|
||||
it("returns the same module promise for every render", () => {
|
||||
@@ -55,7 +64,7 @@ describe("widget manifest promise stability", () => {
|
||||
});
|
||||
|
||||
it("covers every declared widget kind", () => {
|
||||
expect(new Set(widgetKinds)).toEqual(new Set(definedWidgetKinds));
|
||||
expect(new Set(widgetKinds)).toEqual(new Set(declaredWidgetKinds));
|
||||
});
|
||||
|
||||
it("loads matching definitions and component loaders for every widget", async () => {
|
||||
@@ -67,6 +76,7 @@ describe("widget manifest promise stability", () => {
|
||||
const canonicalComponent = await module.componentLoader();
|
||||
const component = await loadWidgetComponent(kind);
|
||||
const resources = await loadWidgetResources(kind);
|
||||
expect(module.definition.kind).toBe(kind);
|
||||
expect(definitions.get(kind)).toBe(module.definition);
|
||||
expect(component.default).toBe(canonicalComponent.default);
|
||||
expect(component.default).toBeDefined();
|
||||
@@ -95,7 +105,8 @@ describe("widget manifest promise stability", () => {
|
||||
const definition = definitions.get(kind);
|
||||
const supportedIntegrations =
|
||||
definition && "supportedIntegrations" in definition ? (definition.supportedIntegrations ?? []) : [];
|
||||
expect([...(widgetIntegrationSupport[kind] ?? [])].toSorted()).toEqual([...supportedIntegrations].toSorted());
|
||||
const expectedIntegrations = widgetIntegrationSupport[kind] ?? [];
|
||||
expect(expectedIntegrations.toSorted()).toEqual([...supportedIntegrations].toSorted());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -111,11 +122,11 @@ describe("widget manifest promise stability", () => {
|
||||
const definitions = await loadAllWidgetDefinitions();
|
||||
const expectedQueryKeys = new Map([
|
||||
["anchorNote", [["widget", "anchorNotes"]]],
|
||||
["beszelAlerts", [["widget", "beszel"]]],
|
||||
["clock", [["widget", "weather"]]],
|
||||
["mediaMissing", [["widget", "mediaOrganizer"]]],
|
||||
["mediaRequests-requestList", [["widget", "mediaRequests"]]],
|
||||
["mediaRequests-requestStats", [["widget", "mediaRequests"]]],
|
||||
["beszelAlerts", [["widget", "beszel", "getAlerts"]]],
|
||||
["clock", [["widget", "weather", "atLocation"]]],
|
||||
["mediaMissing", [["widget", "mediaOrganizer", "getData"]]],
|
||||
["mediaRequests-requestList", [["widget", "mediaRequests", "getLatestRequests"]]],
|
||||
["mediaRequests-requestStats", [["widget", "mediaRequests", "getStats"]]],
|
||||
["smartHome-entityState", [["widget", "smartHome"]]],
|
||||
] as const);
|
||||
|
||||
@@ -133,19 +144,38 @@ describe("widget manifest promise stability", () => {
|
||||
const definition = definitions.get(kind);
|
||||
if (definition?.refetchInterval === undefined) continue;
|
||||
|
||||
const entry = {
|
||||
queryKey: definition.queryKey ?? [["widget", kind]],
|
||||
intervalSeconds: definition.refetchInterval,
|
||||
} as const;
|
||||
const serializedQueryKey = JSON.stringify(entry.queryKey);
|
||||
const existing = expectedByQueryKey.get(serializedQueryKey);
|
||||
expect(existing?.intervalSeconds ?? entry.intervalSeconds).toBe(entry.intervalSeconds);
|
||||
expectedByQueryKey.set(serializedQueryKey, entry);
|
||||
for (const queryKey of getWidgetQueryKeys(definition, kind)) {
|
||||
const path = queryKey[0];
|
||||
if (!Array.isArray(path) || (path[0] !== "widget" && path[0] !== "docker")) continue;
|
||||
const entry = { queryKey, intervalSeconds: definition.refetchInterval } as const;
|
||||
const serializedQueryKey = JSON.stringify(entry.queryKey);
|
||||
const existing = expectedByQueryKey.get(serializedQueryKey);
|
||||
expect(existing?.intervalSeconds ?? entry.intervalSeconds).toBe(entry.intervalSeconds);
|
||||
expectedByQueryKey.set(serializedQueryKey, entry);
|
||||
}
|
||||
}
|
||||
|
||||
const serializePolicy = (entry: PollingPolicy) => JSON.stringify(entry);
|
||||
expect(widgetQueryRefetchIntervals.map(serializePolicy).toSorted()).toEqual(
|
||||
[...expectedByQueryKey.values()].map(serializePolicy).toSorted(),
|
||||
expect(widgetQueryRefetchIntervals.map(serializePollingPolicy).toSorted()).toEqual(
|
||||
[...expectedByQueryKey.values()].map(serializePollingPolicy).toSorted(),
|
||||
);
|
||||
});
|
||||
|
||||
it("does not poll integration handlers faster than their cache can refresh", async () => {
|
||||
const definitions = await loadAllWidgetDefinitions();
|
||||
const cachedWidgetKinds = [
|
||||
"dnsHoleControls",
|
||||
"dnsHoleSummary",
|
||||
"downloads",
|
||||
"firewall",
|
||||
"healthMonitoring",
|
||||
"mediaServer",
|
||||
"systemDisks",
|
||||
"systemResources",
|
||||
"tracearr",
|
||||
] as const;
|
||||
|
||||
for (const kind of cachedWidgetKinds) {
|
||||
expect(definitions.get(kind)?.refetchInterval).toBe(10);
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user