fix: simplify protocol for toBeInViewport (#20960)

This commit is contained in:
Andrey Lushnikov 2023-02-16 11:02:19 -08:00 committed by GitHub
parent ffc2477a00
commit 1db04f2839
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 2 additions and 6 deletions

View File

@ -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),

View File

@ -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 };
}
}

View File

@ -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);
}

View File

@ -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,
};

View File

@ -2144,7 +2144,6 @@ Frame:
items: ExpectedTextValue
expectedNumber: number?
expectedValue: SerializedArgument?
viewportRatio: number?
useInnerText: boolean?
isNot: boolean
timeout: number?