Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(#9409): ellipse rendering edge case #9443

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ jobs:
uses: ./.github/actions/build-fabric-cached
# Playwright suggests against caching the browser install
- name: Install Playwright Browsers
run: npx playwright install --with-deps chromium
run: npx playwright install --with-deps chromium firefox
- name: Run Playwright tests
run: xvfb-run npm run test:e2e
- name: Upload Test Output
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## [next]

- test(#9409): ellipse rendering edge case [#9443](https://github.com/fabricjs/fabric.js/pull/9443)
- fix(#9172): dep export `Object`, `Text`, `Image` [#9433](https://github.com/fabricjs/fabric.js/pull/9433)

## [6.0.0-beta13]
Expand Down
25 changes: 25 additions & 0 deletions e2e/tests/9409/common.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* Runs from both the browser and node
*/

import type { StaticCanvas } from 'fabric';

// eslint-disable-next-line @typescript-eslint/consistent-type-imports
export function render(canvas: StaticCanvas, fabric: typeof import('fabric')) {
canvas.setDimensions({ width: 640, height: 100 });

const ellipse = new fabric.Ellipse({
originX: 'center',
originY: 'center',
rx: 300,
ry: 30,
fill: 'green',
stroke: 'black',
strokeWidth: 40,
top: 20,
});

canvas.add(ellipse);
canvas.centerObject(ellipse);
canvas.renderAll();
}
28 changes: 28 additions & 0 deletions e2e/tests/9409/index.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { expect, test } from '@playwright/test';
import setup from '../../setup';
import { CanvasUtil } from '../../utils/CanvasUtil';
import { createNodeSnapshot } from '../../utils/createNodeSnapshot';
import { render } from './common';

setup();

test('#9409 Ellipse stroke edge case', async ({ page }, config) => {
await test.step('browser', async () => {
expect(
await new CanvasUtil(page).screenshot(),
'browser snapshot'
).toMatchSnapshot({
name: 'ellipse.png',
maxDiffPixelRatio: 0.05,
});
});

await test.step('node', async () => {
// we want the browser snapshot of a test to be committed and not the node snapshot
config.config.updateSnapshots = 'none';
expect(
await createNodeSnapshot(render),
'node snapshot should match browser snapshot'
).toMatchSnapshot({ name: 'ellipse.png', maxDiffPixelRatio: 0.05 });
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions e2e/tests/9409/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* Runs in the **BROWSER**
*/

import * as fabric from 'fabric';
import { beforeAll } from '../test';
import { render } from './common';

beforeAll((canvas) => render(canvas, fabric), { enableRetinaScaling: false });
70 changes: 46 additions & 24 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"@babel/core": "^7.22.9",
"@babel/preset-env": "^7.22.9",
"@babel/preset-typescript": "^7.22.5",
"@playwright/test": "^1.31.2",
"@playwright/test": "^1.39.0",
"@rollup/plugin-babel": "^6.0.3",
"@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-terser": "^0.4.1",
Expand Down
9 changes: 5 additions & 4 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,11 @@ const config: PlaywrightTestConfig = {
projects: [
{
name: 'chromium',
use: {
...devices['Desktop Chrome'],
browserName: 'chromium',
},
use: devices['Desktop Chrome'],
},
{
name: 'firefox',
use: devices['Desktop Firefox'],
},
],

Expand Down