1 |
|
2 | declare module 'ember-cli-page-object' {
|
3 | import {
|
4 | Component,
|
5 | Definition,
|
6 | FindOptions,
|
7 | TriggerOptions,
|
8 | GetterDescriptor,
|
9 | MethodDescriptor,
|
10 | DSL
|
11 | } from 'ember-cli-page-object/-private';
|
12 |
|
13 | export function create<T extends Partial<Definition>>(definition?: T): Component<T>;
|
14 | export function collection<T extends Partial<Definition>>(scope: string, definition?: T): Collection<T>;
|
15 |
|
16 |
|
17 | export function attribute(attributeName: string, scope?: string, options?: FindOptions): GetterDescriptor<string>;
|
18 | export function isVisible(scope?: string, options?: FindOptions): GetterDescriptor<boolean>;
|
19 | export function isHidden(scope?: string, options?: FindOptions): GetterDescriptor<boolean>;
|
20 | export function isPresent(scope?: string, options?: FindOptions): GetterDescriptor<boolean>;
|
21 | export function text(scope?: string, options?: FindOptions & { normalize?: boolean }): GetterDescriptor<string>;
|
22 | export function value(scope?: string, options?: FindOptions): GetterDescriptor<string>;
|
23 | export function property<T = unknown>(name: string, scope?: string, options?: FindOptions): GetterDescriptor<T>;
|
24 | export function hasClass(className: string, scope?: string, options?: FindOptions): GetterDescriptor<boolean>;
|
25 | export function notHasClass(className: string, scope?: string, options?: FindOptions): GetterDescriptor<boolean>;
|
26 | export function contains(scope?: string, options?: FindOptions): (text: string) => GetterDescriptor<boolean>;
|
27 | export function count(scope?: string, options?: FindOptions): GetterDescriptor<number>;
|
28 |
|
29 |
|
30 | export function clickable(scope?: string, userOptions?: FindOptions): MethodDescriptor<<T>(this: T) => T>;
|
31 | export function clickOnText(scope?: string, userOptions?: FindOptions): MethodDescriptor<<T>(this: T, text: string) => T>;
|
32 | export function fillable(scope?: string, userOptions?: FindOptions): MethodDescriptor<<T>(this: T, clueOrContent: string, content?: string) => T>;
|
33 | export function selectable(scope?: string, userOptions?: FindOptions): MethodDescriptor<<T>(this: T, clueOrContent: string, content?: string) => T>;
|
34 | export function triggerable(event: string, scope?: string, eventOptions?: TriggerOptions, options?: FindOptions): MethodDescriptor<<T>(this: T, options?: {}) => T>;
|
35 | export function focusable(scope?: string, options?: FindOptions): MethodDescriptor<<T>(this: T) => T>;
|
36 | export function blurrable(scope?: string, options?: FindOptions): MethodDescriptor<<T>(this: T) => T>;
|
37 | export function visitable(path: string): MethodDescriptor<<T>(this: T, dynamicSegmentsAndQueryParams?: {}) => T>;
|
38 |
|
39 | export interface Collection<T> {
|
40 | (scope: string, definition?: T): Array<Component<T>>;
|
41 |
|
42 | [i: number]: Component<T>;
|
43 | [Symbol.iterator](): Iterator<Component<T>>;
|
44 |
|
45 | filter(callback: (c: Component<T>) => boolean): Array<Component<T>>;
|
46 | filterBy(propName: keyof T | keyof DSL<T>, value?: any): Array<Component<T>>;
|
47 | findOne(callback: (c: Component<T>) => boolean): Component<T>;
|
48 | findOneBy(propName: keyof T | keyof DSL<T>, value: any): Component<T>;
|
49 | forEach(callback: (c: Component<T>, i: number) => void): void;
|
50 | map<S>(callback: (c: Component<T>) => S): S[];
|
51 | mapBy(propName: keyof T | keyof DSL<T>): any[];
|
52 | objectAt(i: number): Component<T>;
|
53 | toArray(): Array<Component<T>>;
|
54 | }
|
55 |
|
56 | const PageObject: {
|
57 | create: typeof create,
|
58 | attribute: typeof attribute,
|
59 | isVisible: typeof isVisible,
|
60 | isHidden: typeof isHidden,
|
61 | isPresent: typeof isPresent,
|
62 | text: typeof text,
|
63 | value: typeof value,
|
64 | property: typeof property,
|
65 | hasClass: typeof hasClass,
|
66 | notHasClass: typeof notHasClass,
|
67 | contains: typeof contains,
|
68 | count: typeof count,
|
69 | clickable: typeof clickable,
|
70 | clickOnText: typeof clickOnText,
|
71 | fillable: typeof fillable,
|
72 | selectable: typeof selectable,
|
73 | triggerable: typeof triggerable,
|
74 | focusable: typeof focusable,
|
75 | blurrable: typeof blurrable,
|
76 | visitable: typeof visitable,
|
77 | }
|
78 |
|
79 | export default PageObject;
|
80 | }
|
81 |
|
82 | declare module 'ember-cli-page-object/extend' {
|
83 | import type * as JQuery from 'jquery';
|
84 |
|
85 | import { Component, FindElementOptions, FindOptions } from 'ember-cli-page-object/-private';
|
86 |
|
87 | function findElement(pageObject: Component, scope?: string, options?: FindElementOptions): JQuery;
|
88 | function findElementWithAssert(pageObject: Component, scope?: string, options?: FindElementOptions): JQuery;
|
89 |
|
90 | function findOne(pageObject: Component, scope?: string, options?: FindOptions): Element;
|
91 | function findMany(pageObject: Component, scope?: string, options?: FindOptions): Element[];
|
92 | }
|
93 |
|
94 | declare module 'ember-cli-page-object/macros' {
|
95 | import { Component, GetterDescriptor } from 'ember-cli-page-object/-private';
|
96 |
|
97 | function getter<P, T = any>
|
98 | (body: (this: Component<P>, key: string) => T)
|
99 | : GetterDescriptor<T>;
|
100 |
|
101 | function alias(path: string, options?: { chainable: boolean }): any;
|
102 | }
|
103 |
|
104 | declare module 'ember-cli-page-object/adapter' {
|
105 | export default class Adapter {}
|
106 | }
|
107 |
|
108 | declare module 'ember-cli-page-object/adapters/rfc268' {
|
109 | import Adapter from 'ember-cli-page-object/adapter';
|
110 |
|
111 | export default class RFC268Adapter extends Adapter {}
|
112 | }
|
113 |
|
114 | declare module 'ember-cli-page-object/adapters' {
|
115 | import Adapter from 'ember-cli-page-object/adapter';
|
116 |
|
117 | export function setAdapter(adapter: Adapter): void
|
118 | }
|
119 |
|
120 | declare module 'ember-cli-page-object/-private' {
|
121 | import type * as JQuery from 'jquery';
|
122 |
|
123 | interface GetterDescriptor<T> {
|
124 | isGetter: true;
|
125 |
|
126 | get: T;
|
127 | }
|
128 |
|
129 | interface MethodDescriptor<T extends <S>(this: S, ...args: any[]) => S> {
|
130 | isMethod: true;
|
131 |
|
132 | (...args: Parameters<T>): ReturnType<T>;
|
133 |
|
134 | get(): T;
|
135 | }
|
136 |
|
137 | type Component<T = Definition> = UnpackedDefinition<T> & DSL<T> & {
|
138 | [s: string]: unknown;
|
139 | };
|
140 |
|
141 | type UnpackedDefinition<T> = {
|
142 | [k in keyof T]:
|
143 | T[k] extends GetterDescriptor<infer C> ? C
|
144 | : T[k] extends MethodDescriptor<infer C> ? C
|
145 | : T[k] extends Function | Component ? T[k]
|
146 | : T[k] extends object ? Component<T[k]>
|
147 | : T[k]
|
148 | };
|
149 |
|
150 | interface DSL<T> {
|
151 | isHidden?: boolean;
|
152 | isPresent?: boolean;
|
153 | isVisible?: boolean;
|
154 | text?: string;
|
155 | value?: string;
|
156 | contains(textToSearch: string): boolean;
|
157 |
|
158 | blur(): Component<T>;
|
159 | click(): Component<T>;
|
160 | clickOn(text: string): Component<T>;
|
161 | fillIn(clueOrContent: string, content?: string): Component<T>;
|
162 | focus(): Component<T>;
|
163 |
|
164 | then(
|
165 | onfulfilled?: (value: any) => any,
|
166 | onrejected?: (reason: any) => any
|
167 | ): Component<T>;
|
168 | }
|
169 |
|
170 | interface Definition extends SelectorQueryOptions {
|
171 | scope?: string;
|
172 |
|
173 | [l: string]: unknown;
|
174 | }
|
175 |
|
176 | interface FindElementOptions extends FindOptions {
|
177 | multiple?: boolean;
|
178 | }
|
179 |
|
180 | interface FindOptions extends DomElementQueryOptions, QueryFilterOptions {
|
181 | scope?: string;
|
182 | }
|
183 |
|
184 | interface TriggerOptions extends FindOptions {
|
185 | eventProperties?: object;
|
186 | }
|
187 |
|
188 | interface DomElementQueryOptions extends SelectorQueryOptions {
|
189 | pageObjectKey?: string;
|
190 | }
|
191 |
|
192 | interface SelectorQueryOptions {
|
193 | resetScope?: boolean;
|
194 | testContainer?: string|HTMLElement|JQuery;
|
195 | }
|
196 |
|
197 | interface QueryFilterOptions {
|
198 | at?: number;
|
199 | contains?: string;
|
200 | last?: boolean;
|
201 | visible?: boolean;
|
202 | }
|
203 | }
|