|
| 1 | +import { describe, expect, it } from "vitest"; |
| 2 | + |
| 3 | +import { RegistryConfigurationBanner } from "../../src/components/RegistryConfigurationBanner"; |
| 4 | +import { render } from "../utils/render.tsx"; |
| 5 | + |
| 6 | +describe("RegistryConfigurationBanner", () => { |
| 7 | + it("directs administrators to the invalid aggregator URL setting", async () => { |
| 8 | + const screen = await render( |
| 9 | + <RegistryConfigurationBanner |
| 10 | + error={{ |
| 11 | + code: "REGISTRY_AGGREGATOR_URL_INVALID", |
| 12 | + field: "experimental.registry.aggregatorUrl", |
| 13 | + }} |
| 14 | + />, |
| 15 | + ); |
| 16 | + |
| 17 | + await expect |
| 18 | + .element(screen.getByRole("alert", { name: "Plugin registry configuration error" })) |
| 19 | + .toBeInTheDocument(); |
| 20 | + await expect |
| 21 | + .element( |
| 22 | + screen.getByText( |
| 23 | + "Check experimental.registry.aggregatorUrl in astro.config.mjs, then restart EmDash.", |
| 24 | + ), |
| 25 | + ) |
| 26 | + .toBeInTheDocument(); |
| 27 | + }); |
| 28 | + |
| 29 | + it("directs administrators to the invalid release policy setting", async () => { |
| 30 | + const screen = await render( |
| 31 | + <RegistryConfigurationBanner |
| 32 | + error={{ |
| 33 | + code: "REGISTRY_MINIMUM_RELEASE_AGE_INVALID", |
| 34 | + field: "experimental.registry.policy.minimumReleaseAge", |
| 35 | + }} |
| 36 | + />, |
| 37 | + ); |
| 38 | + |
| 39 | + await expect |
| 40 | + .element( |
| 41 | + screen.getByText( |
| 42 | + "Check experimental.registry.policy.minimumReleaseAge in astro.config.mjs, then restart EmDash.", |
| 43 | + ), |
| 44 | + ) |
| 45 | + .toBeInTheDocument(); |
| 46 | + }); |
| 47 | + |
| 48 | + it("does not name the wrong setting for a diagnostic from a newer server", async () => { |
| 49 | + const screen = await render( |
| 50 | + <RegistryConfigurationBanner |
| 51 | + error={ |
| 52 | + { |
| 53 | + code: "REGISTRY_FUTURE_SETTING_INVALID", |
| 54 | + field: "experimental.registry.futureSetting", |
| 55 | + } as never |
| 56 | + } |
| 57 | + />, |
| 58 | + ); |
| 59 | + |
| 60 | + await expect |
| 61 | + .element( |
| 62 | + screen.getByText("Check experimental.registry in astro.config.mjs, then restart EmDash."), |
| 63 | + ) |
| 64 | + .toBeInTheDocument(); |
| 65 | + expect(screen.container.textContent).not.toContain("aggregatorUrl"); |
| 66 | + }); |
| 67 | +}); |
0 commit comments