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'))),
|
||||
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…
x
Reference in New Issue
Block a user