@cepharum/contextual-gherkin 3.0.0-beta.4 → 3.0.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +50 -10
- package/index.js +2 -0
- package/lib/api.js +6 -4
- package/lib/step-helper.js +579 -0
- package/package.json +2 -2
- package/steps/global-action.js +19 -169
- package/steps/global-find.js +8 -104
- package/steps/local-action.js +1 -42
- package/steps/local-find.js +8 -117
- package/steps/local-state.js +7 -110
package/index.d.ts
CHANGED
|
@@ -18,17 +18,24 @@ declare module "@cepharum/contextual-gherkin" {
|
|
|
18
18
|
* Inserts or augments current runtime's instance of contextual-gherkin or
|
|
19
19
|
* returns the most recently instance injected that way.
|
|
20
20
|
*
|
|
21
|
-
*
|
|
21
|
+
* Provided configuration may differ between invocations causing a previous
|
|
22
|
+
* configuration to be augmented. A browser adapter must be identical on
|
|
23
|
+
* succeeding invocations or should be omitted in follow-up invocations.
|
|
24
|
+
*
|
|
25
|
+
* When omitting both configuration and a browser adapter, a promise for
|
|
26
|
+
* some previously configured instance is returned.
|
|
27
|
+
*
|
|
28
|
+
* @param configuration runtime configuration of instance to create
|
|
22
29
|
* @param adapter interface for interacting with a browser instance
|
|
23
|
-
* @returns instance of contextual-gherkin
|
|
30
|
+
* @returns promise for instance of contextual-gherkin
|
|
24
31
|
*/
|
|
25
|
-
function ContextualGherkin(configuration?: Configuration, adapter?: BrowserAdapter): Api
|
|
32
|
+
async function ContextualGherkin(configuration?: Configuration, adapter?: BrowserAdapter): Promise<Api>;
|
|
26
33
|
|
|
27
34
|
/**
|
|
28
35
|
* Implements singleton API instance for interacting with contextual-gherkin
|
|
29
36
|
* in current runtime.
|
|
30
37
|
*/
|
|
31
|
-
class Api<B = BrowserAdapter, C = AbstractContext> {
|
|
38
|
+
class Api<B = BrowserAdapter<C, A>, C = AbstractContext, A = Assertions> {
|
|
32
39
|
/**
|
|
33
40
|
* Creates singleton instance of contextual-gherkin API in current
|
|
34
41
|
* runtime on first invocation or augments configuration of existing
|
|
@@ -43,7 +50,7 @@ declare module "@cepharum/contextual-gherkin" {
|
|
|
43
50
|
* Provides singleton instance of current runtime's contextual-gherkin
|
|
44
51
|
* API for interacting with content of one or more browser views.
|
|
45
52
|
*/
|
|
46
|
-
static access<BA =
|
|
53
|
+
static access<BA = B, AC = C, AS = A>(): Api<BA, AC, AS>;
|
|
47
54
|
|
|
48
55
|
/**
|
|
49
56
|
* Exposes normalized configuration of contextual-gherkin.
|
|
@@ -66,7 +73,7 @@ declare module "@cepharum/contextual-gherkin" {
|
|
|
66
73
|
* Exposes assertions library for assessing state of contexts addressing
|
|
67
74
|
* elements in a document.
|
|
68
75
|
*/
|
|
69
|
-
expect:
|
|
76
|
+
expect: A;
|
|
70
77
|
|
|
71
78
|
/**
|
|
72
79
|
* Fetches view considered current one.
|
|
@@ -226,7 +233,7 @@ declare module "@cepharum/contextual-gherkin" {
|
|
|
226
233
|
* Describes interface for interacting with a framework actually controlling
|
|
227
234
|
* browsers, inspecting documents and performing actions on its content.
|
|
228
235
|
*/
|
|
229
|
-
abstract class BrowserAdapter<C = AbstractContext> {
|
|
236
|
+
abstract class BrowserAdapter<C = AbstractContext, A = Assertions> {
|
|
230
237
|
/**
|
|
231
238
|
* Creates (another) view for presenting documents, querying and
|
|
232
239
|
* interacting with their elements.
|
|
@@ -254,7 +261,7 @@ declare module "@cepharum/contextual-gherkin" {
|
|
|
254
261
|
/**
|
|
255
262
|
* Provides assertions library for assessing state of elements.
|
|
256
263
|
*/
|
|
257
|
-
async getAssertions(): Promise<() =>
|
|
264
|
+
async getAssertions(): Promise<() => A>;
|
|
258
265
|
}
|
|
259
266
|
|
|
260
267
|
/**
|
|
@@ -744,7 +751,7 @@ declare module "@cepharum/contextual-gherkin" {
|
|
|
744
751
|
* @param value value to expect in a matching element's attribute
|
|
745
752
|
* @returns another context with all those elements of current one which have a matching value in named attribute
|
|
746
753
|
*/
|
|
747
|
-
withAttribute( name: string, value: string|RegExp ): Context;
|
|
754
|
+
withAttribute( name: string, value: string|RegExp|boolean ): Context;
|
|
748
755
|
|
|
749
756
|
/**
|
|
750
757
|
* Limits set of matching elements to those with a named DOM property
|
|
@@ -761,7 +768,7 @@ declare module "@cepharum/contextual-gherkin" {
|
|
|
761
768
|
* @param value value to expect in a matching element's DOM property, use callback invoked with found value to return truthy on a match
|
|
762
769
|
* @returns another context with all those elements of current one which have a matching value in named DOM property
|
|
763
770
|
*/
|
|
764
|
-
withProperty( name: string, value: string|RegExp|SelectorFn ): Context;
|
|
771
|
+
withProperty( name: string, value: string|RegExp|boolean|SelectorFn ): Context;
|
|
765
772
|
|
|
766
773
|
/**
|
|
767
774
|
* Limits set of matching elements to those with a named DOM property
|
|
@@ -856,6 +863,8 @@ declare module "@cepharum/contextual-gherkin" {
|
|
|
856
863
|
*/
|
|
857
864
|
type ContextFramework = "playwright";
|
|
858
865
|
|
|
866
|
+
type Assertions = Expect;
|
|
867
|
+
|
|
859
868
|
/**
|
|
860
869
|
* Defines actions available in a context of elements matching some query.
|
|
861
870
|
*
|
|
@@ -991,4 +1000,35 @@ declare module "@cepharum/contextual-gherkin" {
|
|
|
991
1000
|
type PlaywrightBrowserContextOptions = BrowserContextOptions;
|
|
992
1001
|
type PlaywrightBrowser = Browser;
|
|
993
1002
|
type PlaywrightLocator = Locator;
|
|
1003
|
+
|
|
1004
|
+
type Action = "click" | "hover" | "enter";
|
|
1005
|
+
|
|
1006
|
+
async function globalFind( cardinal: NumberAndWord ): Promise<void>;
|
|
1007
|
+
async function globalFindByAttribute( cardinal: NumberAndWord, name: string, value: string|RegExp ): Promise<void>;
|
|
1008
|
+
async function globalFindByProperty( cardinal: NumberAndWord, name: string, value: string|RegExp ): Promise<void>;
|
|
1009
|
+
async function globalFindByClass( cardinal: NumberAndWord, className: string, negated: boolean ): Promise<void>;
|
|
1010
|
+
async function globalFindByLabel( cardinal: NumberAndWord, label: string, partially: boolean ): Promise<void>;
|
|
1011
|
+
async function globalFindByTextContent( cardinal: NumberAndWord, text: string, partially: boolean ): Promise<void>;
|
|
1012
|
+
|
|
1013
|
+
async function globalActionByAttribute( cardinal: NumberAndWord, name: string, value: string|RegExp, action: Action, input?: string ): Promise<void>;
|
|
1014
|
+
async function globalActionByProperty( cardinal: NumberAndWord, name: string, value: string|RegExp, action: Action, input?: string ): Promise<void>;
|
|
1015
|
+
async function globalActionByClass( cardinal: NumberAndWord, className: string, negated?: boolean, action: Action, input?: string ): Promise<void>;
|
|
1016
|
+
async function globalActionByLabel( cardinal: NumberAndWord, label: string, partially: boolean, action: Action, input?: string ): Promise<void>;
|
|
1017
|
+
async function globalActionByTextContent( cardinal: NumberAndWord, text: string, partially: boolean, action: Action, input?: string ): Promise<void>;
|
|
1018
|
+
|
|
1019
|
+
async function localFind( phrase: ContextualWord, cardinal: NumberAndWord ): Promise<void>;
|
|
1020
|
+
async function localFindByAttribute( phrase: ContextualWord, cardinal: NumberAndWord, name: string, value: string|RegExp ): Promise<void>;
|
|
1021
|
+
async function localFindByProperty( phrase: ContextualWord, cardinal: NumberAndWord, name: string, value: string|RegExp ): Promise<void>;
|
|
1022
|
+
async function localFindByClass( phrase: ContextualWord, cardinal: NumberAndWord, className: string, negated: boolean ): Promise<void>;
|
|
1023
|
+
async function localFindByLabel( phrase: ContextualWord, cardinal: NumberAndWord, label: string, partially: boolean ): Promise<void>;
|
|
1024
|
+
async function localFindByTextContent( phrase: ContextualWord, cardinal: NumberAndWord, text: string, partially: boolean ): Promise<void>;
|
|
1025
|
+
|
|
1026
|
+
async function localAction( phrase: ContextualWord, action: Action, input?: string ): Promise<void>;
|
|
1027
|
+
|
|
1028
|
+
async function localStateByAttribute( phrase: ContextualWord, all: boolean, name: string, value: string|RegExp ): Promise<void>;
|
|
1029
|
+
async function localStateByProperty( phrase: ContextualWord, all: boolean, name: string, value: string|RegExp ): Promise<void>;
|
|
1030
|
+
async function localStateByClass( phrase: ContextualWord, all: boolean, className: string, negated: boolean ): Promise<void>;
|
|
1031
|
+
async function localStateByLabel( phrase: ContextualWord, label: string, partially: boolean ): Promise<void>;
|
|
1032
|
+
async function localStateByTextContent( phrase: ContextualWord, text: string, partially: boolean ): Promise<void>;
|
|
1033
|
+
async function localStateExists( phrase: ContextualWord, mustExist: boolean ): Promise<void>;
|
|
994
1034
|
}
|
package/index.js
CHANGED
|
@@ -13,6 +13,8 @@ export * from "./lib/adapter/playwright.js";
|
|
|
13
13
|
export * from "./lib/context/abstract.js";
|
|
14
14
|
export * from "./lib/context/playwright.js";
|
|
15
15
|
|
|
16
|
+
export * from "./lib/step-helper.js";
|
|
17
|
+
|
|
16
18
|
/**
|
|
17
19
|
* Configures test controller to support phrases of contextual Gherkin.
|
|
18
20
|
*
|
package/lib/api.js
CHANGED
|
@@ -157,11 +157,12 @@ export class Api {
|
|
|
157
157
|
* view in case you need a view with a dedicated session.
|
|
158
158
|
*
|
|
159
159
|
* @param {string} name name of view to provide
|
|
160
|
+
* @param {boolean} sharedSession if true, the optionally created view shares a session with current one, otherwise it runs in a different session
|
|
160
161
|
*/
|
|
161
|
-
async getViewByName( name = "default" ) {
|
|
162
|
+
async getViewByName( name = "default", sharedSession = true ) {
|
|
162
163
|
const view = this.#views.get( name );
|
|
163
164
|
|
|
164
|
-
return view == null ? await this.createView( name ) : view;
|
|
165
|
+
return view == null ? await this.createView( name, sharedSession ) : view;
|
|
165
166
|
}
|
|
166
167
|
|
|
167
168
|
/**
|
|
@@ -173,12 +174,13 @@ export class Api {
|
|
|
173
174
|
* view in case you need a view with a dedicated session.
|
|
174
175
|
*
|
|
175
176
|
* @param {string} name name of view to provide
|
|
177
|
+
* @param {boolean} sharedSession if true, the optionally created view shares a session with current one, otherwise it runs in a different session
|
|
176
178
|
*/
|
|
177
|
-
async selectViewByName( name = "default" ) {
|
|
179
|
+
async selectViewByName( name = "default", sharedSession = true ) {
|
|
178
180
|
const view = this.#views.get( name );
|
|
179
181
|
|
|
180
182
|
if ( view == null ) {
|
|
181
|
-
return await this.createView( name,
|
|
183
|
+
return await this.createView( name, sharedSession, true );
|
|
182
184
|
}
|
|
183
185
|
|
|
184
186
|
this.#currentViewName = name;
|