-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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: electron slowness within cy origin #21445
Changes from 4 commits
06fe5b1
7e31364
ec2ea63
05a9a99
cf12f0f
be1fc4f
90bd99f
017ebff
70e3251
cf856bf
f784d00
0ff55b1
83b5746
80837d9
eb89971
e26ae8b
7cf3afe
9f318ab
7690f0e
2c98438
dbbf06a
0fe394f
739897f
1a89e94
5707d36
b89e336
4f4a074
fcc910c
eb64e96
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -94,12 +94,4 @@ | |
transform-origin: 50% 0; | ||
width: 100%; | ||
} | ||
} | ||
|
||
.spec-bridge-iframe { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these styles were still being injected, but it doesn't really make sense for the style to live here any longer, but inside the |
||
border: none; | ||
height: 100%; | ||
position: fixed; | ||
visibility: hidden; | ||
width: 100%; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
exports['e2e spec bridge in viewport / Overlays the reporter/AUT and is not positioned off screen, leading to potential performance impacts with cy.origin'] = ` | ||
|
||
==================================================================================================== | ||
|
||
(Run Starting) | ||
|
||
┌────────────────────────────────────────────────────────────────────────────────────────────────┐ | ||
│ Cypress: 1.2.3 │ | ||
│ Browser: FooBrowser 88 │ | ||
│ Specs: 1 found (spec_bridge.cy.ts) │ | ||
│ Searched: cypress/e2e/spec_bridge.cy.ts │ | ||
│ Experiments: experimentalSessionAndOrigin=true │ | ||
└────────────────────────────────────────────────────────────────────────────────────────────────┘ | ||
|
||
|
||
──────────────────────────────────────────────────────────────────────────────────────────────────── | ||
|
||
Running: spec_bridge.cy.ts (1 of 1) | ||
|
||
|
||
✓ visits foobar.com and types foobar inside an input | ||
|
||
1 passing | ||
|
||
|
||
(Results) | ||
|
||
┌────────────────────────────────────────────────────────────────────────────────────────────────┐ | ||
│ Tests: 1 │ | ||
│ Passing: 1 │ | ||
│ Failing: 0 │ | ||
│ Pending: 0 │ | ||
│ Skipped: 0 │ | ||
│ Screenshots: 0 │ | ||
│ Video: true │ | ||
│ Duration: X seconds │ | ||
│ Spec Ran: spec_bridge.cy.ts │ | ||
└────────────────────────────────────────────────────────────────────────────────────────────────┘ | ||
|
||
|
||
(Video) | ||
|
||
- Started processing: Compressing to 32 CRF | ||
- Finished processing: /XXX/XXX/XXX/cypress/videos/spec_bridge.cy.ts.mp4 (X second) | ||
|
||
|
||
==================================================================================================== | ||
|
||
(Run Finished) | ||
|
||
|
||
Spec Tests Passing Failing Pending Skipped | ||
┌────────────────────────────────────────────────────────────────────────────────────────────────┐ | ||
│ ✔ spec_bridge.cy.ts XX:XX 1 1 - - - │ | ||
└────────────────────────────────────────────────────────────────────────────────────────────────┘ | ||
✔ All specs passed! XX:XX 1 1 - - - | ||
|
||
|
||
` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
it('visits foobar.com and types foobar inside an input', () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any reason this can't be a driver test instead of system test? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not in particular. Main reason I didn't add it to the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd prefer that this and the other ones be driver tests. In general, it's better to use regular Cypress tests (driver tests, etc) if possible and reserve system tests for when it's not possible to write regular Cypress tests, like when the tests need specific project configuration, need dependencies the driver does not have, or when testing certain failures. It's much easier to iterate on driver tests as well as debug any failures, plus the results go to the Dashboard and utilize retries and config we already have set up for them. It's alright if the tests cover more than driver behavior. A lot of the driver tests are true e2e tests. Since this issue is specific to cy.origin(), I'd say the driver is as appropriate a place as any for the tests. |
||
cy.visit('primary_origin.html') | ||
cy.get('[data-cy="cross_origin_secondary_link"]').click() | ||
|
||
cy.origin('http://foobar.com:4466', () => { | ||
cy.get('[data-cy="text-input"]').type('foobar') | ||
}) | ||
|
||
// ensure stability | ||
cy.then(() => { | ||
AtofStryker marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const specBridgeIframe: HTMLIFrameElement = window.top.document.querySelector('.spec-bridge-iframe') | ||
const currentBody = window.top.document.querySelector('body') | ||
|
||
// make sure the spec bridge overlays the reporter/AUT and is not off the screen | ||
expect(specBridgeIframe.offsetTop).to.equal(currentBody.offsetTop) | ||
expect(specBridgeIframe.offsetLeft).to.equal(currentBody.offsetLeft) | ||
expect(specBridgeIframe.clientWidth).to.equal(currentBody.clientWidth) | ||
expect(specBridgeIframe.clientHeight).to.equal(currentBody.clientHeight) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know this PR is fixing a performance issue, but I believe the original reason the spec bridge needed to have the same dimensions as the AUT is for the sake of screenshots having the correct dimensions. I wonder if there was a behavioral regression as well that this fixes, but it doesn't look like we have test coverage around screenshot dimensions for screenshots taken within cy.origin(), so it didn't result in a failing test. If so, I think asserting on the screenshot behavior would be a good idea. It would also be better since it would assert on the behavior instead of the implementation details. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed. I am going to look into seeing if we can add in a few screenshot tests that assert on the behavior of the screensize within There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's unlikely there was a behavioral regression since the size of the frame was still correct. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think a few system tests could hurt to verify the screenshot in case there are some weird layout issues that occur in future. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @chrisbreiding how is something like 70e3251? It's based on the system tests that currently exist for snapshotting to just verify the dimensions of clipped, element, and full page snapshots. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks good! Those are exactly what I had in mind. Like I said in my other comment, I think they should be moved into the driver's tests. They would fit in well in origin/commands/screenshot.spec.ts. You'll just need to copy over the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
@chrisbreiding I got everything moved over into the driver and now looks to be working properly. |
||
}) | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import path from 'path' | ||
import systemTests from '../lib/system-tests' | ||
import Fixtures from '../lib/fixtures' | ||
|
||
const e2ePath = Fixtures.projectPath('e2e') | ||
|
||
const PORT = 3500 | ||
const onServer = function (app) { | ||
app.get('/secondary_origin.html', (_, res) => { | ||
res.sendFile(path.join(e2ePath, `secondary_origin.html`)) | ||
}) | ||
} | ||
|
||
describe('e2e spec bridge in viewport', () => { | ||
systemTests.setup({ | ||
servers: [{ | ||
port: 4466, | ||
onServer, | ||
}], | ||
settings: { | ||
hosts: { | ||
'*.foobar.com': '127.0.0.1', | ||
}, | ||
}, | ||
}) | ||
|
||
systemTests.it('Overlays the reporter/AUT and is not positioned off screen, leading to potential performance impacts with cy.origin', { | ||
// keep the port the same to prevent issues with the snapshot | ||
port: PORT, | ||
spec: 'spec_bridge.cy.ts', | ||
snapshot: true, | ||
browser: 'electron', | ||
expectedExitCode: 0, | ||
config: { | ||
experimentalSessionAndOrigin: true, | ||
}, | ||
}) | ||
}) |
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.
🎉