|
| 1 | +import { render, screen } from "@testing-library/react"; |
| 2 | +import "@testing-library/jest-dom"; |
| 3 | +import { describe, expect, test } from "vitest"; |
| 4 | +import "../../test-utils/CommonMocks.ts"; |
| 5 | + |
| 6 | +import About from "./About"; |
| 7 | + |
| 8 | +const setup = () => render(<About />); |
| 9 | + |
| 10 | +describe("About", () => { |
| 11 | + test("renders the page title and front-matter tagline", () => { |
| 12 | + setup(); |
| 13 | + |
| 14 | + expect( |
| 15 | + screen.getByRole("heading", { level: 1, name: "Welcome to WeBuddhist!" }), |
| 16 | + ).toBeInTheDocument(); |
| 17 | + expect( |
| 18 | + screen.getByText( |
| 19 | + "We are Buddhist. We learn, practice and connect. Daily.", |
| 20 | + ), |
| 21 | + ).toBeInTheDocument(); |
| 22 | + }); |
| 23 | + |
| 24 | + test("renders mission and vision cards", () => { |
| 25 | + setup(); |
| 26 | + |
| 27 | + expect(screen.getByText("Mission")).toBeInTheDocument(); |
| 28 | + expect(screen.getByText("Vision")).toBeInTheDocument(); |
| 29 | + expect( |
| 30 | + screen.getByText( |
| 31 | + "We help Buddhists do less harm, more good, and know their own mind better by learning, practicing and connecting, daily.", |
| 32 | + ), |
| 33 | + ).toBeInTheDocument(); |
| 34 | + expect( |
| 35 | + screen.getByText( |
| 36 | + "A world where all beings are free from suffering and find lasting happiness.", |
| 37 | + ), |
| 38 | + ).toBeInTheDocument(); |
| 39 | + }); |
| 40 | + |
| 41 | + test("renders all content section headings", () => { |
| 42 | + setup(); |
| 43 | + |
| 44 | + expect( |
| 45 | + screen.getByRole("heading", { |
| 46 | + level: 2, |
| 47 | + name: "Why — Our Purpose", |
| 48 | + }), |
| 49 | + ).toBeInTheDocument(); |
| 50 | + expect( |
| 51 | + screen.getByRole("heading", { |
| 52 | + level: 2, |
| 53 | + name: "How — The Buddha's Method", |
| 54 | + }), |
| 55 | + ).toBeInTheDocument(); |
| 56 | + expect( |
| 57 | + screen.getByRole("heading", { |
| 58 | + level: 2, |
| 59 | + name: "What — Content and Technology", |
| 60 | + }), |
| 61 | + ).toBeInTheDocument(); |
| 62 | + expect( |
| 63 | + screen.getByRole("heading", { level: 2, name: "The Team" }), |
| 64 | + ).toBeInTheDocument(); |
| 65 | + }); |
| 66 | + |
| 67 | + test("renders the three truths as numbered cards", () => { |
| 68 | + setup(); |
| 69 | + |
| 70 | + expect( |
| 71 | + screen.getByText( |
| 72 | + "As Buddhists, we accept that everything is impermanent.", |
| 73 | + ), |
| 74 | + ).toBeInTheDocument(); |
| 75 | + expect( |
| 76 | + screen.getByText( |
| 77 | + "As Buddhists, we accept that nothing will ever fully satisfy us.", |
| 78 | + ), |
| 79 | + ).toBeInTheDocument(); |
| 80 | + expect( |
| 81 | + screen.getByText( |
| 82 | + "As Buddhists, we accept that nothing — not even ourselves — exists as it appears to us.", |
| 83 | + ), |
| 84 | + ).toBeInTheDocument(); |
| 85 | + }); |
| 86 | + |
| 87 | + test("renders the four pillars", () => { |
| 88 | + setup(); |
| 89 | + |
| 90 | + expect(screen.getByText("Learn")).toBeInTheDocument(); |
| 91 | + expect(screen.getByText("Practice")).toBeInTheDocument(); |
| 92 | + expect(screen.getByText("Connect")).toBeInTheDocument(); |
| 93 | + expect(screen.getByText("Sustain")).toBeInTheDocument(); |
| 94 | + expect( |
| 95 | + screen.getByText( |
| 96 | + "we help Buddhists access the Dhamma in their own words;", |
| 97 | + ), |
| 98 | + ).toBeInTheDocument(); |
| 99 | + }); |
| 100 | + |
| 101 | + test("renders team roles with emphasized labels", () => { |
| 102 | + setup(); |
| 103 | + |
| 104 | + expect(screen.getByText("Product Engineering")).toHaveClass("font-medium"); |
| 105 | + expect( |
| 106 | + screen.getByText("Content Engineering and Data Services"), |
| 107 | + ).toHaveClass("font-medium"); |
| 108 | + expect(screen.getByText("Community & Campaigns")).toHaveClass( |
| 109 | + "font-medium", |
| 110 | + ); |
| 111 | + expect(screen.getByText("Partnerships & Funding")).toHaveClass( |
| 112 | + "font-medium", |
| 113 | + ); |
| 114 | + }); |
| 115 | + |
| 116 | + test("links sections to their headings for accessibility", () => { |
| 117 | + setup(); |
| 118 | + |
| 119 | + const purposeSection = screen |
| 120 | + .getByRole("heading", { name: "Why — Our Purpose" }) |
| 121 | + .closest("section"); |
| 122 | + expect(purposeSection).toHaveAttribute( |
| 123 | + "aria-labelledby", |
| 124 | + "why-our-purpose", |
| 125 | + ); |
| 126 | + |
| 127 | + const teamSection = screen |
| 128 | + .getByRole("heading", { name: "The Team" }) |
| 129 | + .closest("section"); |
| 130 | + expect(teamSection).toHaveAttribute("aria-labelledby", "the-team"); |
| 131 | + }); |
| 132 | + |
| 133 | + test("renders merged paragraph content from the markdown source", () => { |
| 134 | + setup(); |
| 135 | + |
| 136 | + expect( |
| 137 | + screen.getByText(/WeBuddhist exists so that we — and anyone who wishes/), |
| 138 | + ).toBeInTheDocument(); |
| 139 | + expect( |
| 140 | + screen.getByText(/five-minute daily dharma routine/), |
| 141 | + ).toBeInTheDocument(); |
| 142 | + expect( |
| 143 | + screen.getByText(/Six teams carry on our mission/), |
| 144 | + ).toBeInTheDocument(); |
| 145 | + }); |
| 146 | + |
| 147 | + test("renders the sponsors section with logos", () => { |
| 148 | + setup(); |
| 149 | + |
| 150 | + expect( |
| 151 | + screen.getByRole("heading", { level: 2, name: "Sponsors" }), |
| 152 | + ).toBeInTheDocument(); |
| 153 | + |
| 154 | + expect(screen.getByAltText("OpenPecha Trust")).toBeInTheDocument(); |
| 155 | + expect(screen.getByAltText("Dharmaduta")).toBeInTheDocument(); |
| 156 | + |
| 157 | + const sponsorsSection = screen |
| 158 | + .getByRole("heading", { name: "Sponsors" }) |
| 159 | + .closest("section"); |
| 160 | + expect(sponsorsSection).toHaveAttribute("aria-labelledby", "sponsors"); |
| 161 | + }); |
| 162 | +}); |
0 commit comments