From ab2503efb81cfe704a4473c7b162af2689fe3ccf Mon Sep 17 00:00:00 2001 From: William Valentin Date: Sat, 29 Nov 2025 15:27:56 -0800 Subject: [PATCH] feat: Add comprehensive E2E tests with Playwright and enhance component test IDs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add end-to-end testing infrastructure for the application: - Implemented Playwright E2E test suite with 31 passing tests across authentication and feature workflows - Created mock API fixtures for testing without requiring backend/database - Added data-testid attributes to major React components (Login, Register, TaskList, Events, SocialFeed, Profile, Navbar) - Set up test fixtures with test images (profile-pic.jpg, test-image.jpg) - Configured playwright.config.js for multi-browser testing (Chromium, Firefox, Safari) Test Coverage: - Authentication flows (register, login, logout, protected routes) - Task management (view, complete, filter, search) - Social feed (view posts, create post, like, view comments) - Events (view, join/RSVP, filter, view details) - User profile (view profile, streets, badges, statistics) - Premium features page - Leaderboard and rankings - Map view 🤖 Generated with OpenCode Co-Authored-By: AI Assistant --- frontend/src/components/Events.js | 24 +- frontend/src/components/Login.js | 7 +- frontend/src/components/Navbar.js | 28 +- frontend/src/components/Profile.js | 35 +- frontend/src/components/Register.js | 8 +- frontend/src/components/SocialFeed.js | 23 +- frontend/src/components/TaskList.js | 11 +- package-lock.json | 66 ++++ package.json | 3 + playwright.config.js | 34 ++ tests/e2e/auth.spec.js | 172 ++++++++++ tests/e2e/features.spec.js | 453 ++++++++++++++++++++++++++ tests/e2e/fixtures/mock-api.js | 390 ++++++++++++++++++++++ tests/e2e/fixtures/profile-pic.jpg | Bin 0 -> 757 bytes tests/e2e/fixtures/test-image.jpg | Bin 0 -> 415 bytes 15 files changed, 1194 insertions(+), 60 deletions(-) create mode 100644 playwright.config.js create mode 100644 tests/e2e/auth.spec.js create mode 100644 tests/e2e/features.spec.js create mode 100644 tests/e2e/fixtures/mock-api.js create mode 100644 tests/e2e/fixtures/profile-pic.jpg create mode 100644 tests/e2e/fixtures/test-image.jpg diff --git a/frontend/src/components/Events.js b/frontend/src/components/Events.js index bf48620..85f25dc 100644 --- a/frontend/src/components/Events.js +++ b/frontend/src/components/Events.js @@ -150,49 +150,49 @@ const Events = () => { } return ( -
+

Events

{connected && ( - + Live Updates )}
{events.length === 0 ? ( -
+
No events available at the moment. Check back later!
) : ( -
+
{events.map((event) => { const eventDate = new Date(event.date); const isUpcoming = eventDate > new Date(); return ( -
+
-
{event.title}
-

{event.description}

+
{event.title}
+

{event.description}

- + Date: {eventDate.toLocaleDateString()}{" "} {eventDate.toLocaleTimeString()}
- + Location: {event.location}
{event.organizer && (
- + Organizer:{" "} {event.organizer.name || event.organizer} @@ -204,10 +204,11 @@ const Events = () => { className={`badge badge-${ isUpcoming ? "success" : "secondary" } mr-2`} + data-testid={`event-status-${event._id}`} > {isUpcoming ? "Upcoming" : "Past"} - + {event.participants?.length || 0} Participants
@@ -216,6 +217,7 @@ const Events = () => { diff --git a/frontend/src/components/Login.js b/frontend/src/components/Login.js index d2db617..1ef8b15 100644 --- a/frontend/src/components/Login.js +++ b/frontend/src/components/Login.js @@ -44,11 +44,11 @@ const Login = () => { } return ( -
+

Login

-
+
{ placeholder="Email" required disabled={loading} + data-testid="email-input" />
@@ -71,12 +72,14 @@ const Login = () => { placeholder="Password" required disabled={loading} + data-testid="password-input" />