Skip to content

Comments

Add visual regression testing with light and dark mode support#3

Merged
Sagyam merged 1 commit intomasterfrom
claude/add-visual-regression-and-linter-fixes-011CV49AGiBFQddYG4cXHTFd
Nov 15, 2025
Merged

Add visual regression testing with light and dark mode support#3
Sagyam merged 1 commit intomasterfrom
claude/add-visual-regression-and-linter-fixes-011CV49AGiBFQddYG4cXHTFd

Conversation

@Sagyam
Copy link
Owner

@Sagyam Sagyam commented Nov 12, 2025

This commit adds comprehensive visual regression testing infrastructure using Playwright, with full support for both light and dark themes.

Features:

  • Visual regression tests for key sections (homepage, presets, general, compute, storage, results) in both light and dark modes
  • Playwright configuration optimized for visual testing
  • GitHub Actions workflows for automated testing and baseline generation
  • Comprehensive documentation and usage guides

Setup includes:

  • playwright.config.ts: Configuration for light/dark mode projects
  • e2e/visual-regression.spec.ts: Complete test suite covering all major sections
  • .github/workflows/visual-regression.yml: Main CI workflow
  • .github/workflows/visual-regression-init.yml: Baseline generation workflow
  • e2e/README.md: Detailed test documentation
  • VISUAL_REGRESSION_TESTING.md: Complete setup and usage guide

Testing workflow:

  1. Tests run automatically on push and PRs
  2. Baselines can be generated via GitHub Actions
  3. Test reports and screenshots uploaded as artifacts
  4. Support for local development with npm scripts

npm scripts added:

  • test:e2e: Run all visual regression tests
  • test:e2e:ui: Run tests with interactive UI
  • test:e2e:debug: Run tests in debug mode
  • test:e2e:update: Update baseline screenshots
  • test:e2e:report: View HTML test report

Dependencies added:

  • @playwright/test: Testing framework
  • playwright: Browser automation

The baselines should be generated using the "Initialize Visual Regression Baselines" workflow in GitHub Actions for consistency across environments.

Summary by CodeRabbit

  • New Features

    • Added automated visual regression testing for UI consistency checks across light and dark themes, integrated into CI/CD pipelines.
  • Documentation

    • Added comprehensive guides for visual regression testing setup and usage.
  • Chores

    • Updated development server port configuration.
    • Added testing framework dependencies and new test commands.

This commit adds comprehensive visual regression testing infrastructure
using Playwright, with full support for both light and dark themes.

Features:
- Visual regression tests for key sections (homepage, presets, general,
  compute, storage, results) in both light and dark modes
- Playwright configuration optimized for visual testing
- GitHub Actions workflows for automated testing and baseline generation
- Comprehensive documentation and usage guides

Setup includes:
- playwright.config.ts: Configuration for light/dark mode projects
- e2e/visual-regression.spec.ts: Complete test suite covering all major sections
- .github/workflows/visual-regression.yml: Main CI workflow
- .github/workflows/visual-regression-init.yml: Baseline generation workflow
- e2e/README.md: Detailed test documentation
- VISUAL_REGRESSION_TESTING.md: Complete setup and usage guide

Testing workflow:
1. Tests run automatically on push and PRs
2. Baselines can be generated via GitHub Actions
3. Test reports and screenshots uploaded as artifacts
4. Support for local development with npm scripts

npm scripts added:
- test:e2e: Run all visual regression tests
- test:e2e:ui: Run tests with interactive UI
- test:e2e:debug: Run tests in debug mode
- test:e2e:update: Update baseline screenshots
- test:e2e:report: View HTML test report

Dependencies added:
- @playwright/test: Testing framework
- playwright: Browser automation

The baselines should be generated using the "Initialize Visual Regression
Baselines" workflow in GitHub Actions for consistency across environments.
@vercel
Copy link

vercel bot commented Nov 12, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
infra-wise Error Error Nov 12, 2025 3:15pm

@coderabbitai
Copy link

coderabbitai bot commented Nov 12, 2025

Walkthrough

This change introduces a comprehensive visual regression testing framework using Playwright to the project. It includes GitHub Actions workflows for baseline initialization and continuous testing, a Playwright configuration supporting light and dark themes, an extensive test suite covering multiple UI sections, npm scripts for test execution, and detailed documentation for setup and usage.

Changes

Cohort / File(s) Summary
GitHub Actions Workflows
.github/workflows/visual-regression-init.yml, .github/workflows/visual-regression.yml
Introduces two new workflows: one for manually generating initial visual regression baselines with PR creation, and one for automated testing on pushes/PRs with baseline update capabilities.
Playwright Configuration
playwright.config.ts
Adds Playwright configuration with test discovery parameters, HTML/list reporters, two browser projects (chromium-light and chromium-dark), baseline tolerance settings, and local dev server integration.
Test Suite
e2e/visual-regression.spec.ts
New comprehensive test file with nested test suites for light mode, dark mode, theme toggling, and results display. Captures and compares full-page and section-specific screenshots across themes.
Package Configuration
package.json
Updates start script to run on port 3100, adds five e2e test scripts (test:e2e, test:e2e:ui, test:e2e:debug, test:e2e:update, test:e2e:report), and adds @playwright/test and playwright dev dependencies.
Build Artifacts Configuration
.gitignore
Adds three new ignore patterns: /test-results/, /playwright-report/, and /playwright/.cache/.
Documentation
VISUAL_REGRESSION_TESTING.md, e2e/README.md
Two new markdown documents covering visual regression setup, testing commands, workflow, CI/CD integration, test structure, configuration details, troubleshooting, and best practices.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant User
    participant GHA as GitHub Actions
    participant Build as Build Process
    participant E2E as Playwright E2E
    participant Snapshots as Snapshot Storage
    participant PR as Pull Request

    User->>GHA: Trigger visual-regression-init workflow
    GHA->>Build: Checkout & setup Node.js
    Build->>Build: npm ci & playwright install
    Build->>Build: npm run build (production)
    GHA->>E2E: npm run test:e2e:update (CI=true)
    E2E->>Snapshots: Generate baseline screenshots
    Snapshots-->>E2E: Baseline images created
    GHA->>PR: Create PR with baselines
    PR-->>User: Review & merge baselines
    
    rect rgb(220, 240, 255)
    Note over GHA,E2E: Continuous Testing Flow
    User->>GHA: Push to main or open PR
    GHA->>Build: Checkout & setup
    Build->>Build: npm ci & build
    GHA->>E2E: npm run test:e2e
    E2E->>Snapshots: Compare against baselines
    Snapshots-->>E2E: Pass/Fail results
    GHA-->>User: Test results & artifacts
    end
Loading

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~28 minutes

  • e2e/visual-regression.spec.ts: Requires careful review of test structure, locators, and theme-switching logic to ensure comprehensive coverage and correct snapshot comparisons.
  • GitHub Actions workflows: Verify workflow logic, PR creation parameters, and conditional step execution for baseline updates.
  • playwright.config.ts: Confirm browser configuration, threshold tolerances, and color scheme definitions align with project requirements.
  • Integration points: Review package.json script definitions and port changes to ensure no conflicts with existing infrastructure.

Poem

🐰 A twitching nose detects each hue,
Light and dark themes captured true,
Baselines born, regressions caught,
Playwright's magic, flawlessly wrought—
Visual gardens, pixel-perfect delight! ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely summarizes the main change: adding visual regression testing with light/dark mode support, which aligns with all major additions (test suite, Playwright config, workflows, docs, and npm scripts).
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch claude/add-visual-regression-and-linter-fixes-011CV49AGiBFQddYG4cXHTFd

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
VISUAL_REGRESSION_TESTING.md (1)

98-118: Add language hint for the project tree block.

Markdownlint (MD040) flags fences without a language. Tag this one as plain text so docs CI stays green.

-```
+```text
 Infra-Wise/
 ├── e2e/
 │   ├── README.md                          # Detailed test documentation
 │   ├── visual-regression.spec.ts          # Test suite
 │   └── visual-regression.spec.ts-snapshots/  # Baseline images
 ...
-```
+```
e2e/README.md (1)

90-103: Label the project tree fence.

Same MD040 warning here—declare the fence as text (or similar) to satisfy markdownlint.

-```
+```text
 e2e/
 ├── README.md                          # This file
 ├── visual-regression.spec.ts          # Visual regression test suite
 └── visual-regression.spec.ts-snapshots/  # Baseline screenshots (git-tracked)
 ...
-```
+```
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c67ff61 and 7efd70f.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (8)
  • .github/workflows/visual-regression-init.yml (1 hunks)
  • .github/workflows/visual-regression.yml (1 hunks)
  • .gitignore (1 hunks)
  • VISUAL_REGRESSION_TESTING.md (1 hunks)
  • e2e/README.md (1 hunks)
  • e2e/visual-regression.spec.ts (1 hunks)
  • package.json (3 hunks)
  • playwright.config.ts (1 hunks)
🧰 Additional context used
🪛 LanguageTool
e2e/README.md

[grammar] ~135-~135: Ensure spelling is correct
Context: ...2e:update` ### Tests Timeout If tests timeout during execution: - Ensure the develop...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

🪛 markdownlint-cli2 (0.18.1)
e2e/README.md

98-98: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: test (20.x)

Comment on lines +252 to +281
// Click on Results section in sidebar
const resultsButton = page.getByRole('button', { name: /results/i }).first()
if (await resultsButton.isVisible()) {
await resultsButton.click()
await page.waitForTimeout(500)

await expect(page).toHaveScreenshot('results-section-light.png', {
fullPage: true,
})
}
})

test('results should match snapshot in dark mode', async ({ page }) => {
await page.evaluate(() => {
document.documentElement.classList.remove('light')
document.documentElement.classList.add('dark')
})
await page.waitForTimeout(500)

// Click on Results section in sidebar
const resultsButton = page.getByRole('button', { name: /results/i }).first()
if (await resultsButton.isVisible()) {
await resultsButton.click()
await page.waitForTimeout(500)

await expect(page).toHaveScreenshot('results-section-dark.png', {
fullPage: true,
})
}
})
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Stop skipping the Results screenshot when the section is missing.

Because the screenshot assertion lives inside if (await resultsButton.isVisible()), the test happily passes even when the Results entry disappears—precisely the regression we want to catch. Assert visibility, always click it, and always compare the screenshot so the suite fails loudly when Results vanish.

-      const resultsButton = page.getByRole('button', { name: /results/i }).first()
-      if (await resultsButton.isVisible()) {
-        await resultsButton.click()
-        await page.waitForTimeout(500)
-
-        await expect(page).toHaveScreenshot('results-section-light.png', {
-          fullPage: true,
-        })
-      }
+      const resultsButton = page.getByRole('button', { name: /results/i }).first()
+      await expect(resultsButton).toBeVisible()
+      await resultsButton.click()
+      await page.waitForTimeout(500)
+
+      await expect(page).toHaveScreenshot('results-section-light.png', {
+        fullPage: true,
+      })
@@
-      const resultsButton = page.getByRole('button', { name: /results/i }).first()
-      if (await resultsButton.isVisible()) {
-        await resultsButton.click()
-        await page.waitForTimeout(500)
-
-        await expect(page).toHaveScreenshot('results-section-dark.png', {
-          fullPage: true,
-        })
-      }
+      const resultsButton = page.getByRole('button', { name: /results/i }).first()
+      await expect(resultsButton).toBeVisible()
+      await resultsButton.click()
+      await page.waitForTimeout(500)
+
+      await expect(page).toHaveScreenshot('results-section-dark.png', {
+        fullPage: true,
+      })
🤖 Prompt for AI Agents
In e2e/visual-regression.spec.ts around lines 252 to 281, the screenshot
assertion is gated by an if-check on resultsButton.isVisible(), which lets the
test pass when the Results entry is missing; change this to assert the button is
visible (e.g., await expect(resultsButton).toBeVisible()), then always perform
the click and await necessary waits, and always call the screenshot assertion so
the test fails loudly if the Results section is absent or not rendered.

@Sagyam Sagyam merged commit 80037a2 into master Nov 15, 2025
4 of 6 checks passed
@Sagyam Sagyam deleted the claude/add-visual-regression-and-linter-fixes-011CV49AGiBFQddYG4cXHTFd branch November 15, 2025 04:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants