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

fix(browser): scale iframe for non ui case #6512

Draft
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

hi-ogawa
Copy link
Contributor

@hi-ogawa hi-ogawa commented Sep 15, 2024

Description

The test case I added is failing on webdriverio regardless of with or without UI. I couldn't figure out webdriverio, so this PR only fixes playwright where it has inconsistency with or without UI.

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. If the feature is substantial or introduces breaking changes without a discussion, PR might be closed.
  • Ideally, include a test that fails without this PR but passes with it.
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.

Tests

  • Run the tests with pnpm test:ci.

Documentation

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs command.

Changesets

  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.

@hi-ogawa hi-ogawa changed the title fix(browser): fix viewport for non ui case fix(browser): fix viewport for non ui case on playwright provider Sep 15, 2024
@hi-ogawa hi-ogawa marked this pull request as ready for review September 15, 2024 10:07
Copy link
Member

@sheremet-va sheremet-va left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't fix it when you call page.viewport

We already experimented with this before. Now we just need to keep the same iframe scaling that we have in ui

@hi-ogawa
Copy link
Contributor Author

This doesn't fix it when you call page.viewport

Ah, I didn't think about that. I've read #6257 and scaling seems more involved but I'll see what I can do.

@hi-ogawa hi-ogawa marked this pull request as draft September 17, 2024 06:56
Copy link

netlify bot commented Sep 18, 2024

Deploy Preview for vitest-dev ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 43459ea
🔍 Latest deploy log https://app.netlify.com/sites/vitest-dev/deploys/66ea23ea00d69d00084b6065
😎 Deploy Preview https://deploy-preview-6512--vitest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@hi-ogawa hi-ogawa changed the title fix(browser): fix viewport for non ui case on playwright provider fix(browser): scale iframe for non ui case Sep 18, 2024
Copy link
Contributor Author

@hi-ogawa hi-ogawa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only Mac chromium playwright is timing out with specs/runner.test.ts https://github.com/vitest-dev/vitest/actions/runs/10915841527/job/30296283296?pr=6512#step:9:24

I cannot reproduce it locally on my Linux chromium headless, so it's hard to diagnose what's wrong. I would appreciate if someone can check it on Mac machine locally.

Comment on lines +138 to +141
// not exact due to scaling and rounding
expect(spy).toHaveBeenCalledWith({
x: 200,
y: 150,
x: expect.closeTo(200, -1),
y: expect.closeTo(150, -1),
Copy link
Contributor Author

@hi-ogawa hi-ogawa Sep 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scaling round issue seems to already exist for UI case. For example, I can reproduce it on main branch with firefox.

$ PROVIDER=playwright BROWSER=firefox pnpm -C test/browser test-fixtures /userEvent. -t 'x/y'

 FAIL  test/userEvent.test.ts > userEvent.click > clicks with x/y coords
AssertionError: expected "spy" to be called with arguments: [ { x: 200, y: 150 } ]

Received: 

  1st spy call:

  Array [
    Object {
-     "x": 200,
+     "x": 199,
      "y": 150,
    },
  ]

I'm not sure if there's a way to fix this, so I loosened the assertion.

@@ -273,6 +273,21 @@ async function setIframeViewport(
if (ui) {
await ui.setIframeViewport(width, height)
}
else if (getBrowserState().provider === 'playwright') {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't figure out what's wrong with webdriverio, so I added scaling only for playwright and CI seems mostly happy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Browser viewport does not match iframe viewport when the UI is disabled
2 participants