Skip to content

Add CI workflow and comprehensive test suite#52

Merged
Tomer-David merged 6 commits into
mainfrom
feature/add-ci-and-tests
Jan 14, 2026
Merged

Add CI workflow and comprehensive test suite#52
Tomer-David merged 6 commits into
mainfrom
feature/add-ci-and-tests

Conversation

@Tomer-David
Copy link
Copy Markdown
Contributor

Summary

Adds GitHub Actions CI and a comprehensive test suite for the frontend.

Changes

  • CI Workflow (.github/workflows/ci.yml)

    • Runs on every push/PR to main/master
    • Lints, type-checks, tests, and builds
  • Jest Configuration

    • jest.config.ts - Jest setup for Next.js
    • jest.setup.ts - Testing library setup
  • 132 Tests covering:

    • LoginForm - validation, submission, error handling (14 tests)
    • ProtectedRoute - auth guards, redirects (8 tests)
    • Header - navigation, cart icon, logout (11 tests)
    • SearchableSelect - filtering, selection, dropdown (12 tests)
    • EquipmentList - toggle, quantity changes (11 tests)
    • SaveToCartButton - validation, payload, temp disable (15 tests)
    • ConfirmDialog - buttons, keyboard, backdrop (12 tests)
    • Toast - timing, auto-dismiss (6 tests)
    • CartPage - empty state, items, remove, clear (17 tests)
    • AuthContext / CartContext - hook validation (2 tests)

Testing

npm test

Copilot AI review requested due to automatic review settings January 11, 2026 15:46
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds GitHub Actions CI workflow and a comprehensive test suite for the frontend Next.js application. The PR includes Jest configuration, 132 tests across 11 test files covering various components and pages, and a CI pipeline for automated testing.

Changes:

  • Added GitHub Actions CI workflow for linting, type-checking, testing, and building
  • Configured Jest with Next.js integration and testing library setup
  • Added 132 comprehensive unit tests for components (LoginForm, Header, Toast, ConfirmDialog, SearchableSelect, EquipmentList, SaveToCartButton, ProtectedRoute) and pages (CartPage), plus context hook validation tests

Reviewed changes

Copilot reviewed 15 out of 16 changed files in this pull request and generated 14 comments.

Show a summary per file
File Description
.github/workflows/ci.yml Adds CI pipeline with lint, type-check, test, and build steps
jest.config.ts Configures Jest for Next.js with module mapping and coverage settings
jest.setup.ts Imports testing-library/jest-dom for test assertions
package.json Adds test scripts and testing dependencies (Jest, Testing Library, etc.)
src/tests/pages/CartPage.test.tsx Tests cart display, item removal, clear cart, and empty state (17 tests)
src/tests/contexts/CartContext.test.tsx Tests CartContext hook validation (1 test)
src/tests/contexts/AuthContext.test.tsx Tests AuthContext hook validation (1 test)
src/tests/components/Toast.test.tsx Tests toast display, auto-dismiss, and timing (6 tests)
src/tests/components/SearchableSelect.test.tsx Tests dropdown, filtering, selection, and keyboard interactions (12 tests)
src/tests/components/SaveToCartButton.test.tsx Tests button states, validation, and cart payload (15 tests)
src/tests/components/ProtectedRoute.test.tsx Tests auth guards and route protection (8 tests)
src/tests/components/LoginForm.test.tsx Tests form validation, submission, and error handling (14 tests)
src/tests/components/Header.test.tsx Tests navigation, cart icon, and logout functionality (11 tests)
src/tests/components/EquipmentList.test.tsx Tests equipment display, toggle, and quantity changes (11 tests)
src/tests/components/ConfirmDialog.test.tsx Tests modal display, buttons, and keyboard handling (12 tests)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/__tests__/components/EquipmentList.test.tsx Outdated
Comment thread .github/workflows/ci.yml
Comment thread src/__tests__/pages/CartPage.test.tsx
Comment thread src/__tests__/components/Toast.test.tsx
Comment thread src/__tests__/components/ConfirmDialog.test.tsx Outdated
Comment thread src/__tests__/pages/CartPage.test.tsx Outdated
Comment thread src/__tests__/components/Toast.test.tsx
* Tests all login functionality including validation, submission, error handling
*/
import React from 'react';
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused import fireEvent.

Suggested change
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
import { render, screen, waitFor } from '@testing-library/react';

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed - Removed unused fireEvent import. The test uses userEvent instead for user interactions.

Comment thread src/__tests__/contexts/AuthContext.test.tsx
Comment thread src/__tests__/contexts/CartContext.test.tsx
@Tomer-David Tomer-David self-assigned this Jan 12, 2026
@Tomer-David Tomer-David added the enhancement New feature or request label Jan 12, 2026
@Tomer-David Tomer-David linked an issue Jan 12, 2026 that may be closed by this pull request
@NoamBenShimon NoamBenShimon self-requested a review January 13, 2026 14:10
Copy link
Copy Markdown
Contributor

@NoamBenShimon NoamBenShimon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for implementing that. It's useful to have in the repository.

- Add GitHub Actions CI workflow (.github/workflows/ci.yml)
- Add Jest configuration for Next.js (jest.config.ts, jest.setup.ts)
- Add 132 tests covering all components:
  - LoginForm: validation, submission, error handling
  - ProtectedRoute: auth guards, redirects
  - Header: navigation, cart icon, logout
  - SearchableSelect: filtering, selection, dropdown
  - EquipmentList: toggle, quantity changes
  - SaveToCartButton: validation, payload, temp disable
  - ConfirmDialog: buttons, keyboard, backdrop
  - Toast: timing, auto-dismiss
  - CartPage: empty state, items, remove, clear
  - Auth/Cart contexts: hook validation
- Update package.json with test scripts
- Fix grammar: '1 items' -> '1 item' in SaveToCartButton test
- Simplify button selector in CartPage removeFromCart test
- Add assertion to Toast cleanup test
@NoamBenShimon NoamBenShimon force-pushed the feature/add-ci-and-tests branch from 606ac09 to c081053 Compare January 14, 2026 10:26
@Tomer-David Tomer-David merged commit 84caec1 into main Jan 14, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add CI Pipeline for Frontend Code

3 participants