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
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
with:
node-version: 25
check-latest: true
- name: npm install
- name: Install dependencies
run: npm i
- name: Biome
run: node --run biome:ci
Expand All @@ -33,6 +33,8 @@ jobs:
- name: Test
run: node --run test
timeout-minutes: 4
- name: Visual regression test
run: node --run visual
- name: Upload coverage
uses: codecov/codecov-action@v5
with:
Expand Down
57 changes: 57 additions & 0 deletions .github/workflows/update-screenshots.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Update Screenshots

on:
pull_request:
types: [labeled]
workflow_dispatch:

env:
AUTHOR_NAME: 'github-actions[bot]'
AUTHOR_EMAIL: '41898282+github-actions[bot]@users.noreply.github.com'
COMMIT_MESSAGE: |
Update screenshots

Co-authored-by: ${{ github.actor }}

jobs:
update-screenshots:
if: ${{ github.event.label.name == 'Update Screenshots' }}
runs-on: ubuntu-latest

permissions:
contents: write
pull-requests: write

# one at a time per branch
concurrency:
group: update-screenshots@${{ github.head_ref }}
cancel-in-progress: true

steps:
- uses: actions/checkout@v5
with:
ref: ${{ github.head_ref }}
- uses: actions/setup-node@v6
with:
node-version: 25
check-latest: true
- name: Remove label
if: github.event_name == 'pull_request'
run: gh pr edit --remove-label 'Update Screenshots'
env:
GH_TOKEN: ${{ github.token }}
- name: Install dependencies
run: npm i
- name: Install Playwright Browsers
run: npx playwright install chromium firefox
- name: Update screenshots
run: |
rm -r test/visual/__screenshots__
node --run visual:update
- name: Push new screenshots
run: |
git config --global user.name "${{ env.AUTHOR_NAME }}"
git config --global user.email "${{ env.AUTHOR_EMAIL }}"
git add test/visual/__screenshots__/.
git diff-index --quiet HEAD || git commit -m "${{ env.COMMIT_MESSAGE }}"
git push
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/lib
/node_modules
/package-lock.json
__screenshots__
test/browser/**/__screenshots__

npm-debug.log
**.orig
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@
"preview": "vite preview",
"build:website": "vite build",
"build": "rolldown -c",
"test": "vitest run",
"test:watch": "vitest watch",
"test": "vitest run --project browser --project node --coverage.reportsDirectory='./coverage/test'",
"test:watch": "vitest watch --project browser --project node",
"visual": "vitest run --project visual --coverage.reportsDirectory='./coverage/visual'",
"visual:update": "vitest run --project visual --update",
"format": "biome format --write",
"check": "biome check --error-on-warnings",
"biome:ci": "biome ci --error-on-warnings",
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
54 changes: 54 additions & 0 deletions test/visual/basicGrid.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { page } from 'vitest/browser';

import { DataGrid, SelectColumn, type Column } from '../../src';
import { getGrid } from '../browser/utils';

interface Row {
id: number;
name: string;
}

const columns: readonly Column<Row, Row>[] = [
SelectColumn,
{
key: 'name',
name: 'Name',
renderSummaryCell(props) {
return props.row.name;
}
}
];

const rows: readonly Row[] = [
{ id: 1, name: 'Row 1' },
{ id: 2, name: 'Row 2' },
{ id: 3, name: 'Row 3' }
];

const topSummaryRows: readonly Row[] = [
{ id: 4, name: 'Top Summary Row 1' },
{ id: 5, name: 'Top Summary Row 2' }
];

const bottomSummaryRows: readonly Row[] = [
{ id: 6, name: 'Bottom Summary Row 1' },
{ id: 7, name: 'Bottom Summary Row 2' }
];

function rowKeyGetter(row: Row) {
return row.id;
}

test('basic grid', async () => {
await page.render(
<DataGrid
rowKeyGetter={rowKeyGetter}
columns={columns}
rows={rows}
topSummaryRows={topSummaryRows}
bottomSummaryRows={bottomSummaryRows}
/>
);

await expect(getGrid()).toMatchScreenshot('basic-grid');
});
20 changes: 20 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,26 @@ export default defineConfig(
setupFiles: ['test/setupBrowser.ts']
}
},
{
extends: true,
test: {
name: 'visual',
include: ['test/visual/*.test.*'],
browser: {
enabled: true,
provider: playwright({
contextOptions: {
viewport
}
}),
instances: [{ browser: 'chromium' }, { browser: 'firefox' }],
viewport,
headless: true,
screenshotFailures: false
},
setupFiles: ['test/setupBrowser.ts']
}
},
{
extends: true,
test: {
Expand Down
Loading