Commit Graph

29 Commits

Author SHA1 Message Date
Mike Plummer
efc195896a fix: Improve error handling around calls to this.next in middleware (#25702) 2023-02-08 10:17:28 -06:00
Bill Glesias
d470f59ea2 feat: experimental skip domain injection (#25307)
* feat: set up experimentalUseDefaultDocumentDomain to disallow document.domain overwritting

* use default domain around experimentalUseDefaultDocumentDomain in main iframe and spec bridge iframes. Also adapt CORS policy to use same-origin if experimental flag is set

* run ci

* fix: add insertion of experimental flag where is was needed/missing

* chore: add system test to exercise experimental flag for expected behavior

* fix: fix issues with template updates to conform to squirrelly v7

* fix: update config tests to include new experimental flag

* run ci

* fix: trailing whitespace [run ci]

* chore: update snapshot

* run ci

* fix: update proxy unit tests to account for experimentalUseDefaultDocumentDomain

* run ci

* fix: Allow component tests with special characters in filepath (#25299)

feat: cut over experimental flag to take list of known problematic domains via string/glob pattern

run ci

chore: update system test and fix broken config

* fix: fix server unit and integration tests. integration tests should no longer use google to test against injection as we do not inject document.domain on google domains

* run ci

* run ci

* fix: server integration tests where google documents are expected to receive document.domain injection. Kept test same by changing URL

* run ci

* fix: update server test with mssing unupdated assertions

* run ci

* fix: turn off experimental flag by default while recommending sane defaults to users to configure

* run ci

* chore: fix typings [run ci]

* run ci

* chore: make experiment an e2e option only

* run ci

* chore: address comments in code review

* chore: rename experimentalUseDefaultDocumentDomain to experimentalSkipDomainInjection

* fix regression in shouldInjectionDocumentDomain utility function and add unit tests

* run ci

* chore: rename documentSuperDomainIfExists to superDomain [run ci]

* chore: address comments from code review

* chore: just pass opts through to policyForDomain

* run ci

Co-authored-by: Mike Plummer <mike-plummer@users.noreply.github.com>
2023-01-09 10:00:05 -05:00
Zach Bloomquist
e02f6bf905 feat: add resourceType support to cy.intercept() on req/routeMatcher (#25075)
Co-authored-by: Bill Glesias <bglesias@gmail.com>
2022-12-14 17:40:53 +00:00
Matt Henkes
23299acc88 fix: Disallow same-superdomain-origin cy.origin blocks (#24569)
* fix: throw error if the cy.origin origin is in the same superDomainOrigin as top.

* testing test tweaks

* 'fix' cypress in cypress tests

* Inject cross origin in google subdomains when not same-origin

* style tweaks

* Ensure strict same-origin check works for google.

* test fixes

* we don't need the location object when we just want the href.

* what is in a name?

* Address PR Comments
2022-11-09 08:29:27 -06:00
Bill Glesias
695dd275bc feat: same origin spec bridges (#23885)
* chore: enforce strict origin spec bridges

chore: refactor spec bridges to strictly enforce same origin

fix: wrap fullCrossOrigin injection around feature flag inside buffered response

* fix: do NOT set the initial cypress cookie inside the spec bridge as it is sending unecessary cookies

* chore: simplify the finding cypress in the injection code

* chore: change order in which callback fn is declared

* chore: add spec bridge performance issue to validation tests
2022-10-04 18:26:04 -04:00
Bill Glesias
18321f80dd chore: refactor originPolicy to use superDomainOrigin nomenclat… (#23879)
* chore: refactor originPolicy to use superDomainOriginPolicy nomenclature and add sameSite/superDomainOrigin policy functions and make originMatch functions match fully same origin policy including sub domains

* chore: change doesAutMatchTopSuperOriginPolicy to doesAUTMatchTopSuperDomainOriginPolicy

* chore: rename originPolicy references to just be origin. Rename superDomainOriginPolicy to superDomainOrigin

* fix: remove duplicate origin keys and add check for remote.origin to return null

* chore: further rename variables to fit origin paradigm

* chore: remove latestActiveSuperDomainOrigin as it is no longer used

* fix: key order in consoleProps yielded test

* remove isAnticipatingCrossOriginResponse as it is no longer available

* chore: update documentation to urlMatchesSameSiteProps to show why the strictPortMatch is an option

* chore: refactor cors package to use a single parse function and update unit tests

* chore: refactor getOrigin to use url origin

* chore: update same-site documentation to now be dependent on cookies

* chore: update same-site policy to be schemeful-same-site policy as we consider protocol mismatches to be not same-site
2022-09-21 18:27:17 -04:00
Matt Henkes
6ee305ba41 feat: Allow cy.visit to visit cross origin sites. (#23297)
* Initial async changes

* Small fixes and test updates.

* updating tests

* Fixes for cookie login tests

* remove the onlys

* Most tests passing

* Fix driver tests?

* fix firefox test?

* fix unit tests

* fix tests??

* a better check

* fix integration tests

* minor cleanup

* Comment out tyler fix for 10.0 origin issue

* also fix integration tests

* remove fixmes

* Adding Retries for cookie actions. May break other error tests.

* Address (some) PR comments

* update to warn about cross origin command AUT in assertions

* Fix type errors

* Move document.cookie patch to injection

* Adding iframe patching.

* forward errors prior to attaching

* Add error message when using visit to visit a cross origin site with the onLoad or onBeforeLoad options.

* Attempt to fix test errors.

* more fixes, but not all

* use the origin policy

* Fix types

* more fixes

* consider chromeWebSecurity when checking if you can communicate with the AUT

* firefox

* prevent hangs if before unload happens after on load.

* Fix some ToDos

* code cleanup

* remove quotes

* Code review changes

* more cr changes

* fix tests possibly

* for realz this time

* roll back change

* Fix some flake

* Fix flakey xhr test hopefully.

* oops, forgot communicator changes. need those.

* modify error message to not lose the original error

* read config right derp

* simpler check

* no unused vars

* don't put config on window

* Make isRunnerAbleToCommunicateWithTheAUT a util function instead of attaching it to cypress.

* fix a race condition maybe

* clear document when window is cross origin... we'll see if this breaks anything.

* Retry if querying against the wrong AUT

* use timeout

* Don't print the retrying string unless you're retrying due to command aut origin mismatch

* try handling undefined document

* Code review updates. What could go wrong??

* Apply suggestions from code review

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

* minor fixes

* try aut location and move the async state collection.

* fix flake around the loading message, probably

* Fix system tests and some flake around redirect counts.

* Improve error handler prior to attaching.

* Code review suggestions

* use a generated ID when promisifying post message

* clean up promise helper

* skip xhr test until issue is resolved.

* Apply suggestions from code review

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

* use state directly

* Apply suggestions from code review

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

* Update packages/driver/src/cypress/error_messages.ts

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

Co-authored-by: Bill Glesias <bglesias@gmail.com>
Co-authored-by: Chris Breiding <chrisbreiding@users.noreply.github.com>
2022-09-15 12:28:27 -05:00
Emily Rohrbough
2324d703c2 chore(server): remove redundant supportFile check (#23543)
Co-authored-by: Chris Breiding <chrisbreiding@users.noreply.github.com>
2022-08-29 10:21:58 -05:00
Eiríkur Fannar Torfason
d65e2d2fab fix: Infinite recursion when identical intercept routes exist (#22940)
* Minimal fix, hacky repro

* Convert getRouteForRequest into a generator function

* Create separate test for reproducing the original issue

* Remove TODO, check .done property instead of .value

* Improve readability

Co-authored-by: Eiríkur Fannar Torfason <eirikur.torfason@gmail.com>
Co-authored-by: Tyler Biethman <tbiethman@users.noreply.github.com>
2022-08-05 12:59:15 -05:00
Bill Glesias
bbd9e7f1b2 Merge branch 'develop' into md-10.0-merge 2022-04-29 10:39:54 -04:00
Chris Breiding
3e6d6bfe15 chore: Updates based on PR feedback (#21137)
* 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 35ccc28b6f.

* 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>
2022-04-22 14:58:02 -05:00
Matt Schile
d7ce86541d chore: (cross-origin) add support for redirecting back to primary (#21144) 2022-04-20 23:03:08 -06:00
Matt Henkes
25af92134a chore: [Multi-domain] Rename isMultiDomain for the driver and the server (#20947)
* chore: [Multi-domain] Rename isMultiDomain for the driver and the server

* A couple more changes

* Update packages/driver/src/cy/commands/navigation.ts

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

Co-authored-by: Matt Schile <mschile@gmail.com>
2022-04-07 09:22:49 -05:00
Matt Schile
fedb65c97c chore: (multi-domain) support multiple remote states (#20752) 2022-03-28 15:26:51 -06:00
Ryan Manuel
111949a869 feat: add subscription for specs changing (#20657)
Co-authored-by: Barthélémy Ledoux <bart@cypress.io>
Co-authored-by: Ryan Manuel <ryanm@cypress.io>
Co-authored-by: Jess <jess@jessicasachs.io>
Co-authored-by: Lachlan Miller <lachlan.miller.1990@outlook.com>
Co-authored-by: ElevateBart <ledouxb@gmail.com>
Co-authored-by: Emily Rohrbough  <emilyrohrbough@users.noreply.github.com>
Co-authored-by: Tim Griesser <tgriesser10@gmail.com>
Co-authored-by: Emily Rohrbough <emilyrohrbough@users.noreply.github.com>
Co-authored-by: David Munechika <david.munechika@gatech.edu>
Co-authored-by: BlueWinds <blue@everblue.info>
2022-03-22 11:53:00 -05:00
Tim Griesser
e7efc10aed feat: Add initial structure to support GraphQL subscriptions (#20558)
* feat: rename __socket.io -> __socket, add __socket-graphql for graphql-ws

* fix: remove currentTestingType from Query type

* feat: add subscription to refresh when auth state changes

* Update packages/frontend-shared/src/gql-components/HeaderBarContent.vue

* PR review updates, add docs, tests for authChange subscription

* remove login/logout toApp/toLaunchpad calls

* remove login/logout/devChange toApp/toLaunchpad calls

* fix, getCtx lazily to fix proxy performance spec

* Fix, thanks @JessicaSachs

* test fixes, remove flash of missing content in wizard

Co-authored-by: Ryan Manuel <ryanm@cypress.io>
Co-authored-by: Jess <jess@jessicasachs.io>
Co-authored-by: Lachlan Miller <lachlan.miller.1990@outlook.com>
2022-03-14 10:03:48 -04:00
Matt Schile
74dea8921e feat: (multi-domain) adding support for cy.visit in multi-domain (#20467) 2022-03-08 13:50:39 -07:00
Brian Mann
923ab0a9ba export additional properties on error, update refs, fix tests 2022-02-15 02:03:14 -05:00
Brian Mann
29841f32b9 feat: redesign server errors (#20072)
* chore: rename errors.js -> errors.ts

* refactor: type safety on errors

* refactor: add err_template for consistent error formatting

* fix a few system tests

* fix tests; update snapshots

* Fix types

* normalize snapshot - remove chalk ansi colors

* more unit test fixes

* more system test fixes

* circleci build

* backtick always in stdout, fix error formatting and failing snapshots

* refactor: create @packages/errors

* fix import

* fix import

* fixing build / tests

* remove extraneous file

* move warnIfExplicitCiBuildId

* fix build / tests

* Fix

* error, type fixes, documentation, standardize child process error serialization

* fix import

* build errors on install

* wrote specs generating visual images of all errors

* remove unused dep

* sanitize stack traces

* add image diffing

- if base images don't exist, create them
- if base images don't match and local, overwrite them, if in CI throw
- if base images are stale and local, delete them, if in CI throw

* remove Courier New + MesloLGS NF font

* type fixes, remove Bluebird, general cleanup

* TS Cleanup

* skip typecheck on tests for now

* yarn.lock

* fix @types/chai version

* fix yarn.lock

* Different version of mocha types so it isnt patched

* errors spec snapshot

* CI fix

* fixes

* store snapshot images in circle artifacts

* dont change artifact destination prefix

* use Courier Prime

* antialias the text

* decrease pixelmatch threshold, fail in CI only when changed pixels > 100

* increase timeout

* overflow: hidden, remove new Promise, add debug logging

Co-Authored-By: Tim Griesser <tgriesser@gmail.com>

* run unit tests w/ concurrency=1

* unique window per file

* disable app hardware acceleration + use in process gpu + single process

* do not do image diffing

- conditionally convert html to images
- store html snapshots
- do not store images in git

* store snapshot html

* Merge branch 'tgriesser/chore/refactor-errors' of https://github.com/cypress-io/cypress into tgriesser/chore/refactor-errors

* remove concurrency

* fix assertion

* fixing ci

* Link in readme

* pass the browsers to listItems

* fix: build @packages/errors in CI, defer import to prevent errors locally

* Merge branch 'develop' into tgriesser/chore/refactor-errors

* develop:
  chore: fix cypress npm package artifact upload path (#20023)
  chore(driver): move cy.within logic into it's own file (#20036)
  chore: update automerge workflows (#19982)
  fix(selectFile): use target window's File/DataTransfer classes (#20003)
  chore: Update Chrome (stable) to 98.0.4758.80 and Chrome (beta) to 98.0.4758.80 (#19995)
  fix: Adjust ffmpeg CLI args for performance (#19983)
  build: allow unified to run cypress on Apple Silicon (arm64) (backport #19067 to 9.x) (#19968)

* fix run-if-ci.sh

* remove dead code

* Mark the .html files as generated in gitattributes

* fix running single error case, slice out more of the brittle stack

* remove additional brittle stack line

* firefox web security error

* nest inside of describe

* reformat and redesign errors

* more error cleanup and standardization

* additional formatting of errors, code cleanup, refactoring

* update ansi colors to match terminal colors

* cleanup remaining loose ends, update several errors, compact excess formatters

* fix types

* additional formatting, remove TODO's, ensure no [object Object] in output

* add test for 412 server response on invalid schema

* update unknown dashboard error on creating run

* use fs.access instead of fs.stat for perf

* added PLUGINS_FILE_NOT_FOUND error

- separated out from PLUGINS_FILE_ERROR
- add system tests for both cases
- update snapshots
- remove stack trace from PLUGINS_FILE_NOT_FOUND fka PLUGINS_FILE_ERROR

* add plugins system test around plugins synchronously throwing on require

* remove forcing process.cwd() to be packages/server, update affected code

- this was a long needed hangover from very old code that was doing unnecessary things due to respawning electron from node and handling various entrypoints into booting cypress
- this also makes the root yarn dev and dev-debug work correctly because options.cwd is set correctly now

* perf: lazy load chalk

* remove excessive line since the file exists but is invalid

* fix types

* add system test when plugins function throws a synchronous error

* create new PLUGINS_INVALID_EVENT_ERROR, wire it up correctly for error template use

- properly pass error instance from child to ensure proper user stack frames
- move error display code into the right place

* only show a single stack trace, either originalError or internal cypressError

* push error html snapshots

* fix tests, types

* fix test

* fix failing tests

* fix tests

* fixes lots of broken tests

* more test fixes

* fixes more tests

* fix type checking

* wip: consistent handling of interpolated values

* feat: fixing up errors, added simple error comparison tool

* wrapping up error formatting

* Fixes for unit tests

* fix PLUGINS_VALIDATION_ERROR

* fix fs.readdir bug, show rows even if there's only markdown formatting [SKIP CI]

* when in base-list, show full width of errors

* Fix type errors

* added searching and filtering for files based on error name

* fix: system tests

* updated NO_SPECS_FOUND error to properly join searched folder + pattern

- join patterns off of process.cwd, not projectRoot
- highlight original specPattern in yellow, baseDir in blue
- add tests

* fixes failing tests

* fix test

* preserve original spec pattern, display relative to projectRoot for terminal banner

* make the nodeVersion path display in gray, not white

* fix tests, pass right variables

* fix chrome:canary snapshots

* update snapshots

* update snapshot

* strip newlines caused by "Still waiting to connect to {browser}..."

* don't remove the snapshotHtmlFolder in CI, add additional verification snapshots match to error keys symmetrically

* update snapshot

* update snapshot

* update snapshot

* update snapshot

* update snapshot

* update snapshot

* update gitignore

* fix snapshot

* update snapshot html

* update logic for parsing the resolve pattern matching, add tests

* update snapshots

* update snapshot

* update snapshot

* update snapshot

* fix failing test

* fix: error_message_spec

* fix snapshot

* run each variant through an it(...) so multiple failures are received

* add newlines to multiline formatters, add fmt.stringify, allow format overrides

* stringify invalid return values from plugins

* move config validation errors into packages/errors, properly highlight and stringify values

* add component testing yarn commands

* fix the arrow not showing on details

* fix typescript error

* fixed lots of poorly written tests that weren't actually testing anything. created settings validation error when given a string validation result.

* fixes tests

* fixes tests, adds new error template for validating within an array list (for browser validation)

* remove dupe line

* fix copy for consistency, update snapshots

* remove redundant errors, standardize formatting and phrasing

* more formatting

* remove excess snapshots

* prune out excessive error snapshot html files when not in CI

* add missing tests, add case for when config validation fails without a fileType

* fixes test

* update snapshot

* update snapshot

* update snapshot

* sort uniqErrors + errorKeys prior to assertion - assert one by one

* add system test for binding to an event with the wrong handler

* fixes tests

* set more descriptive errors when setting invalid plugin events, or during plugin event validation

* remove duplicate PLUGINS_EVENT_ERROR, collapse into existing error

* use the same multiline formatting as @packages/errors

* standardize verbiage and highlighting for consistency

* fix incorrect error path

* fixes tests, standardized and condensed more language

* Update packages/errors/src/errors.ts

Co-authored-by: Ryan Manuel <ryanm@cypress.io>

* Update guides/error-handling.md

Co-authored-by: Ryan Manuel <ryanm@cypress.io>

* Update guides/error-handling.md

Co-authored-by: Ryan Manuel <ryanm@cypress.io>

* added some final todo's

* fix types

Co-authored-by: Tim Griesser <tgriesser10@gmail.com>
Co-authored-by: Tim Griesser <tgriesser@gmail.com>
Co-authored-by: Ryan Manuel <ryanm@cypress.io>
2022-02-11 02:06:07 -05:00
Lachlan Miller
ab401ecd35 chore: use import type syntax (#17864)
* chore: use import type across repo

* chore: use import type across repo

* chore: use import type across repo

* chore: use import type across repo

* update exports

* update test

* update import type

* update types

* use import type in driver

* correctly export function

* revert test

* remove unrelated code

* revert code

* improve type imports

* override for reporter
2021-08-25 09:11:56 +10:00
Lachlan Miller
257ff95dcb chore: change ct -> component, projectType -> testingType everywhere for consistency (#17461)
Co-authored-by: Barthélémy Ledoux <bart@cypress.io>
2021-07-26 11:11:56 -05:00
Lachlan Miller
b3dd061c52 chore(server): remove need to pass project object to Server#open (#17435)
* only pass necessary values to createRoutes

* simplify object passed to createRoutes

* fix tests

* update imports

* use correct types

* types

* remove unused method
2021-07-26 11:20:28 +10:00
Lachlan Miller
b945b8197e chore(server): reduce coupling between methods to instantiate a project (#17200)
* wip

* wip: use async/await

* slowly refactor

* slowly refactor

* use typescript

* use async/await

* update spec

* do not use tap because bluebird sucks

* refactor

* update

* remove bluebird

* update

* remove then

* change to async/await to make it easier to reason about

* remove more bluebird

* no more bluebird

* remov ts ignore

* do not tap

* refactor

* simplify cfg

* move static methods to separate file

* update snapshot

* comment out test

* simplifying options merging

* update tests

* change order of options

* move code out of project-base

* update tests

* update tests

* type reporter

* simplify onWatchSettings function

* sep starting websockets and watching settings. reduce need to pass large cfg object

* move util functions out of project class

* move tests to new file

* update test

* move code around

* update tests

* remove need to pass options to getConfig

* fix tests

* separate get and init config

* set browser warnings in initializeConfig

* move Ct specific concerns to same function

* do not pass config to initializeSpecStore

* remove onOpen function

* improve types

* update typing errors

* update types

* types

* fix types

* update tests

* update tests

* fix tests

* update tests

* comment back in test

* update methods

* update types

* add defensive code against config.clientRoute

* do not use async

* update tests

* use same baseUrl for proxy regardless

* remove comment

* revert change to baseUrl
2021-07-13 11:32:59 +10:00
Lachlan Miller
8e11b2d3b2 chore(server,server-ct): share initPlugins and spec watcher via Server Base class #16974 (#16981)
* move specs store to server

* customize spec directory in store

* share plugins via project base

* shared updated config

* share spec finding logic

* fix test

* share spec store code

* remove comment

* try fixing test

* move code around

* move more code

* share sendSpecList

* comment out line

* comments

* logs

* stub chokidar

* remove stub

* move spec watcher to later in the lifecycle

* refactor watcher

* stub out chikidar

* remove old code

* refactor

* update server-ct

* fix implementation

* fix implementation

* fix test

* update types

* add back check for config

* add comment

* make server base abstract

* fix type

* export interface

* move routes to TS

* update types

* types

* fix types

* correctly pass specs store in test

Co-authored-by: Barthélémy Ledoux <bart@cypress.io>
2021-06-23 10:35:12 +10:00
Zach Bloomquist
66303f6331 chore: correlate proxied HTTP requests with browser pre-request data (#16835) 2021-06-09 18:39:51 +00:00
Barthélémy Ledoux
6c12a6c7b7 fix: run-ct does not hang on windows anymore (#16022) 2021-04-16 10:34:14 -05:00
vodlogic
b18c1d07e7 feat: Support application/xhtml content type of cy.visit() (#15741) 2021-04-01 15:38:55 +00:00
Lachlan Miller
2d182902ca chore: update files based on TR review 2021-02-08 16:49:52 +10:00
Brian Mann
af26fbebe6 feat: component testing (#14479)
Co-authored-by: Jessica Sachs <jess@jessicasachs.io>
Co-authored-by: Barthélémy Ledoux <bart@cypress.io>
Co-authored-by: Lachlan Miller <lachlan.miller.1990@outlook.com>
Co-authored-by: Zach Bloomquist <github@chary.us>
Co-authored-by: Dmitriy Kovalenko <dmtr.kovalenko@outlook.com>
Co-authored-by: ElevateBart <ledouxb@gmail.com>
Co-authored-by: Ben Kucera <14625260+Bkucera@users.noreply.github.com>
2021-02-04 15:45:16 -05:00