From e5f4ad31999b567705f9f393fa96a8e375161315 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Tue, 3 Feb 2026 09:47:55 -0800 Subject: [PATCH] Remove linkwarden test --- src/widgets/linkwarden/component.test.jsx | 88 ----------------------- 1 file changed, 88 deletions(-) delete mode 100644 src/widgets/linkwarden/component.test.jsx diff --git a/src/widgets/linkwarden/component.test.jsx b/src/widgets/linkwarden/component.test.jsx deleted file mode 100644 index 735b27d2a..000000000 --- a/src/widgets/linkwarden/component.test.jsx +++ /dev/null @@ -1,88 +0,0 @@ -// @vitest-environment jsdom - -import { screen, waitFor } 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"; - -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(); - }); - - it("renders placeholders while loading", () => { - useWidgetAPI - .mockReturnValueOnce({ data: undefined, error: undefined }) // collections - .mockReturnValueOnce({ data: undefined, error: undefined }); // tags - - const { container } = renderWithProviders( - , - { settings: { hideErrors: false } }, - ); - - expect(container.querySelectorAll(".service-block")).toHaveLength(3); - expect(screen.getByText("linkwarden.links")).toBeInTheDocument(); - expect(screen.getByText("linkwarden.collections")).toBeInTheDocument(); - expect(screen.getByText("linkwarden.tags")).toBeInTheDocument(); - }); - - it("renders error UI when either endpoint errors", () => { - useWidgetAPI - .mockReturnValueOnce({ data: undefined, error: { message: "nope" } }) - .mockReturnValueOnce({ data: undefined, error: undefined }); - - renderWithProviders(, { - settings: { hideErrors: false }, - }); - - expect(screen.getAllByText(/widget\.api_error/i).length).toBeGreaterThan(0); - expect(screen.getByText("nope")).toBeInTheDocument(); - }); - - it("computes totalLinks from collection _count.links once both endpoints are loaded", async () => { - useWidgetAPI.mockImplementation((widget, endpoint) => { - if (endpoint === "collections") { - return { - data: { - response: [ - // eslint-disable-next-line no-underscore-dangle - { _count: { links: 2 } }, - // eslint-disable-next-line no-underscore-dangle - { _count: { links: 4 } }, - ], - }, - error: undefined, - }; - } - - if (endpoint === "tags") { - return { data: { response: [{ id: 1 }, { id: 2 }, { id: 3 }] }, error: undefined }; - } - - return { data: undefined, error: undefined }; - }); - - const { container } = renderWithProviders( - , - { settings: { hideErrors: false } }, - ); - - await waitFor(() => { - expectBlockValue(container, "linkwarden.links", 6); - }); - expectBlockValue(container, "linkwarden.collections", 2); - expectBlockValue(container, "linkwarden.tags", 3); - }); -});