feat: port release-v2 experience improvements from #6582 (audited subset) (#6609)

This commit is contained in:
Thomas authored and GitHub committed 2026-08-18 09:40:02 +02:00
1 parent e3a713d2df
commit e842177d9b
163 files changed
+7390 -1240

No files matched your search

@@ -0,0 +1,93 @@
import { describe, expect, test } from "vitest";
import { buildDockerServiceUrlCandidates, matchDockerService } from "../docker-service-discovery";
describe("matchDockerService", () => {
test("reports image matches with high confidence and name fallbacks with medium confidence", () => {
expect(matchDockerService({ image: "linuxserver/sonarr:latest", name: "media" })).toEqual({
kind: "sonarr",
confidence: "high",
source: "image",
});
expect(matchDockerService({ image: "custom/media:latest", name: "sonarr" })).toEqual({
kind: "sonarr",
confidence: "medium",
source: "name",
});
});
});
describe("buildDockerServiceUrlCandidates", () => {
test("never emits wildcard or socket-path browser URLs", () => {
const candidates = buildDockerServiceUrlCandidates({
containerName: "sonarr",
endpointHost: "/var/run/docker.sock",
preferredPort: 8989,
ports: [{ IP: "0.0.0.0", PrivatePort: 8989, PublicPort: 8989, Type: "tcp" }],
});
expect(candidates.map(({ url }) => url)).not.toContain("http://0.0.0.0:8989");
expect(candidates.map(({ url }) => url)).not.toContain("http:///var/run/docker.sock:8989");
expect(candidates[0]).toMatchObject({
url: "http://sonarr:8989",
scopes: ["server"],
reason: "sharedContainerNetwork",
});
expect(candidates.at(-1)).toMatchObject({ url: "", reason: "manualHostRequired" });
});
test("uses a remote Docker endpoint hostname for wildcard published ports", () => {
const candidates = buildDockerServiceUrlCandidates({
containerName: "sonarr",
endpointHost: "docker.example.test:2375",
preferredPort: 8989,
ports: [{ IP: "0.0.0.0", PrivatePort: 8989, PublicPort: 8989, Type: "tcp" }],
});
expect(candidates[0]).toMatchObject({
url: "http://docker.example.test:8989",
scopes: ["browser", "server"],
reason: "dockerEndpointHost",
});
});
test.each(["127.0.0.1", "127.12.0.9", "::1", "::ffff:127.0.0.1", "localhost"])(
"does not advertise loopback address %s to browsers",
(address) => {
const candidates = buildDockerServiceUrlCandidates({
containerName: "sonarr",
endpointHost: "socket",
preferredPort: 8989,
ports: [{ IP: address, PrivatePort: 8989, PublicPort: 8989, Type: "tcp" }],
});
expect(candidates.some(({ source }) => source === "publishedAddress")).toBe(false);
expect(candidates.some(({ url, scopes }) => url.includes(address) && scopes.includes("browser"))).toBe(false);
},
);
test("does not use a loopback Docker endpoint as a browser URL", () => {
const candidates = buildDockerServiceUrlCandidates({
containerName: "sonarr",
endpointHost: "[::1]:2375",
preferredPort: 8989,
ports: [{ IP: "0.0.0.0", PrivatePort: 8989, PublicPort: 8989, Type: "tcp" }],
});
expect(candidates.some(({ source }) => source === "endpointHost")).toBe(false);
});
test.each(["tcp://10.0.0.5:2375", "unix:///var/run/docker.sock", "https://10.0.0.5"])(
"rejects a scheme-bearing endpoint host %s as a browser URL",
(endpointHost) => {
const candidates = buildDockerServiceUrlCandidates({
containerName: "sonarr",
endpointHost,
preferredPort: 8989,
ports: [{ IP: "0.0.0.0", PrivatePort: 8989, PublicPort: 8989, Type: "tcp" }],
});
expect(candidates.some(({ source }) => source === "endpointHost")).toBe(false);
},
);
});
@@ -1,10 +1,17 @@
import { describe, expect, it } from "vitest";
import { beforeEach, describe, expect, it, vi } from "vitest";
import { objectEntries } from "@homarr/common";
import { integrationDefs } from "../integration";
describe("Icon url's of integrations should be valid and return 200", () => {
beforeEach(() => {
vi.stubGlobal(
"fetch",
vi.fn(async () => new Response(null, { status: 200 })),
);
});
objectEntries(integrationDefs).forEach(([integration, { iconUrl }]) => {
it(`should return 200 for ${integration}`, { concurrent: true, retry: 2, timeout: 15_000 }, async () => {
const res = await fetch(iconUrl);
@@ -0,0 +1,47 @@
import { describe, expect, test } from "vitest";
import { integrationKinds } from "../integration";
import {
getWidgetKindsForIntegration,
integrationWidgetSupport,
nativeFeatureCapabilities,
widgetIntegrationLimits,
widgetIntegrationSupport,
widgetKindsWithOptionalIntegrations,
} from "../widget-integration-map";
describe("native feature capability descriptor", () => {
test("derives forward and reverse support without losing relationships", () => {
for (const [widgetKind, capability] of Object.entries(nativeFeatureCapabilities)) {
expect(widgetIntegrationSupport[widgetKind as keyof typeof widgetIntegrationSupport]).toEqual(
capability.integrations,
);
for (const integrationKind of capability.integrations) {
expect(integrationWidgetSupport[integrationKind]).toContain(widgetKind);
}
}
for (const integrationKind of integrationKinds) {
expect(getWidgetKindsForIntegration(integrationKind)).toEqual(integrationWidgetSupport[integrationKind]);
}
});
test("derives optional connections and server selection limits", () => {
expect(widgetKindsWithOptionalIntegrations).toEqual(new Set(["calendar"]));
expect(widgetIntegrationLimits).toEqual({
"smartHome-entityState": 1,
"smartHome-executeAutomation": 1,
mediaTranscoding: 1,
"immich-serverStats": 1,
"immich-albumCarousel": 1,
paperlessNgx: 1,
patchmon: 1,
bazarr: 1,
audioStats: 1,
umami: 1,
archiveTeamWarrior: 1,
anchorNote: 1,
wud: 1,
});
});
});