learn and share notes on atproto (wip) 馃 malfestio.stormlightlabs.org/
readability solid axum atproto srs
at main 86 lines 3.1 kB view raw
1import { cleanup, fireEvent, render, screen } from "@solidjs/testing-library"; 2import { JSX } from "solid-js"; 3import { afterEach, describe, expect, it, vi } from "vitest"; 4import Help from "../Help"; 5 6vi.mock( 7 "@solidjs/router", 8 () => ({ 9 A: (props: { href: string; children: JSX.Element; class?: string }) => ( 10 <a href={props.href} class={props.class}>{props.children}</a> 11 ), 12 }), 13); 14 15vi.mock("$components/layout/Footer", () => ({ Footer: () => <footer data-testid="footer">Footer</footer> })); 16 17describe("Help Page", () => { 18 afterEach(cleanup); 19 20 it("renders the help page header", () => { 21 render(() => <Help />); 22 expect(screen.getByText("Help Center")).toBeInTheDocument(); 23 }); 24 25 it("displays beta notice", () => { 26 render(() => <Help />); 27 expect(screen.getByText("Beta Notice:")).toBeInTheDocument(); 28 expect(screen.getByText(/Malfestio is still in active development/i)).toBeInTheDocument(); 29 }); 30 31 it("shows all FAQ categories", () => { 32 render(() => <Help />); 33 expect(screen.getByText("Getting Started")).toBeInTheDocument(); 34 expect(screen.getByText("Spaced Repetition")).toBeInTheDocument(); 35 expect(screen.getByText("AT Protocol & Privacy")).toBeInTheDocument(); 36 expect(screen.getByText("Community & Sharing")).toBeInTheDocument(); 37 }); 38 39 it("displays FAQ questions", () => { 40 render(() => <Help />); 41 expect(screen.getByText("What is Malfestio?")).toBeInTheDocument(); 42 expect(screen.getByText("What is spaced repetition?")).toBeInTheDocument(); 43 expect(screen.getByText("What is the AT Protocol?")).toBeInTheDocument(); 44 expect(screen.getByText("What does 'Fork' mean?")).toBeInTheDocument(); 45 }); 46 47 it("expands accordion when question is clicked", async () => { 48 render(() => <Help />); 49 50 expect(screen.queryByText(/Malfestio is a decentralized learning platform/i)).not.toBeInTheDocument(); 51 52 const question = screen.getByText("What is Malfestio?"); 53 fireEvent.click(question); 54 expect(screen.getByText(/Malfestio is a decentralized learning platform/i)).toBeInTheDocument(); 55 }); 56 57 it("collapses accordion when clicked again", async () => { 58 render(() => <Help />); 59 60 const question = screen.getByText("What is Malfestio?"); 61 62 fireEvent.click(question); 63 expect(screen.getByText(/Malfestio is a decentralized learning platform/i)).toBeInTheDocument(); 64 65 fireEvent.click(question); 66 expect(screen.queryByText(/Malfestio is a decentralized learning platform/i)).not.toBeInTheDocument(); 67 }); 68 69 it("has link back to app", () => { 70 render(() => <Help />); 71 const backLink = screen.getByRole("link", { name: /Back to App/i }); 72 expect(backLink).toHaveAttribute("href", "/"); 73 }); 74 75 it("shows contact section", () => { 76 render(() => <Help />); 77 expect(screen.getByText("Still have questions?")).toBeInTheDocument(); 78 expect(screen.getByText("Bluesky")).toBeInTheDocument(); 79 expect(screen.getByText("GitHub")).toBeInTheDocument(); 80 }); 81 82 it("includes footer", () => { 83 render(() => <Help />); 84 expect(screen.getByTestId("footer")).toBeInTheDocument(); 85 }); 86});