mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
chore: make expect timeout field required in the protocol (#33309)
This commit is contained in:
parent
4facda8685
commit
c66af9c525
@ -21,7 +21,7 @@ import * as util from 'util';
|
|||||||
import { asLocator, isString, monotonicTime } from '../utils';
|
import { asLocator, isString, monotonicTime } from '../utils';
|
||||||
import { ElementHandle } from './elementHandle';
|
import { ElementHandle } from './elementHandle';
|
||||||
import type { Frame } from './frame';
|
import type { Frame } from './frame';
|
||||||
import type { FilePayload, FrameExpectOptions, Rect, SelectOption, SelectOptionOptions, TimeoutOptions } from './types';
|
import type { FilePayload, FrameExpectParams, Rect, SelectOption, SelectOptionOptions, TimeoutOptions } from './types';
|
||||||
import { parseResult, serializeArgument } from './jsHandle';
|
import { parseResult, serializeArgument } from './jsHandle';
|
||||||
import { escapeForTextSelector } from '../utils/isomorphic/stringUtils';
|
import { escapeForTextSelector } from '../utils/isomorphic/stringUtils';
|
||||||
import type { ByRoleOptions } from '../utils/isomorphic/locatorUtils';
|
import type { ByRoleOptions } from '../utils/isomorphic/locatorUtils';
|
||||||
@ -354,7 +354,7 @@ export class Locator implements api.Locator {
|
|||||||
await this._frame._channel.waitForSelector({ selector: this._selector, strict: true, omitReturnValue: true, ...options });
|
await this._frame._channel.waitForSelector({ selector: this._selector, strict: true, omitReturnValue: true, ...options });
|
||||||
}
|
}
|
||||||
|
|
||||||
async _expect(expression: string, options: Omit<FrameExpectOptions, 'expectedValue'> & { expectedValue?: any }): Promise<{ matches: boolean, received?: any, log?: string[], timedOut?: boolean }> {
|
async _expect(expression: string, options: FrameExpectParams): Promise<{ matches: boolean, received?: any, log?: string[], timedOut?: boolean }> {
|
||||||
const params: channels.FrameExpectParams = { selector: this._selector, expression, ...options, isNot: !!options.isNot };
|
const params: channels.FrameExpectParams = { selector: this._selector, expression, ...options, isNot: !!options.isNot };
|
||||||
params.expectedValue = serializeArgument(options.expectedValue);
|
params.expectedValue = serializeArgument(options.expectedValue);
|
||||||
const result = (await this._frame._channel.expect(params));
|
const result = (await this._frame._channel.expect(params));
|
||||||
|
@ -154,4 +154,4 @@ export type SelectorEngine = {
|
|||||||
export type RemoteAddr = channels.RemoteAddr;
|
export type RemoteAddr = channels.RemoteAddr;
|
||||||
export type SecurityDetails = channels.SecurityDetails;
|
export type SecurityDetails = channels.SecurityDetails;
|
||||||
|
|
||||||
export type FrameExpectOptions = channels.FrameExpectOptions & { isNot?: boolean };
|
export type FrameExpectParams = Omit<channels.FrameExpectParams, 'selector'|'expression'|'expectedValue'> & { expectedValue?: any };
|
||||||
|
@ -1770,7 +1770,7 @@ scheme.FrameExpectParams = tObject({
|
|||||||
expectedValue: tOptional(tType('SerializedArgument')),
|
expectedValue: tOptional(tType('SerializedArgument')),
|
||||||
useInnerText: tOptional(tBoolean),
|
useInnerText: tOptional(tBoolean),
|
||||||
isNot: tBoolean,
|
isNot: tBoolean,
|
||||||
timeout: tOptional(tNumber),
|
timeout: tNumber,
|
||||||
});
|
});
|
||||||
scheme.FrameExpectResult = tObject({
|
scheme.FrameExpectResult = tObject({
|
||||||
matches: tBoolean,
|
matches: tBoolean,
|
||||||
|
@ -22,6 +22,8 @@ export function buildFullSelector(framePath: string[], selector: string) {
|
|||||||
return [...framePath, selector].join(' >> internal:control=enter-frame >> ');
|
return [...framePath, selector].join(' >> internal:control=enter-frame >> ');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const kDefaultTimeout = 5_000;
|
||||||
|
|
||||||
export function traceParamsForAction(actionInContext: recorderActions.ActionInContext): { method: string, params: any } {
|
export function traceParamsForAction(actionInContext: recorderActions.ActionInContext): { method: string, params: any } {
|
||||||
const { action } = actionInContext;
|
const { action } = actionInContext;
|
||||||
|
|
||||||
@ -101,6 +103,7 @@ export function traceParamsForAction(actionInContext: recorderActions.ActionInCo
|
|||||||
selector: action.selector,
|
selector: action.selector,
|
||||||
expression: 'to.be.checked',
|
expression: 'to.be.checked',
|
||||||
isNot: !action.checked,
|
isNot: !action.checked,
|
||||||
|
timeout: kDefaultTimeout,
|
||||||
};
|
};
|
||||||
return { method: 'expect', params };
|
return { method: 'expect', params };
|
||||||
}
|
}
|
||||||
@ -110,6 +113,7 @@ export function traceParamsForAction(actionInContext: recorderActions.ActionInCo
|
|||||||
expression: 'to.have.text',
|
expression: 'to.have.text',
|
||||||
expectedText: [],
|
expectedText: [],
|
||||||
isNot: false,
|
isNot: false,
|
||||||
|
timeout: kDefaultTimeout,
|
||||||
};
|
};
|
||||||
return { method: 'expect', params };
|
return { method: 'expect', params };
|
||||||
}
|
}
|
||||||
@ -119,6 +123,7 @@ export function traceParamsForAction(actionInContext: recorderActions.ActionInCo
|
|||||||
expression: 'to.have.value',
|
expression: 'to.have.value',
|
||||||
expectedValue: undefined,
|
expectedValue: undefined,
|
||||||
isNot: false,
|
isNot: false,
|
||||||
|
timeout: kDefaultTimeout,
|
||||||
};
|
};
|
||||||
return { method: 'expect', params };
|
return { method: 'expect', params };
|
||||||
}
|
}
|
||||||
@ -127,6 +132,7 @@ export function traceParamsForAction(actionInContext: recorderActions.ActionInCo
|
|||||||
selector,
|
selector,
|
||||||
expression: 'to.be.visible',
|
expression: 'to.be.visible',
|
||||||
isNot: false,
|
isNot: false,
|
||||||
|
timeout: kDefaultTimeout,
|
||||||
};
|
};
|
||||||
return { method: 'expect', params };
|
return { method: 'expect', params };
|
||||||
}
|
}
|
||||||
@ -136,6 +142,7 @@ export function traceParamsForAction(actionInContext: recorderActions.ActionInCo
|
|||||||
expression: 'to.match.snapshot',
|
expression: 'to.match.snapshot',
|
||||||
expectedText: [],
|
expectedText: [],
|
||||||
isNot: false,
|
isNot: false,
|
||||||
|
timeout: kDefaultTimeout,
|
||||||
};
|
};
|
||||||
return { method: 'expect', params };
|
return { method: 'expect', params };
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import type { Locator, Page, APIResponse } from 'playwright-core';
|
import type { Locator, Page, APIResponse } from 'playwright-core';
|
||||||
import type { FrameExpectOptions } from 'playwright-core/lib/client/types';
|
import type { FrameExpectParams } from 'playwright-core/lib/client/types';
|
||||||
import { colors } from 'playwright-core/lib/utilsBundle';
|
import { colors } from 'playwright-core/lib/utilsBundle';
|
||||||
import { expectTypes, callLogText } from '../util';
|
import { expectTypes, callLogText } from '../util';
|
||||||
import { toBeTruthy } from './toBeTruthy';
|
import { toBeTruthy } from './toBeTruthy';
|
||||||
@ -28,7 +28,7 @@ import type { ExpectMatcherState } from '../../types/test';
|
|||||||
import { takeFirst } from '../common/config';
|
import { takeFirst } from '../common/config';
|
||||||
|
|
||||||
export interface LocatorEx extends Locator {
|
export interface LocatorEx extends Locator {
|
||||||
_expect(expression: string, options: Omit<FrameExpectOptions, 'expectedValue'> & { expectedValue?: any }): Promise<{ matches: boolean, received?: any, log?: string[], timedOut?: boolean }>;
|
_expect(expression: string, options: FrameExpectParams): Promise<{ matches: boolean, received?: any, log?: string[], timedOut?: boolean }>;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface APIResponseEx extends APIResponse {
|
interface APIResponseEx extends APIResponse {
|
||||||
|
@ -3162,7 +3162,7 @@ export type FrameExpectParams = {
|
|||||||
expectedValue?: SerializedArgument,
|
expectedValue?: SerializedArgument,
|
||||||
useInnerText?: boolean,
|
useInnerText?: boolean,
|
||||||
isNot: boolean,
|
isNot: boolean,
|
||||||
timeout?: number,
|
timeout: number,
|
||||||
};
|
};
|
||||||
export type FrameExpectOptions = {
|
export type FrameExpectOptions = {
|
||||||
expressionArg?: any,
|
expressionArg?: any,
|
||||||
@ -3170,7 +3170,6 @@ export type FrameExpectOptions = {
|
|||||||
expectedNumber?: number,
|
expectedNumber?: number,
|
||||||
expectedValue?: SerializedArgument,
|
expectedValue?: SerializedArgument,
|
||||||
useInnerText?: boolean,
|
useInnerText?: boolean,
|
||||||
timeout?: number,
|
|
||||||
};
|
};
|
||||||
export type FrameExpectResult = {
|
export type FrameExpectResult = {
|
||||||
matches: boolean,
|
matches: boolean,
|
||||||
|
@ -2388,7 +2388,7 @@ Frame:
|
|||||||
expectedValue: SerializedArgument?
|
expectedValue: SerializedArgument?
|
||||||
useInnerText: boolean?
|
useInnerText: boolean?
|
||||||
isNot: boolean
|
isNot: boolean
|
||||||
timeout: number?
|
timeout: number
|
||||||
returns:
|
returns:
|
||||||
matches: boolean
|
matches: boolean
|
||||||
received: SerializedValue?
|
received: SerializedValue?
|
||||||
|
Loading…
x
Reference in New Issue
Block a user