Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
young-robot committed Sep 22, 2023
2 parents 4adb2fd + 273d8ce commit 8663014
Show file tree
Hide file tree
Showing 7 changed files with 112 additions and 20 deletions.
40 changes: 34 additions & 6 deletions .circleci/workflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,16 @@ commands:
circleci-agent step halt
fi
maybe_skip_binary_jobs:
steps:
- run:
name: Skip binary job if external PR
command: |
if [[ -z "$CIRCLE_TOKEN" ]]; then
echo "There is no CIRCLE_TOKEN set for this job. Cannot trigger binary build. Skipping job."
circleci-agent step halt
fi
restore_workspace_binaries:
steps:
- attach_workspace:
Expand Down Expand Up @@ -593,7 +603,7 @@ commands:
if [[ <<parameters.type>> == 'ct' ]]; then
# component tests are located side by side with the source codes.
# for the app component tests, ignore specs that are known to cause failures on contributor PRs (see https://discuss.circleci.com/t/how-to-exclude-certain-files-from-circleci-test-globbing/41028)
TESTFILES=$(find src -regextype posix-extended -name '*.cy.*' -not -regex '.*(FileMatch|PromoAction|SelectorPlayground|useDurationFormat|useTestingType|SpecPatterns|DebugPendingRunCounts).cy.*' | circleci tests split --total=$CIRCLE_NODE_TOTAL)
TESTFILES=$(find src -regextype posix-extended -name '*.cy.*' -not -regex '.*(FileMatch|PromoAction|SelectorPlayground|useDurationFormat|useTestingType|SpecPatterns|DebugPendingRunCounts|DebugRunStates|DebugPageHeader|DebugPendingRunSplash|DebugRunNavigation|DebugRunNavigationLimitMessage).cy.*' | circleci tests split --total=$CIRCLE_NODE_TOTAL)
else
GLOB="cypress/e2e/**/*cy.*"
TESTFILES=$(circleci tests glob "$GLOB" | circleci tests split --total=$CIRCLE_NODE_TOTAL)
Expand Down Expand Up @@ -1648,6 +1658,7 @@ jobs:
docker_layer_caching: true
resource_class: medium
steps:
- maybe_skip_binary_jobs
- run-binary-system-tests

system-tests-chrome:
Expand Down Expand Up @@ -2091,6 +2102,7 @@ jobs:
default: xlarge
resource_class: << parameters.resource_class >>
steps:
- maybe_skip_binary_jobs
- restore_cached_workspace
- check-if-binary-exists
- setup_should_persist_artifacts
Expand All @@ -2106,6 +2118,7 @@ jobs:
default: large
resource_class: << parameters.resource_class >>
steps:
- maybe_skip_binary_jobs
- restore_cached_workspace
- run:
name: Check pipeline info
Expand Down Expand Up @@ -2247,6 +2260,7 @@ jobs:
docker:
- image: cypress/base-internal:18.15.0
steps:
- maybe_skip_binary_jobs
- restore_workspace_binaries
- run: mkdir test-binary
- run:
Expand Down Expand Up @@ -2283,6 +2297,7 @@ jobs:
<<: *defaults
resource_class: small
steps:
- maybe_skip_binary_jobs
- restore_workspace_binaries
- run: mkdir <<parameters.wd>>
- run:
Expand Down Expand Up @@ -2322,6 +2337,7 @@ jobs:
<<: *defaults
resource_class: small
steps:
- maybe_skip_binary_jobs
- restore_workspace_binaries
- run: mkdir <<parameters.wd>>
- run:
Expand Down Expand Up @@ -2414,6 +2430,7 @@ jobs:
test-binary-against-kitchensink:
<<: *defaults
steps:
- maybe_skip_binary_jobs
- test-binary-against-repo:
repo: cypress-example-kitchensink
browser: electron
Expand Down Expand Up @@ -2476,6 +2493,7 @@ jobs:
test-binary-as-specific-user:
<<: *defaults
steps:
- maybe_skip_binary_jobs
- restore_workspace_binaries
# the user should be "node"
- run: whoami
Expand Down Expand Up @@ -2829,15 +2847,19 @@ linux-x64-workflow: &linux-x64-workflow
requires:
- build
- test-npm-module-on-minimum-node-version:
context: publish-binary
requires:
- get-published-artifacts
- test-types-cypress-and-jest:
context: publish-binary
requires:
- get-published-artifacts
- test-full-typescript-project:
context: publish-binary
requires:
- get-published-artifacts
- test-binary-against-kitchensink:
context: publish-binary
requires:
- get-published-artifacts
- test-npm-module-and-verify-binary:
Expand Down Expand Up @@ -2881,13 +2903,16 @@ linux-x64-workflow: &linux-x64-workflow
- test-binary-as-specific-user:
name: "test binary as a non-root user"
executor: non-root-docker-user
context: publish-binary
requires:
- get-published-artifacts
- test-binary-as-specific-user:
name: "test binary as a root user"
context: publish-binary
requires:
- get-published-artifacts
- binary-system-tests:
context: publish-binary
requires:
- get-published-artifacts
- system-tests-node-modules-install
Expand Down Expand Up @@ -3179,14 +3204,10 @@ linux-x64-contributor-workflow: &linux-x64-contributor-workflow
context: [test-runner:upload, test-runner:build-binary, publish-binary]
requires:
- contributor-pr
- wait-for-binary-publish:
type: approval
requires:
- create-and-trigger-packaging-artifacts
- get-published-artifacts:
context: [publish-binary, test-runner:commit-status-checks]
requires:
- wait-for-binary-publish
- create-and-trigger-packaging-artifacts
# various testing scenarios, like building full binary
# and testing it on a real project
- test-against-staging:
Expand All @@ -3203,15 +3224,19 @@ linux-x64-contributor-workflow: &linux-x64-contributor-workflow
requires:
- build
- test-npm-module-on-minimum-node-version:
context: publish-binary
requires:
- get-published-artifacts
- test-types-cypress-and-jest:
context: publish-binary
requires:
- get-published-artifacts
- test-full-typescript-project:
context: publish-binary
requires:
- get-published-artifacts
- test-binary-against-kitchensink:
context: publish-binary
requires:
- get-published-artifacts
- test-npm-module-and-verify-binary:
Expand Down Expand Up @@ -3255,13 +3280,16 @@ linux-x64-contributor-workflow: &linux-x64-contributor-workflow
- test-binary-as-specific-user:
name: "test binary as a non-root user"
executor: non-root-docker-user
context: publish-binary
requires:
- get-published-artifacts
- test-binary-as-specific-user:
name: "test binary as a root user"
context: publish-binary
requires:
- get-published-artifacts
- binary-system-tests:
context: publish-binary
requires:
- get-published-artifacts
- system-tests-node-modules-install
Expand Down
8 changes: 6 additions & 2 deletions cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ _Released 09/19/2023 (PENDING)_

- Introduces new layout for Runs page providing additional run information. Addresses [#27203](https://github.com/cypress-io/cypress/issues/27203).

**Bugfixes:**

- Fixed an issue where actionability checks trigger a flood of font requests. Removing the font requests has the potential to improve performance and removes clutter from Test Replay. Addressed in [#27860](https://github.com/cypress-io/cypress/pull/27860)

## 13.2.0

_Released 09/12/2023_
Expand All @@ -17,7 +21,7 @@ _Released 09/12/2023_

**Bugfixes:**

- Edge cases where `cy.intercept()` would not properly intercept and asset response bodies would not properly be captured for test replay have been addressed. Addressed in [#27771](https://github.com/cypress-io/cypress/pull/27771).
- Edge cases where `cy.intercept()` would not properly intercept and asset response bodies would not properly be captured for Test Replay have been addressed. Addressed in [#27771](https://github.com/cypress-io/cypress/pull/27771).
- Fixed an issue where `enter`, `keyup`, and `space` events were not triggering `click` events properly in some versions of Firefox. Addressed in [#27715](https://github.com/cypress-io/cypress/pull/27715).
- Fixed a regression in `13.0.0` where tests using Basic Authorization can potentially hang indefinitely on chromium browsers. Addressed in [#27781](https://github.com/cypress-io/cypress/pull/27781).
- Fixed a regression in `13.0.0` where component tests using an intercept that matches all requests can potentially hang indefinitely. Addressed in [#27788](https://github.com/cypress-io/cypress/pull/27788).
Expand All @@ -37,7 +41,7 @@ _Released 08/31/2023_
**Bugfixes:**

- Fixed a regression introduced in Cypress [13.0.0](#13-0-0) where the [Module API](https://docs.cypress.io/guides/guides/module-api), [`after:run`](https://docs.cypress.io/api/plugins/after-run-api), and [`after:spec`](https://docs.cypress.io/api/plugins/after-spec-api) results did not include the `stats.skipped` field for each run result. Fixes [#27694](https://github.com/cypress-io/cypress/issues/27694). Addressed in [#27695](https://github.com/cypress-io/cypress/pull/27695).
- Individual CDP errors that occur while capturing data for test replay will no longer prevent the entire run from being available. Addressed in [#27709](https://github.com/cypress-io/cypress/pull/27709).
- Individual CDP errors that occur while capturing data for Test Replay will no longer prevent the entire run from being available. Addressed in [#27709](https://github.com/cypress-io/cypress/pull/27709).
- Fixed an issue where the release date on the `v13` landing page was a day behind. Fixed in [#27711](https://github.com/cypress-io/cypress/pull/27711).
- Fixed an issue where fatal protocol errors would leak between specs causing all subsequent specs to fail to upload protocol information. Fixed in [#27720](https://github.com/cypress-io/cypress/pull/27720)
- Updated `plist` from `3.0.6` to `3.1.0` to address [CVE-2022-37616](https://github.com/advisories/GHSA-9pgh-qqpf-7wqj) and [CVE-2022-39353](https://github.com/advisories/GHSA-crh6-fp67-6883). Fixed in [#27710](https://github.com/cypress-io/cypress/pull/27710).
Expand Down
4 changes: 4 additions & 0 deletions packages/driver/cypress/e2e/commands/actions/click.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -1678,12 +1678,16 @@ describe('src/cy/commands/actions/click', () => {
it('can scroll to and click elements in html with scroll-behavior: smooth', () => {
cy.get('html').invoke('css', 'scrollBehavior', 'smooth')
cy.get('#table tr:first').click()
// Validate that the scrollBehavior is still smooth even after the actionability fixes we do
cy.get('html').invoke('css', 'scrollBehavior').then((scrollBehavior) => expect(scrollBehavior).to.eq('smooth'))
})

// https://github.com/cypress-io/cypress/issues/3200
it('can scroll to and click elements in ancestor element with scroll-behavior: smooth', () => {
cy.get('#dom').invoke('css', 'scrollBehavior', 'smooth')
cy.get('#table tr:first').click()
// Validate that the scrollBehavior is still smooth even after the actionability fixes we do
cy.get('#dom').invoke('css', 'scrollBehavior').then((scrollBehavior) => expect(scrollBehavior).to.eq('smooth'))
})
})
})
Expand Down
25 changes: 24 additions & 1 deletion packages/driver/cypress/e2e/dom/visibility.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe('src/cypress/dom/visibility', () => {
expect(fn()).to.be.true
})

it('returns false window and body > window height', () => {
it('returns false if window and body < window height', () => {
cy.$$('body').html('<div>foo</div>')

const win = cy.state('window')
Expand All @@ -65,6 +65,29 @@ describe('src/cypress/dom/visibility', () => {
expect(fn()).to.be.false
})

it('returns true if document element and body > window height', function () {
this.add('<div style="height: 1000px; width: 10px;" />')
const documentElement = Cypress.dom.wrap(cy.state('document').documentElement)

const fn = () => {
return dom.isScrollable(documentElement)
}

expect(fn()).to.be.true
})

it('returns false if document element and body < window height', () => {
cy.$$('body').html('<div>foo</div>')

const documentElement = Cypress.dom.wrap(cy.state('document').documentElement)

const fn = () => {
return dom.isScrollable(documentElement)
}

expect(fn()).to.be.false
})

it('returns false el is not scrollable', function () {
const noScroll = this.add(`\
<div style="height: 100px; overflow: auto;">
Expand Down
44 changes: 33 additions & 11 deletions packages/driver/src/cy/actionability.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import $utils from './../cypress/utils'
import type { ElWindowPostion, ElViewportPostion, ElementPositioning } from '../dom/coordinates'
import $elements from '../dom/elements'
import $errUtils from '../cypress/error_utils'
import { callNativeMethod, getNativeProp } from '../dom/elements/nativeProps'
const debug = debugFn('cypress:driver:actionability')

const delay = 50
Expand Down Expand Up @@ -460,24 +461,46 @@ const verify = function (cy, $el, config, options, callbacks: VerifyCallbacks) {
// make scrolling occur instantly. we do this by adding a style tag
// and then removing it after we finish scrolling
// https://github.com/cypress-io/cypress/issues/3200
const addScrollBehaviorFix = () => {
let style
const addScrollBehaviorFix = (element: JQuery<HTMLElement>) => {
const affectedParents: Map<HTMLElement, string> = new Map()

try {
const doc = $el.get(0).ownerDocument
let parent: JQuery<HTMLElement> | null = element

style = doc.createElement('style')
style.innerHTML = '* { scroll-behavior: inherit !important; }'
// there's guaranteed to be a <script> tag, so that's the safest thing
// to query for and add the style tag after
doc.querySelector('script').after(style)
do {
if ($dom.isScrollable(parent)) {
const parentElement = parent[0]
const style = getNativeProp(parentElement, 'style')
const styles = getComputedStyle(parentElement)

if (styles.scrollBehavior === 'smooth') {
affectedParents.set(parentElement, callNativeMethod(style, 'getStyleProperty', 'scroll-behavior'))
callNativeMethod(style, 'setStyleProperty', 'scroll-behavior', 'auto')
}
}

parent = $dom.getFirstScrollableParent(parent)
} while (parent)
} catch (err) {
// the above shouldn't error, but out of an abundance of caution, we
// ignore any errors since this fix isn't worth failing the test over
}

return () => {
if (style) style.remove()
for (const [parent, value] of affectedParents) {
const style = getNativeProp(parent, 'style')

if (value === '') {
if (callNativeMethod(style, 'getStyleProperty', 'length') === 1) {
callNativeMethod(parent, 'removeAttribute', 'style')
} else {
callNativeMethod(style, 'removeProperty', 'scroll-behavior')
}
} else {
callNativeMethod(style, 'setStyleProperty', 'scroll-behavior', value)
}
}
affectedParents.clear()
}
}

Expand All @@ -500,8 +523,7 @@ const verify = function (cy, $el, config, options, callbacks: VerifyCallbacks) {
if (options.scrollBehavior !== false) {
// scroll the element into view
const scrollBehavior = scrollBehaviorOptionsMap[options.scrollBehavior]

const removeScrollBehaviorFix = addScrollBehaviorFix()
const removeScrollBehaviorFix = addScrollBehaviorFix($el)

debug('scrollIntoView:', $el[0])
$el.get(0).scrollIntoView({ block: scrollBehavior })
Expand Down
6 changes: 6 additions & 0 deletions packages/driver/src/dom/elements/complexElements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,12 @@ export const isScrollable = ($el) => {
return false
}

const documentElement = $document.getDocumentFromElement(el).documentElement

if (el === documentElement) {
return checkDocumentElement($window.getWindowByElement(el), el)
}

// if we're any other element, we do some css calculations
// to see that the overflow is correct and the scroll
// area is larger than the actual height or width
Expand Down
5 changes: 5 additions & 0 deletions packages/driver/src/dom/elements/nativeProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ const nativeGetters = {
body: descriptor('Document', 'body').get,
frameElement: Object.getOwnPropertyDescriptor(window, 'frameElement')!.get,
maxLength: _getMaxLength,
style: descriptor('HTMLElement', 'style').get,
}

const nativeSetters = {
Expand All @@ -224,12 +225,16 @@ const nativeMethods = {
execCommand: window.document.execCommand,
getAttribute: window.Element.prototype.getAttribute,
setAttribute: window.Element.prototype.setAttribute,
removeAttribute: window.Element.prototype.removeAttribute,
setSelectionRange: _nativeSetSelectionRange,
modify: window.Selection.prototype.modify,
focus: _nativeFocus,
hasFocus: window.document.hasFocus,
blur: _nativeBlur,
select: _nativeSelect,
getStyleProperty: window.CSSStyleDeclaration.prototype.getPropertyValue,
setStyleProperty: window.CSSStyleDeclaration.prototype.setProperty,
removeStyleProperty: window.CSSStyleDeclaration.prototype.removeProperty,
}

export const getNativeProp = function<T, K extends keyof T> (obj: T, prop: K): T[K] {
Expand Down

0 comments on commit 8663014

Please sign in to comment.