-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
fix(browser): scale iframe for non ui case #6512
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
sheremet-va
merged 46 commits into
vitest-dev:main
from
hi-ogawa:fix-browser-non-ui-viewport
Apr 17, 2025
Merged
Changes from 45 commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
c13849c
fix(browser): fix viewport for non ui case
hi-ogawa 8df9e9c
test: tweak
hi-ogawa 2cdab66
test: playwright only
hi-ogawa e2d9d09
Merge branch 'main' into fix-browser-non-ui-viewport
hi-ogawa ad7f47e
fix: scale iframe wrapper
hi-ogawa fd69f0c
fix: set data-scale
hi-ogawa 43459ea
Merge branch 'main' into fix-browser-non-ui-viewport
hi-ogawa ecac5ad
fix: scale userEvent
hi-ogawa 8fe8f35
wip: tweak
hi-ogawa 402b571
wip: how about ubuntu
hi-ogawa 3196a22
Revert "wip: tweak"
hi-ogawa 8d49953
Revert "wip: how about ubuntu"
hi-ogawa 2c36ca9
chore: revert this too
hi-ogawa 5f76302
test: non exact click position
hi-ogawa 3db24eb
wip: give up webdriverio
hi-ogawa 24bbb16
Merge branch 'main' into fix-browser-non-ui-viewport
hi-ogawa d3fef7c
Merge branch 'main' into fix-browser-non-ui-viewport
hi-ogawa 900f33a
fix: scale all providers + relax tests
hi-ogawa 75531f6
Merge branch 'main' into fix-browser-non-ui-viewport
hi-ogawa e983ea3
fix: leave webdriverio out
hi-ogawa e68478d
chore: comment
hi-ogawa 06c9297
test: tweak
hi-ogawa 7d291c7
Merge branch 'main' into fix-browser-non-ui-viewport
hi-ogawa e3cabb7
Merge branch 'main' into fix-browser-non-ui-viewport
hi-ogawa 40dcb01
wip
hi-ogawa fb0c8bb
debug
hi-ogawa 1edd33c
debug
hi-ogawa 640ade6
debug
hi-ogawa 705e61a
debug cleanup
hi-ogawa afce721
chore: cleanup
hi-ogawa a03e9b8
debug
hi-ogawa b21e780
debug
hi-ogawa 8ae2bcd
test: tweak
hi-ogawa a47bb2a
test: more tweak
hi-ogawa 36f5c9a
debug
hi-ogawa 1296e06
debug: isolate
hi-ogawa a82ae78
Merge branch 'main' into fix-browser-non-ui-viewport
hi-ogawa e02cc1d
Merge branch 'main' into fix-browser-non-ui-viewport
hi-ogawa 9b18f3f
Merge branch 'main' into fix-browser-non-ui-viewport
hi-ogawa 453bb8e
chore: cleanup
hi-ogawa fc940e3
Merge branch 'main' into fix-browser-non-ui-viewport
hi-ogawa 09f14ee
Merge branch 'main' into fix-browser-non-ui-viewport
hi-ogawa f63502b
chore: lint
hi-ogawa 3c0e0c7
test: tweak
hi-ogawa 6c646fa
chore: cleanup
hi-ogawa e89b710
refactor: move data-scale
hi-ogawa 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| import { page, userEvent, server } from "@vitest/browser/context"; | ||
| import { expect, test } from "vitest"; | ||
|
|
||
| test("drag and drop over large viewport", async () => { | ||
| // put boxes horizontally [1] [2] ... [30] | ||
| // then drag-and-drop from [1] to [30] | ||
|
|
||
| const wrapper = document.createElement("div"); | ||
| wrapper.style.cssText = "display: flex; width: 3000px;"; | ||
| document.body.appendChild(wrapper); | ||
|
|
||
| const events: { i: number; type: string }[] = []; | ||
|
|
||
| for (let i = 1; i <= 30; i++) { | ||
| const el = document.createElement("div"); | ||
| el.textContent = `[${i}]`; | ||
| el.style.cssText = ` | ||
| flex: none; | ||
| width: 100px; | ||
| height: 100px; | ||
| border: 1px solid black; | ||
| box-sizing: border-box; | ||
| display: flex; | ||
| justify-content: center; | ||
| align-items: center; | ||
| `; | ||
| el.draggable = true; | ||
| wrapper.append(el); | ||
|
|
||
| el.addEventListener("dragstart", (ev) => { | ||
| ev.dataTransfer.effectAllowed = "move"; | ||
| events.push({ type: "dragstart", i }); | ||
| }); | ||
| el.addEventListener("dragover", (ev) => { | ||
| ev.preventDefault(); | ||
| ev.dataTransfer.dropEffect = "move"; | ||
| events.push({ type: "dragover", i }); | ||
| }); | ||
| el.addEventListener("drop", (ev) => { | ||
| ev.preventDefault(); | ||
| events.push({ type: "drop", i }); | ||
| }); | ||
| } | ||
|
|
||
| // drag and drop only works reliably on playwright | ||
| if (server.provider !== 'playwright') { | ||
| return | ||
| } | ||
|
|
||
| await userEvent.dragAndDrop(page.getByText("[1]"), page.getByText("[30]")); | ||
|
|
||
| expect(events).toMatchObject( | ||
| expect.arrayContaining([ | ||
| { type: "dragstart", i: 1 }, | ||
| { type: "drop", i: 30 }, | ||
| ]), | ||
| ); | ||
| }); |
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,21 @@ | ||
| import { fileURLToPath } from 'node:url' | ||
| import { defineConfig } from 'vitest/config' | ||
| import { instances, provider } from '../../settings' | ||
|
|
||
| // pnpm -C test/browser test-fixtures --root fixtures/viewport --browser.ui=false | ||
| // pnpm -C test/browser test-fixtures --root fixtures/viewport --browser.headless=true | ||
|
|
||
| export default defineConfig({ | ||
| test: { | ||
| browser: { | ||
| enabled: true, | ||
| provider, | ||
| instances: instances.map(instance => ({ | ||
| ...instance, | ||
| viewport: { width: 3000, height: 400 } | ||
| })), | ||
|
|
||
| }, | ||
| }, | ||
| cacheDir: fileURLToPath(new URL("./node_modules/.vite", import.meta.url)), | ||
| }) |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import { expect, test } from 'vitest' | ||
| import { runBrowserTests } from './utils' | ||
|
|
||
| test('viewport', async () => { | ||
| const { stderr, ctx } = await runBrowserTests({ | ||
| root: './fixtures/viewport', | ||
| }) | ||
|
|
||
| expect(stderr).toBe('') | ||
| expect( | ||
| Object.fromEntries( | ||
| ctx.state.getFiles().map(f => [f.name, f.result.state]), | ||
| ), | ||
| ).toMatchInlineSnapshot(` | ||
| { | ||
| "basic.test.ts": "pass", | ||
| } | ||
| `) | ||
| }) |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should always add a
data-scaleattribute and throw an error if it's incorrect. TheisNaNcheck after that checks exactly that scenario