Skip to content

Commit

Permalink
refactor: updated fixture typings
Browse files Browse the repository at this point in the history
  • Loading branch information
iamkenos committed Mar 1, 2025
1 parent d52757e commit 54a8f0a
Show file tree
Hide file tree
Showing 72 changed files with 274 additions and 137 deletions.
2 changes: 2 additions & 0 deletions src/fixtures/context/commands/close-last-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ export async function closeLastPage(this: BrowserContext) {

return main;
}

export type CloseLastPageCommand = typeof closeLastPage;
2 changes: 2 additions & 0 deletions src/fixtures/context/commands/close-other-pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ export async function closeOtherPages(this: BrowserContext) {

return main;
}

export type CloseOtherPagesCommand = typeof closeOtherPages;
2 changes: 2 additions & 0 deletions src/fixtures/context/commands/last-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ export function lastPage(this: BrowserContext) {
const [last] = this.pages().slice(-1);
return new PageClass(last) as Page;
}

export type LastPageCommand = typeof lastPage;
2 changes: 2 additions & 0 deletions src/fixtures/context/commands/new-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ export async function newPage(this: BrowserContext) {
const from = await this.__proto.newPage();
return new PageClass(from) as Page;
}

export type NewPageCommand = typeof newPage;
16 changes: 8 additions & 8 deletions src/fixtures/context/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ import type { BrowserContext as PlaywrightBrowserContext } from "@playwright/tes
import type { Page } from "@fixtures/page/types";
import type { Locator } from "@fixtures/locator/types";
import type { BrowserContext as BrowserContextClass } from "./context";
import type { closeLastPage } from "./commands/close-last-page";
import type { closeOtherPages } from "./commands/close-other-pages";
import type { lastPage } from "./commands/last-page";
import type { newPage } from "./commands/new-page";
import type { CloseLastPageCommand } from "./commands/close-last-page";
import type { CloseOtherPagesCommand } from "./commands/close-other-pages";
import type { LastPageCommand } from "./commands/last-page";
import type { NewPageCommand } from "./commands/new-page";

export interface BrowserContext extends PlaywrightBrowserContext, BrowserContextClass {
locator: Locator;
closeLastPage(...args: Parameters<typeof closeLastPage>): ReturnType<typeof closeLastPage>;
closeOtherPages(...args: Parameters<typeof closeOtherPages>): ReturnType<typeof closeOtherPages>;
lastPage(...args: Parameters<typeof lastPage>): ReturnType<typeof lastPage>;
newPage(...args: Parameters<typeof newPage>): ReturnType<typeof newPage>;
closeLastPage(...args: Parameters<CloseLastPageCommand>): ReturnType<CloseLastPageCommand>;
closeOtherPages(...args: Parameters<CloseOtherPagesCommand>): ReturnType<CloseOtherPagesCommand>;
lastPage(...args: Parameters<LastPageCommand>): ReturnType<LastPageCommand>;
newPage(...args: Parameters<NewPageCommand>): ReturnType<NewPageCommand>;
pages: () => Page[];
}
2 changes: 2 additions & 0 deletions src/fixtures/frame/commands/first.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ import type { FrameLocator } from "@fixtures/frame/types";
export function first(this: FrameLocator, ...args: Parameters<PlaywrightFrameLocator["first"]>) {
return new FrameLocatorClass(this.__proto.first(...args)) as FrameLocator;
}

export type FirstCommand = typeof first;
2 changes: 2 additions & 0 deletions src/fixtures/frame/commands/frame-locator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ import type { FrameLocator } from "@fixtures/frame/types";
export function frameLocator(this: FrameLocator, ...args: Parameters<PlaywrightFrameLocator["frameLocator"]>) {
return new FrameLocatorClass(this.__proto.frameLocator(...args)) as FrameLocator;
}

export type FrameLocatorCommand = typeof frameLocator;
2 changes: 2 additions & 0 deletions src/fixtures/frame/commands/get-by-alt-text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ import type { Locator } from "@fixtures/locator/types";
export function getByAltText(this: FrameLocator, ...args: Parameters<PlaywrightFrameLocator["getByAltText"]>) {
return new LocatorClass(this.__proto.getByAltText(...args)) as Locator;
}

export type GetByAltTextCommand = typeof getByAltText;
2 changes: 2 additions & 0 deletions src/fixtures/frame/commands/get-by-label.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ import type { Locator } from "@fixtures/locator/types";
export function getByLabel(this: FrameLocator, ...args: Parameters<PlaywrightFrameLocator["getByLabel"]>) {
return new LocatorClass(this.__proto.getByLabel(...args)) as Locator;
}

export type GetByLabelCommand = typeof getByLabel;
2 changes: 2 additions & 0 deletions src/fixtures/frame/commands/get-by-role.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ import type { Locator } from "@fixtures/locator/types";
export function getByRole(this: FrameLocator, ...args: Parameters<PlaywrightFrameLocator["getByRole"]>) {
return new LocatorClass(this.__proto.getByRole(...args)) as Locator;
}

export type GetByRoleCommand = typeof getByRole;
2 changes: 2 additions & 0 deletions src/fixtures/frame/commands/get-by-test-id.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ import type { Locator } from "@fixtures/locator/types";
export function getByTestId(this: FrameLocator, ...args: Parameters<PlaywrightFrameLocator["getByTestId"]>) {
return new LocatorClass(this.__proto.getByTestId(...args)) as Locator;
}

export type GetByTestIdCommand = typeof getByTestId;
2 changes: 2 additions & 0 deletions src/fixtures/frame/commands/get-by-text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ import type { Locator } from "@fixtures/locator/types";
export function getByText(this: FrameLocator, ...args: Parameters<PlaywrightFrameLocator["getByText"]>) {
return new LocatorClass(this.__proto.getByText(...args)) as Locator;
}

export type GetByTextCommand = typeof getByText;
2 changes: 2 additions & 0 deletions src/fixtures/frame/commands/get-by-title.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ import type { Locator } from "@fixtures/locator/types";
export function getByTitle(this: FrameLocator, ...args: Parameters<PlaywrightFrameLocator["getByTitle"]>) {
return new LocatorClass(this.__proto.getByTitle(...args)) as Locator;
}

export type GetByTitleCommand = typeof getByTitle;
2 changes: 2 additions & 0 deletions src/fixtures/frame/commands/last.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ import type { FrameLocator } from "@fixtures/frame/types";
export function last(this: FrameLocator, ...args: Parameters<PlaywrightFrameLocator["last"]>) {
return new FrameLocatorClass(this.__proto.last(...args)) as FrameLocator;
}

export type LastCommand = typeof last;
2 changes: 2 additions & 0 deletions src/fixtures/frame/commands/locator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ import type { Locator } from "@fixtures/locator/types";
export function locator(this: FrameLocator, ...args: Parameters<PlaywrightFrameLocator["locator"]>) {
return new LocatorClass(this.__proto.locator(...args)) as Locator;
}

export type LocatorCommand = typeof locator;
2 changes: 2 additions & 0 deletions src/fixtures/frame/commands/nth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ import type { FrameLocator } from "@fixtures/frame/types";
export function nth(this: FrameLocator, ...args: Parameters<PlaywrightFrameLocator["nth"]>) {
return new FrameLocatorClass(this.__proto.nth(...args)) as FrameLocator;
}

export type NthCommand = typeof nth;
45 changes: 22 additions & 23 deletions src/fixtures/frame/types.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
import type { FrameLocator as PlaywrightFrameLocator } from "@playwright/test";
import type { FrameLocator as FrameLocatorClass } from "./frame";
import type { first } from "./commands/first";
import type { frameLocator } from "./commands/frame-locator";
import type { getByAltText } from "./commands/get-by-alt-text";
import type { getByLabel } from "./commands/get-by-label";
import type { getByRole } from "./commands/get-by-role";
import type { getByTestId } from "./commands/get-by-test-id";
import type { getByText } from "./commands/get-by-text";
import type { getByTitle } from "./commands/get-by-title";
import type { last } from "./commands/last";
import type { locator } from "./commands/locator";
import type { nth } from "./commands/nth";
import type { FirstCommand } from "./commands/first";
import type { FrameLocatorCommand } from "./commands/frame-locator";
import type { GetByAltTextCommand } from "./commands/get-by-alt-text";
import type { GetByLabelCommand } from "./commands/get-by-label";
import type { GetByRoleCommand } from "./commands/get-by-role";
import type { GetByTestIdCommand } from "./commands/get-by-test-id";
import type { GetByTextCommand } from "./commands/get-by-text";
import type { GetByTitleCommand } from "./commands/get-by-title";
import type { LastCommand } from "./commands/last";
import type { LocatorCommand } from "./commands/locator";
import type { NthCommand } from "./commands/nth";

export interface FrameLocator extends PlaywrightFrameLocator, FrameLocatorClass {
first(...args: Parameters<typeof first>): ReturnType<typeof first>;
frameLocator(...args: Parameters<typeof frameLocator>): ReturnType<typeof frameLocator>;
frameLocator(...args: Parameters<typeof frameLocator>): ReturnType<typeof frameLocator>;
getByAltText(...args: Parameters<typeof getByAltText>): ReturnType<typeof getByAltText>;
getByLabel(...args: Parameters<typeof getByLabel>): ReturnType<typeof getByLabel>;
getByRole(...args: Parameters<typeof getByRole>): ReturnType<typeof getByRole>;
getByTestId(...args: Parameters<typeof getByTestId>): ReturnType<typeof getByTestId>;
getByText(...args: Parameters<typeof getByText>): ReturnType<typeof getByText>;
getByTitle(...args: Parameters<typeof getByTitle>): ReturnType<typeof getByTitle>;
last(...args: Parameters<typeof last>): ReturnType<typeof last>;
locator(...args: Parameters<typeof locator>): ReturnType<typeof locator>;
nth(...args: Parameters<typeof nth>): ReturnType<typeof nth>;
first(...args: Parameters<FirstCommand>): ReturnType<FirstCommand>;
frameLocator(...args: Parameters<FrameLocatorCommand>): ReturnType<FrameLocatorCommand>;
getByAltText(...args: Parameters<GetByAltTextCommand>): ReturnType<GetByAltTextCommand>;
getByLabel(...args: Parameters<GetByLabelCommand>): ReturnType<GetByLabelCommand>;
getByRole(...args: Parameters<GetByRoleCommand>): ReturnType<GetByRoleCommand>;
getByTestId(...args: Parameters<GetByTestIdCommand>): ReturnType<GetByTestIdCommand>;
getByText(...args: Parameters<GetByTextCommand>): ReturnType<GetByTextCommand>;
getByTitle(...args: Parameters<GetByTitleCommand>): ReturnType<GetByTitleCommand>;
last(...args: Parameters<LastCommand>): ReturnType<LastCommand>;
locator(...args: Parameters<LocatorCommand>): ReturnType<LocatorCommand>;
nth(...args: Parameters<NthCommand>): ReturnType<NthCommand>;
}
2 changes: 2 additions & 0 deletions src/fixtures/locator/commands/all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ export async function all(this: Locator, ...args: Parameters<PlaywrightLocator["
const all = await this.__proto.all(...args);
return all.map(locator => new LocatorClass(locator)) as Locator[];
}

export type AllCommand = typeof all;
2 changes: 2 additions & 0 deletions src/fixtures/locator/commands/and.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ import type { Locator, PlaywrightLocator } from "@fixtures/locator/types";
export function and(this: Locator, ...args: Parameters<PlaywrightLocator["and"]>) {
return new LocatorClass(this.__proto.and(...args)) as Locator;
}

export type AndCommand = typeof and;
5 changes: 4 additions & 1 deletion src/fixtures/locator/commands/center-point.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import type { Component } from "@fixtures/component/component";
import type { Locator } from "@fixtures/locator/types";

export async function centerPoint(this: Locator) {
export async function centerPoint(this: Locator | Component) {
const box = await this.boundingBox();
const x = Math.round((box.x + (box.width / 2)) * 100) / 100;
const y = Math.round((box.y + (box.height / 2)) * 100) / 100;
return { x, y };
}

export type CenterPointCommand = typeof centerPoint;
2 changes: 2 additions & 0 deletions src/fixtures/locator/commands/click-until.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ export async function clickUntil(this: Locator, conditions: ExpectedConditions,
const fn = async() => await this.click(...args);
await this.doUntil(fn, conditions.setName(clickUntil.name));
}

export type ClickUntilCommand = typeof clickUntil;
2 changes: 2 additions & 0 deletions src/fixtures/locator/commands/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ export function component<T>(this: Locator, Component: Constructor<T>, filters?:
const from = this.locator(prototype.root);
return GenericComponent.create({ prototype, from }) as T;
}

export type ComponentCommand = typeof component;
2 changes: 2 additions & 0 deletions src/fixtures/locator/commands/do-until.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ import type { ExpectedConditions } from "@conditions/types";
export async function doUntil(this: Locator, action: Function, conditions: ExpectedConditions) {
await conditions.setAction(action).poll();
}

export type DoUntilCommand = typeof doUntil;
2 changes: 2 additions & 0 deletions src/fixtures/locator/commands/drag-and-drop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ export async function dragAndDrop(this: Locator, target: Locator | Component) {
await target.hoverIntoView();
await page.mouse.up();
}

export type DragAndDropCommand = typeof dragAndDrop;
2 changes: 2 additions & 0 deletions src/fixtures/locator/commands/dropdown-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ export async function dropdownOptions(this: Locator, group?: { index: number })
}
return options;
}

export type DropdownOptionsCommand = typeof dropdownOptions;
2 changes: 2 additions & 0 deletions src/fixtures/locator/commands/expect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ import type { ExpectedConditionOptions } from "@conditions/types";
export function expect(this: Locator, options?: ExpectedConditionOptions) {
return new LocatorConditions(this, { ...options, timeout: options?.timeout || world.config.timeout });
}

export type ExpectCommand = typeof expect;
2 changes: 2 additions & 0 deletions src/fixtures/locator/commands/fill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ export async function fill(this: Locator, ...args: FillArgs) {
await this.__proto.fill(...args);
}
}

export type FillCommand = typeof fill;
2 changes: 2 additions & 0 deletions src/fixtures/locator/commands/filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ import type { Locator, PlaywrightLocator } from "@fixtures/locator/types";
export function filter(this: Locator, ...args: Parameters<PlaywrightLocator["filter"]>) {
return new LocatorClass(this.__proto.filter(...args)) as Locator;
}

export type FilterCommand = typeof filter;
2 changes: 2 additions & 0 deletions src/fixtures/locator/commands/first.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ import type { Locator, PlaywrightLocator } from "@fixtures/locator/types";
export function first(this: Locator, ...args: Parameters<PlaywrightLocator["first"]>) {
return new LocatorClass(this.__proto.first(...args)) as Locator;
}

export type FirstCommand = typeof first;
2 changes: 2 additions & 0 deletions src/fixtures/locator/commands/get-by-alt-text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ import type { Locator, PlaywrightLocator } from "@fixtures/locator/types";
export function getByAltText(this: Locator, ...args: Parameters<PlaywrightLocator["getByAltText"]>) {
return new LocatorClass(this.__proto.getByAltText(...args)) as Locator;
}

export type GetByAltTextCommand = typeof getByAltText;
2 changes: 2 additions & 0 deletions src/fixtures/locator/commands/get-by-label.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ import type { Locator, PlaywrightLocator } from "@fixtures/locator/types";
export function getByLabel(this: Locator, ...args: Parameters<PlaywrightLocator["getByLabel"]>) {
return new LocatorClass(this.__proto.getByLabel(...args)) as Locator;
}

export type GetByLabelCommand = typeof getByLabel;
2 changes: 2 additions & 0 deletions src/fixtures/locator/commands/get-by-placeholder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ import type { Locator, PlaywrightLocator } from "@fixtures/locator/types";
export function getByPlaceholder(this: Locator, ...args: Parameters<PlaywrightLocator["getByPlaceholder"]>) {
return new LocatorClass(this.__proto.getByPlaceholder(...args)) as Locator;
}

export type GetByPlaceholderCommand = typeof getByPlaceholder;
2 changes: 2 additions & 0 deletions src/fixtures/locator/commands/get-by-role.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ import type { Locator, PlaywrightLocator } from "@fixtures/locator/types";
export function getByRole(this: Locator, ...args: Parameters<PlaywrightLocator["getByRole"]>) {
return new LocatorClass(this.__proto.getByRole(...args)) as Locator;
}

export type GetByRoleCommand = typeof getByRole;
2 changes: 2 additions & 0 deletions src/fixtures/locator/commands/get-by-test-id.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ import type { Locator, PlaywrightLocator } from "@fixtures/locator/types";
export function getByTestId(this: Locator, ...args: Parameters<PlaywrightLocator["getByTestId"]>) {
return new LocatorClass(this.__proto.getByTestId(...args)) as Locator;
}

export type GetByTestIdCommand = typeof getByTestId;
2 changes: 2 additions & 0 deletions src/fixtures/locator/commands/get-by-text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ import type { Locator, PlaywrightLocator } from "@fixtures/locator/types";
export function getByText(this: Locator, ...args: Parameters<PlaywrightLocator["getByText"]>) {
return new LocatorClass(this.__proto.getByText(...args)) as Locator;
}

export type GetByTextCommand = typeof getByText;
2 changes: 2 additions & 0 deletions src/fixtures/locator/commands/get-by-title.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ import type { Locator, PlaywrightLocator } from "@fixtures/locator/types";
export function getByTitle(this: Locator, ...args: Parameters<PlaywrightLocator["getByTitle"]>) {
return new LocatorClass(this.__proto.getByTitle(...args)) as Locator;
}

export type GetByTitleCommand = typeof getByTitle;
2 changes: 2 additions & 0 deletions src/fixtures/locator/commands/given.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ import type { ExpectedConditionOptions } from "@conditions/types";
export function given(this: Locator, options?: Omit<ExpectedConditionOptions, "soft" | "name">) {
return this.expect({ ...options, soft: true });
}

export type GivenCommand = typeof given;
5 changes: 4 additions & 1 deletion src/fixtures/locator/commands/hover-into-view.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Component } from "@fixtures/component/component";
import type { Locator } from "@fixtures/locator/types";

export async function hoverIntoView(this: Locator, options?: { position?: { x: number, y: number } }) {
export async function hoverIntoView(this: Locator | Component, options?: { position?: { x: number, y: number } }) {
const hasOffset = options?.position;
const page = this.page();
await this.scrollIntoView();
Expand All @@ -17,3 +18,5 @@ export async function hoverIntoView(this: Locator, options?: { position?: { x: n

await page.mouse.move(x, y);
}

export type HoverIntoViewCommand = typeof hoverIntoView;
2 changes: 2 additions & 0 deletions src/fixtures/locator/commands/is-focused.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ export async function isFocused(this: Locator) {
return false;
}
}

export type IsFocusedCommand = typeof isFocused;
2 changes: 2 additions & 0 deletions src/fixtures/locator/commands/is-selected.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ import type { Locator } from "@fixtures/locator/types";
export async function isSelected(this: Locator) {
return await this.evaluate((node: HTMLOptionElement) => node.selected) as boolean;
}

export type IsSelectedCommand = typeof isSelected;
2 changes: 2 additions & 0 deletions src/fixtures/locator/commands/last.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ import type { Locator, PlaywrightLocator } from "@fixtures/locator/types";
export function last(this: Locator, ...args: Parameters<PlaywrightLocator["last"]>) {
return new LocatorClass(this.__proto.last(...args)) as Locator;
}

export type LastCommand = typeof last;
2 changes: 2 additions & 0 deletions src/fixtures/locator/commands/location.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ export async function location(this: Locator) {
const y = Math.round((box.y - body.y) * 100) / 100;
return { x, y };
}

export type LocationCommand = typeof location;
2 changes: 2 additions & 0 deletions src/fixtures/locator/commands/locator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ import type { Locator, PlaywrightLocator } from "@fixtures/locator/types";
export function locator(this: Locator, ...args: Parameters<PlaywrightLocator["locator"]>) {
return new LocatorClass(this.__proto.locator(...args)) as Locator;
}

export type LocatorCommand = typeof locator;
2 changes: 2 additions & 0 deletions src/fixtures/locator/commands/nth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ import type { Locator, PlaywrightLocator } from "@fixtures/locator/types";
export function nth(this: Locator, ...args: Parameters<PlaywrightLocator["nth"]>) {
return new LocatorClass(this.__proto.nth(...args)) as Locator;
}

export type NthCommand = typeof nth;
2 changes: 2 additions & 0 deletions src/fixtures/locator/commands/or.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ import type { Locator, PlaywrightLocator } from "@fixtures/locator/types";
export function or(this: Locator, ...args: Parameters<PlaywrightLocator["or"]>) {
return new LocatorClass(this.__proto.or(...args)) as Locator;
}

export type OrCommand = typeof or;
2 changes: 2 additions & 0 deletions src/fixtures/locator/commands/press.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ export async function press(this: Locator, ...args: PressArgs) {

this.__proto.press(...args);
}

export type PressCommand = typeof press;
5 changes: 4 additions & 1 deletion src/fixtures/locator/commands/scroll-into-view.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import type { Component } from "@fixtures/component/component";
import type { Locator } from "@fixtures/locator/types";

export async function scrollIntoView(this: Locator) {
export async function scrollIntoView(this: Locator | Component) {
await this.evaluate((node: HTMLElement) => node.scrollIntoView({ behavior: "auto", block: "center", inline: "center" }));
}

export type ScrollIntoViewCommand = typeof scrollIntoView;
2 changes: 2 additions & 0 deletions src/fixtures/locator/commands/select-option.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,5 @@ export async function selectOption(this: Locator, ...args: SelectOptionArgs) {
return this.__proto.selectOption(...args);
}
}

export type SelectOptionCommand = typeof selectOption;
2 changes: 2 additions & 0 deletions src/fixtures/locator/commands/upload-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ export async function uploadFiles(this: Locator, ...files: string[]) {
const mapped = files.length > 0 ? files.map(file => path.isAbsolute(file) ? file : path.join(world.config.baseDir, file)) : files;
await fileChooser.setFiles(mapped);
}

export type UploadFilesCommand = typeof uploadFiles;
Loading

0 comments on commit 54a8f0a

Please sign in to comment.