import { fireEvent, render, screen } from "@testing-library/svelte"; import { describe, expect, it, vi } from "vitest"; import AppPasswordStep from "../components/migration/AppPasswordStep.svelte"; describe("AppPasswordStep", () => { it("hides the generated app password until the user reveals it", async () => { const appPassword = "abcd-efgh-ijkl-mnop"; render(AppPasswordStep, { props: { appPassword, appPasswordName: "Generated during registration", loading: false, onContinue: vi.fn(), }, }); expect(screen.queryByText(appPassword)).not.toBeInTheDocument(); await fireEvent.click(screen.getByRole("button", { name: "Show" })); expect(screen.getByText(appPassword)).toBeInTheDocument(); await fireEvent.click(screen.getByRole("button", { name: "Hide" })); expect(screen.queryByText(appPassword)).not.toBeInTheDocument(); }); });