Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/ci.yml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [22.x]

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup pnpm
uses: pnpm/action-setup@v4

- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: pnpm

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Lint
run: pnpm run lint

- name: Run tests
run: pnpm run test

- name: Build
run: pnpm run build
Binary file modified.gitignore
Binary file not shown.
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
pnpm exec lint-staged
12 changes: 7 additions & 5 deletions README.md
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
[![CI](https://github.com/FranGuh/ComputerSelectorHelper/actions/workflows/ci.yml/badge.svg)](https://github.com/FranGuh/ComputerSelectorHelper/actions/workflows/ci.yml)

# Computer Selector Helper 🖥️

> Respondé unas preguntas y recibí una recomendación personalizada de laptop según tu presupuesto y necesidades reales.
Expand DownExpand Up@@ -64,19 +66,19 @@ git clone https://github.com/FranGuh/ComputerSelectorHelper.git
cd ComputerSelectorHelper

# Instalar dependencias
npm install
pnpm install

# Modo desarrollo
npm run dev
pnpm run dev

# Build para producción
npm run build
pnpm run build

# Linting
npm run lint
pnpm run lint

# Preview del build
npm run preview
pnpm run preview
```

## Estructura del Proyecto
Expand Down
121 changes: 121 additions & 0 deletions conductor/tracks/foundation-testing-ci/acceptance.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
# Acceptance Criteria — Foundation Testing CI

## Testing Suite

### Criteria
- [ ] `pnpm run test` runs all tests and passes
- [ ] Inference engine coverage ≥ 80%
- [ ] Overall project coverage ≥ 60%
- [ ] All 17 previously-fixed bugs have regression tests
- [ ] Edge cases tested: empty answers, conflicting answers, budget extremes
- [ ] Component tests cover: quiz flow, results rendering, fallback UI, error boundary
- [ ] Tests run in < 30 seconds on CI

### Verification
```bash
pnpm run test
pnpm run test:coverage
```

## CI/CD Pipeline

### Criteria
- [ ] GitHub Actions workflow triggers on push/PR to main
- [ ] Workflow runs: lint → test → build
- [ ] Workflow fails if any step errors
- [ ] Status badge visible in README.md
- [ ] Workflow completes in < 5 minutes
- [ ] Dependency caching works (second run is faster)

### Verification
- Push to test branch, verify workflow runs in GitHub Actions tab
- Intentionally break a test, verify workflow fails
- Fix test, verify workflow passes

## Pre-commit Hooks

### Criteria
- [ ] `husky` installed and configured
- [ ] `lint-staged` runs ESLint on staged files only
- [ ] Commit with lint error → blocked
- [ ] Commit with clean code → succeeds
- [ ] `pre-push` hook runs `pnpm run build`
- [ ] Push with build error → blocked
- [ ] Existing codebase has zero lint violations

### Verification
```bash
# Test lint blocking
echo "const x = " >> src/test.js
git add src/test.js
git commit -m "test: should fail" # Expected: blocked

# Test build blocking
# Introduce syntax error, try to push # Expected: blocked
```

## Comparison View

### Criteria
- [ ] "Compare" checkbox visible on each laptop card
- [ ] Selecting 2 laptops enables "Compare" button
- [ ] Selecting 3 laptops enables "Compare" button
- [ ] Clicking "Compare" opens `/compare` route
- [ ] Side-by-side table shows all specs for selected laptops
- [ ] Better specs highlighted in green, worse in red
- [ ] Mobile (320px): stacked cards, usable, no horizontal scroll
- [ ] Desktop (1024px): 2-3 column table
- [ ] Accessibility: screen reader announces comparison content
- [ ] Keyboard navigation works through comparison table
- [ ] Direct navigation to `/compare` without selection → redirects to results

### Verification
- Complete quiz, select 2 laptops, click Compare
- Verify all specs shown, differences highlighted
- Resize to 320px, verify stacked layout
- Use keyboard Tab/Enter to navigate table
- Navigate directly to `/compare`, verify redirect

## Shareable Links

### Criteria
- [ ] "Copy link" button copies URL to clipboard
- [ ] "Share on WhatsApp" button opens WhatsApp with pre-filled message
- [ ] Pasting encoded URL in new tab restores results
- [ ] Invalid/expired URL → redirects to quiz with error message
- [ ] URL length < 2,000 characters for typical quiz results
- [ ] Clipboard copy shows success feedback ("Link copied!")
- [ ] WhatsApp message includes: results summary + link

### Verification
```bash
# Test encoding
pnpm run dev
# Complete quiz, click "Copy link"
# Paste URL in new tab, verify results match

# Test WhatsApp
# Click "Share on WhatsApp", verify message format

# Test invalid URL
# Navigate to /results?r=invalid, verify redirect to quiz
```

## Overall Track Acceptance

### Criteria
- [ ] All phases complete (1-7)
- [ ] `pnpm run build` passes
- [ ] `pnpm run lint` passes
- [ ] `pnpm run test` passes
- [ ] No new console warnings/errors
- [ ] No breaking changes to existing features
- [ ] All acceptance criteria met
- [ ] Documentation updated (README, docs/)

### Final Verification
```bash
pnpm run lint && pnpm run test && pnpm run build
```

All three must pass with zero errors.
134 changes: 134 additions & 0 deletions conductor/tracks/foundation-testing-ci/plan.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
# Implementation Plan — Foundation Testing CI

## Phase Order & Dependencies

```
Phase 1: Testing Setup (no dependencies)
Phase 2: Inference Engine Tests (depends on Phase 1)
Phase 3: Component Tests (depends on Phase 1)
Phase 4: CI/CD Pipeline (depends on Phase 2+3 having tests)
Phase 5: Pre-commit Hooks (depends on Phase 4)
Phase 6: Comparison View (parallel with Phase 1-5)
Phase 7: Shareable Links (parallel with Phase 1-5)
```

## Phase 1: Testing Setup

**Files**: `vitest.config.js`, `package.json` (scripts), `src/__tests__/setup.js`
**Steps**:
1. Install: `pnpm add -D vitest @testing-library/react @testing-library/jest-dom jsdom`
2. Create `vitest.config.js` with `environment: 'jsdom'`
3. Add scripts: `"test": "vitest run"`, `"test:watch": "vitest"`, `"test:coverage": "vitest run --coverage"`
4. Create setup file for RTL matchers
5. Verify: `pnpm run test` runs with zero tests (passes)

## Phase 2: Inference Engine Tests

**Files**: `src/__tests__/convertToSpecs.test.jsx`, `src/__tests__/matchLaptopClass.test.jsx`
**Test Cases**:
- `convertToSpecs`:
- Basic quiz answers → valid spec profile
- Gaming use case → high GPU score, prioritizeGaming flag
- Content creation → high RAM, storage, screen quality flag
- Budget constraints → appropriate spec tier
- macOS + gaming → warning flag
- ChromeOS + heavy tasks → warning flag
- Empty answers → graceful fallback
- Conflicting answers → resolved spec profile
- Apple Silicon matching (M1/M2/M3 not stripped by normalize)
- RAM comparison (string vs number edge cases)
- `matchLaptopClass`:
- Strict matching returns correct models
- Relaxed matching widens budget ~30%
- GPU scoring tiers correct
- No matches → returns empty array (not generic class)
- OS filter works correctly
- Generic class excluded from OS filter

## Phase 3: Component Tests

**Files**: `src/__tests__/Recommendation.test.jsx`, `src/__tests__/LaptopCard.test.jsx`
**Test Cases**:
- `Recommendation`:
- Quiz renders with first question
- Answering questions advances step
- Back navigation works
- Results page shows laptop cards
- Fallback UI shows when no matches
- localStorage persistence (mock)
- ErrorBoundary catches render errors
- `LaptopCard`:
- Renders with all props
- Image fallback shows on error
- Match score displays correctly
- Price formatted in MXN

## Phase 4: CI/CD Pipeline

**Files**: `.github/workflows/ci.yml`
**Steps**:
1. Create workflow triggering on `push` and `pull_request` to `main`
2. Steps: checkout → setup Node 22.x → cache → `pnpm install --frozen-lockfile` → `pnpm run lint` → `pnpm run test` → `pnpm run build`
3. Add status badge to `README.md`
4. Verify: push to branch, confirm workflow runs

## Phase 5: Pre-commit Hooks

**Files**: `.husky/pre-commit`, `.husky/pre-push`, `package.json` (lint-staged config)
**Steps**:
1. Install: `pnpm add -D husky lint-staged`
2. Run: `pnpm exec husky init`
3. Configure `lint-staged` in `package.json`: `{"src/**/*.{js,jsx}": ["eslint --fix"]}`
4. Add `pre-push` hook: `pnpm run build`
5. Run `eslint --fix .` to clean existing violations first
6. Verify: commit with lint error → blocked

## Phase 6: Comparison View

**Files**: `src/components/Comparison/Comparison.jsx`, `src/components/Comparison/Comparison.css`, `src/routes/AppRoutes.jsx` (add route), `src/components/LaptopCard/LaptopCard.jsx` (add checkbox)
**Steps**:
1. Add "Compare" checkbox to `LaptopCard` (controlled by parent state)
2. Create `Comparison` component with side-by-side table
3. Highlight differences: compare each spec, mark better/worse
4. Add route `/compare` in `AppRoutes.jsx`
5. Mobile: stacked cards with sticky labels
6. Desktop: 2-3 column table
7. Accessibility: proper `<table>`, `<th>`, `aria-label`
8. Test: select 2-3 laptops, verify comparison renders correctly

## Phase 7: Shareable Links

**Files**: `src/utils/encodeResults.js`, `src/utils/decodeResults.js`, `src/components/Recommendation/Recommendation.jsx` (add share buttons), `src/routes/AppRoutes.jsx` (handle URL params)
**Steps**:
1. Create `encodeResults(answers, result)` → base64 string
2. Create `decodeResults(encoded)` → parsed answers + result
3. Add URL param handling in `Recommendation.jsx`: if `?r=<data>`, decode and show results
4. Add "Copy link" button → copies `window.location.href` to clipboard
5. Add "Share on WhatsApp" button → opens `wa.me/?text=<message>`
6. Handle invalid/expired URLs → redirect to quiz with error message
7. Test: encode results, paste URL in new tab, verify results restore

## Estimated Effort

| Phase | Days | Complexity |
|-------|------|------------|
| 1. Testing Setup | 0.5 | Low |
| 2. Inference Tests | 1.5 | Medium |
| 3. Component Tests | 1 | Medium |
| 4. CI/CD Pipeline | 0.5 | Low |
| 5. Pre-commit Hooks | 0.5 | Low |
| 6. Comparison View | 1.5 | Medium |
| 7. Shareable Links | 1 | Medium |
| **Total** | **~6.5 days** | |

## Parallel Execution

- Phases 1-5 can run sequentially (foundation)
- Phases 6-7 can run in parallel with 1-5 (feature work, no dependencies on tests)
- Recommended: 2 agents — one on foundation (1-5), one on features (6-7)
Loading
Loading