Skip to content

feat: add visual regression tests for key application pages - #767

Open
priscannanna85-lgtm wants to merge 1 commit into
ritik4ever:mainfrom
priscannanna85-lgtm:feature/visual-regression-tests
Open

feat: add visual regression tests for key application pages#767
priscannanna85-lgtm wants to merge 1 commit into
ritik4ever:mainfrom
priscannanna85-lgtm:feature/visual-regression-tests

Conversation

@priscannanna85-lgtm

@priscannanna85-lgtm priscannanna85-lgtm commented Aug 2, 2026

Copy link
Copy Markdown

Category: testing
Project area: e2e/, .github/workflows/, package.json

Implementation:

  • Adds Playwright screenshot regression coverage for the homepage, campaign detail, pledge form, creator analytics, and dark mode.
  • Updates the visual-regression workflow with reproducible dependencies, Chromium setup, concurrency control, artifacts, and failure summaries.
  • Adds test:visual:update to refresh approved screenshot baselines.

Acceptance Criteria:

  • Visual tests run through npm run test:visual.
  • The workflow uploads Playwright reports and screenshot diffs when a visual check fails.
  • A failed visual run posts a PR summary identifying detected image diffs.
  • Existing visual baselines can be updated through npm run test:visual:update.

Summary by CodeRabbit

  • Tests
    • Expanded visual coverage across key pages, including campaign details, pledges, creator analytics, and dark mode.
    • Added consistent screenshot comparisons at a standard desktop resolution.
  • Chores
    • Improved automated visual-check reliability and reporting.
    • Added a convenient command for updating approved visual baselines.

@vercel

vercel Bot commented Aug 2, 2026

Copy link
Copy Markdown

@priscannanna85-lgtm is attempting to deploy a commit to the ritik4ever's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Aug 2, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The PR adds Playwright visual tests for five page states, a snapshot update command, and GitHub Actions support for concurrency control, Chromium-only execution, screenshot artifacts, and pull-request failure comments.

Changes

Visual regression coverage

Layer / File(s) Summary
Page visual regression coverage
e2e/pages.visual.spec.ts
Adds fixed 1440×900 screenshots for the homepage, campaign detail, pledge form, creator analytics, and dark-mode homepage.
Snapshot update command
package.json
Adds test:visual:update for updating Playwright snapshots.
CI execution and failure reporting
.github/workflows/playwright-visual-regression.yml
Adds run cancellation, Node.js 22, npm ci, Chromium-only installation, failure comments, and screenshot artifacts.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested reviewers: emeditweb

Sequence Diagram(s)

sequenceDiagram
  participant PullRequest
  participant GitHubActions
  participant Playwright
  participant Application
  participant GitHubScript

  PullRequest->>GitHubActions: Start visual regression workflow
  GitHubActions->>Playwright: Run Chromium visual tests
  Playwright->>Application: Navigate and capture page states
  Application-->>Playwright: Return rendered pages
  Playwright-->>GitHubActions: Return test results and screenshots
  GitHubActions->>GitHubScript: Generate failure summary
  GitHubScript->>PullRequest: Post visual-diff comment
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding visual regression tests for key application pages.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/playwright-visual-regression.yml:
- Around line 37-53: Update the “Generate visual diff report” step to initialize
diff_found as false before scanning test-results/**/*.png, then set it to true
inside the existing file check when at least one PNG diff artifact is found.
Keep the report generation behavior unchanged while ensuring downstream PR
comment logic receives false for non-screenshot failures.
- Around line 55-67: Add a job-level permissions block for the workflow
containing only repository contents read access and issues write access, so the
existing actions/github-script step can create PR comments without inheriting
broader token permissions. Keep the current visual-diff and comment behavior
unchanged.
- Around line 8-10: Update the workflow concurrency group to use
github.event.pull_request.number for pull request runs, with github.ref as the
fallback for non-pull-request events, while preserving cancel-in-progress
behavior.

In `@e2e/pages.visual.spec.ts`:
- Around line 22-26: Require the named visual states in e2e/pages.visual.spec.ts
at lines 22-26, 37-45, 57-60, and 71-75 instead of allowing isVisible() branches
to continue when targets are absent: require the campaign card, assert the
campaign detail panel after clicking, require the detail and pledge input and
assert the entered value, require the creator analytics section, and require the
theme toggle and assert the dark-theme state after clicking. Replace
timeout-only or optional checks with assertions that fail before screenshots
when the expected state is not rendered.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 3cf2156d-1a3e-4ca4-974e-a652f3db3082

📥 Commits

Reviewing files that changed from the base of the PR and between 5389a59 and 6cecb2a.

📒 Files selected for processing (3)
  • .github/workflows/playwright-visual-regression.yml
  • e2e/pages.visual.spec.ts
  • package.json

Comment on lines +8 to +10
concurrency:
group: visual-regression-${{ github.head_ref }}
cancel-in-progress: true

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== workflow files =="
git ls-files .github/workflows || true

echo
echo "== target workflow excerpt =="
if [ -f .github/workflows/playwright-visual-regression.yml ]; then
  nl -ba .github/workflows/playwright-visual-regression.yml | sed -n '1,80p'
else
  echo "target workflow not found"
fi

echo
echo "== all uses of head_ref in workflows =="
rg -n "head_ref|pull_request.number|ref_name|github.ref" .github/workflows || true

echo
echo "== diff stat/name status =="
git diff --stat -- .github/workflows/playwright-visual-regression.yml || true
git diff -- .github/workflows/playwright-visual-regression.yml | sed -n '1,120p' || true

Repository: ritik4ever/stellar-goal-vault

Length of output: 861


🌐 Web query:

GitHub Actions context github.head_ref pull_request.number fork same branch concurrent runs concurrency group

💡 Result:

To effectively manage concurrency and cancel redundant in-progress workflow runs in GitHub Actions, you should define a concurrency group at the workflow level [1]. Using a group key that is too specific (like using only github.head_ref or including unique identifiers like github.run_id) can lead to unintended behavior, such as collisions across different pull requests or failure to cancel redundant runs [2][3][4]. Recommended Strategy: The most robust concurrency group key combines the workflow name and the reference identifier [5][1][4]. This ensures that each workflow instance is scoped to its specific branch or pull request and prevents different workflows (e.g., CI and Lint) from cancelling each other [2][6][4]. A commonly recommended configuration is: concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true Why this configuration works: 1. github.workflow: Ensures that the concurrency group is unique to the specific workflow file, preventing separate workflows from interfering with one another [2][6][5]. 2. github.ref: On pull requests, this provides a unique reference (e.g., refs/pull/123/merge) that distinguishes one PR from another, even if they share the same source branch name (common when using forks) [3][4]. This avoids the risk of different users' PRs cancelling each other's runs [6][3]. 3. cancel-in-progress: Setting this to true causes the currently running workflow in the same group to be cancelled immediately when a new commit is pushed, ensuring that resources are focused on the latest commit [1][4]. Alternative Considerations: - If you use github.head_ref, be aware that it is only defined for pull_request events and can lead to unintended cancellations across different PRs that share the same branch name (e.g., both named 'patch-1' in different forks) [7][3]. If you must use github.head_ref, you should provide a fallback, such as ${{ github.head_ref || github.ref }} [7][4]. - For critical workflows (like deployments or releases), you may prefer to set cancel-in-progress to false or use conditional logic to avoid cancelling runs on the main branch, ensuring every deployment completes fully [1][4]. Top Results: [7], [3], [1], [4]

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== target workflow excerpt =="
if [ -f .github/workflows/playwright-visual-regression.yml ]; then
  awk '{printf "%5d  %s\n", NR, $0}' .github/workflows/playwright-visual-regression.yml | sed -n '1,120p'
else
  echo "target workflow not found"
fi

echo
echo "== triggers in target workflow =="
python3 - <<'PY'
from pathlib import Path
p=Path(".github/workflows/playwright-visual-regression.yml")
for i,line in enumerate(p.read_text().splitlines(),1):
    if any(s in line for s in ["pull_request", "github.head_ref", "concurrency:", "workflow_dispatch", "push:", "schedule:", "issues:", "pull_request_target"]):
        print(f"{i}: {line}")
PY

echo
echo "== all head_ref/use in workflows =='
rg -n -C 2 "github\.head_ref|pull_request\.number|concurrency:" .github/workflows || true

Repository: ritik4ever/stellar-goal-vault

Length of output: 3233


Use a unique pull request identifier for the concurrency group.

github.head_ref only contains the source branch name. Concurrent pull requests with the same branch name, including forked pull requests, share this group and can cancel each other.

Use github.event.pull_request.number for pull requests, with github.ref as a fallback for non-pull-request events.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/playwright-visual-regression.yml around lines 8 - 10,
Update the workflow concurrency group to use github.event.pull_request.number
for pull request runs, with github.ref as the fallback for non-pull-request
events, while preserving cancel-in-progress behavior.

Comment on lines +37 to +53
- name: Generate visual diff report
if: failure()
id: visual-diff
run: |
echo 'diff_found=true' >> "$GITHUB_OUTPUT"
echo '### Visual Regression Results' > /tmp/visual-report.md
echo '' >> /tmp/visual-report.md
echo '| Test | Status |' >> /tmp/visual-report.md
echo '|------|--------|' >> /tmp/visual-report.md
for f in test-results/**/*.png; do
if [ -f "$f" ]; then
name=$(basename "$f" .png)
echo "| $name | :x: Diff detected |" >> /tmp/visual-report.md
fi
done
echo '' >> /tmp/visual-report.md
echo 'Review the uploaded artifacts for full screenshot diffs.' >> /tmp/visual-report.md

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Locate and inspect the workflow and related Playwright config/artifact artifacts handling.
if [ -f .github/workflows/playwright-visual-regression.yml ]; then
  echo "== workflow excerpt =="
  cat -n .github/workflows/playwright-visual-regression.yml | sed -n '1,140p'
else
  echo "workflow file not found"
fi

echo "== search for visual-diff and playwrites artifact patterns =="
rg -n "visual diff|visual-diff|diff_found|test-results|upload-artifact|playwright" .github/workflows playwright*.config.* 2>/dev/null || true

Repository: ritik4ever/stellar-goal-vault

Length of output: 5892


Set diff_found only when a screenshot diff artifact exists.

The workflow sets diff_found=true before scanning test-results/**/*.png, while the PR comment step uses only that output. Set diff_found=false by default and set it to true only after finding generated diff images to avoid posting a misleading summary for non-screenshot test failures.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/playwright-visual-regression.yml around lines 37 - 53,
Update the “Generate visual diff report” step to initialize diff_found as false
before scanning test-results/**/*.png, then set it to true inside the existing
file check when at least one PNG diff artifact is found. Keep the report
generation behavior unchanged while ensuring downstream PR comment logic
receives false for non-screenshot failures.

Comment on lines +55 to +67
- name: Comment PR with visual diff summary
if: failure() && steps.visual-diff.outputs.diff_found == 'true'
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const body = fs.readFileSync('/tmp/visual-report.md', 'utf8');
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: body
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== workflow files =="
git ls-files .github/workflows || true

file=".github/workflows/playwright-visual-regression.yml"
if [ -f "$file" ]; then
  echo "== permissions / comments around lines 1-120 =="
  sed -n '1,120p' "$file" | cat -n
  echo
  echo "== relevant references =="
  rg -n "permissions:|GITHUB_TOKEN|contents:|issues:|actions/github-script|createComment|pull-requests" "$file"
fi

Repository: ritik4ever/stellar-goal-vault

Length of output: 3806


Declare least-privilege workflow permissions.

This job installs dependencies, runs test code, calls actions/github-script, and creates PR comments with GITHUB_TOKEN. Add a permissions block that grants only repository read access and issue-comment write access to avoid relying on repository-wide defaults.

Proposed fix
+permissions:
+  contents: read
+  issues: write
+
 concurrency:
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/playwright-visual-regression.yml around lines 55 - 67, Add
a job-level permissions block for the workflow containing only repository
contents read access and issues write access, so the existing
actions/github-script step can create PR comments without inheriting broader
token permissions. Keep the current visual-diff and comment behavior unchanged.

Source: Linters/SAST tools

Comment thread e2e/pages.visual.spec.ts
Comment on lines +22 to +26
const firstCard = page.locator('[class*="campaign"]').first();
if (await firstCard.isVisible()) {
await firstCard.click();
await page.waitForTimeout(500);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Require the named visual state before taking each screenshot.

Each isVisible() branch permits the test to continue when the required target is absent. The screenshot can then capture the homepage and still update or pass its baseline. waitForTimeout() does not prove that the target state rendered.

  • e2e/pages.visual.spec.ts#L22-L26: Require a campaign card and assert that the selected campaign detail panel is visible after the click.
  • e2e/pages.visual.spec.ts#L37-L45: Require the campaign detail and pledge input, then assert the entered pledge value.
  • e2e/pages.visual.spec.ts#L57-L60: Require the creator analytics section before the screenshot.
  • e2e/pages.visual.spec.ts#L71-L75: Require the theme toggle and assert the dark-theme state after the click.
📍 Affects 1 file
  • e2e/pages.visual.spec.ts#L22-L26 (this comment)
  • e2e/pages.visual.spec.ts#L37-L45
  • e2e/pages.visual.spec.ts#L57-L60
  • e2e/pages.visual.spec.ts#L71-L75
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@e2e/pages.visual.spec.ts` around lines 22 - 26, Require the named visual
states in e2e/pages.visual.spec.ts at lines 22-26, 37-45, 57-60, and 71-75
instead of allowing isVisible() branches to continue when targets are absent:
require the campaign card, assert the campaign detail panel after clicking,
require the detail and pledge input and assert the entered value, require the
creator analytics section, and require the theme toggle and assert the
dark-theme state after clicking. Replace timeout-only or optional checks with
assertions that fail before screenshots when the expected state is not rendered.

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.

1 participant