Skip to content

Conversation

@mschile
Copy link
Contributor

@mschile mschile commented Mar 23, 2022

User facing changelog

n/a

Additional details

Added support for multiple remote states. This allows us to better determine when to inject multi-domain and to support carrying forward the cy.visit auth options to subsequent requests. Multiple remote states works as follows:

  • top origin added to origin stack
  • remote state added when ready:for:domain event received
    • the origin is added to the origin stack
  • when requesting the remote state, the remote state for the latest origin is returned
  • when processing auth in the request-middleware, the remote state for the requested origin is retrieved to determine if auth needs to be applied to the request.
  • when determining if a response should be delayed for multi-domain, the cross-origin check now only passes if the request is not for the current origin or any other previous origins in the stack
  • when determining if multi-domain should be injected into the response, an additional check is made to ensure the response is for a secondary origin in the origin stack
  • when the switchToDomain command ends, the origin is removed from the origin stack but the remote state is not removed since the user could make another request to that origin that would need the state applied
  • origin stack and secondary remote states are reset between tests and when loading the tests to ensure the previous state is cleaned up before starting any new test
  • if switchToDomain validation fails or if the fallback switchToDomain timeout occurs, the response is released but the remote state and origin are not added

How has the user experience changed?

  • auth options are now applied to subsequent requests in a secondary origin
  • multi-domain is only injected for known secondary origins

PR Tasks

  • Have tests been added/updated?
  • [na] Has the original issue (or this PR, if no issue exists) been tagged with a release in ZenHub? (user-facing changes only)
  • [na] Has a PR for user-facing changes been opened in cypress-documentation?
  • [na] Have API changes been updated in the type definitions?
  • [na] Have new configuration options been added to the cypress.schema.json?

mschile and others added 17 commits March 21, 2022 17:36
* chore: [Multi-domain] Fix Flake when subdomain loads faster than toSpecBridge Command called.

* Add Test

* simplify test

* Loading a cross domain page won't happen until the spec bridge is active (or a timeout will happen)

* Update packages/driver/src/multi-domain/domain_fn.ts
…tance (#20653)

* fix: make the primary domain communicator a singleton per cypress instance

* leverage a factory to make typescript happy with their super() constructor rules

* remove singleton instance from communicator and only bind message events once in the primary and per spec bridge. Forward all message events to the respective communicator instance, if available.

* remove data.actual reference in primary communicator onMessage as it is no longer needed
* Better timeout error handling

* quick fix, should re-visit

* cancel dangling timeouts

* re-broadcast the window load event.

* clean up code and comment more

* ignore better

* PR updates

* oops, didn't mean to enable this

* Apply suggestions from code review

Co-authored-by: Bill Glesias <bglesias@gmail.com>

* moar pr updates

* Apply suggestions from code review

Co-authored-by: Chris Breiding <chrisbreiding@users.noreply.github.com>
Co-authored-by: Bill Glesias <bglesias@gmail.com>

* Fix test

* message changes

* message update

Co-authored-by: Bill Glesias <bglesias@gmail.com>
Co-authored-by: Chris Breiding <chrisbreiding@users.noreply.github.com>
* chore: [multi-domain] fix count-logs-by-test

* add tests, fix preAttempts

* formatting

* remove redundant test
@mschile mschile requested a review from a team as a code owner March 23, 2022 14:55
@mschile mschile requested review from rockhold and removed request for a team March 23, 2022 14:55
@mschile mschile requested review from AtofStryker, chrisbreiding and mjhenkes and removed request for rockhold March 23, 2022 14:56
@cypress
Copy link

cypress bot commented Mar 23, 2022



Test summary

436 0 2 0Flakiness 0


Run details

Project cypress
Status Passed
Commit ccc836a
Started Mar 28, 2022 9:18 PM
Ended Mar 28, 2022 9:28 PM
Duration 09:27 💡
OS Linux Debian - 10.10
Browser Multiple

View run in Cypress Dashboard ➡️


This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Mar 23, 2022

Thanks for taking the time to open a PR!

Copy link
Contributor

@chrisbreiding chrisbreiding left a comment

Choose a reason for hiding this comment

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

A lot cleaner with RemoteStates extracted. Very nice!

@mschile mschile requested a review from AtofStryker March 28, 2022 14:35
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.

5 participants