Spaces:
Configuration error
Configuration error
Download frontend/__tests__/components/browser.test.tsx from flyingdarkdev/README: direct link, hf CLI and curl.
- Browser
- Download file 1.76 kB
-
https://huggingface.co/spaces/flyingdarkdev/README/resolve/main/frontend/__tests__/components/browser.test.tsx
- Command line
-
hf download hf://spaces/flyingdarkdev/README/frontend/__tests__/components/browser.test.tsx
-
curl -L -o browser.test.tsx https://huggingface.co/spaces/flyingdarkdev/README/resolve/main/frontend/__tests__/components/browser.test.tsx
1.76 kB
| import { describe, it, expect, afterEach, vi } from "vitest"; | |
| // Mock useParams before importing components | |
| vi.mock("react-router", async () => { | |
| const actual = await vi.importActual("react-router"); | |
| return { | |
| ...(actual as object), | |
| useParams: () => ({ conversationId: "test-conversation-id" }), | |
| }; | |
| }); | |
| // Mock i18next | |
| vi.mock("react-i18next", async () => { | |
| const actual = await vi.importActual("react-i18next"); | |
| return { | |
| ...(actual as object), | |
| useTranslation: () => ({ | |
| t: (key: string) => key, | |
| i18n: { | |
| changeLanguage: () => new Promise(() => {}), | |
| }, | |
| }), | |
| }; | |
| }); | |
| import { screen } from "@testing-library/react"; | |
| import { renderWithProviders } from "../../test-utils"; | |
| import { BrowserPanel } from "#/components/features/browser/browser"; | |
| describe("Browser", () => { | |
| afterEach(() => { | |
| vi.clearAllMocks(); | |
| }); | |
| it("renders a message if no screenshotSrc is provided", () => { | |
| renderWithProviders(<BrowserPanel />, { | |
| preloadedState: { | |
| browser: { | |
| url: "https://example.com", | |
| screenshotSrc: "", | |
| }, | |
| }, | |
| }); | |
| // i18n empty message key | |
| expect(screen.getByText("BROWSER$NO_PAGE_LOADED")).toBeInTheDocument(); | |
| }); | |
| it("renders the url and a screenshot", () => { | |
| renderWithProviders(<BrowserPanel />, { | |
| preloadedState: { | |
| browser: { | |
| url: "https://example.com", | |
| screenshotSrc: | |
| "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mN0uGvyHwAFCAJS091fQwAAAABJRU5ErkJggg==", | |
| }, | |
| }, | |
| }); | |
| expect(screen.getByText("https://example.com")).toBeInTheDocument(); | |
| expect(screen.getByAltText(/browser screenshot/i)).toBeInTheDocument(); | |
| }); | |
| }); | |