Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove command type todos #20601

Merged
merged 37 commits into from Apr 22, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
bff7f0b
Remove @ts-ignore.
sainthkh Mar 14, 2022
93f2b2b
clock.ts
sainthkh Mar 14, 2022
a0fbd97
cookies.ts
sainthkh Mar 14, 2022
e9120ad
debugging.ts
sainthkh Mar 14, 2022
9216026
files.ts
sainthkh Mar 14, 2022
edb7d39
exec.ts
sainthkh Mar 14, 2022
0c62852
location.ts
sainthkh Mar 14, 2022
ce302e8
misc.ts
sainthkh Mar 14, 2022
585fbe8
type.ts
sainthkh Mar 14, 2022
b650488
browser.ts
sainthkh Mar 14, 2022
9801c7c
angular.ts
sainthkh Mar 14, 2022
f4adb3a
navigation.ts
sainthkh Mar 14, 2022
b17da05
screenshot.ts
sainthkh Mar 14, 2022
0dfffc6
task.ts
sainthkh Mar 14, 2022
6674167
window.ts
sainthkh Mar 14, 2022
9cf79c8
focus.ts
sainthkh Mar 15, 2022
0659e3b
scroll.ts
sainthkh Mar 15, 2022
f03249a
scroll.ts
sainthkh Mar 15, 2022
95cc205
select.ts
sainthkh Mar 15, 2022
c8face7
submit.ts
sainthkh Mar 15, 2022
021774c
focused.ts
sainthkh Mar 15, 2022
5493561
querying.ts
sainthkh Mar 15, 2022
6b8c4be
root.ts .
sainthkh Mar 15, 2022
2d4191c
fix
sainthkh Mar 15, 2022
d2b2dd8
querying.ts
sainthkh Mar 18, 2022
136d989
feedback
sainthkh Mar 18, 2022
8fb7463
fix screenshot.ts test bug.
sainthkh Mar 18, 2022
33f0885
fix _log type.
sainthkh Apr 14, 2022
ea2126b
Merge branch 'develop' into remove-command-type-todos
flotwig Apr 15, 2022
b43ca6a
Merge branch 'develop' into remove-command-type-todos
jennifer-shehane Apr 18, 2022
7fcf88a
Merge branch 'develop' into remove-command-type-todos
rachelruderman Apr 19, 2022
c8e33fd
log to _log when we're manipulating `_log`.
sainthkh Apr 20, 2022
35c9445
feedback
sainthkh Apr 20, 2022
fc8e114
Use a better type with generics.
sainthkh Apr 20, 2022
4bd4536
Correct type.
sainthkh Apr 20, 2022
01de010
Merge branch 'develop' into remove-command-type-todos
tbiethman Apr 20, 2022
cf50abb
Merge branch 'develop' into remove-command-type-todos
flotwig Apr 22, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/driver/src/cy/commands/actions/focus.ts
Expand Up @@ -4,16 +4,17 @@ import $dom from '../../../dom'
import $utils from '../../../cypress/utils'
import $errUtils from '../../../cypress/error_utils'
import $elements from '../../../dom/elements'
import type { Log } from '../../../cypress/log'

interface InternalFocusOptions extends Partial<Cypress.Loggable & Cypress.Timeoutable> {
_log?: any
_log?: Log
$el: JQuery
error: boolean
verify: boolean
}

interface InternalBlurOptions extends Partial<Cypress.BlurOptions> {
_log?: any
_log?: Log
$el: JQuery
$focused: JQuery
error: boolean
Expand Down
5 changes: 3 additions & 2 deletions packages/driver/src/cy/commands/actions/scroll.ts
Expand Up @@ -5,6 +5,7 @@ import Promise from 'bluebird'
import $dom from '../../../dom'
import $utils from '../../../cypress/utils'
import $errUtils from '../../../cypress/error_utils'
import type { Log } from '../../../cypress/log'

const findScrollableParent = ($el, win) => {
const $parent = $dom.getParent($el)
Expand All @@ -29,15 +30,15 @@ const isNaNOrInfinity = (item) => {
}

interface InternalScrollIntoViewOptions extends Partial<Cypress.ScrollToOptions> {
_log?: any
_log?: Log
$el: JQuery
$parent: any
axis: string
offset?: object
}

interface InternalScrollToOptions extends Partial<Cypress.ScrollToOptions> {
_log?: any
_log?: Log
$el: any
x: number
y: number
Expand Down
5 changes: 3 additions & 2 deletions packages/driver/src/cy/commands/actions/select.ts
Expand Up @@ -5,11 +5,12 @@ import $dom from '../../../dom'
import $utils from '../../../cypress/utils'
import $errUtils from '../../../cypress/error_utils'
import $elements from '../../../dom/elements'
import type { Log } from '../../../cypress/log'

const newLineRe = /\n/g

interface InternalSelectOptions extends Partial<Cypress.SelectOptions> {
_log?: any
_log?: Log
$el: JQuery<HTMLSelectElement>
error?: any
}
Expand Down Expand Up @@ -58,7 +59,7 @@ export default (Commands, Cypress, cy) => {
},
})

options._log.snapshot('before', { next: 'after' })
options._log!.snapshot('before', { next: 'after' })
}

let node
Expand Down
5 changes: 3 additions & 2 deletions packages/driver/src/cy/commands/actions/submit.ts
Expand Up @@ -5,9 +5,10 @@ import $dom from '../../../dom'
import $utils from '../../../cypress/utils'
import $errUtils from '../../../cypress/error_utils'
import $actionability from '../../actionability'
import type { Log } from '../../../cypress/log'

interface InternalSubmitOptions extends Partial<Cypress.Loggable & Cypress.Timeoutable>{
_log?: any
_log?: Log
$el: JQuery<HTMLFormElement>
}

Expand Down Expand Up @@ -37,7 +38,7 @@ export default (Commands, Cypress, cy) => {
},
})

options._log.snapshot('before', { next: 'after' })
options._log!.snapshot('before', { next: 'after' })
}

if (!options.$el.is('form')) {
Expand Down
8 changes: 5 additions & 3 deletions packages/driver/src/cy/commands/actions/type.ts
Expand Up @@ -8,19 +8,21 @@ import $utils from '../../../cypress/utils'
import $errUtils from '../../../cypress/error_utils'
import $actionability from '../../actionability'
import $Keyboard from '../../../cy/keyboard'
import type { Log } from '../../../cypress/log'

import debugFn from 'debug'
const debug = debugFn('cypress:driver:command:type')

interface InternalTypeOptions extends Partial<Cypress.TypeOptions> {
_log?: any
_log?: Log
$el: JQuery
ensure?: object
verify: boolean
interval?: number
}

interface InternalClearOptions extends Partial<Cypress.ClearOptions> {
_log?: any
_log?: Log
ensure?: object
}

Expand Down Expand Up @@ -118,7 +120,7 @@ export default function (Commands, Cypress, cy, state, config) {
},
})

options._log.snapshot('before', { next: 'after' })
options._log!.snapshot('before', { next: 'after' })
}

if (options.$el.length > 1) {
Expand Down
3 changes: 2 additions & 1 deletion packages/driver/src/cy/commands/angular.ts
Expand Up @@ -3,11 +3,12 @@ import $ from 'jquery'
import Promise from 'bluebird'

import $errUtils from '../../cypress/error_utils'
import type { Log } from '../../cypress/log'

const ngPrefixes = ['ng-', 'ng_', 'data-ng-', 'x-ng-']

interface InternalNgOptions extends Partial<Cypress.Loggable & Cypress.Timeoutable> {
_log?: any
_log?: Log
}

export default (Commands, Cypress, cy, state) => {
Expand Down
9 changes: 5 additions & 4 deletions packages/driver/src/cy/commands/cookies.ts
Expand Up @@ -3,6 +3,7 @@ import Promise from 'bluebird'

import $utils from '../../cypress/utils'
import $errUtils from '../../cypress/error_utils'
import type { Log } from '../../cypress/log'
import { $Location } from '../../cypress/location'

// TODO: add hostOnly to COOKIE_PROPS
Expand Down Expand Up @@ -79,25 +80,25 @@ function cookieValidatesSecurePrefix (options) {
}

interface InternalGetCookieOptions extends Partial<Cypress.Loggable & Cypress.Timeoutable> {
_log?: any
_log?: Log
cookie?: any
}

interface InternalGetCookiesOptions extends Partial<Cypress.Loggable & Cypress.Timeoutable> {
_log?: any
_log?: Log
cookies?: any
sainthkh marked this conversation as resolved.
Show resolved Hide resolved
}

interface InternalSetCookieOptions extends Partial<Cypress.SetCookieOptions> {
_log?: any
_log?: Log
name: string
cookie?: any
sainthkh marked this conversation as resolved.
Show resolved Hide resolved
}

type InternalClearCookieOptions = InternalGetCookieOptions

interface InternalClearCookiesOptions extends Partial<Cypress.Loggable & Cypress.Timeoutable> {
_log?: any
_log?: Log
cookies?: any
domain?: any
}
Expand Down
7 changes: 4 additions & 3 deletions packages/driver/src/cy/commands/debugging.ts
@@ -1,6 +1,7 @@
import _ from 'lodash'

import $utils from '../../cypress/utils'
import type { Log } from '../../cypress/log'

const resume = (state, resumeAll = true) => {
const onResume = state('onResume')
Expand Down Expand Up @@ -33,11 +34,11 @@ const getNextQueuedCommand = (state, queue) => {
}

interface InternalPauseOptions extends Partial<Cypress.Loggable> {
_log?: any
_log?: Log
}

interface InternalDebugOptions extends Partial<Cypress.Loggable> {
_log?: any
_log?: Log
}

export default (Commands, Cypress, cy, state, config) => {
Expand Down Expand Up @@ -78,7 +79,7 @@ export default (Commands, Cypress, cy, state, config) => {
state('onPaused', null)

if (options.log) {
options._log.end()
options._log!.end()
}
}

Expand Down
3 changes: 2 additions & 1 deletion packages/driver/src/cy/commands/exec.ts
Expand Up @@ -2,9 +2,10 @@ import _ from 'lodash'
import Promise from 'bluebird'

import $errUtils from '../../cypress/error_utils'
import type { Log } from '../../cypress/log'

interface InternalExecOptions extends Partial<Cypress.ExecOptions> {
_log?: any
_log?: Log
cmd?: string
}

Expand Down
5 changes: 3 additions & 2 deletions packages/driver/src/cy/commands/files.ts
Expand Up @@ -2,14 +2,15 @@ import _ from 'lodash'
import { basename } from 'path'

import $errUtils from '../../cypress/error_utils'
import type { Log } from '../../cypress/log'

interface InternalReadFileOptions extends Partial<Cypress.Loggable & Cypress.Timeoutable> {
_log?: any
_log?: Log
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
_log?: Log
_log?: Cypress.Log

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please check the comment above.

encoding: Cypress.Encodings
}

interface InternalWriteFileOptions extends Partial<Cypress.WriteFileOptions & Cypress.Timeoutable> {
_log?: any
_log?: Log
}

export default (Commands, Cypress, cy, state) => {
Expand Down
5 changes: 3 additions & 2 deletions packages/driver/src/cy/commands/location.ts
Expand Up @@ -2,14 +2,15 @@ import _ from 'lodash'
import Promise from 'bluebird'

import $errUtils from '../../cypress/error_utils'
import type { Log } from '../../cypress/log'
const { throwErrByPath } = $errUtils

interface InternalUrlOptions extends Partial<Cypress.UrlOptions> {
_log?: any
_log?: Log
}

interface InternalHashOptions extends Partial<Cypress.Loggable & Cypress.Timeoutable> {
_log?: any
_log?: Log
}

export default (Commands, Cypress, cy) => {
Expand Down
5 changes: 3 additions & 2 deletions packages/driver/src/cy/commands/misc.ts
Expand Up @@ -4,9 +4,10 @@ import Promise from 'bluebird'
import $Command from '../../cypress/command'
import $dom from '../../dom'
import $errUtils from '../../cypress/error_utils'
import type { Log } from '../../cypress/log'

interface InternalWrapOptions extends Partial<Cypress.Loggable & Cypress.Timeoutable> {
_log?: any
_log?: Log
timeout: number
}

Expand Down Expand Up @@ -70,7 +71,7 @@ export default (Commands, Cypress, cy, state) => {
})

if ($dom.isElement(arg)) {
options._log.set({ $el: arg })
options._log!.set({ $el: arg })
}
}

Expand Down
8 changes: 4 additions & 4 deletions packages/driver/src/cy/commands/navigation.ts
Expand Up @@ -5,7 +5,7 @@ import Promise from 'bluebird'

import $utils from '../../cypress/utils'
import $errUtils from '../../cypress/error_utils'
import { LogUtils } from '../../cypress/log'
import { LogUtils, Log } from '../../cypress/log'
import { bothUrlsMatchAndOneHasHash } from '../navigation'
import { $Location } from '../../cypress/location'

Expand Down Expand Up @@ -411,7 +411,7 @@ type InvalidContentTypeError = Error & {
}

interface InternalVisitOptions extends Partial<Cypress.VisitOptions> {
_log?: any
_log?: Log
}

export default (Commands, Cypress, cy, state, config) => {
Expand Down Expand Up @@ -974,13 +974,13 @@ export default (Commands, Cypress, cy, state, config) => {
}

if (options.log) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be worth changing the check at this point since we're fairly removed from the initial setting of _log.

Suggested change
if (options.log) {
if (options._log) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

log and _log can be a bit different.

  • log is a user-provided or default option.
  • _log can be undefined if some conditions are met.

I personally think changing log to _log doesn't change much in this case, but I believe it's safer to leave it as-is.

Copy link
Member

Choose a reason for hiding this comment

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

+1. Agree with @tbiethman, at this point _log is referencing the Log instance created by the command when the user options are log = true

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed log to _log when we're trying to manipulate the _log.

let message = options._log.get('message')
let message = options._log!.get('message')

if (redirects && redirects.length) {
message = [message].concat(redirects).join(' -> ')
}

options._log.set({ message })
options._log!.set({ message })
}

consoleProps['Resolved Url'] = url
Expand Down
5 changes: 3 additions & 2 deletions packages/driver/src/cy/commands/querying/focused.ts
Expand Up @@ -2,9 +2,10 @@ import _ from 'lodash'
import Promise from 'bluebird'

import $dom from '../../../dom'
import type { Log } from '../../../cypress/log'

interface InternalFocusedOptions extends Partial<Cypress.Loggable & Cypress.Timeoutable>{
_log?: any
_log?: Log
verify: boolean
}

Expand All @@ -25,7 +26,7 @@ export default (Commands, Cypress, cy, state) => {
return
}

options._log.set({
options._log!.set({
$el,
consoleProps () {
const ret = $el ? $dom.getElements($el) : '--nothing--'
Expand Down
13 changes: 7 additions & 6 deletions packages/driver/src/cy/commands/querying/querying.ts
Expand Up @@ -4,19 +4,20 @@ import Promise from 'bluebird'
import $dom from '../../../dom'
import $elements from '../../../dom/elements'
import $errUtils from '../../../cypress/error_utils'
import type { Log } from '../../../cypress/log'
import { resolveShadowDomInclusion } from '../../../cypress/shadow_dom_utils'
import { getAliasedRequests, isDynamicAliasingPossible } from '../../net-stubbing/aliasing'

interface InternalGetOptions extends Partial<Cypress.Loggable & Cypress.Timeoutable & Cypress.Withinable & Cypress.Shadow> {
_log?: any
_log?: Log
_retries?: number
filter?: any
onRetry?: Function
verify?: boolean
}

interface InternalContainsOptions extends Partial<Cypress.Loggable & Cypress.Timeoutable & Cypress.CaseMatchable & Cypress.Shadow> {
_log?: any
_log?: Log
}

export default (Commands, Cypress, cy, state) => {
Expand Down Expand Up @@ -110,7 +111,7 @@ export default (Commands, Cypress, cy, state) => {
return consoleProps
}

options._log.set(obj)
options._log!.set(obj)
}

let allParts
Expand Down Expand Up @@ -273,7 +274,7 @@ export default (Commands, Cypress, cy, state) => {
consoleProps.Yielded = $dom.getElements($el)
consoleProps.Elements = $el != null ? $el.length : undefined

options._log.set({ $el })
options._log!.set({ $el })
}

const getElements = () => {
Expand Down Expand Up @@ -305,7 +306,7 @@ export default (Commands, Cypress, cy, state) => {
return err
}

options._log.error(err)
options._log!.error(err)
}

throw err
Expand Down Expand Up @@ -466,7 +467,7 @@ export default (Commands, Cypress, cy, state) => {
consoleProps.Yielded = $dom.getElements($el)
consoleProps.Elements = $el != null ? $el.length : undefined

options._log.set({ $el })
options._log!.set({ $el })
}

// find elements by the :cy-contains psuedo selector
Expand Down