From 54227d1930b9276a97dfcd635cbdf374ef36e9b9 Mon Sep 17 00:00:00 2001
From: adilallo <39313955+adilallo@users.noreply.github.com>
Date: Fri, 29 Aug 2025 09:26:27 -0600
Subject: [PATCH] Add more unit tests
---
.runner.pid | 1 +
TESTING_STRATEGY.md | 257 ++++++++++++++++++++
app/components/Header.js | 82 ++++---
app/components/Logo.js | 1 -
stories/Header.responsive.stories.js | 200 ++++++++++++++++
tests/e2e/header.responsive.spec.js | 185 ++++++++++++++
tests/unit/Footer.test.jsx | 253 ++++++++++++++++++++
tests/unit/Header.test.jsx | 344 +++++++++++++++++++++++++++
tests/unit/Layout.test.jsx | 183 ++++++++++++++
tests/unit/Page.test.jsx | 248 +++++++++++++++++++
tests/unit/jsx-in-js.test.js | 12 -
tests/unit/simple.test.js | 7 -
12 files changed, 1715 insertions(+), 58 deletions(-)
create mode 100644 .runner.pid
create mode 100644 TESTING_STRATEGY.md
create mode 100644 stories/Header.responsive.stories.js
create mode 100644 tests/e2e/header.responsive.spec.js
create mode 100644 tests/unit/Footer.test.jsx
create mode 100644 tests/unit/Header.test.jsx
create mode 100644 tests/unit/Layout.test.jsx
create mode 100644 tests/unit/Page.test.jsx
delete mode 100644 tests/unit/jsx-in-js.test.js
delete mode 100644 tests/unit/simple.test.js
diff --git a/.runner.pid b/.runner.pid
new file mode 100644
index 0000000..5c1838f
--- /dev/null
+++ b/.runner.pid
@@ -0,0 +1 @@
+39731
diff --git a/TESTING_STRATEGY.md b/TESTING_STRATEGY.md
new file mode 100644
index 0000000..be3cb19
--- /dev/null
+++ b/TESTING_STRATEGY.md
@@ -0,0 +1,257 @@
+# Testing Strategy for CommunityRule
+
+## Overview
+
+This document outlines our comprehensive testing strategy that properly separates unit testing from responsive behavior testing, following best practices for JSDOM limitations and real browser testing.
+
+## Current Test Status
+
+- **184 total tests** across the project
+- **176 tests passing** (95.7% success rate)
+- **8 tests failing** (all related to multiple element instances)
+- **13 test files** covering all major components
+
+## Testing Philosophy
+
+### The Problem with JSDOM and Responsive Testing
+
+**Short take: Unit tests in JSDOM can't truly "switch breakpoints."** JSDOM doesn't evaluate CSS media queries, so Tailwind's `hidden sm:block …` won't change visibility when you "resize" the window.
+
+### Solution: Proper Test Separation
+
+- **Unit / component tests (Vitest + RTL):** assert **structure and classes**, not responsive visibility.
+- **Responsive behavior:** verify with **browser-based tests** (Playwright) or **visual tests** (Chromatic/Storybook) at real viewport widths.
+
+## Test Categories
+
+### 1. Unit Tests (Vitest + React Testing Library)
+
+**Purpose:** Test component structure, accessibility, and configuration data.
+
+**What to test:**
+
+- DOM roles/labels exist: `role="banner"`, nav landmark, menu items
+- The right **Tailwind classes** are present on wrappers (`block sm:hidden`, `hidden md:block`, etc.)
+- Data-driven bits produce the expected count/order (e.g., `navigationItems`, `avatarImages`, `logoConfig`)
+- Component configuration and exported data structures
+
+**Example:**
+
+```javascript
+// tests/unit/Header.structure.test.js
+test("logo wrappers include breakpoint classes", () => {
+ render(