UNPKG

@applitools/eyes-browser

Version:
281 lines (280 loc) 13.7 kB
/// <reference types="node" /> import type * as Core from '@applitools/core'; import { EyesSelector } from './EyesSelector'; import { Image } from './Image'; import { AccessibilityRegionType } from '../enums/AccessibilityRegionType'; import { MatchLevel } from '../enums/MatchLevel'; import { Region, LegacyRegion } from './Region'; import { Location } from './Location'; import { LazyLoadOptions } from './LazyLoadOptions'; import { DensityMetrics } from './DensityMetrics'; import * as utils from '@applitools/utils'; import { DynamicTextType } from '../enums/DynamicTextType'; import { type StitchMode } from '../enums/StitchMode'; type RegionReference<TSpec extends Core.SpecType> = Region | LegacyRegion | ElementReference<TSpec>; type ElementReference<TSpec extends Core.SpecType> = TSpec['element'] | SelectorReference<TSpec>; type SelectorReference<TSpec extends Core.SpecType> = EyesSelector<TSpec['selector']>; type FrameReference<TSpec extends Core.SpecType> = ElementReference<TSpec> | string | number; type ContextReference<TSpec extends Core.SpecType> = { frame: FrameReference<TSpec>; scrollRootElement?: ElementReference<TSpec>; }; type CodedRegion<TRegion = never> = { region: Region | LegacyRegion | TRegion; padding?: number | { top: number; bottom: number; left: number; right: number; }; regionId?: string; }; type CodedFloatingRegion<TRegion = never> = CodedRegion<TRegion> & { offset?: { top?: number; bottom?: number; left?: number; right?: number; }; }; /** @deprecated */ type LegacyCodedFloatingRegion<TRegion = never> = CodedRegion<TRegion> & { maxUpOffset?: number; maxDownOffset?: number; maxLeftOffset?: number; maxRightOffset?: number; }; type CodedAccessibilityRegion<TRegion = never> = CodedRegion<TRegion> & { type?: AccessibilityRegionType; }; type DynamicTextTypeOrPattern = DynamicTextType | string; type CodedDynamicRegion<TRegion = never> = CodedRegion<TRegion> & { type?: DynamicTextTypeOrPattern | DynamicTextTypeOrPattern[]; }; export type CheckSettingsBase<TRegion = never> = { name?: string; region?: Region | LegacyRegion | TRegion; matchLevel?: MatchLevel; useDom?: boolean; sendDom?: boolean; enablePatterns?: boolean; ignoreDisplacements?: boolean; ignoreMismatch?: boolean; ignoreCaret?: boolean; ignoreRegions?: (CodedRegion<TRegion> | Region | LegacyRegion | TRegion)[]; layoutRegions?: (CodedRegion<TRegion> | Region | LegacyRegion | TRegion)[]; strictRegions?: (CodedRegion<TRegion> | Region | LegacyRegion | TRegion)[]; contentRegions?: (CodedRegion<TRegion> | Region | LegacyRegion | TRegion)[]; floatingRegions?: (CodedFloatingRegion<TRegion> | LegacyCodedFloatingRegion<TRegion> | Region | LegacyRegion | TRegion)[]; accessibilityRegions?: (CodedAccessibilityRegion<TRegion> | Region | LegacyRegion | TRegion)[]; dynamicRegions?: (CodedDynamicRegion<TRegion> | Region | TRegion)[]; pageId?: string; variationGroupId?: string; densityMetrics?: DensityMetrics; stitchMode?: StitchMode; }; export type CheckSettingsImage = CheckSettingsBase; type LayoutBreakpoints = boolean | number[] | { breakpoints: number[] | boolean; reload?: boolean; } | { breakpoints: boolean; heightBreakpoints: boolean; reload?: boolean; }; export type CheckSettingsAutomation<TSpec extends Core.SpecType> = CheckSettingsBase<RegionReference<TSpec>> & { frames?: (ContextReference<TSpec> | FrameReference<TSpec>)[]; webview?: boolean | string; scrollRootElement?: ElementReference<TSpec>; fully?: boolean; disableBrowserFetching?: boolean; layoutBreakpoints?: LayoutBreakpoints; /** @deprecated */ visualGridOptions?: { [key: string]: any; }; ufgOptions?: { [key: string]: any; }; /** @deprecated */ nmgOptions?: { [key: string]: any; }; useSystemScreenshot?: boolean; hooks?: { beforeCaptureScreenshot: string; }; timeout?: number; waitBeforeCapture?: number | (() => Promise<void>); lazyLoad?: boolean | LazyLoadOptions; }; export declare class CheckSettingsBaseFluent<TRegion = never> { protected _settings: CheckSettingsBase<TRegion>; protected parent?: this; protected childs: this[]; constructor(settings?: CheckSettingsBase<TRegion> | CheckSettingsBaseFluent<TRegion>, parent?: CheckSettingsBaseFluent<TRegion>); region(region: Region | LegacyRegion | TRegion): typeof this; name(name: string): typeof this; withName(name: string): this; ignoreRegion(region: CodedRegion<TRegion> | Region | LegacyRegion | TRegion): typeof this; ignoreRegions(...regions: (CodedRegion<TRegion> | Region | LegacyRegion | TRegion)[]): typeof this; /** @deprecated */ ignore(region: Region | LegacyRegion | TRegion): this; /** @deprecated */ ignores(...regions: (Region | LegacyRegion | TRegion)[]): typeof this; layoutRegion(region: CodedRegion<TRegion> | Region | LegacyRegion | TRegion): typeof this; layoutRegions(...regions: (CodedRegion<TRegion> | Region | LegacyRegion | TRegion)[]): typeof this; strictRegion(region: CodedRegion<TRegion> | Region | LegacyRegion | TRegion): typeof this; strictRegions(...regions: (CodedRegion<TRegion> | Region | LegacyRegion | TRegion)[]): typeof this; contentRegion(region: CodedRegion<TRegion> | Region | LegacyRegion | TRegion): typeof this; contentRegions(...regions: (CodedRegion<TRegion> | Region | LegacyRegion | TRegion)[]): typeof this; floatingRegion(region: CodedFloatingRegion<TRegion>): this; floatingRegion(region: LegacyCodedFloatingRegion<TRegion>): this; floatingRegion(region: Region | LegacyRegion | TRegion, maxUpOffset?: number, maxDownOffset?: number, maxLeftOffset?: number, maxRightOffset?: number): this; floatingRegions(...regions: (CodedFloatingRegion<TRegion> | Region | LegacyRegion | TRegion)[]): this; floatingRegions(maxOffset: number, ...regions: (Region | LegacyRegion | TRegion)[]): this; /** @deprecated */ floating(region: CodedFloatingRegion<TRegion>): this; /** @deprecated */ floating(region: Region | LegacyRegion | TRegion): this; /** @deprecated */ floatings(...regions: (CodedFloatingRegion<TRegion> | Region | LegacyRegion | TRegion)[]): this; /** @deprecated */ floatings(maxOffset: number, ...regions: (Region | LegacyRegion | TRegion)[]): this; accessibilityRegion(region: CodedAccessibilityRegion<TRegion>): this; accessibilityRegion(region: Region | LegacyRegion | TRegion, type?: AccessibilityRegionType): this; accessibilityRegions(...regions: (CodedAccessibilityRegion<TRegion> | Region | LegacyRegion | TRegion)[]): this; accessibilityRegions(type: AccessibilityRegionType, ...regions: (Region | LegacyRegion | TRegion)[]): this; dynamicRegion(region: CodedDynamicRegion<TRegion>): this; dynamicRegion(region: Region | TRegion): this; dynamicRegion(region: Region | TRegion, type?: DynamicTextTypeOrPattern | DynamicTextTypeOrPattern[]): this; dynamicRegions(...regions: (CodedDynamicRegion<TRegion> | Region | TRegion)[]): this; matchLevel(matchLevel: MatchLevel): typeof this; layout(): typeof this; exact(): typeof this; strict(): typeof this; ignoreColors(): typeof this; dynamic(): typeof this; /** @deprecated */ content(): typeof this; enablePatterns(enablePatterns?: boolean): typeof this; ignoreDisplacements(ignoreDisplacements?: boolean): typeof this; ignoreCaret(ignoreCaret?: boolean): typeof this; useDom(useDom?: boolean): typeof this; sendDom(sendDom?: boolean): typeof this; pageId(pageId: string): typeof this; variationGroupId(variationGroupId: string): typeof this; /** @internal */ toObject(): CheckSettingsBase<TRegion>; /** @internal */ toString(): string; /** @internal */ protected assumesMutability(): true | undefined; protected static makeMutableTreeProxy<K, T extends CheckSettingsBaseFluent<K>>(self: T, ctor: new (...args: any[]) => T): T; protected toCoreCodedRegion(region: CodedRegion<TRegion> | Region | LegacyRegion | TRegion): Core.CodedRegion<TRegion | utils.Region> | utils.Region | TRegion; protected toCoreCodedFloatingRegion(region: CodedFloatingRegion<TRegion> | LegacyCodedFloatingRegion<TRegion> | Region | LegacyRegion | TRegion): Core.FloatingRegion<TRegion | utils.Region> | utils.Region | TRegion; protected toCoreRegion(region: Region | LegacyRegion | TRegion): utils.Region | TRegion; } export declare class CheckSettingsImageFluent extends CheckSettingsBaseFluent { protected _target: Image; constructor(settings?: CheckSettingsImage | CheckSettingsImageFluent, target?: Image, parent?: CheckSettingsImageFluent); image(image: Buffer | URL | string): typeof this; buffer(imageBuffer: Buffer): typeof this; base64(imageBase64: Buffer): typeof this; path(imagePath: string): typeof this; url(imageUrl: URL | string): typeof this; name(name: string): typeof this; withDom(dom: string): typeof this; withLocation(locationInViewport: Location): typeof this; /** @internal */ toJSON(): { target: Image; settings: Core.CheckSettings<never, 'classic'>; }; } export declare class CheckSettingsAutomationFluent<TSpec extends Core.SpecType = Core.SpecType> extends CheckSettingsBaseFluent<RegionReference<TSpec>> { protected _settings: CheckSettingsAutomation<TSpec>; protected static readonly _spec: Core.SpecDriver<Core.SpecType>; protected _spec: Core.SpecDriver<TSpec>; protected _isElementReference(value: any): value is ElementReference<TSpec>; protected _isSelectorReference(selector: any): selector is SelectorReference<TSpec>; protected _isFrameReference(value: any): value is FrameReference<TSpec>; constructor(settings?: CheckSettingsAutomation<TSpec> | CheckSettingsAutomationFluent<TSpec>); /** @internal */ constructor(settings?: CheckSettingsAutomation<TSpec> | CheckSettingsAutomationFluent<TSpec>, spec?: Core.SpecDriver<TSpec>, parent?: CheckSettingsAutomationFluent<TSpec>); region(region: RegionReference<TSpec>): this; shadow(selector: SelectorReference<TSpec>): typeof this; frame(context: ContextReference<TSpec>): this; frame(frame: FrameReference<TSpec>, scrollRootElement?: ElementReference<TSpec>): this; webview(webview?: string | boolean): typeof this; scrollRootElement(scrollRootElement: ElementReference<TSpec>): typeof this; fully(fully?: boolean): typeof this; /** @deprecated */ stitchContent(stitchContent?: boolean): this; disableBrowserFetching(disableBrowserFetching: boolean): typeof this; layoutBreakpoints(breakpoints: boolean, heightBreakpoints: boolean, settings?: { reload?: boolean; }): this; layoutBreakpoints(breakpoints: boolean | number[], settings?: { reload?: boolean; }): this; hook(name: string, script: string): typeof this; beforeRenderScreenshotHook(script: string): typeof this; /** @deprecated */ webHook(script: string): typeof this; ufgOption(key: string, value: any): this; ufgOptions(options: { [key: string]: any; }): this; /** @deprecated */ nmgOption(key: string, value: any): this; /** @deprecated */ nmgOptions(options: { [key: string]: any; }): this; /** @deprecated */ visualGridOption(key: string, value: any): this; /** @deprecated */ visualGridOptions(options: { [key: string]: any; }): this; useSystemScreenshot(useSystemScreenshot?: boolean): this; timeout(timeout: number): typeof this; waitBeforeCapture(waitBeforeCapture: number | (() => Promise<void>)): typeof this; lazyLoad(options?: LazyLoadOptions | boolean): typeof this; densityMetrics(options: DensityMetrics): typeof this; stitchMode(stitchMode: StitchMode): typeof this; /** @internal */ protected toLayoutBreakpoints(): { breakpoints: number[] | boolean; heightBreakpoints?: boolean; reload?: boolean; }; /** @internal */ toJSON(): { target: undefined; settings: Core.CheckSettings<TSpec, 'classic'> & Core.CheckSettings<TSpec, 'ufg'>; }; } export type TargetImage = { image(image: Buffer | URL | string): CheckSettingsImageFluent; buffer(imageBuffer: Buffer): CheckSettingsImageFluent; base64(imageBase64: string): CheckSettingsImageFluent; path(imagePath: string): CheckSettingsImageFluent; url(imageUrl: URL | string): CheckSettingsImageFluent; }; export declare const TargetImage: TargetImage; export type TargetAutomation<TSpec extends Core.SpecType = Core.SpecType> = { /** @internal */ spec: Core.SpecDriver<TSpec>; window(): CheckSettingsAutomationFluent<TSpec>; region(region: RegionReference<TSpec> | LegacyRegion): CheckSettingsAutomationFluent<TSpec>; frame(context: ContextReference<TSpec>): CheckSettingsAutomationFluent<TSpec>; frame(frame: FrameReference<TSpec>, scrollRootElement?: ElementReference<TSpec>): CheckSettingsAutomationFluent<TSpec>; shadow(selector: SelectorReference<TSpec>): CheckSettingsAutomationFluent<TSpec>; webview(webview?: string | boolean): CheckSettingsAutomationFluent<TSpec>; }; export declare const TargetAutomation: TargetAutomation<Core.SpecType>; export type Target<TSpec extends Core.SpecType = Core.SpecType> = TargetImage & TargetAutomation<TSpec>; export declare const Target: Target<Core.SpecType>; export {};