mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
fix: simplify protocol for toBeInViewport (#20960)
This commit is contained in:
parent
ffc2477a00
commit
1db04f2839
@ -1586,7 +1586,6 @@ scheme.FrameExpectParams = tObject({
|
|||||||
expectedText: tOptional(tArray(tType('ExpectedTextValue'))),
|
expectedText: tOptional(tArray(tType('ExpectedTextValue'))),
|
||||||
expectedNumber: tOptional(tNumber),
|
expectedNumber: tOptional(tNumber),
|
||||||
expectedValue: tOptional(tType('SerializedArgument')),
|
expectedValue: tOptional(tType('SerializedArgument')),
|
||||||
viewportRatio: tOptional(tNumber),
|
|
||||||
useInnerText: tOptional(tBoolean),
|
useInnerText: tOptional(tBoolean),
|
||||||
isNot: tBoolean,
|
isNot: tBoolean,
|
||||||
timeout: tOptional(tNumber),
|
timeout: tOptional(tNumber),
|
||||||
|
|||||||
@ -1191,7 +1191,7 @@ export class InjectedScript {
|
|||||||
// Viewport intersection
|
// Viewport intersection
|
||||||
if (expression === 'to.be.in.viewport') {
|
if (expression === 'to.be.in.viewport') {
|
||||||
const ratio = await this.viewportRatio(element);
|
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 },
|
options?: { timeout?: number, ratio?: number },
|
||||||
) {
|
) {
|
||||||
return toBeTruthy.call(this, 'toBeInViewport', locator, 'Locator', async (isNot, timeout, customStackTrace) => {
|
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);
|
}, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2844,7 +2844,6 @@ export type FrameExpectParams = {
|
|||||||
expectedText?: ExpectedTextValue[],
|
expectedText?: ExpectedTextValue[],
|
||||||
expectedNumber?: number,
|
expectedNumber?: number,
|
||||||
expectedValue?: SerializedArgument,
|
expectedValue?: SerializedArgument,
|
||||||
viewportRatio?: number,
|
|
||||||
useInnerText?: boolean,
|
useInnerText?: boolean,
|
||||||
isNot: boolean,
|
isNot: boolean,
|
||||||
timeout?: number,
|
timeout?: number,
|
||||||
@ -2854,7 +2853,6 @@ export type FrameExpectOptions = {
|
|||||||
expectedText?: ExpectedTextValue[],
|
expectedText?: ExpectedTextValue[],
|
||||||
expectedNumber?: number,
|
expectedNumber?: number,
|
||||||
expectedValue?: SerializedArgument,
|
expectedValue?: SerializedArgument,
|
||||||
viewportRatio?: number,
|
|
||||||
useInnerText?: boolean,
|
useInnerText?: boolean,
|
||||||
timeout?: number,
|
timeout?: number,
|
||||||
};
|
};
|
||||||
|
|||||||
@ -2144,7 +2144,6 @@ Frame:
|
|||||||
items: ExpectedTextValue
|
items: ExpectedTextValue
|
||||||
expectedNumber: number?
|
expectedNumber: number?
|
||||||
expectedValue: SerializedArgument?
|
expectedValue: SerializedArgument?
|
||||||
viewportRatio: number?
|
|
||||||
useInnerText: boolean?
|
useInnerText: boolean?
|
||||||
isNot: boolean
|
isNot: boolean
|
||||||
timeout: number?
|
timeout: number?
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user