-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
test(playwright): add snapshots, refactor utils, coverage #9078
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
Merged
Merged
Changes from 15 commits
Commits
Show all changes
77 commits
Select commit
Hold shift + click to select a range
9dbcc6d
step
ShaMan123 693ba03
Update text-editing.spec.ts
ShaMan123 31316ca
cute
ShaMan123 2d9c037
snapshots!
ShaMan123 885a85c
great
ShaMan123 5b92828
update CHANGELOG.md
github-actions[bot] dfcd4c8
beautiful
ShaMan123 5eedece
Merge branch 'test-playwright' of https://github.com/fabricjs/fabric.…
ShaMan123 da7004a
Update tests.yml
ShaMan123 a2d8bbe
Update tests.yml
ShaMan123 ad95201
Update tests.yml
ShaMan123 f696407
Update playwright.config.ts
ShaMan123 0f7264c
Update tests.yml
ShaMan123 eabe24c
Update tests.yml
ShaMan123 43f20be
update CHANGELOG.md
github-actions[bot] 36aa953
Update playwright.config.ts
ShaMan123 7f1b2ee
Update tests.yml
ShaMan123 072be5d
Merge branch 'master' into test-playwright
ShaMan123 77d7bb7
Update tests.yml
ShaMan123 d1d6fa9
Update tests.yml
ShaMan123 28bfaa7
Update playwright.config.ts
ShaMan123 daf1846
coverage
ShaMan123 3f3b314
fix snapshot naming
ShaMan123 0b15bcd
Update .npmignore
ShaMan123 3a56887
Update text-editing.spec.ts
ShaMan123 f1d1b58
again
ShaMan123 1676c42
Update tests.yml
ShaMan123 ce5d820
fix coverage reporting
ShaMan123 bb8b5e4
try cache playwright browsers
ShaMan123 ea51a06
Update tests.yml
ShaMan123 d76c5b6
update CHANGELOG.md
github-actions[bot] 7a8ae28
perf(): install only chromium
ShaMan123 cd2f566
cache playwright browsers
ShaMan123 92e58eb
update CHANGELOG.md
github-actions[bot] ac351ad
perf(): install only chromium
ShaMan123 042bc8e
Update tests.yml
ShaMan123 15e8f86
Merge branch 'test-playwright' of https://github.com/fabricjs/fabric.…
ShaMan123 203a8bc
extract methods for reuse
ShaMan123 9e72d8e
Update playwright.config.ts
ShaMan123 a3ac0d6
Create startVanillaApp.ts
ShaMan123 948874b
Create setupApp.ts
ShaMan123 484544b
Update setupApp.ts
ShaMan123 32406ca
Update package.json
ShaMan123 9135347
config
ShaMan123 a03f22c
feat(): allow vanilla app in tests
ShaMan123 b1927e3
Revert "extract methods for reuse"
ShaMan123 ab7c15a
progress
ShaMan123 90aabcc
point
ShaMan123 056170a
progress
ShaMan123 98c5a13
rename
ShaMan123 40e0f0f
Update tsconfig.json
ShaMan123 66f8d7d
Update index.html
ShaMan123 4d56f0f
Update setupTest.ts
ShaMan123 a76d408
fix race condition
ShaMan123 614ba02
mv
ShaMan123 524f3c1
stable
ShaMan123 696c766
cleanup
ShaMan123 a47d078
Update setupCoverage.ts
ShaMan123 8bd78b3
Merge branch 'master' into test-playwright
ShaMan123 40e91b2
Update setupApp.ts
ShaMan123 e61db33
Update tsconfig.json
ShaMan123 0892b4c
finalize hopefully
ShaMan123 69b1d2c
watch mode
ShaMan123 ef3d685
Update setupCoverage.ts
ShaMan123 a47e09f
template
ShaMan123 7a0da31
body
ShaMan123 7e806d4
selectors
ShaMan123 2048de7
multiple canvas init
ShaMan123 fe6d6d7
Update setupTest.ts
ShaMan123 562b234
Update playwright.config.ts
ShaMan123 acd274d
run CI in headed mode
ShaMan123 c1222e6
mv
ShaMan123 8cef2bf
comments
ShaMan123 5d49b4c
cleanup
ShaMan123 3fba4c3
Update index.ts
ShaMan123 78cc1ee
Update index.ts
ShaMan123 3e38676
extract
ShaMan123 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+55.7 KB
e2e/tests/text/text-editing.spec.ts-snapshots/decrease-width-ml-chromium-win32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+55.7 KB
e2e/tests/text/text-editing.spec.ts-snapshots/decrease-width-mr-chromium-win32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+55.2 KB
e2e/tests/text/text-editing.spec.ts-snapshots/exit-editing-chromium-win32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+20.1 KB
e2e/tests/text/text-editing.spec.ts-snapshots/increase-width-ml-chromium-win32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+46.4 KB
e2e/tests/text/text-editing.spec.ts-snapshots/increase-width-mr-chromium-win32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+10.5 KB
e2e/tests/text/text-editing.spec.ts-snapshots/initial-chromium-win32.png
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.
Binary file added
BIN
+55.9 KB
e2e/tests/text/text-editing.spec.ts-snapshots/typed-chromium-win32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| import { Page, expect } from '@playwright/test'; | ||
| import type { Canvas, Object as FabricObject } from '../..'; | ||
|
|
||
| export class ObjectUtil { | ||
| constructor(readonly objectId: string, readonly page: Page) {} | ||
|
|
||
| executeInBrowser<C, R>( | ||
| runInBrowser: ( | ||
| context: Omit<C, 'objectId'> & { | ||
| object: FabricObject; | ||
| canvas: Canvas; | ||
| } | ||
| ) => R, | ||
| context?: C | ||
| ): Promise<R> { | ||
| return this.page.evaluate( | ||
| ({ objectId, runInBrowser, ...context }) => { | ||
| return eval(runInBrowser)({ | ||
| object: | ||
| objectId && | ||
| fabricCanvas.getObjects().find((obj) => obj.id === objectId), | ||
| canvas: fabricCanvas, | ||
| ...context, | ||
| }); | ||
| }, | ||
| { | ||
| ...context, | ||
| objectId: this.objectId, | ||
| runInBrowser: runInBrowser.toString(), | ||
| } | ||
| ); | ||
| } | ||
|
|
||
| getObjectCenter() { | ||
| return this.executeInBrowser(({ object }) => object.getCenterPoint()); | ||
| } | ||
|
|
||
| getObjectControlPoint(controlName: string) { | ||
| return this.executeInBrowser( | ||
| ({ object, controlName }) => object.oCoords[controlName], | ||
| { controlName } | ||
| ); | ||
| } | ||
|
|
||
| async expectObjectToMatch<T extends Record<string, unknown>>(expected: T) { | ||
| const snapshot = await this.executeInBrowser(({ object }) => object); | ||
| expect(snapshot).toMatchObject(expected); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import { Page } from '@playwright/test'; | ||
| import { ObjectUtil } from './ObjectUtil'; | ||
|
|
||
| let ID = 0; | ||
| const uuid = () => `test${ID++}`; | ||
|
|
||
| export class TestUtil { | ||
| constructor(readonly page: Page) {} | ||
ShaMan123 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| clickCanvas(clickProperties: Parameters<Page['click']>[1]) { | ||
| return this.page.click('canvas.upper-canvas', clickProperties); | ||
| } | ||
|
|
||
| async addTextbox(text: string, properties) { | ||
ShaMan123 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| const id = uuid(); | ||
| await this.page.evaluate( | ||
| ({ id, text, ...properties }) => { | ||
| const textbox = new fabric.Textbox(text, { | ||
| ...properties, | ||
| id, | ||
| }); | ||
| fabricCanvas.add(textbox); | ||
| return id; | ||
| }, | ||
| { id, text, ...properties } | ||
| ); | ||
| return new ObjectUtil(id, this.page); | ||
| } | ||
| } | ||
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.