merge develop

This commit is contained in:
David Munechika
2022-03-15 10:56:04 -04:00
11 changed files with 222 additions and 28 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
{
"chrome:beta": "100.0.4896.20",
"chrome:beta": "100.0.4896.30",
"chrome:stable": "99.0.4844.51"
}
+7
View File
@@ -1,3 +1,10 @@
# [@cypress/react-v5.12.4](https://github.com/cypress-io/cypress/compare/@cypress/react-v5.12.3...@cypress/react-v5.12.4) (2022-03-03)
### Bug Fixes
* avoid nextjs unsafeCache and watchOptions ([#20440](https://github.com/cypress-io/cypress/issues/20440)) ([9f60901](https://github.com/cypress-io/cypress/commit/9f6090170b0675d25b26b98cd0f987a5e395ab78))
# [@cypress/react-v5.12.3](https://github.com/cypress-io/cypress/compare/@cypress/react-v5.12.2...@cypress/react-v5.12.3) (2022-02-10)
@@ -41,6 +41,15 @@ async function getNextWebpackConfig (config) {
checkSWC(nextWebpackConfig, config)
if (nextWebpackConfig.watchOptions && Array.isArray(nextWebpackConfig.watchOptions.ignored)) {
nextWebpackConfig.watchOptions = {
...nextWebpackConfig.watchOptions,
ignored: [...nextWebpackConfig.watchOptions.ignored.filter((pattern) => !/node_modules/.test(pattern)), '**/node_modules/!(@cypress/webpack-dev-server/dist/browser.js)**'],
}
debug('found options next.js watchOptions.ignored %O', nextWebpackConfig.watchOptions.ignored)
}
return nextWebpackConfig
}
+8
View File
@@ -1,3 +1,11 @@
# [@cypress/webpack-dev-server-v1.8.2](https://github.com/cypress-io/cypress/compare/@cypress/webpack-dev-server-v1.8.1...@cypress/webpack-dev-server-v1.8.2) (2022-03-03)
### Bug Fixes
* avoid nextjs unsafeCache and watchOptions ([#20440](https://github.com/cypress-io/cypress/issues/20440)) ([9f60901](https://github.com/cypress-io/cypress/commit/9f6090170b0675d25b26b98cd0f987a5e395ab78))
* error regression - strip ansi colors out of cy.fixture() error message ([#20335](https://github.com/cypress-io/cypress/issues/20335)) ([e0bd6ac](https://github.com/cypress-io/cypress/commit/e0bd6ac2aaf8d00b9233fffefed8f6ed2484bf45))
# [@cypress/webpack-dev-server-v1.8.1](https://github.com/cypress-io/cypress/compare/@cypress/webpack-dev-server-v1.8.0...@cypress/webpack-dev-server-v1.8.1) (2022-02-08)
@@ -96,6 +96,14 @@ export async function makeWebpackConfig (userWebpackConfig: webpack.Configuratio
})
}
if (typeof userWebpackConfig?.module?.unsafeCache === 'function') {
const originalCachePredicate = userWebpackConfig.module.unsafeCache
userWebpackConfig.module.unsafeCache = (module: any) => {
return originalCachePredicate(module) && !/[\\/]webpack-dev-server[\\/]dist[\\/]browser\.js/.test(module.resource)
}
}
const mergedConfig = merge<webpack.Configuration>(
userWebpackConfig,
makeDefaultWebpackConfig(indexHtmlFile),
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "cypress",
"version": "9.5.1",
"version": "9.5.2",
"description": "Cypress.io end to end testing tool",
"private": true,
"scripts": {
@@ -585,16 +585,16 @@ describe('src/cy/commands/actions/type - #type events', () => {
describe('triggers', () => {
const targets = [
'#target-button-tag',
'#target-input-button',
'#target-input-image',
'#target-input-reset',
'#target-input-submit',
'button-tag',
'input-button',
'input-image',
'input-reset',
'input-submit',
]
targets.forEach((target) => {
it(target, () => {
cy.get(target).focus().type('{enter}')
cy.get(`#target-${target}`).focus().type('{enter}')
cy.get('li').should('have.length', 4)
cy.get('li').eq(0).should('have.text', 'keydown')
@@ -603,17 +603,31 @@ describe('src/cy/commands/actions/type - #type events', () => {
cy.get('li').eq(3).should('have.text', 'keyup')
})
})
describe('keydown triggered on another element', () => {
targets.forEach((target) => {
it(target, () => {
cy.get('#focus-options').select(target)
cy.get('#input-text').focus().type('{enter}')
cy.get('li').should('have.length', 3)
cy.get('li').eq(0).should('have.text', 'keypress')
cy.get('li').eq(1).should('have.text', 'click')
cy.get('li').eq(2).should('have.text', 'keyup')
})
})
})
})
describe('does not trigger', () => {
const targets = [
'#target-input-checkbox',
'#target-input-radio',
'input-checkbox',
'input-radio',
]
targets.forEach((target) => {
it(target, () => {
cy.get(target).focus().type('{enter}')
cy.get(`#target-${target}`).focus().type('{enter}')
cy.get('li').should('have.length', 3)
cy.get('li').eq(0).should('have.text', 'keydown')
@@ -621,6 +635,19 @@ describe('src/cy/commands/actions/type - #type events', () => {
cy.get('li').eq(2).should('have.text', 'keyup')
})
})
describe('keydown triggered on another element', () => {
targets.forEach((target) => {
it(target, () => {
cy.get('#focus-options').select(target)
cy.get('#input-text').focus().type('{enter}')
cy.get('li').should('have.length', 2)
cy.get('li').eq(0).should('have.text', 'keypress')
cy.get('li').eq(1).should('have.text', 'keyup')
})
})
})
})
})
@@ -770,5 +797,28 @@ describe('src/cy/commands/actions/type - #type events', () => {
cy.get('#target-input-radio').should('be.checked')
})
})
describe('keydown on another element does not trigger click', () => {
const targets = [
'button-tag',
'input-button',
'input-image',
'input-reset',
'input-submit',
'input-checkbox',
'input-radio',
]
targets.forEach((target) => {
it(target, () => {
cy.get('#focus-options').select('button-tag')
cy.get('#input-text').focus().type(' ')
cy.get('li').should('have.length', 2)
cy.get('li').eq(0).should('have.text', 'keypress')
cy.get('li').eq(1).should('have.text', 'keyup')
})
})
})
})
})
@@ -6,14 +6,33 @@
</head>
<body>
<button id="reset">clear log</button>
<button id="target-button-tag">button tag</button>
<input id="target-input-button" type="button" value="input button" />
<input id="target-input-image" type="image" value="input image" />
<input id="target-input-reset" type="reset" value="input reset" />
<input id="target-input-submit" type="submit" value="input submit" />
<input id="target-input-checkbox" type="checkbox" value="input checkbox" />
<input id="target-input-radio" type="radio" value="input radio" />
<div>
<button id="reset">clear log</button>
</div>
<div>
<input id="input-text" type="text" />
<select id="focus-options">
<option value="clear">clear</option>
<option value="button-tag">button tag</option>
<option value="input-button">input button</option>
<option value="input-image">input image</option>
<option value="input-reset">input reset</option>
<option value="input-submit">input submit</option>
<option value="input-checkbox">input checkbox</option>
<option value="input-radio">input radio</option>
</select>
</div>
<div>
<button id="target-button-tag">button tag</button>
<input id="target-input-button" type="button" value="input button" />
<input id="target-input-image" type="image" value="input image" />
<input id="target-input-reset" type="reset" value="input reset" />
<input id="target-input-submit" type="submit" value="input submit" />
<input id="target-input-checkbox" type="checkbox" value="input checkbox" />
<input id="target-input-radio" type="radio" value="input radio" />
</div>
<div id="log"></div>
@@ -70,6 +89,32 @@
updateLog("keyup");
});
});
let handler = null
const focusOptions = document.getElementById("focus-options");
focusOptions.addEventListener('change', (event) => {
const val = event.target.value;
const target = document.getElementById('input-text');
if (handler) {
target.removeEventListener('keydown', handler);
}
if (val === 'clear') {
handler = null
return
}
handler = (e) => {
const focusEl = document.getElementById(`target-${val}`);
focusEl.focus()
}
target.addEventListener('keydown', handler);
})
</script>
</body>
</html>
@@ -0,0 +1,57 @@
const { create } = require('@packages/driver/src/cypress/log')
describe('src/cypress/log', function () {
context('#snapshot', function () {
beforeEach(function () {
this.cy = {
createSnapshot: cy.stub().returns({}),
}
this.state = cy.stub()
this.config = cy.stub()
this.config.withArgs('isInteractive').returns(true)
this.config.withArgs('numTestsKeptInMemory').returns(50)
this.log = create(Cypress, this.cy, this.state, this.config)
})
it('creates a snapshot and returns the log', function () {
const div = Cypress.$('<div />')
const log = this.log({ '$el': div })
const result = log.snapshot()
expect(this.cy.createSnapshot).to.be.calledWith(undefined, div)
expect(result).to.equal(log)
})
// https://github.com/cypress-io/cypress/issues/15816
it('does not add snapshot if createSnapshot returns null', function () {
this.cy.createSnapshot.returns(null)
const log = this.log()
const result = log.snapshot()
expect(result.get('snapshots')).to.have.length(0)
})
it('is no-op if not interactive', function () {
this.config.withArgs('isInteractive').returns(false)
const log = this.log()
const result = log.snapshot()
expect(this.cy.createSnapshot).not.to.be.called
expect(result).to.equal(log)
})
it('is no-op if numTestsKeptInMemory is 0', function () {
this.config.withArgs('numTestsKeptInMemory').returns(0)
const log = this.log()
const result = log.snapshot()
expect(this.cy.createSnapshot).not.to.be.called
expect(result).to.equal(log)
})
})
})
@@ -275,11 +275,6 @@ export default function (Commands, Cypress, cy, state, config) {
const isContentEditable = $elements.isContentEditable(options.$el.get(0))
const isTextarea = $elements.isTextarea(options.$el.get(0))
// click event is only fired on button, image, submit, reset elements.
// That's why we cannot use $elements.isButtonLike() here.
const type = (type) => $elements.isInputType(options.$el.get(0), type)
const sendClickEvent = type('button') || type('image') || type('submit') || type('reset')
const fireClickEvent = (el) => {
const ctor = $dom.getDocumentFromElement(el).defaultView!.PointerEvent
const event = new ctor('click')
@@ -287,6 +282,8 @@ export default function (Commands, Cypress, cy, state, config) {
el.dispatchEvent(event)
}
let keydownEvents: any[] = []
return keyboard.type({
$el: options.$el,
chars,
@@ -332,21 +329,29 @@ export default function (Commands, Cypress, cy, state, config) {
updateTable(id, key, event, value)
}
if (event.type === 'keydown') {
keydownEvents.push(event.target)
}
if (
// Firefox sends a click event when the Space key is pressed.
// We don't want send it twice.
// We don't want to send it twice.
!Cypress.isBrowser('firefox') &&
// Click event is sent after keyup event with space key.
event.type === 'keyup' && event.code === 'Space' &&
// When event is prevented, the click event should not be emitted
!event.defaultPrevented &&
// Click events should be only sent to button-like elements.
// event.target is null when used with shadow DOM.
(event.target && $elements.isButtonLike(event.target)) &&
// When a space key is pressed for input radio elements, the click event is only fired when it's not checked.
!(event.target.tagName === 'INPUT' && event.target.type === 'radio' && event.target.checked === true) &&
// When event is prevented, the click event should not be emitted
!event.defaultPrevented
// When a space key is pressed on another element, the click event should not be fired.
keydownEvents.includes(event.target)
) {
fireClickEvent(event.target)
keydownEvents = []
}
},
@@ -391,6 +396,11 @@ export default function (Commands, Cypress, cy, state, config) {
return
}
// click event is only fired on button, image, submit, reset elements.
// That's why we cannot use $elements.isButtonLike() here.
const type = (type) => $elements.isInputType(el, type)
const sendClickEvent = type('button') || type('image') || type('submit') || type('reset')
// https://github.com/cypress-io/cypress/issues/19541
// Send click event on type('{enter}')
if (sendClickEvent) {
+1 -1
View File
@@ -23,7 +23,7 @@ describe('e2e downloads', () => {
systemTests.it('allows changing the downloads folder', {
project: 'downloads',
spec: '*',
spec: 'downloads_spec.ts',
config: {
downloadsFolder: 'cypress/dls',
video: false,