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: Improve pkg/driver types part 2 #21610
Changes from all commits
b3c99ef
409a266
1c37f4d
7e17f9c
751835e
de5a348
1c31800
1f972f5
5952742
13bc680
871942a
a61c182
d16a33f
b8692fe
79dca18
37da715
0c85d52
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ import $selection from '../dom/selection' | |
import $utils from '../cypress/utils' | ||
import $window from '../dom/window' | ||
import type { Log } from '../cypress/log' | ||
import type { StateFunc } from '../cypress/state' | ||
|
||
const debug = Debug('cypress:driver:keyboard') | ||
|
||
|
@@ -23,17 +24,6 @@ export interface KeyboardModifiers { | |
shift: boolean | ||
} | ||
|
||
export interface KeyboardState { | ||
keyboardModifiers?: KeyboardModifiers | ||
} | ||
|
||
export interface ProxyState<T> { | ||
<K extends keyof T>(arg: K): T[K] | undefined | ||
<K extends keyof T>(arg: K, arg2: T[K] | null): void | ||
} | ||
|
||
export type State = ProxyState<KeyboardState> | ||
|
||
Comment on lines
-26
to
-36
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code is added before |
||
interface KeyDetailsPartial extends Partial<KeyDetails> { | ||
key: string | ||
} | ||
|
@@ -169,11 +159,11 @@ const joinKeyArrayToString = (keyArr: KeyInfo[]) => { | |
}).join('') | ||
} | ||
|
||
type modifierKeyDetails = KeyDetails & { | ||
type KeyModifiers = { | ||
key: keyof typeof keyToModifierMap | ||
} | ||
|
||
const isModifier = (details: KeyInfo): details is modifierKeyDetails => { | ||
const isModifier = (details: KeyInfo): details is KeyDetails & KeyModifiers => { | ||
return details.type === 'key' && !!keyToModifierMap[details.key] | ||
Comment on lines
-172
to
167
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} | ||
|
||
|
@@ -697,7 +687,7 @@ export interface typeOptions { | |
} | ||
|
||
export class Keyboard { | ||
constructor (private state: State) {} | ||
constructor (private state: StateFunc) {} | ||
|
||
type (opts: typeOptions) { | ||
const options = _.defaults({}, opts, { | ||
|
@@ -1108,7 +1098,7 @@ export class Keyboard { | |
return details | ||
} | ||
|
||
flagModifier (key: modifierKeyDetails, setTo = true) { | ||
flagModifier (key: KeyModifiers, setTo = true) { | ||
debug('handleModifier', key.key) | ||
const modifier = keyToModifierMap[key.key] | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
import _ from 'lodash' | ||
// @ts-ignore | ||
import { registerFetch } from 'unfetch' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
import $selection from '../dom/selection' | ||
|
||
export const create = (state, config, focused, snapshots) => { | ||
import type { ICypress } from '../cypress' | ||
import type { StateFunc } from '../cypress/state' | ||
import type { IFocused } from './focused' | ||
import type { ISnapshots } from './snapshots' | ||
|
||
export const create = (state: StateFunc, config: ICypress['config'], focused: IFocused, snapshots: ISnapshots) => { | ||
const wrapNativeMethods = function (contentWindow) { | ||
try { | ||
// return null to trick contentWindow into thinking | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice to clean this up.