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

feat: Cross Origin Testing Support #18075

Merged
merged 174 commits into from Apr 25, 2022
Merged

feat: Cross Origin Testing Support #18075

merged 174 commits into from Apr 25, 2022

Conversation

chrisbreiding
Copy link
Contributor

@chrisbreiding chrisbreiding commented Sep 13, 2021

!!! DO NOT SQUASH !!!

User facing changelog

  • Removed experimentalSessionSupport Flag
  • Added experimentalSessionAndOrigin Flag containing:
    • All features from the experimentalSessionSupportFlag
    • A new Cypress command called origin which allows users to run commands within multiple origins from a single test.
    • Cross-domain requests will no longer fail immediately, but instead, time out based on pageLoadTimeout.
    • Tests will no longer wait on page loads before moving on to the next test.

Additional details

This is the feature for multi-domain.. more details coming.

How has the user experience changed?

PR Tasks

chrisbreiding and others added 30 commits May 26, 2021 15:11
* add multidomain bundle

* add a spec for manually testing and experimenting with multidomain bundle

* get cy.now('get') functioning

* move majority of multidomain entry point into driver
mschile and others added 3 commits April 20, 2022 23:03
…with experimentalSessionAndOrigin on (#21148)

* Attempt to run tests without the feature flag and the multi-domain folder

* do it for real this time dummy

* trying circleci changes

* valid file???

* moar changes!

* i am a master of bash scripting

* try another exclude pattern

* one more time with feeling

* lets do it again

* maybe this?

* different parallel group

* lets try this

* updating tests phase 1

* updating tests phase 2

* Apply suggestions from code review

Co-authored-by: Matt Schile <mschile@gmail.com>

* Update tests

* Run more tests

* Re-locate system test

* Flex message for firefox

Co-authored-by: Matt Schile <mschile@gmail.com>
AtofStryker and others added 3 commits April 22, 2022 09:41
* Empty commit to get a new percy nonce

* Implement snapshots and consoleprops within multi origin

further progress with getters

cleaned up log/snapshot serialization

attempt to pass and hydrate value state of serialized dom elements

temp commit traversal dom

by some stretch of a miracle this is working...

still somehow working

after massive performance issues with full tree serialization, fix here is to just attach values to inputs for reifying on primary

now we are cookin

test WIP

tests WIP

working multi-domain actions snapshots tests

added more tests to verify snapshots

add tests and refactor certain tests to make simpler

added misc snapshot tests

add navigation snapshot placeholder

add network request snapshot tests

add shadow querying snapshot tests

update test names

added snapshot querying spec

added screenshot snapshot test

add spies,clocks, and stubs tests

implement snapshot tests for traversal commands

rename local storeage snapshot tests to fit convention

add viewport snapshot tests

rename snapshot traversal to fit naming convention

add snapshot waiting tests

added window snapshot tests

implement navigation snapshot tests now that sinon proxy issues internal to log are now fixed

refactor multi-domain snapshot tests to leverage utility method over redefining in each spec

* fix lint types issues on serializationKeys

* rename switchToDomain to origin (might help with failing tests... ya know?)

* rename snapshot files to fit origin paradigm and fix misname on primaryDomainCommunicator

* fix .tick() snapshot/consoleProps test (figure out the deal with consoleProps sometimes being a function)

* rename multiDomainCommunicator to origin primaryDomainCommunicator

* don't invoke functions with arguments (we need to be more explicit about the functions we are invoking

* opt for my explicit serialization behavior with functions, never attempt to serialize bluebird promises

* move serialization to folder and change name to index

* refactor log serialization to own file, clean up code and add comments to what is going on in this 'here be dragons' code

* make sure to serialize functions for snapshots

* fix pause snapshot test for multi origin

* refactor postprocess snapshot into own method to handle in final state snapshot processing for cross origin

* update snapshot comments to be more accurate

* fix renamings within tests

* fix path in log.ts serialization

* revert about:blank changes in aut-iframe which was breaking session

* move all log/snapshot serialization magic invokations into the communicator

* update typos and fix namings of preprocess and reify

* further name changes

* fix snapshot generator to always reify snapshot (<body>) over attempting to match in the DOM

* unskip test that was fixed with explicit function serialization for logs

* fix flaky screenshot test that was screensize dependent

* rename a few items in the log serialization file

* clean up snapshot style reification to be more straightforward and remove redundancies

* refactor snapshots code to be more readable

* update reifyDomElement docs to actually explain what hte method does

* fix typos within the log serialization file pertaining to comments

* use Cypress._ over lodash import to reduce spec bundle size

* remove snapshots test folder and migrate tests into commands directory with #consoleProps context blocks for each

* change removeSrcAttributeFromAUTIframe name to removeSrcAttribute as it is implied on the AUT

* update log consoleProps comment to better reflect cross origin nature

* remove skipped consoleProps tests that do not have a command log to test against

* add createSnapshot to internal types (might need more specifics on this)

* refactor multi-domain consoleProp tests to use shouldWithTimeout custom command to avoid setTimeouts on command queue event to make test implementation cleaner

* simplify DOM hydration for input based elements

* update preprocessedHTMLElement type

* clean up some documentation and remove TS ignores. added getStyles to internal-types.

* add comment to aut-iframe on src attr removal for posterity

* reverse snapshot ternary for readability

* add shouldWithTimeout into spec-types and refactor out of internal-types

* add getAll type to cypress spec-types

* compare originPolicy of top and AUT instead of just origin to make snapshots work in subdomains

* add comment to _storeOriginalState for future developers and to add clarity

* add some basic log serialization tests that show full pre/reification of log, as well as state hydration for innerHTML. break out object/array methods from log like serialization into own methods

* update variables to metasyntactic

* add renderProps assertion for cy.request

* apply suggestions from code review to clean up log serializer

* make snapshot serialization more generic and typesafe

* work around firefox 93 issues by unsetting the document in cy state as the document is in a cross origin context in the primary, which means accessing any elements will not work

* clean up code and implement suggestions in code review

* remove crossOriginLog in favor of nullish coalescing if visible on the log is not set

* if get is null, return null for whole snapshot

Co-authored-by: Ryan Manuel <ryanm@cypress.io>
Co-authored-by: Matt Henkes <mjhenkes@gmail.com>
@chrisbreiding
Copy link
Contributor Author

Fixed the type issue in this merge: 5e71789

chrisbreiding and others added 2 commits April 22, 2022 14:58
* add generic to cy.origin type

* fix log type, update/add comments

* fix comment indentation

* specific generic

* move RemoteState to internal types

* add on links to experimental flag descriptions

* chore: reduce nesting by flipping condition

* fix test title

* simplify failing log

* rename variable

* delete error property

* fix types

* fix type

* remove unnecessary todo

* update wait test

* jquery -> this

* update comment

* remove vestigial autoRun

* use finally

* re-throw non-security errors

* move back getting index

* add new state types

* remove unnecessary export

* startsWith -> includes

* it -> them

* update system test

* remove use of promise constructor

* Revert "remove use of promise constructor"

This reverts commit 35ccc28.

* log errors from Page.getFrameTree

* test if anything breaks when removing optional chaining operator

* remove vestigial file

* handle queue ending in cross-origin driver

* fix coordinates spec

* improve chrome/firefox check in extension

* improve secure cookie regex

* use production mode for cross-origin driver bundle

* adding remoteStates.getPrimary

* catch and ignore queue errors

* remove optional chaining in postMessage handler

* removed unnecessary async

* update frame tree on cri client reconnect

* fix formatting

* renaming remoteStates variable

* prevent requests from being paused if experimentalSessionAndOrigin flag is off

Co-authored-by: Matt Schile <mschile@cypress.io>
Co-authored-by: Zach Bloomquist <git@chary.us>
Copy link
Collaborator

@ryanthemanuel ryanthemanuel left a comment

Choose a reason for hiding this comment

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

Looks good to me at this point. Nice work all!

@chrisbreiding
Copy link
Contributor Author

FWIW in regards to performance, I ran the cypress-example-kitchensink tests and got the following run times:

  • feature-multidomain branch, flag on: 284.58s
  • feature-multidomain branch, flag off: 273.79s
  • develop branch: 284.60s

I'm working on running the driver tests as well, but those take a lot longer, so I figured I would post what I have so far.

@ganeshac123
Copy link

@cy-veronica @cypress-app-bot : Code changes of these are available for users in recent version of Cypress app? or how can we clone changes of this release?

@chrisbreiding chrisbreiding deleted the feature-multidomain branch September 29, 2022 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: cy.origin Problems or enhancements related to cy.origin command
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cross-origin Testing max 1 site... support visiting multiple superdomains in one test