cherry-pick(#20960): fix: simplify protocol for toBeInViewport
This commit is contained in:
parent
8d3481ea22
commit
a8542d86cf
|
|
@ -1586,7 +1586,6 @@ scheme.FrameExpectParams = tObject({
|
|||
expectedText: tOptional(tArray(tType('ExpectedTextValue'))),
|
||||
expectedNumber: tOptional(tNumber),
|
||||
expectedValue: tOptional(tType('SerializedArgument')),
|
||||
viewportRatio: tOptional(tNumber),
|
||||
useInnerText: tOptional(tBoolean),
|
||||
isNot: tBoolean,
|
||||
timeout: tOptional(tNumber),
|
||||
|
|
|
|||
|
|
@ -1191,7 +1191,7 @@ export class InjectedScript {
|
|||
// Viewport intersection
|
||||
if (expression === 'to.be.in.viewport') {
|
||||
const ratio = await this.viewportRatio(element);
|
||||
return { received: `viewport ratio ${ratio}`, matches: ratio > 0 && ratio > (options.viewportRatio ?? 0) - 1e-9 };
|
||||
return { received: `viewport ratio ${ratio}`, matches: ratio > 0 && ratio > (options.expectedNumber ?? 0) - 1e-9 };
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ export function toBeInViewport(
|
|||
options?: { timeout?: number, ratio?: number },
|
||||
) {
|
||||
return toBeTruthy.call(this, 'toBeInViewport', locator, 'Locator', async (isNot, timeout, customStackTrace) => {
|
||||
return await locator._expect(customStackTrace, 'to.be.in.viewport', { isNot, viewportRatio: options?.ratio, timeout });
|
||||
return await locator._expect(customStackTrace, 'to.be.in.viewport', { isNot, expectedNumber: options?.ratio, timeout });
|
||||
}, options);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2844,7 +2844,6 @@ export type FrameExpectParams = {
|
|||
expectedText?: ExpectedTextValue[],
|
||||
expectedNumber?: number,
|
||||
expectedValue?: SerializedArgument,
|
||||
viewportRatio?: number,
|
||||
useInnerText?: boolean,
|
||||
isNot: boolean,
|
||||
timeout?: number,
|
||||
|
|
@ -2854,7 +2853,6 @@ export type FrameExpectOptions = {
|
|||
expectedText?: ExpectedTextValue[],
|
||||
expectedNumber?: number,
|
||||
expectedValue?: SerializedArgument,
|
||||
viewportRatio?: number,
|
||||
useInnerText?: boolean,
|
||||
timeout?: number,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -2144,7 +2144,6 @@ Frame:
|
|||
items: ExpectedTextValue
|
||||
expectedNumber: number?
|
||||
expectedValue: SerializedArgument?
|
||||
viewportRatio: number?
|
||||
useInnerText: boolean?
|
||||
isNot: boolean
|
||||
timeout: number?
|
||||
|
|
|
|||
Loading…
Reference in a new issue