@cepharum/contextual-gherkin 3.0.0-beta.5 → 3.0.0
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 +33 -2
- 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/steps/global-action.js
CHANGED
|
@@ -1,108 +1,36 @@
|
|
|
1
1
|
import { When } from "@cucumber/cucumber";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
await api.expect( target.locator, `none or multiple matching $${action} target for selected ${cardinal.word} to ${input == null ? action : `enter '${input}' into`}` )
|
|
9
|
-
.toHaveCount( 1 );
|
|
10
|
-
|
|
11
|
-
// detach matches first as interacting with them might change them in a way
|
|
12
|
-
// so that the original query isn't finding them anymore (e.g. changing
|
|
13
|
-
// label of a button on click)
|
|
14
|
-
const detached = await matches.detach( cardinal.cardinality );
|
|
15
|
-
|
|
16
|
-
if ( input == null ) {
|
|
17
|
-
await target.actions[action]();
|
|
18
|
-
} else {
|
|
19
|
-
await target.actions.fill( input );
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
await detached.track( cardinal.word, cardinal.cardinality );
|
|
23
|
-
|
|
24
|
-
const wait = Number( process.env.ACTION_WAIT ) || 100;
|
|
25
|
-
if ( wait > 0 ) {
|
|
26
|
-
await api.wait( wait );
|
|
27
|
-
}
|
|
28
|
-
};
|
|
2
|
+
import {
|
|
3
|
+
globalActionByAttribute,
|
|
4
|
+
globalActionByClass,
|
|
5
|
+
globalActionByLabel,
|
|
6
|
+
globalActionByProperty, globalActionByTextContent
|
|
7
|
+
} from "../lib/step-helper.js";
|
|
29
8
|
|
|
30
9
|
When( "I click (on ){cardinal-word} with ID/id {text-or-regexp}", ( cardinal, id ) => globalActionByAttribute( cardinal, "id", id, "click" ) );
|
|
31
10
|
When( "I click (on ){cardinal-word} with name {text-or-regexp}", ( cardinal, name ) => globalActionByAttribute( cardinal, "name", name, "click" ) );
|
|
32
11
|
When( "I click (on ){cardinal-word} named {text-or-regexp}", ( cardinal, name ) => globalActionByAttribute( cardinal, "name", name, "click" ) );
|
|
12
|
+
When( "I click (on ){cardinal-word} with icon {text-or-regexp}", ( cardinal, icon ) => globalActionByAttribute( cardinal, "icon", icon, "click" ) );
|
|
33
13
|
|
|
34
14
|
When( "I hover (over ){cardinal-word} with ID/id {text-or-regexp}", ( cardinal, id ) => globalActionByAttribute( cardinal, "id", id, "hover" ) );
|
|
35
15
|
When( "I hover (over ){cardinal-word} with name {text-or-regexp}", ( cardinal, name ) => globalActionByAttribute( cardinal, "name", name, "hover" ) );
|
|
36
16
|
When( "I hover (over ){cardinal-word} named {text-or-regexp}", ( cardinal, name ) => globalActionByAttribute( cardinal, "name", name, "hover" ) );
|
|
17
|
+
When( "I hover (over ){cardinal-word} with icon {text-or-regexp}", ( cardinal, icon ) => globalActionByAttribute( cardinal, "icon", icon, "hover" ) );
|
|
37
18
|
|
|
38
19
|
When( "I enter {string-or-word} into {cardinal-word} with ID/id {text-or-regexp}", ( input, cardinal, id ) => globalActionByAttribute( cardinal, "id", id, "enter", input ) );
|
|
39
20
|
When( "I enter {string-or-word} into {cardinal-word} with name {text-or-regexp}", ( input, cardinal, name ) => globalActionByAttribute( cardinal, "name", name, "enter", input ) );
|
|
40
21
|
When( "I enter {string-or-word} into {cardinal-word} named {text-or-regexp}", ( input, cardinal, name ) => globalActionByAttribute( cardinal, "name", name, "enter", input ) );
|
|
22
|
+
When( "I enter {string-or-word} into {cardinal-word} with icon {text-or-regexp}", ( input, cardinal, icon ) => globalActionByAttribute( cardinal, "icon", icon, "enter", input ) );
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
When( "I click (on ){cardinal-word} marked/tagged as {word}", ( cardinal, className ) => globalActionByClass( cardinal, className, false, "click" ) );
|
|
26
|
+
When( "I click (on ){cardinal-word} not marked/tagged as {word}", ( cardinal, className ) => globalActionByClass( cardinal, className, true, "click" ) );
|
|
27
|
+
|
|
28
|
+
When( "I hover (over ){cardinal-word} marked/tagged as {word}", ( cardinal, className ) => globalActionByClass( cardinal, className, false, "hover" ) );
|
|
29
|
+
When( "I hover (over ){cardinal-word} not marked/tagged as {word}", ( cardinal, className ) => globalActionByClass( cardinal, className, true, "hover" ) );
|
|
30
|
+
|
|
31
|
+
When( "I enter {string-or-word} into {cardinal-word} marked/tagged as {word}", ( input, cardinal, className ) => globalActionByClass( cardinal, className, false, "enter", input ) );
|
|
32
|
+
When( "I enter {string-or-word} into {cardinal-word} not marked/tagged as {word}", ( input, cardinal, className ) => globalActionByClass( cardinal, className, true, "enter", input ) );
|
|
41
33
|
|
|
42
|
-
/**
|
|
43
|
-
* Searches for element matching a named attribute by value and performs
|
|
44
|
-
* selected action on it.
|
|
45
|
-
*
|
|
46
|
-
* @param {NumberAndWord} cardinal describes what to search
|
|
47
|
-
* @param {string|RegExp} name name of attribute to match
|
|
48
|
-
* @param {string|RegExp} value value of named attribute to match
|
|
49
|
-
* @param {'click'|'hover'|'enter'} action action to perform on found element
|
|
50
|
-
* @param {string} [input] text to enter into selected field (instead of clicking or hovering)
|
|
51
|
-
* @return {Promise<void>} promises step passed
|
|
52
|
-
*/
|
|
53
|
-
export async function globalActionByAttribute( cardinal, name, value, action, input ) {
|
|
54
|
-
const api = Api.access();
|
|
55
|
-
|
|
56
|
-
if ( cardinal.cardinality !== "singular" ) {
|
|
57
|
-
await api.expect( false, `selector is not addressing a single ${cardinal.word} to ${input == null ? action : `enter '${input}' into`}` )
|
|
58
|
-
.toEqual( true );
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const matches = api.find( cardinal.word ).withAttribute( name, value );
|
|
62
|
-
|
|
63
|
-
await api.expect( matches.locator, `no single matching ${cardinal.word} with attribute ${name} == "${value}" to ${input == null ? action : `enter '${input}' into`}` )
|
|
64
|
-
.toHaveCount( 1 );
|
|
65
|
-
|
|
66
|
-
await actAndTrack( cardinal, matches, action, input );
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
When( "I click (on ){cardinal-word} marked/tagged as {word}", ( cardinal, className ) => globalActionByClass( cardinal, className, "click", false ) );
|
|
70
|
-
When( "I click (on ){cardinal-word} not marked/tagged as {word}", ( cardinal, className ) => globalActionByClass( cardinal, className, "click", true ) );
|
|
71
|
-
|
|
72
|
-
When( "I hover (over ){cardinal-word} marked/tagged as {word}", ( cardinal, className ) => globalActionByClass( cardinal, className, "hover", false ) );
|
|
73
|
-
When( "I hover (over ){cardinal-word} not marked/tagged as {word}", ( cardinal, className ) => globalActionByClass( cardinal, className, "hover", true ) );
|
|
74
|
-
|
|
75
|
-
When( "I enter {string-or-word} into {cardinal-word} marked/tagged as {word}", ( input, cardinal, className ) => globalActionByClass( cardinal, className, "enter", false, input ) );
|
|
76
|
-
When( "I enter {string-or-word} into {cardinal-word} not marked/tagged as {word}", ( input, cardinal, className ) => globalActionByClass( cardinal, className, "enter", true, input ) );
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Searches for element matching a named attribute by value and performs
|
|
80
|
-
* selected action on it.
|
|
81
|
-
*
|
|
82
|
-
* @param {NumberAndWord} cardinal describes what to search
|
|
83
|
-
* @param {string|RegExp} className class required for match
|
|
84
|
-
* @param {'click'|'hover'|'enter'} action action to perform on found element
|
|
85
|
-
* @param {boolean} negated inverts the assertion by means of requiring one or all elements of context not to have selected class
|
|
86
|
-
* @param {string} [input] text to enter into selected field (instead of clicking or hovering)
|
|
87
|
-
* @return {Promise<void>} promises step passed
|
|
88
|
-
*/
|
|
89
|
-
export async function globalActionByClass( cardinal, className, action, negated, input ) {
|
|
90
|
-
const api = Api.access();
|
|
91
|
-
|
|
92
|
-
if ( cardinal.cardinality !== "singular" ) {
|
|
93
|
-
await api.expect( false, `selector is not addressing a single ${cardinal.word} ${negated ? "not " : ""}marked as ${className} to ${input == null ? action : `enter '${input}' into`}` )
|
|
94
|
-
.toEqual( true );
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const matches = api
|
|
98
|
-
.find( cardinal.word )
|
|
99
|
-
.withListProperty( "classList", className, negated );
|
|
100
|
-
|
|
101
|
-
await api.expect( matches.locator, `no single matching ${cardinal.word} ${negated ? "not " : ""}marked as ${className} to ${input == null ? action : `enter '${input}' into`}` )
|
|
102
|
-
.toHaveCount( 1 );
|
|
103
|
-
|
|
104
|
-
await actAndTrack( cardinal, matches, action, input );
|
|
105
|
-
}
|
|
106
34
|
|
|
107
35
|
When( "I click (on ){cardinal-word} with value {text-or-regexp}", ( cardinal, value ) => globalActionByProperty( cardinal, "value", value, "click" ) );
|
|
108
36
|
|
|
@@ -110,32 +38,6 @@ When( "I hover (over ){cardinal-word} with value {text-or-regexp}", ( cardinal,
|
|
|
110
38
|
|
|
111
39
|
When( "I enter {string-or-word} into {cardinal-word} with value {text-or-regexp}", ( input, cardinal, value ) => globalActionByProperty( cardinal, "value", value, "enter", input ) );
|
|
112
40
|
|
|
113
|
-
/**
|
|
114
|
-
* Searches for element matching a named DOM property by value and performs
|
|
115
|
-
* selected action on it.
|
|
116
|
-
*
|
|
117
|
-
* @param {NumberAndWord} cardinal describes what to search
|
|
118
|
-
* @param {string|RegExp} name name of attribute to match
|
|
119
|
-
* @param {string|RegExp} value value of named attribute to match
|
|
120
|
-
* @param {'click'|'hover'|'enter'} action action to perform on found element
|
|
121
|
-
* @param {string} [input] text to enter into selected field (instead of clicking or hovering)
|
|
122
|
-
* @return {Promise<void>} promises step passed
|
|
123
|
-
*/
|
|
124
|
-
export async function globalActionByProperty( cardinal, name, value, action, input ) {
|
|
125
|
-
const api = Api.access();
|
|
126
|
-
|
|
127
|
-
if ( cardinal.cardinality !== "singular" ) {
|
|
128
|
-
await api.expect( false, `selector is not addressing a single ${cardinal.word} with property ${name} == "${value}" to ${input == null ? action : `enter '${input}' into`}` )
|
|
129
|
-
.toEqual( true );
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
const matches = api.find( cardinal.word ).withProperty( name, value );
|
|
133
|
-
|
|
134
|
-
await api.expect( matches.locator, `no single matching ${cardinal.word} with property ${name} == "${value}" to ${input == null ? action : `enter '${input}' into`}` )
|
|
135
|
-
.toHaveCount( 1 );
|
|
136
|
-
|
|
137
|
-
await actAndTrack( cardinal, matches, action, input );
|
|
138
|
-
}
|
|
139
41
|
|
|
140
42
|
When( "I click (on ){cardinal-word} with label {text-or-regexp}", ( cardinal, label ) => globalActionByLabel( cardinal, label, false, "click" ) );
|
|
141
43
|
When( "I click (on ){cardinal-word} with partial label {text-or-regexp}", ( cardinal, label ) => globalActionByLabel( cardinal, label, true, "click" ) );
|
|
@@ -152,32 +54,6 @@ When( "I enter {string-or-word} into {cardinal-word} with partial label {text-or
|
|
|
152
54
|
When( "I enter {string-or-word} into {cardinal-word} labelled with {text-or-regexp}", ( input, cardinal, label ) => globalActionByLabel( cardinal, label, false, "enter", input ) );
|
|
153
55
|
When( "I enter {string-or-word} into {cardinal-word} partially labelled with {text-or-regexp}", ( input, cardinal, label ) => globalActionByLabel( cardinal, label, false, "enter", input ) );
|
|
154
56
|
|
|
155
|
-
/**
|
|
156
|
-
* Searches for type of element with a certain label and performs selected
|
|
157
|
-
* action on it.
|
|
158
|
-
*
|
|
159
|
-
* @param {NumberAndWord} cardinal provides cardinal number and word
|
|
160
|
-
* @param {string} label provides required label of matching element(s)
|
|
161
|
-
* @param {boolean} partially if true, provided text does not have to match whole content of matching subs
|
|
162
|
-
* @param {'click'|'hover'|'enter'} action action to perform on found element
|
|
163
|
-
* @param {string} [input] text to enter into selected field (instead of clicking or hovering)
|
|
164
|
-
* @returns {Promise<void>} promises step passed
|
|
165
|
-
*/
|
|
166
|
-
export async function globalActionByLabel( cardinal, label, partially, action, input ) {
|
|
167
|
-
const api = Api.access();
|
|
168
|
-
|
|
169
|
-
if ( cardinal.cardinality !== "singular" ) {
|
|
170
|
-
await api.expect( false, `selector is not addressing a single ${cardinal.word} with ${partially ? "partial " : ""}label "${label}" to ${input == null ? action : `enter '${input}' into`}` )
|
|
171
|
-
.toEqual( true );
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
const matches = api.find( cardinal.word ).filterBySubsWithText( "$label", "label", label, partially );
|
|
175
|
-
|
|
176
|
-
await api.expect( matches.locator, `no single matching ${cardinal.word} with ${partially ? "partial " : ""}label "${label}" to ${input == null ? action : `enter '${input}' into`}` )
|
|
177
|
-
.toHaveCount( 1 );
|
|
178
|
-
|
|
179
|
-
await actAndTrack( cardinal, matches, action, input );
|
|
180
|
-
}
|
|
181
57
|
|
|
182
58
|
When( "I click (on ){cardinal-word} reading {text-or-regexp}", ( cardinal, text ) => globalActionByTextContent( cardinal, text, false, "click" ) );
|
|
183
59
|
When( "I click (on ){cardinal-word} with text {text-or-regexp}", ( cardinal, text ) => globalActionByTextContent( cardinal, text, false, "click" ) );
|
|
@@ -194,29 +70,3 @@ When( "I enter {string-or-word} into {cardinal-word} with text {text-or-regexp}"
|
|
|
194
70
|
When( "I enter {string-or-word} into {cardinal-word} partially reading {text-or-regexp}", ( input, cardinal, text ) => globalActionByTextContent( cardinal, text, true, "enter", input ) );
|
|
195
71
|
When( "I enter {string-or-word} into {cardinal-word} with partial text {text-or-regexp}", ( input, cardinal, text ) => globalActionByTextContent( cardinal, text, true, "enter", input ) );
|
|
196
72
|
|
|
197
|
-
/**
|
|
198
|
-
* Searches for type of element with given text content and performs selected
|
|
199
|
-
* action on it.
|
|
200
|
-
*
|
|
201
|
-
* @param {NumberAndWord} cardinal provides cardinal number and word
|
|
202
|
-
* @param {string} text provides text to be found in eventually matching element(s)
|
|
203
|
-
* @param {boolean} partially if true, provided text does not have to match whole content of matching subs
|
|
204
|
-
* @param {'click'|'hover'|'enter'} action action to perform on found element
|
|
205
|
-
* @param {string} [input] text to enter into selected field (instead of clicking or hovering)
|
|
206
|
-
* @returns {Promise<void>} promises step passed
|
|
207
|
-
*/
|
|
208
|
-
export async function globalActionByTextContent( cardinal, text, partially, action, input ) {
|
|
209
|
-
const api = Api.access();
|
|
210
|
-
|
|
211
|
-
if ( cardinal.cardinality !== "singular" ) {
|
|
212
|
-
await api.expect( false, `selector is not addressing a single ${cardinal.word} ${partially ? "partially " : ""}reading "${text}" to ${input == null ? action : `enter '${input}' into`}` )
|
|
213
|
-
.toEqual( true );
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
const matches = api.find( cardinal.word ).filterBySubsWithText( "$text", false, text, partially );
|
|
217
|
-
|
|
218
|
-
await api.expect( matches.locator, `no single matching ${cardinal.word} ${partially ? "partially " : ""}reading "${text}" to ${input == null ? action : `enter '${input}' into`}` )
|
|
219
|
-
.toHaveCount( 1 );
|
|
220
|
-
|
|
221
|
-
await actAndTrack( cardinal, matches, action, input );
|
|
222
|
-
}
|
package/steps/global-find.js
CHANGED
|
@@ -1,44 +1,21 @@
|
|
|
1
1
|
import { Given } from "@cucumber/cucumber";
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import {
|
|
3
|
+
globalFind,
|
|
4
|
+
globalFindByAttribute,
|
|
5
|
+
globalFindByClass,
|
|
6
|
+
globalFindByLabel,
|
|
7
|
+
globalFindByProperty, globalFindByTextContent
|
|
8
|
+
} from "../lib/step-helper.js";
|
|
4
9
|
|
|
5
10
|
Given( "there is/are {cardinal-word}", globalFind );
|
|
6
11
|
Given( "there is a list/set of {cardinal-word}", globalFind );
|
|
7
12
|
|
|
8
|
-
/**
|
|
9
|
-
* Searches for type of elements with a certain label.
|
|
10
|
-
*
|
|
11
|
-
* @param {NumberAndWord} cardinal provides cardinal number and word
|
|
12
|
-
* @returns {Promise<void>} promises step passed
|
|
13
|
-
*/
|
|
14
|
-
export async function globalFind( cardinal ) {
|
|
15
|
-
const api = Api.access();
|
|
16
|
-
|
|
17
|
-
await api
|
|
18
|
-
.find( cardinal.word )
|
|
19
|
-
.checkCardinalWord( cardinal );
|
|
20
|
-
}
|
|
21
13
|
|
|
22
14
|
Given( "there is/are {cardinal-word} with ID/id {text-or-regexp}", ( cardinal, id ) => globalFindByAttribute( cardinal, "id", id ) );
|
|
23
15
|
Given( "there is/are {cardinal-word} with name {text-or-regexp}", ( cardinal, name ) => globalFindByAttribute( cardinal, "name", name ) );
|
|
24
16
|
Given( "there is/are {cardinal-word} named {text-or-regexp}", ( cardinal, name ) => globalFindByAttribute( cardinal, "name", name ) );
|
|
17
|
+
Given( "there is/are {cardinal-word} with icon {text-or-regexp}", ( cardinal, icon ) => globalFindByAttribute( cardinal, "icon", icon ) );
|
|
25
18
|
|
|
26
|
-
/**
|
|
27
|
-
* Searches for element(s) matching a named attribute by value.
|
|
28
|
-
*
|
|
29
|
-
* @param {NumberAndWord} cardinal describes what to search
|
|
30
|
-
* @param {string|RegExp} name name of attribute to match
|
|
31
|
-
* @param {string|RegExp|boolean} value value of named attribute to match, boolean value to explicitly test for named attribute being truthy or falsy
|
|
32
|
-
* @return {Promise<void>} promises step passed
|
|
33
|
-
*/
|
|
34
|
-
export async function globalFindByAttribute( cardinal, name, value ) {
|
|
35
|
-
const api = Api.access();
|
|
36
|
-
|
|
37
|
-
await api
|
|
38
|
-
.find( cardinal.word )
|
|
39
|
-
.withAttribute( name, value )
|
|
40
|
-
.checkCardinalWord( cardinal, true, `expected %amount with ${name} ${sOp( value )} ${value}` );
|
|
41
|
-
}
|
|
42
19
|
|
|
43
20
|
Given( "there is/are {cardinal-word} with value {text-or-regexp}", ( cardinal, value ) => globalFindByProperty( cardinal, "value", value ) );
|
|
44
21
|
Given( "there is/are {cardinal-word} which is/are enabled", cardinal => globalFindByProperty( cardinal, "disabled", false ) );
|
|
@@ -50,91 +27,18 @@ Given( "there is/are {cardinal-word} which is/are selected", cardinal => globalF
|
|
|
50
27
|
Given( "there is/are {cardinal-word} which is/are not selected", cardinal => globalFindByProperty( cardinal, "selected", false ) );
|
|
51
28
|
Given( "there is/are {cardinal-word} which is/are unselected", cardinal => globalFindByProperty( cardinal, "selected", false ) );
|
|
52
29
|
|
|
53
|
-
/**
|
|
54
|
-
* Searches for element(s) matching a named DOM property by value.
|
|
55
|
-
*
|
|
56
|
-
* @param {NumberAndWord} cardinal describes what to search
|
|
57
|
-
* @param {string} name name of DOM property to match
|
|
58
|
-
* @param {string|boolean} value value of named DOM property to match, or boolean value to explicitly test if property is truthy or falsy
|
|
59
|
-
* @return {Promise<void>} promises step passed
|
|
60
|
-
*/
|
|
61
|
-
export async function globalFindByProperty( cardinal, name, value ) {
|
|
62
|
-
const api = Api.access();
|
|
63
|
-
|
|
64
|
-
let text;
|
|
65
|
-
|
|
66
|
-
if ( typeof value === "boolean" ) {
|
|
67
|
-
text = `${value ? "not " : ""}${name}`;
|
|
68
|
-
} else {
|
|
69
|
-
text = `with ${name} ${sOp( value )} ${value}`;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
await api
|
|
73
|
-
.find( cardinal.word )
|
|
74
|
-
.withProperty( name, value )
|
|
75
|
-
.checkCardinalWord( cardinal, true, `expected %amount ${text}` );
|
|
76
|
-
}
|
|
77
30
|
|
|
78
31
|
Given( "there is/are {cardinal-word} marked/tagged as {word}", ( cardinal, mark ) => globalFindByClass( cardinal, mark, false ) );
|
|
79
32
|
Given( "there is/are {cardinal-word} not marked/tagged as {word}", ( cardinal, mark ) => globalFindByClass( cardinal, mark, true ) );
|
|
80
33
|
|
|
81
|
-
/**
|
|
82
|
-
* Searches for element(s) with a named class set.
|
|
83
|
-
*
|
|
84
|
-
* @param {NumberAndWord} cardinal describes what to search
|
|
85
|
-
* @param {string} className name of class to test
|
|
86
|
-
* @param {boolean} negated inverts the assertion by means of requiring one or all elements of context not to have selected class
|
|
87
|
-
* @return {Promise<void>} promises step passed
|
|
88
|
-
*/
|
|
89
|
-
export async function globalFindByClass( cardinal, className, negated ) {
|
|
90
|
-
const api = Api.access();
|
|
91
|
-
const matches = api
|
|
92
|
-
.find( cardinal.word )
|
|
93
|
-
.withListProperty( "classList", className, negated );
|
|
94
|
-
|
|
95
|
-
await matches.checkCardinalWord( cardinal, true, `expected %amount ${negated ? "not " : ""}marked as "${className}"` );
|
|
96
|
-
}
|
|
97
34
|
|
|
98
35
|
Given( "there is/are {cardinal-word} with label {text-or-regexp}", ( cardinal, label ) => globalFindByLabel( cardinal, label, false ) );
|
|
99
36
|
Given( "there is/are {cardinal-word} with partial label {text-or-regexp}", ( cardinal, label ) => globalFindByLabel( cardinal, label, true ) );
|
|
100
37
|
Given( "there is/are {cardinal-word} labelled with {text-or-regexp}", ( cardinal, label ) => globalFindByLabel( cardinal, label, false ) );
|
|
101
38
|
Given( "there is/are {cardinal-word} partially labelled with {text-or-regexp}", ( cardinal, label ) => globalFindByLabel( cardinal, label, false ) );
|
|
102
39
|
|
|
103
|
-
/**
|
|
104
|
-
* Searches for type of elements with a certain label.
|
|
105
|
-
*
|
|
106
|
-
* @param {NumberAndWord} cardinal provides cardinal number and word
|
|
107
|
-
* @param {string} label provides required label of matching element(s)
|
|
108
|
-
* @param {boolean} partially if true, provided text does not have to match whole content of matching subs
|
|
109
|
-
* @returns {Promise<void>} promises step passed
|
|
110
|
-
*/
|
|
111
|
-
export async function globalFindByLabel( cardinal, label, partially ) {
|
|
112
|
-
const api = Api.access();
|
|
113
|
-
|
|
114
|
-
await api
|
|
115
|
-
.find( cardinal.word )
|
|
116
|
-
.filterBySubsWithText( "$label", "label", label, partially )
|
|
117
|
-
.checkCardinalWord( cardinal, true, `expected %amount ${partially ? "partially " : ""}labelled with "${label}"` );
|
|
118
|
-
}
|
|
119
40
|
|
|
120
41
|
Given( "there is/are {cardinal-word} reading {text-or-regexp}", ( cardinal, text ) => globalFindByTextContent( cardinal, text, false ) );
|
|
121
42
|
Given( "there is/are {cardinal-word} with text {text-or-regexp}", ( cardinal, text ) => globalFindByTextContent( cardinal, text, false ) );
|
|
122
43
|
Given( "there is/are {cardinal-word} partially reading {text-or-regexp}", ( cardinal, text ) => globalFindByTextContent( cardinal, text, true ) );
|
|
123
44
|
Given( "there is/are {cardinal-word} with partial text {text-or-regexp}", ( cardinal, text ) => globalFindByTextContent( cardinal, text, true ) );
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Searches for type of elements with a certain label.
|
|
127
|
-
*
|
|
128
|
-
* @param {NumberAndWord} cardinal provides cardinal number and word
|
|
129
|
-
* @param {string} text provides text to be found in eventually matching element(s)
|
|
130
|
-
* @param {boolean} partially if true, provided text does not have to match whole content of matching subs
|
|
131
|
-
* @returns {Promise<void>} promises step passed
|
|
132
|
-
*/
|
|
133
|
-
export async function globalFindByTextContent( cardinal, text, partially ) {
|
|
134
|
-
const api = Api.access();
|
|
135
|
-
|
|
136
|
-
await api
|
|
137
|
-
.find( cardinal.word )
|
|
138
|
-
.filterBySubsWithText( "$text", false, text, partially )
|
|
139
|
-
.checkCardinalWord( cardinal, true, `expected %amount ${partially ? "partially " : ""}reading "${text}"` );
|
|
140
|
-
}
|
package/steps/local-action.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { When } from "@cucumber/cucumber";
|
|
2
|
-
import {
|
|
2
|
+
import { localAction } from "../lib/step-helper.js";
|
|
3
3
|
|
|
4
4
|
When( "I click (on ){contextual-word}", context => localAction( context, "click" ) );
|
|
5
5
|
|
|
@@ -7,44 +7,3 @@ When( "I hover (over ){contextual-word}", context => localAction( context, "hove
|
|
|
7
7
|
|
|
8
8
|
When( "I enter {string-or-word} into {contextual-word}", ( input, context ) => localAction( context, "enter", input ) );
|
|
9
9
|
|
|
10
|
-
/**
|
|
11
|
-
* Searches for type of element in current context and performs selected action
|
|
12
|
-
* on it.
|
|
13
|
-
*
|
|
14
|
-
* @param {ContextualWord} phrase description of element to be clicked.
|
|
15
|
-
* @param {'click'|'hover'|'enter'} action action to perform on found element
|
|
16
|
-
* @param {string} [input] text to enter into selected field (instead of clicking or hovering)
|
|
17
|
-
* @returns {Promise<void>} promises element clicked
|
|
18
|
-
*/
|
|
19
|
-
export async function localAction( phrase, action, input ) {
|
|
20
|
-
const api = Api.access();
|
|
21
|
-
const context = api.getContextFor( phrase );
|
|
22
|
-
|
|
23
|
-
await api.expect( context.locator, `no single matching ${phrase.word} to ${input == null ? action : `enter '${input}' into`}` )
|
|
24
|
-
.toHaveCount( 1 );
|
|
25
|
-
|
|
26
|
-
const target = context.find( "$" + action, false );
|
|
27
|
-
|
|
28
|
-
await api.expect( target.locator, `no single matching $${action} target for selected ${phrase.word} to ${input == null ? action : `enter '${input}' into`}` )
|
|
29
|
-
.toHaveCount( 1 );
|
|
30
|
-
|
|
31
|
-
// detach matches first as interacting with them might change them in a way
|
|
32
|
-
// so that the original query isn't finding them anymore (e.g. changing
|
|
33
|
-
// label of a button on click)
|
|
34
|
-
const detached = await context.detach( phrase.targetCardinality );
|
|
35
|
-
|
|
36
|
-
if ( input == null ) {
|
|
37
|
-
await target.actions[action]();
|
|
38
|
-
} else {
|
|
39
|
-
await target.actions.fill( input );
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if ( phrase.isRefining ) {
|
|
43
|
-
await detached.track( phrase.word, phrase.targetCardinality );
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const wait = Number( process.env.ACTION_WAIT ) || 100;
|
|
47
|
-
if ( wait > 0 ) {
|
|
48
|
-
await api.wait( wait );
|
|
49
|
-
}
|
|
50
|
-
}
|
package/steps/local-find.js
CHANGED
|
@@ -1,49 +1,21 @@
|
|
|
1
1
|
import { Given } from "@cucumber/cucumber";
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import {
|
|
3
|
+
localFind,
|
|
4
|
+
localFindByAttribute,
|
|
5
|
+
localFindByClass,
|
|
6
|
+
localFindByLabel,
|
|
7
|
+
localFindByProperty, localFindByTextContent
|
|
8
|
+
} from "../lib/step-helper.js";
|
|
4
9
|
|
|
5
10
|
Given( "{contextual-word} has/have {cardinal-word}", ( context, cardinal ) => localFind( context, cardinal ) );
|
|
6
11
|
Given( "{contextual-word} has/have a list/set of {cardinal-word}", ( context, cardinal ) => localFind( context, cardinal ) );
|
|
7
12
|
|
|
8
|
-
/**
|
|
9
|
-
* Finds elements in context of containing elements.
|
|
10
|
-
*
|
|
11
|
-
* @param {ContextualWord} phrase describes context of search
|
|
12
|
-
* @param {NumberAndWord} cardinal describes what to search
|
|
13
|
-
* @return {Promise<void>} promises step passed
|
|
14
|
-
*/
|
|
15
|
-
export async function localFind( phrase, cardinal ) {
|
|
16
|
-
const api = Api.access();
|
|
17
|
-
const context = api.getContextFor( phrase );
|
|
18
|
-
|
|
19
|
-
await context
|
|
20
|
-
.find( cardinal.word )
|
|
21
|
-
.checkCardinalWord( cardinal );
|
|
22
|
-
}
|
|
23
13
|
|
|
24
14
|
Given( "{contextual-word} has/have {cardinal-word} with ID/id {text-or-regexp}", ( context, cardinal, id ) => localFindByAttribute( context, cardinal, "id", id ) );
|
|
25
15
|
Given( "{contextual-word} has/have {cardinal-word} with name {text-or-regexp}", ( context, cardinal, name ) => localFindByAttribute( context, cardinal, "name", name ) );
|
|
26
16
|
Given( "{contextual-word} has/have {cardinal-word} named {text-or-regexp}", ( context, cardinal, name ) => localFindByAttribute( context, cardinal, "name", name ) );
|
|
17
|
+
Given( "{contextual-word} has/have {cardinal-word} with icon {text-or-regexp}", ( context, cardinal, icon ) => localFindByAttribute( context, cardinal, "icon", icon ) );
|
|
27
18
|
|
|
28
|
-
/**
|
|
29
|
-
* Finds elements in context of containing elements matching a named attribute
|
|
30
|
-
* by value.
|
|
31
|
-
*
|
|
32
|
-
* @param {ContextualWord} phrase describes context of search
|
|
33
|
-
* @param {NumberAndWord} cardinal describes what to search
|
|
34
|
-
* @param {string|RegExp} name name of attribute to match
|
|
35
|
-
* @param {string|RegExp} value value of named attribute to match
|
|
36
|
-
* @return {Promise<void>} promises step passed
|
|
37
|
-
*/
|
|
38
|
-
export async function localFindByAttribute( phrase, cardinal, name, value ) {
|
|
39
|
-
const api = Api.access();
|
|
40
|
-
const context = api.getContextFor( phrase );
|
|
41
|
-
|
|
42
|
-
await context
|
|
43
|
-
.find( cardinal.word )
|
|
44
|
-
.withAttribute( name, value )
|
|
45
|
-
.checkCardinalWord( cardinal, true, `expected %amount with ${name} ${sOp( value )} ${value}` );
|
|
46
|
-
}
|
|
47
19
|
|
|
48
20
|
Given( "{contextual-word} has/have {cardinal-word} with value {text-or-regexp}", ( context, cardinal, value ) => localFindByProperty( context, cardinal, "value", value ) );
|
|
49
21
|
Given( "{contextual-word} has/have {cardinal-word} which is/are enabled", ( context, cardinal ) => localFindByProperty( context, cardinal, "disabled", false ) );
|
|
@@ -52,99 +24,18 @@ Given( "{contextual-word} has/have {cardinal-word} which is/are checked", ( cont
|
|
|
52
24
|
Given( "{contextual-word} has/have {cardinal-word} which is/are not checked", ( context, cardinal ) => localFindByProperty( context, cardinal, "checked", false ) );
|
|
53
25
|
Given( "{contextual-word} has/have {cardinal-word} which is/are unchecked", ( context, cardinal ) => localFindByProperty( context, cardinal, "checked", false ) );
|
|
54
26
|
|
|
55
|
-
/**
|
|
56
|
-
* Finds elements in context of containing elements matching a named DOM
|
|
57
|
-
* property by value.
|
|
58
|
-
*
|
|
59
|
-
* @param {ContextualWord} phrase describes context of search
|
|
60
|
-
* @param {NumberAndWord} cardinal describes what to search
|
|
61
|
-
* @param {string} name name of DOM property to match
|
|
62
|
-
* @param {string|boolean} value value of named DOM property to match, or boolean to explicitly test named property for being truthy or falsy
|
|
63
|
-
* @return {Promise<void>} promises step passed
|
|
64
|
-
*/
|
|
65
|
-
export async function localFindByProperty( phrase, cardinal, name, value ) {
|
|
66
|
-
const api = Api.access();
|
|
67
|
-
const context = api.getContextFor( phrase );
|
|
68
|
-
let text;
|
|
69
|
-
|
|
70
|
-
if ( typeof value === "boolean" ) {
|
|
71
|
-
text = `${value ? "" : "not "}${name}`;
|
|
72
|
-
} else {
|
|
73
|
-
text = `with ${name} ${value instanceof RegExp ? "matching" : "equals"} ${value}`;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
await context
|
|
77
|
-
.find( cardinal.word )
|
|
78
|
-
.withProperty( name, value )
|
|
79
|
-
.checkCardinalWord( cardinal, true, `expected %amount ${text}` );
|
|
80
|
-
}
|
|
81
27
|
|
|
82
28
|
Given( "{contextual-word} has/have {cardinal-word} marked/tagged as {word}", ( context, cardinal, className ) => localFindByClass( context, cardinal, className, false ) );
|
|
83
29
|
Given( "{contextual-word} has/have {cardinal-word} not marked/tagged as {word}", ( context, cardinal, className ) => localFindByClass( context, cardinal, className, true ) );
|
|
84
30
|
|
|
85
|
-
/**
|
|
86
|
-
* Finds elements in context of containing elements with named class.
|
|
87
|
-
*
|
|
88
|
-
* @param {ContextualWord} phrase describes context of search
|
|
89
|
-
* @param {NumberAndWord} cardinal describes what to search
|
|
90
|
-
* @param {string} className name of class to check
|
|
91
|
-
* @param {boolean} negated inverts the assertion by means of requiring one or all elements of context not to have selected class
|
|
92
|
-
* @return {Promise<void>} promises step passed
|
|
93
|
-
*/
|
|
94
|
-
export async function localFindByClass( phrase, cardinal, className, negated ) {
|
|
95
|
-
const api = Api.access();
|
|
96
|
-
const context = api.getContextFor( phrase );
|
|
97
|
-
const matches = context.find( cardinal.word );
|
|
98
|
-
|
|
99
|
-
await matches
|
|
100
|
-
.withListProperty( "classList", className, negated )
|
|
101
|
-
.checkCardinalWord( cardinal, true, `expected %amount ${negated ? "not " : ""}marked as "${className}"` );
|
|
102
|
-
}
|
|
103
31
|
|
|
104
32
|
Given( "{contextual-word} has/have {cardinal-word} with label {text-or-regexp}", ( context, cardinal, label ) => localFindByLabel( context, cardinal, label, false ) );
|
|
105
33
|
Given( "{contextual-word} has/have {cardinal-word} with partial label {text-or-regexp}", ( context, cardinal, label ) => localFindByLabel( context, cardinal, label, true ) );
|
|
106
34
|
Given( "{contextual-word} has/have {cardinal-word} labelled with {text-or-regexp}", ( context, cardinal, label ) => localFindByLabel( context, cardinal, label, false ) );
|
|
107
35
|
Given( "{contextual-word} has/have {cardinal-word} partially labelled with {text-or-regexp}", ( context, cardinal, label ) => localFindByLabel( context, cardinal, label, true ) );
|
|
108
36
|
|
|
109
|
-
/**
|
|
110
|
-
* Finds elements in context of containing elements with a given label.
|
|
111
|
-
*
|
|
112
|
-
* @param {ContextualWord} phrase describes context of search
|
|
113
|
-
* @param {NumberAndWord} cardinal describes what to search
|
|
114
|
-
* @param {string} label expected label of item(s) to find
|
|
115
|
-
* @param {boolean} partially if true, provided text does not have to match whole content of matching subs
|
|
116
|
-
* @return {Promise<void>} promises step passed
|
|
117
|
-
*/
|
|
118
|
-
export async function localFindByLabel( phrase, cardinal, label, partially ) {
|
|
119
|
-
const api = Api.access();
|
|
120
|
-
const context = api.getContextFor( phrase );
|
|
121
|
-
|
|
122
|
-
await context
|
|
123
|
-
.find( cardinal.word )
|
|
124
|
-
.filterBySubsWithText( "$label", "label", label, partially )
|
|
125
|
-
.checkCardinalWord( cardinal, true, `expected %amount ${partially ? "partially " : ""}labelled with "${label}"` );
|
|
126
|
-
}
|
|
127
37
|
|
|
128
38
|
Given( "{contextual-word} has/have {cardinal-word} reading {text-or-regexp}", ( context, cardinal, text ) => localFindByTextContent( context, cardinal, text, false ) );
|
|
129
39
|
Given( "{contextual-word} has/have {cardinal-word} with text {text-or-regexp}", ( context, cardinal, text ) => localFindByTextContent( context, cardinal, text, false ) );
|
|
130
40
|
Given( "{contextual-word} has/have {cardinal-word} partially reading {text-or-regexp}", ( context, cardinal, text ) => localFindByTextContent( context, cardinal, text, true ) );
|
|
131
41
|
Given( "{contextual-word} has/have {cardinal-word} with partial text {text-or-regexp}", ( context, cardinal, text ) => localFindByTextContent( context, cardinal, text, true ) );
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Finds elements in context of containing elements containing given text.
|
|
135
|
-
*
|
|
136
|
-
* @param {ContextualWord} phrase describes context of search
|
|
137
|
-
* @param {NumberAndWord} cardinal describes what to search
|
|
138
|
-
* @param {string} text provides expected text content of item(s) to find
|
|
139
|
-
* @param {boolean} partially if true, provided text does not have to match whole content of matching subs
|
|
140
|
-
* @return {Promise<void>} promises step passed
|
|
141
|
-
*/
|
|
142
|
-
export async function localFindByTextContent( phrase, cardinal, text, partially ) {
|
|
143
|
-
const api = Api.access();
|
|
144
|
-
const context = api.getContextFor( phrase );
|
|
145
|
-
|
|
146
|
-
await context
|
|
147
|
-
.find( cardinal.word )
|
|
148
|
-
.filterBySubsWithText( "$text", false, text, partially )
|
|
149
|
-
.checkCardinalWord( cardinal, true, `expected %amount ${partially ? "partially " : ""}reading "${text}"` );
|
|
150
|
-
}
|