diff --git a/src/test-utils/widget-assertions.js b/src/test-utils/widget-assertions.js index 67bd2ac44..bf9598c90 100644 --- a/src/test-utils/widget-assertions.js +++ b/src/test-utils/widget-assertions.js @@ -1,4 +1,12 @@ +import { expect } from "vitest"; + export function findServiceBlockByLabel(container, label) { const blocks = Array.from(container.querySelectorAll(".service-block")); return blocks.find((b) => b.textContent?.includes(label)); } + +export function expectBlockValue(container, label, value) { + const block = findServiceBlockByLabel(container, label); + expect(block, `missing block for ${label}`).toBeTruthy(); + expect(block.textContent).toContain(String(value)); +} diff --git a/src/widgets/arcane/component.test.jsx b/src/widgets/arcane/component.test.jsx index cb6fe6a5e..5e6a78587 100644 --- a/src/widgets/arcane/component.test.jsx +++ b/src/widgets/arcane/component.test.jsx @@ -4,6 +4,7 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); @@ -13,13 +14,6 @@ vi.mock("utils/proxy/use-widget-api", () => ({ import Component from "./component"; -function expectBlockValue(container, label, value) { - const blocks = Array.from(container.querySelectorAll(".service-block")); - const block = blocks.find((b) => b.textContent?.includes(label)); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/arcane/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/argocd/component.test.jsx b/src/widgets/argocd/component.test.jsx index e59175cf2..88b102643 100644 --- a/src/widgets/argocd/component.test.jsx +++ b/src/widgets/argocd/component.test.jsx @@ -4,6 +4,7 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); @@ -13,13 +14,6 @@ vi.mock("utils/proxy/use-widget-api", () => ({ import Component from "./component"; -function expectBlockValue(container, label, value) { - const blocks = Array.from(container.querySelectorAll(".service-block")); - const block = blocks.find((b) => b.textContent?.includes(label)); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/argocd/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/audiobookshelf/component.test.jsx b/src/widgets/audiobookshelf/component.test.jsx index 9f74a89d2..449ae0703 100644 --- a/src/widgets/audiobookshelf/component.test.jsx +++ b/src/widgets/audiobookshelf/component.test.jsx @@ -4,6 +4,7 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); @@ -13,13 +14,6 @@ vi.mock("utils/proxy/use-widget-api", () => ({ import Component from "./component"; -function expectBlockValue(container, label, value) { - const blocks = Array.from(container.querySelectorAll(".service-block")); - const block = blocks.find((b) => b.textContent?.includes(label)); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/audiobookshelf/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/authentik/component.test.jsx b/src/widgets/authentik/component.test.jsx index 43a4f39c4..4b1688391 100644 --- a/src/widgets/authentik/component.test.jsx +++ b/src/widgets/authentik/component.test.jsx @@ -4,6 +4,7 @@ import { screen } from "@testing-library/react"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); @@ -13,13 +14,6 @@ vi.mock("utils/proxy/use-widget-api", () => ({ import Component from "./component"; -function expectBlockValue(container, label, value) { - const blocks = Array.from(container.querySelectorAll(".service-block")); - const block = blocks.find((b) => b.textContent?.includes(label)); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/authentik/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/autobrr/component.test.jsx b/src/widgets/autobrr/component.test.jsx index 8f828b2eb..4607bf51a 100644 --- a/src/widgets/autobrr/component.test.jsx +++ b/src/widgets/autobrr/component.test.jsx @@ -4,6 +4,7 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); @@ -13,13 +14,6 @@ vi.mock("utils/proxy/use-widget-api", () => ({ import Component from "./component"; -function expectBlockValue(container, label, value) { - const blocks = Array.from(container.querySelectorAll(".service-block")); - const block = blocks.find((b) => b.textContent?.includes(label)); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/autobrr/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/azuredevops/component.test.jsx b/src/widgets/azuredevops/component.test.jsx index e540e85d7..ae42730f4 100644 --- a/src/widgets/azuredevops/component.test.jsx +++ b/src/widgets/azuredevops/component.test.jsx @@ -4,6 +4,7 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); @@ -13,13 +14,6 @@ vi.mock("utils/proxy/use-widget-api", () => ({ import Component from "./component"; -function expectBlockValue(container, label, value) { - const blocks = Array.from(container.querySelectorAll(".service-block")); - const block = blocks.find((b) => b.textContent?.includes(label)); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/azuredevops/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/beszel/component.test.jsx b/src/widgets/beszel/component.test.jsx index ee6218f2d..cf870b46e 100644 --- a/src/widgets/beszel/component.test.jsx +++ b/src/widgets/beszel/component.test.jsx @@ -4,7 +4,7 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); @@ -12,12 +12,6 @@ vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/beszel/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/caddy/component.test.jsx b/src/widgets/caddy/component.test.jsx index 43a060455..01952a9fc 100644 --- a/src/widgets/caddy/component.test.jsx +++ b/src/widgets/caddy/component.test.jsx @@ -4,7 +4,7 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); @@ -12,12 +12,6 @@ vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/caddy/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/changedetectionio/component.test.jsx b/src/widgets/changedetectionio/component.test.jsx index ef777d16c..b227a07bd 100644 --- a/src/widgets/changedetectionio/component.test.jsx +++ b/src/widgets/changedetectionio/component.test.jsx @@ -4,7 +4,7 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); @@ -12,12 +12,6 @@ vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/changedetectionio/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/channelsdvrserver/component.test.jsx b/src/widgets/channelsdvrserver/component.test.jsx index 5198999e0..0ff4fe72e 100644 --- a/src/widgets/channelsdvrserver/component.test.jsx +++ b/src/widgets/channelsdvrserver/component.test.jsx @@ -4,7 +4,7 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); @@ -12,12 +12,6 @@ vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/channelsdvrserver/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/checkmk/component.test.jsx b/src/widgets/checkmk/component.test.jsx index 25e5e529b..7f00069fa 100644 --- a/src/widgets/checkmk/component.test.jsx +++ b/src/widgets/checkmk/component.test.jsx @@ -4,7 +4,7 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); @@ -12,12 +12,6 @@ vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/checkmk/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/cloudflared/component.test.jsx b/src/widgets/cloudflared/component.test.jsx index e6904536a..9a81a0835 100644 --- a/src/widgets/cloudflared/component.test.jsx +++ b/src/widgets/cloudflared/component.test.jsx @@ -4,7 +4,7 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); @@ -12,12 +12,6 @@ vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/cloudflared/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/crowdsec/component.test.jsx b/src/widgets/crowdsec/component.test.jsx index 4c2d4f2b7..abc4c8696 100644 --- a/src/widgets/crowdsec/component.test.jsx +++ b/src/widgets/crowdsec/component.test.jsx @@ -4,7 +4,7 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); @@ -12,12 +12,6 @@ vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/crowdsec/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/deluge/component.test.jsx b/src/widgets/deluge/component.test.jsx index bdda50f02..677449883 100644 --- a/src/widgets/deluge/component.test.jsx +++ b/src/widgets/deluge/component.test.jsx @@ -4,7 +4,7 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); @@ -16,12 +16,6 @@ vi.mock("../../components/widgets/queue/queueEntry", () => ({ import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/deluge/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/diskstation/component.test.jsx b/src/widgets/diskstation/component.test.jsx index 449c4a619..dc1153fb0 100644 --- a/src/widgets/diskstation/component.test.jsx +++ b/src/widgets/diskstation/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/diskstation/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/dispatcharr/component.test.jsx b/src/widgets/dispatcharr/component.test.jsx index 85f237b33..4a9257811 100644 --- a/src/widgets/dispatcharr/component.test.jsx +++ b/src/widgets/dispatcharr/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/dispatcharr/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/dockhand/component.test.jsx b/src/widgets/dockhand/component.test.jsx index f3ca02fc4..d9f0be490 100644 --- a/src/widgets/dockhand/component.test.jsx +++ b/src/widgets/dockhand/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/dockhand/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/downloadstation/component.test.jsx b/src/widgets/downloadstation/component.test.jsx index 5e25f7e3e..5dd529f63 100644 --- a/src/widgets/downloadstation/component.test.jsx +++ b/src/widgets/downloadstation/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/downloadstation/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/esphome/component.test.jsx b/src/widgets/esphome/component.test.jsx index 41991c1dc..10ad52176 100644 --- a/src/widgets/esphome/component.test.jsx +++ b/src/widgets/esphome/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/esphome/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/evcc/component.test.jsx b/src/widgets/evcc/component.test.jsx index a337deb6f..7922a0135 100644 --- a/src/widgets/evcc/component.test.jsx +++ b/src/widgets/evcc/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/evcc/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/filebrowser/component.test.jsx b/src/widgets/filebrowser/component.test.jsx index 7eb0e12b7..be31633ae 100644 --- a/src/widgets/filebrowser/component.test.jsx +++ b/src/widgets/filebrowser/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/filebrowser/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/fileflows/component.test.jsx b/src/widgets/fileflows/component.test.jsx index 74dd5deec..5b0e42771 100644 --- a/src/widgets/fileflows/component.test.jsx +++ b/src/widgets/fileflows/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/fileflows/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/flood/component.test.jsx b/src/widgets/flood/component.test.jsx index ad49bcfbd..fd53ffecb 100644 --- a/src/widgets/flood/component.test.jsx +++ b/src/widgets/flood/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/flood/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/freshrss/component.test.jsx b/src/widgets/freshrss/component.test.jsx index e5dd20033..c4685de3d 100644 --- a/src/widgets/freshrss/component.test.jsx +++ b/src/widgets/freshrss/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/freshrss/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/frigate/component.test.jsx b/src/widgets/frigate/component.test.jsx index f9805a6df..5f0cfaed7 100644 --- a/src/widgets/frigate/component.test.jsx +++ b/src/widgets/frigate/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/frigate/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/fritzbox/component.test.jsx b/src/widgets/fritzbox/component.test.jsx index 04a7e268e..f1abcaf41 100644 --- a/src/widgets/fritzbox/component.test.jsx +++ b/src/widgets/fritzbox/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component, { fritzboxDefaultFields } from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/fritzbox/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/gamedig/component.test.jsx b/src/widgets/gamedig/component.test.jsx index d56b93bfa..895b4d3bc 100644 --- a/src/widgets/gamedig/component.test.jsx +++ b/src/widgets/gamedig/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/gamedig/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/gatus/component.test.jsx b/src/widgets/gatus/component.test.jsx index 0d5b144a8..51176baad 100644 --- a/src/widgets/gatus/component.test.jsx +++ b/src/widgets/gatus/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/gatus/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/ghostfolio/component.test.jsx b/src/widgets/ghostfolio/component.test.jsx index d71cd5b36..05277071a 100644 --- a/src/widgets/ghostfolio/component.test.jsx +++ b/src/widgets/ghostfolio/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/ghostfolio/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/gitea/component.test.jsx b/src/widgets/gitea/component.test.jsx index c54267677..c0325bba1 100644 --- a/src/widgets/gitea/component.test.jsx +++ b/src/widgets/gitea/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/gitea/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/gitlab/component.test.jsx b/src/widgets/gitlab/component.test.jsx index f19cbf3bc..4fa741519 100644 --- a/src/widgets/gitlab/component.test.jsx +++ b/src/widgets/gitlab/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/gitlab/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/gluetun/component.test.jsx b/src/widgets/gluetun/component.test.jsx index 0e6c1b35a..aeb617493 100644 --- a/src/widgets/gluetun/component.test.jsx +++ b/src/widgets/gluetun/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/gluetun/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/gotify/component.test.jsx b/src/widgets/gotify/component.test.jsx index b83f7cc4e..853c627f2 100644 --- a/src/widgets/gotify/component.test.jsx +++ b/src/widgets/gotify/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/gotify/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/grafana/component.test.jsx b/src/widgets/grafana/component.test.jsx index 30e39c1ea..ab30f90c0 100644 --- a/src/widgets/grafana/component.test.jsx +++ b/src/widgets/grafana/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/grafana/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/hdhomerun/component.test.jsx b/src/widgets/hdhomerun/component.test.jsx index 7f4ef5452..b0afac7b4 100644 --- a/src/widgets/hdhomerun/component.test.jsx +++ b/src/widgets/hdhomerun/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/hdhomerun/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/headscale/component.test.jsx b/src/widgets/headscale/component.test.jsx index 39715ec1f..d4c321556 100644 --- a/src/widgets/headscale/component.test.jsx +++ b/src/widgets/headscale/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/headscale/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/healthchecks/component.test.jsx b/src/widgets/healthchecks/component.test.jsx index 92a11f105..ed1a15a59 100644 --- a/src/widgets/healthchecks/component.test.jsx +++ b/src/widgets/healthchecks/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/healthchecks/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/homebox/component.test.jsx b/src/widgets/homebox/component.test.jsx index 164247d73..0342e8392 100644 --- a/src/widgets/homebox/component.test.jsx +++ b/src/widgets/homebox/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component, { homeboxDefaultFields } from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/homebox/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/immich/component.test.jsx b/src/widgets/immich/component.test.jsx index fa282ee05..2149d21d9 100644 --- a/src/widgets/immich/component.test.jsx +++ b/src/widgets/immich/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/immich/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/jackett/component.test.jsx b/src/widgets/jackett/component.test.jsx index 99cb4ce02..a3ee09cde 100644 --- a/src/widgets/jackett/component.test.jsx +++ b/src/widgets/jackett/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/jackett/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/jdownloader/component.test.jsx b/src/widgets/jdownloader/component.test.jsx index 1a3fab6ff..a83ea1991 100644 --- a/src/widgets/jdownloader/component.test.jsx +++ b/src/widgets/jdownloader/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/jdownloader/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/karakeep/component.test.jsx b/src/widgets/karakeep/component.test.jsx index bf6d7ca2c..6b95e71e8 100644 --- a/src/widgets/karakeep/component.test.jsx +++ b/src/widgets/karakeep/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component, { karakeepDefaultFields } from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/karakeep/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/komga/component.test.jsx b/src/widgets/komga/component.test.jsx index 4459b21bc..a2a6a95f3 100644 --- a/src/widgets/komga/component.test.jsx +++ b/src/widgets/komga/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/komga/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/kopia/component.test.jsx b/src/widgets/kopia/component.test.jsx index 96cd4cb36..98af11a13 100644 --- a/src/widgets/kopia/component.test.jsx +++ b/src/widgets/kopia/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/kopia/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/lidarr/component.test.jsx b/src/widgets/lidarr/component.test.jsx index ecbacfd38..106371433 100644 --- a/src/widgets/lidarr/component.test.jsx +++ b/src/widgets/lidarr/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/lidarr/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/linkwarden/component.test.jsx b/src/widgets/linkwarden/component.test.jsx index 5cb0ba6c5..a87a7975b 100644 --- a/src/widgets/linkwarden/component.test.jsx +++ b/src/widgets/linkwarden/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/linkwarden/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/lubelogger/component.test.jsx b/src/widgets/lubelogger/component.test.jsx index 2890a0f88..da81ff095 100644 --- a/src/widgets/lubelogger/component.test.jsx +++ b/src/widgets/lubelogger/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/lubelogger/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/mailcow/component.test.jsx b/src/widgets/mailcow/component.test.jsx index adc5794fb..a679de650 100644 --- a/src/widgets/mailcow/component.test.jsx +++ b/src/widgets/mailcow/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/mailcow/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/mastodon/component.test.jsx b/src/widgets/mastodon/component.test.jsx index 589dc6fe1..d50b48935 100644 --- a/src/widgets/mastodon/component.test.jsx +++ b/src/widgets/mastodon/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/mastodon/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/mealie/component.test.jsx b/src/widgets/mealie/component.test.jsx index 7cb2fe660..ade5a9b9a 100644 --- a/src/widgets/mealie/component.test.jsx +++ b/src/widgets/mealie/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/mealie/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/medusa/component.test.jsx b/src/widgets/medusa/component.test.jsx index ae6bfa752..9ab501b22 100644 --- a/src/widgets/medusa/component.test.jsx +++ b/src/widgets/medusa/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/medusa/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/mikrotik/component.test.jsx b/src/widgets/mikrotik/component.test.jsx index 87f4af44c..4697d9dd7 100644 --- a/src/widgets/mikrotik/component.test.jsx +++ b/src/widgets/mikrotik/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/mikrotik/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/minecraft/component.test.jsx b/src/widgets/minecraft/component.test.jsx index 399056232..a26c677b4 100644 --- a/src/widgets/minecraft/component.test.jsx +++ b/src/widgets/minecraft/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/minecraft/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/miniflux/component.test.jsx b/src/widgets/miniflux/component.test.jsx index 0a3ec4d1c..938147123 100644 --- a/src/widgets/miniflux/component.test.jsx +++ b/src/widgets/miniflux/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/miniflux/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/moonraker/component.test.jsx b/src/widgets/moonraker/component.test.jsx index dab81e317..f99a5bb74 100644 --- a/src/widgets/moonraker/component.test.jsx +++ b/src/widgets/moonraker/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/moonraker/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/mylar/component.test.jsx b/src/widgets/mylar/component.test.jsx index 4e7846525..d2464c1a5 100644 --- a/src/widgets/mylar/component.test.jsx +++ b/src/widgets/mylar/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/mylar/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/myspeed/component.test.jsx b/src/widgets/myspeed/component.test.jsx index 5bc5fb3b5..740bb460d 100644 --- a/src/widgets/myspeed/component.test.jsx +++ b/src/widgets/myspeed/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/myspeed/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/netalertx/component.test.jsx b/src/widgets/netalertx/component.test.jsx index a4b077dfc..4ab7b2e68 100644 --- a/src/widgets/netalertx/component.test.jsx +++ b/src/widgets/netalertx/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/netalertx/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/netdata/component.test.jsx b/src/widgets/netdata/component.test.jsx index be0341a16..ec084e7a6 100644 --- a/src/widgets/netdata/component.test.jsx +++ b/src/widgets/netdata/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/netdata/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/npm/component.test.jsx b/src/widgets/npm/component.test.jsx index b8316f584..f3c507989 100644 --- a/src/widgets/npm/component.test.jsx +++ b/src/widgets/npm/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/npm/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/nzbget/component.test.jsx b/src/widgets/nzbget/component.test.jsx index bfb076606..bff5f8611 100644 --- a/src/widgets/nzbget/component.test.jsx +++ b/src/widgets/nzbget/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/nzbget/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/octoprint/component.test.jsx b/src/widgets/octoprint/component.test.jsx index e55582be4..2e875362e 100644 --- a/src/widgets/octoprint/component.test.jsx +++ b/src/widgets/octoprint/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/octoprint/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/ombi/component.test.jsx b/src/widgets/ombi/component.test.jsx index 972aa596e..522b0e23a 100644 --- a/src/widgets/ombi/component.test.jsx +++ b/src/widgets/ombi/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/ombi/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/opendtu/component.test.jsx b/src/widgets/opendtu/component.test.jsx index d2652986b..388b3cbbb 100644 --- a/src/widgets/opendtu/component.test.jsx +++ b/src/widgets/opendtu/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/opendtu/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/opnsense/component.test.jsx b/src/widgets/opnsense/component.test.jsx index 2fa972ce0..884525f73 100644 --- a/src/widgets/opnsense/component.test.jsx +++ b/src/widgets/opnsense/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/opnsense/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/overseerr/component.test.jsx b/src/widgets/overseerr/component.test.jsx index 689f10aba..b052fb50e 100644 --- a/src/widgets/overseerr/component.test.jsx +++ b/src/widgets/overseerr/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/overseerr/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/pangolin/component.test.jsx b/src/widgets/pangolin/component.test.jsx index 791a25808..4796b2ee1 100644 --- a/src/widgets/pangolin/component.test.jsx +++ b/src/widgets/pangolin/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue, findServiceBlockByLabel } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/pangolin/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/paperlessngx/component.test.jsx b/src/widgets/paperlessngx/component.test.jsx index 8df49f97e..354af3b61 100644 --- a/src/widgets/paperlessngx/component.test.jsx +++ b/src/widgets/paperlessngx/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue, findServiceBlockByLabel } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/paperlessngx/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/pfsense/component.test.jsx b/src/widgets/pfsense/component.test.jsx index dbfa08944..dd3ba2c31 100644 --- a/src/widgets/pfsense/component.test.jsx +++ b/src/widgets/pfsense/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue, findServiceBlockByLabel } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/pfsense/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/photoprism/component.test.jsx b/src/widgets/photoprism/component.test.jsx index 3f95f1f88..317562ebc 100644 --- a/src/widgets/photoprism/component.test.jsx +++ b/src/widgets/photoprism/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/photoprism/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/plantit/component.test.jsx b/src/widgets/plantit/component.test.jsx index 61502f8cf..c81262542 100644 --- a/src/widgets/plantit/component.test.jsx +++ b/src/widgets/plantit/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/plantit/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/plex/component.test.jsx b/src/widgets/plex/component.test.jsx index 301d0b08b..286b5cb60 100644 --- a/src/widgets/plex/component.test.jsx +++ b/src/widgets/plex/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/plex/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/portainer/component.test.jsx b/src/widgets/portainer/component.test.jsx index 49bb5b782..b87845cde 100644 --- a/src/widgets/portainer/component.test.jsx +++ b/src/widgets/portainer/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/portainer/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/prometheus/component.test.jsx b/src/widgets/prometheus/component.test.jsx index f714f653c..eb86d2af0 100644 --- a/src/widgets/prometheus/component.test.jsx +++ b/src/widgets/prometheus/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/prometheus/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/prometheusmetric/component.test.jsx b/src/widgets/prometheusmetric/component.test.jsx index 8df915874..36731050f 100644 --- a/src/widgets/prometheusmetric/component.test.jsx +++ b/src/widgets/prometheusmetric/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/prometheusmetric/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/prowlarr/component.test.jsx b/src/widgets/prowlarr/component.test.jsx index b9111a5db..19dff8cdc 100644 --- a/src/widgets/prowlarr/component.test.jsx +++ b/src/widgets/prowlarr/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/prowlarr/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/proxmox/component.test.jsx b/src/widgets/proxmox/component.test.jsx index 477c34f01..ca61cb171 100644 --- a/src/widgets/proxmox/component.test.jsx +++ b/src/widgets/proxmox/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/proxmox/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/proxmoxvm/component.test.jsx b/src/widgets/proxmoxvm/component.test.jsx index f535d1d3b..fffaacf42 100644 --- a/src/widgets/proxmoxvm/component.test.jsx +++ b/src/widgets/proxmoxvm/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useSWR } = vi.hoisted(() => ({ useSWR: vi.fn() })); vi.mock("swr", () => ({ default: useSWR })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/proxmoxvm/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/pterodactyl/component.test.jsx b/src/widgets/pterodactyl/component.test.jsx index 66762860e..2c89a7b4a 100644 --- a/src/widgets/pterodactyl/component.test.jsx +++ b/src/widgets/pterodactyl/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/pterodactyl/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/pyload/component.test.jsx b/src/widgets/pyload/component.test.jsx index a34dcb45d..c4b347b4d 100644 --- a/src/widgets/pyload/component.test.jsx +++ b/src/widgets/pyload/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/pyload/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/qbittorrent/component.test.jsx b/src/widgets/qbittorrent/component.test.jsx index d2f46095f..a4e222b75 100644 --- a/src/widgets/qbittorrent/component.test.jsx +++ b/src/widgets/qbittorrent/component.test.jsx @@ -4,7 +4,7 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); @@ -15,12 +15,6 @@ vi.mock("../../components/widgets/queue/queueEntry", () => ({ import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/qbittorrent/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/qnap/component.test.jsx b/src/widgets/qnap/component.test.jsx index c08450258..c6778660d 100644 --- a/src/widgets/qnap/component.test.jsx +++ b/src/widgets/qnap/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/qnap/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/radarr/component.test.jsx b/src/widgets/radarr/component.test.jsx index 7637f0d3c..09a5c34b2 100644 --- a/src/widgets/radarr/component.test.jsx +++ b/src/widgets/radarr/component.test.jsx @@ -4,7 +4,7 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); @@ -15,12 +15,6 @@ vi.mock("../../components/widgets/queue/queueEntry", () => ({ import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/radarr/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/readarr/component.test.jsx b/src/widgets/readarr/component.test.jsx index ac66fdee8..7f0c55fb4 100644 --- a/src/widgets/readarr/component.test.jsx +++ b/src/widgets/readarr/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/readarr/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/romm/component.test.jsx b/src/widgets/romm/component.test.jsx index cabe6dec9..28384f8a1 100644 --- a/src/widgets/romm/component.test.jsx +++ b/src/widgets/romm/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/romm/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/sabnzbd/component.test.jsx b/src/widgets/sabnzbd/component.test.jsx index a81db1399..12a278efb 100644 --- a/src/widgets/sabnzbd/component.test.jsx +++ b/src/widgets/sabnzbd/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/sabnzbd/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/scrutiny/component.test.jsx b/src/widgets/scrutiny/component.test.jsx index 68b0d85bd..03e85c4b9 100644 --- a/src/widgets/scrutiny/component.test.jsx +++ b/src/widgets/scrutiny/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/scrutiny/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/slskd/component.test.jsx b/src/widgets/slskd/component.test.jsx index 2888c6917..4228430d1 100644 --- a/src/widgets/slskd/component.test.jsx +++ b/src/widgets/slskd/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/slskd/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/sonarr/component.test.jsx b/src/widgets/sonarr/component.test.jsx index 4972cd31d..71dd84bb3 100644 --- a/src/widgets/sonarr/component.test.jsx +++ b/src/widgets/sonarr/component.test.jsx @@ -4,7 +4,7 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); @@ -15,12 +15,6 @@ vi.mock("../../components/widgets/queue/queueEntry", () => ({ import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/sonarr/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/sparkyfitness/component.test.jsx b/src/widgets/sparkyfitness/component.test.jsx index f498e44aa..b53a9a0e2 100644 --- a/src/widgets/sparkyfitness/component.test.jsx +++ b/src/widgets/sparkyfitness/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/sparkyfitness/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/speedtest/component.test.jsx b/src/widgets/speedtest/component.test.jsx index 87e9e83b1..54b89558e 100644 --- a/src/widgets/speedtest/component.test.jsx +++ b/src/widgets/speedtest/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/speedtest/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/spoolman/component.test.jsx b/src/widgets/spoolman/component.test.jsx index 1d467fe20..be5ea1d87 100644 --- a/src/widgets/spoolman/component.test.jsx +++ b/src/widgets/spoolman/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/spoolman/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/stash/component.test.jsx b/src/widgets/stash/component.test.jsx index 798ec6e17..201bb9e29 100644 --- a/src/widgets/stash/component.test.jsx +++ b/src/widgets/stash/component.test.jsx @@ -4,16 +4,10 @@ import { screen, waitFor } from "@testing-library/react"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/stash/component", () => { const originalFetch = globalThis.fetch; diff --git a/src/widgets/strelaysrv/component.test.jsx b/src/widgets/strelaysrv/component.test.jsx index 578a17062..933cd628d 100644 --- a/src/widgets/strelaysrv/component.test.jsx +++ b/src/widgets/strelaysrv/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/strelaysrv/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/suwayomi/component.test.jsx b/src/widgets/suwayomi/component.test.jsx index 3945be219..a3a779d85 100644 --- a/src/widgets/suwayomi/component.test.jsx +++ b/src/widgets/suwayomi/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/suwayomi/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/tailscale/component.test.jsx b/src/widgets/tailscale/component.test.jsx index d3214b06a..602d6ba1c 100644 --- a/src/widgets/tailscale/component.test.jsx +++ b/src/widgets/tailscale/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue, findServiceBlockByLabel } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/tailscale/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/tandoor/component.test.jsx b/src/widgets/tandoor/component.test.jsx index e3ab09efc..40162469e 100644 --- a/src/widgets/tandoor/component.test.jsx +++ b/src/widgets/tandoor/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/tandoor/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/tdarr/component.test.jsx b/src/widgets/tdarr/component.test.jsx index 051a5d366..918b5c6c6 100644 --- a/src/widgets/tdarr/component.test.jsx +++ b/src/widgets/tdarr/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/tdarr/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/technitium/component.test.jsx b/src/widgets/technitium/component.test.jsx index af54b493a..7888d687d 100644 --- a/src/widgets/technitium/component.test.jsx +++ b/src/widgets/technitium/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue, findServiceBlockByLabel } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component, { technitiumDefaultFields } from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/technitium/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/traefik/component.test.jsx b/src/widgets/traefik/component.test.jsx index 9f1c9313a..fb638612f 100644 --- a/src/widgets/traefik/component.test.jsx +++ b/src/widgets/traefik/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/traefik/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/transmission/component.test.jsx b/src/widgets/transmission/component.test.jsx index 95d2593e4..25b702add 100644 --- a/src/widgets/transmission/component.test.jsx +++ b/src/widgets/transmission/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/transmission/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/trilium/component.test.jsx b/src/widgets/trilium/component.test.jsx index 6d930b45d..ca7e17111 100644 --- a/src/widgets/trilium/component.test.jsx +++ b/src/widgets/trilium/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/trilium/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/tubearchivist/component.test.jsx b/src/widgets/tubearchivist/component.test.jsx index 5f181d233..b56b765ef 100644 --- a/src/widgets/tubearchivist/component.test.jsx +++ b/src/widgets/tubearchivist/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/tubearchivist/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/unifi/component.test.jsx b/src/widgets/unifi/component.test.jsx index 2947a25ef..ff2e2da00 100644 --- a/src/widgets/unifi/component.test.jsx +++ b/src/widgets/unifi/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue, findServiceBlockByLabel } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/unifi/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/unmanic/component.test.jsx b/src/widgets/unmanic/component.test.jsx index 94b2acea8..cdaae3970 100644 --- a/src/widgets/unmanic/component.test.jsx +++ b/src/widgets/unmanic/component.test.jsx @@ -4,19 +4,13 @@ import { screen, waitFor } from "@testing-library/react"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/unmanic/component", () => { const originalFetch = globalThis.fetch; diff --git a/src/widgets/uptimekuma/component.test.jsx b/src/widgets/uptimekuma/component.test.jsx index 7052d4a91..03065f782 100644 --- a/src/widgets/uptimekuma/component.test.jsx +++ b/src/widgets/uptimekuma/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/uptimekuma/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/uptimerobot/component.test.jsx b/src/widgets/uptimerobot/component.test.jsx index a5f7f3395..cce4626c0 100644 --- a/src/widgets/uptimerobot/component.test.jsx +++ b/src/widgets/uptimerobot/component.test.jsx @@ -4,16 +4,10 @@ import { screen, waitFor } from "@testing-library/react"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/uptimerobot/component", () => { const originalFetch = globalThis.fetch; diff --git a/src/widgets/urbackup/component.test.jsx b/src/widgets/urbackup/component.test.jsx index 06223dba3..125f0576e 100644 --- a/src/widgets/urbackup/component.test.jsx +++ b/src/widgets/urbackup/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/urbackup/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/vikunja/component.test.jsx b/src/widgets/vikunja/component.test.jsx index 494d4f49e..6968c853d 100644 --- a/src/widgets/vikunja/component.test.jsx +++ b/src/widgets/vikunja/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/vikunja/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/wallos/component.test.jsx b/src/widgets/wallos/component.test.jsx index f03fd03fa..7006ed3f2 100644 --- a/src/widgets/wallos/component.test.jsx +++ b/src/widgets/wallos/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/wallos/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/watchtower/component.test.jsx b/src/widgets/watchtower/component.test.jsx index 03cf94bdd..857c40b2b 100644 --- a/src/widgets/watchtower/component.test.jsx +++ b/src/widgets/watchtower/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/watchtower/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/wgeasy/component.test.jsx b/src/widgets/wgeasy/component.test.jsx index 40c1d6180..eebc83915 100644 --- a/src/widgets/wgeasy/component.test.jsx +++ b/src/widgets/wgeasy/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/wgeasy/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/whatsupdocker/component.test.jsx b/src/widgets/whatsupdocker/component.test.jsx index df96f8cb9..7bdcf3c45 100644 --- a/src/widgets/whatsupdocker/component.test.jsx +++ b/src/widgets/whatsupdocker/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/whatsupdocker/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/xteve/component.test.jsx b/src/widgets/xteve/component.test.jsx index caeb1b2e5..ee639f554 100644 --- a/src/widgets/xteve/component.test.jsx +++ b/src/widgets/xteve/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/xteve/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/yourspotify/component.test.jsx b/src/widgets/yourspotify/component.test.jsx index 6e60b46b7..589fcf689 100644 --- a/src/widgets/yourspotify/component.test.jsx +++ b/src/widgets/yourspotify/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/yourspotify/component", () => { beforeEach(() => { vi.clearAllMocks(); diff --git a/src/widgets/zabbix/component.test.jsx b/src/widgets/zabbix/component.test.jsx index 0795eb0bc..25047022a 100644 --- a/src/widgets/zabbix/component.test.jsx +++ b/src/widgets/zabbix/component.test.jsx @@ -4,19 +4,13 @@ import { screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; -import { findServiceBlockByLabel } from "test-utils/widget-assertions"; +import { expectBlockValue } from "test-utils/widget-assertions"; const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() })); vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI })); import Component from "./component"; -function expectBlockValue(container, label, value) { - const block = findServiceBlockByLabel(container, label); - expect(block, `missing block for ${label}`).toBeTruthy(); - expect(block.textContent).toContain(String(value)); -} - describe("widgets/zabbix/component", () => { beforeEach(() => { vi.clearAllMocks();