Skip to content
Closed
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
47 changes: 47 additions & 0 deletions .github/workflows/visualdiffs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Visual URL Comparison

on:
pull_request:

jobs:
visual-diff:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Install deps for PR build
run: npm ci

- name: Install Playwright browsers
run: npx playwright install --with-deps

- name: Build PR version
run: npm run build

- name: Serve PR build
run: npm run preview -- --port 3001 &

# Checkout base branch and build
- name: Checkout base branch
run: |
git fetch origin ${{ github.event.pull_request.base.ref }} --depth=1
git checkout FETCH_HEAD

- name: Install deps for base build
run: npm ci

- name: Build base version
run: npm run build

- name: preview vite build
run: npm run preview -- --port 3002 &

# Run screenshot diff script
- name: Run visual diff
run: node scripts/visualDiff.cjs

- uses: actions/upload-artifact@v4
with:
name: visual-diffs
path: diffs
81 changes: 77 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
"eslint": "^9.33.0",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^5.2.0",
"pixelmatch": "^7.1.0",
"playwright": "^1.57.0",
"pngjs": "^7.0.0",
"tailwindcss": "^4.1.16",
"vite": "^7.1.2"
}
Expand Down
41 changes: 41 additions & 0 deletions scripts/visualDiff.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
const { chromium } = require("playwright");
const pixelmatch = require("pixelmatch").default || require("pixelmatch");
const { PNG } = require("pngjs");
const fs = require("fs");

const urls = [{ name: "home", path: "/" }];

async function run() {
if (!fs.existsSync("diffs")) fs.mkdirSync("diffs");

const browser = await chromium.launch();

for (const { name, path } of urls) {
const page = await browser.newPage();

// PR screenshot
await page.goto(`http://localhost:5173${path}`);
await page.screenshot({ path: `diffs/${name}_pr.png`, fullPage: true });

// Base screenshot
await page.goto(`http://localhost:5173${path}`);
await page.screenshot({ path: `diffs/${name}_base.png`, fullPage: true });

// Compare
const img1 = PNG.sync.read(fs.readFileSync(`diffs/${name}_base.png`));
const img2 = PNG.sync.read(fs.readFileSync(`diffs/${name}_pr.png`));
const out = new PNG({ width: img1.width, height: img1.height });

pixelmatch(img1.data, img2.data, out.data, img1.width, img1.height, {
threshold: 0.3,
});

fs.writeFileSync(`diffs/${name}_diff.png`, PNG.sync.write(out));

await page.close();
}

await browser.close();
}

run();
2 changes: 1 addition & 1 deletion src/components/OptimadeClient/OptimadeFAQs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default function OptimadeFAQs() {
{/* FAQ Content */}
<section className="space-y-2">
<h4 className="font-bold text-lg">
Why is a given provider not shown in the client?
Why is a given provider not shown in the client? ----
</h4>
<p className="text-sm">
The most likely reason is that they have not yet registered with{" "}
Expand Down