Skip to content

Commit a85b64a

Browse files
committed
fix: make sure scrollTo, window, document, title, go, reload, location, hash, and url commands can communicate with the AUT
1 parent 0e8a766 commit a85b64a

File tree

5 files changed

+29
-3
lines changed

5 files changed

+29
-3
lines changed

packages/driver/src/cy/commands/actions/scroll.ts

+3
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,9 @@ export default (Commands, Cypress, cy, state) => {
325325
const subjectChain = cy.subjectChain()
326326

327327
const ensureScrollability = () => {
328+
// Make sure the scroll command can communicate with the AUT
329+
Cypress.ensure.commandCanCommunicateWithAUT(cy)
330+
328331
try {
329332
subject = cy.getSubjectFromChain(subjectChain)
330333

packages/driver/src/cy/commands/location.ts

+9
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import $errUtils from '../../cypress/error_utils'
44

55
export default (Commands, Cypress, cy) => {
66
Commands.addQuery('url', function url (options: Partial<Cypress.UrlOptions> = {}) {
7+
// Make sure the url command can communicate with the AUT.
8+
// otherwise, it yields an empty string
9+
Cypress.ensure.commandCanCommunicateWithAUT(cy)
710
this.set('timeout', options.timeout)
811

912
Cypress.log({ message: '', hidden: options.log === false, timeout: options.timeout })
@@ -16,6 +19,8 @@ export default (Commands, Cypress, cy) => {
1619
})
1720

1821
Commands.addQuery('hash', function url (options: Partial<Cypress.Loggable & Cypress.Timeoutable> = {}) {
22+
// Make sure the hash command can communicate with the AUT.
23+
Cypress.ensure.commandCanCommunicateWithAUT(cy)
1924
this.set('timeout', options.timeout)
2025

2126
Cypress.log({ message: '', hidden: options.log === false, timeout: options.timeout })
@@ -26,6 +31,10 @@ export default (Commands, Cypress, cy) => {
2631
Commands.addQuery('location', function location (key, options: Partial<Cypress.Loggable & Cypress.Timeoutable> = {}) {
2732
// normalize arguments allowing key + options to be undefined
2833
// key can represent the options
34+
35+
// Make sure the location command can communicate with the AUT.
36+
// otherwise the command just yields 'null' and the reason may be unclear to the user.
37+
Cypress.ensure.commandCanCommunicateWithAUT(cy)
2938
if (_.isObject(key)) {
3039
options = key
3140
}

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

+7
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,10 @@ export default (Commands, Cypress, cy, state, config) => {
616616
cleanup()
617617
}
618618

619+
// Make sure the reload command can communicate with the AUT.
620+
// if we failed for any other reason, we need to display the correct error to the user.
621+
Cypress.ensure.commandCanCommunicateWithAUT(cy)
622+
619623
return null
620624
})
621625
},
@@ -700,6 +704,9 @@ export default (Commands, Cypress, cy, state, config) => {
700704
cleanup()
701705
}
702706

707+
// Make sure the go command can communicate with the AUT.
708+
Cypress.ensure.commandCanCommunicateWithAUT(cy)
709+
703710
return null
704711
})
705712
}

packages/driver/src/cy/commands/window.ts

+7
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,18 @@ export default (Commands, Cypress, cy, state) => {
8989
}
9090

9191
Commands.addQuery('title', function title (options: Partial<Cypress.Loggable & Cypress.Timeoutable> = {}) {
92+
// Make sure the window command can communicate with the AUT.
93+
// otherwise, it yields an empty string
94+
Cypress.ensure.commandCanCommunicateWithAUT(cy)
9295
this.set('timeout', options.timeout)
9396
Cypress.log({ timeout: options.timeout, hidden: options.log === false })
9497

9598
return () => (state('document')?.title || '')
9699
})
97100

98101
Commands.addQuery('window', function windowFn (options: Partial<Cypress.Loggable & Cypress.Timeoutable> = {}) {
102+
// Make sure the window command can communicate with the AUT.
103+
Cypress.ensure.commandCanCommunicateWithAUT(cy)
99104
this.set('timeout', options.timeout)
100105
Cypress.log({
101106
hidden: options.log === false,
@@ -114,6 +119,8 @@ export default (Commands, Cypress, cy, state) => {
114119
})
115120

116121
Commands.addQuery('document', function documentFn (options: Partial<Cypress.Loggable & Cypress.Timeoutable> = {}) {
122+
// Make sure the document command can communicate with the AUT.
123+
Cypress.ensure.commandCanCommunicateWithAUT(cy)
117124
this.set('timeout', options.timeout)
118125
Cypress.log({
119126
hidden: options.log === false,

packages/graphql/schemas/cloud.graphql

+3-3
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ type CloudProjectNotFound {
333333
}
334334

335335
union CloudProjectResult =
336-
CloudProject
336+
| CloudProject
337337
| CloudProjectNotFound
338338
| CloudProjectUnauthorized
339339

@@ -456,7 +456,7 @@ type CloudProjectSpec implements Node {
456456
}
457457

458458
union CloudProjectSpecFlakyResult =
459-
CloudFeatureNotEnabled
459+
| CloudFeatureNotEnabled
460460
| CloudProjectSpecFlakyStatus
461461

462462
type CloudProjectSpecFlakyStatus {
@@ -500,7 +500,7 @@ type CloudProjectSpecNotFound {
500500
}
501501

502502
union CloudProjectSpecResult =
503-
CloudProjectSpec
503+
| CloudProjectSpec
504504
| CloudProjectSpecNotFound
505505
| CloudProjectUnauthorized
506506

0 commit comments

Comments
 (0)