@cepharum/contextual-gherkin 1.2.1 → 1.2.2
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/cli.js +2 -2
- package/package.json +2 -2
- package/steps/global-action.js +42 -17
package/cli.js
CHANGED
|
@@ -6,6 +6,7 @@ const Path = require( "node:path" );
|
|
|
6
6
|
const os = require( "node:os" );
|
|
7
7
|
|
|
8
8
|
const semver = require( "semver" );
|
|
9
|
+
const { getShellConfigurationSync, quote } = require( "@cepharum/quoting-db" );
|
|
9
10
|
|
|
10
11
|
const cgFolder = "./node_modules/@cepharum/contextual-gherkin";
|
|
11
12
|
const isWindows = os.platform() === "win32";
|
|
@@ -148,8 +149,7 @@ const isWindows = os.platform() === "win32";
|
|
|
148
149
|
}
|
|
149
150
|
|
|
150
151
|
if ( spawnOptions.shell ) {
|
|
151
|
-
const
|
|
152
|
-
const configuration = await getShellConfiguration();
|
|
152
|
+
const configuration = getShellConfigurationSync( spawnOptions.shell );
|
|
153
153
|
|
|
154
154
|
sanitizer = argument => quote( argument, configuration );
|
|
155
155
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cepharum/contextual-gherkin",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "flexible step definitions for Gherkin",
|
|
5
5
|
"author": "cepharum GmbH <thomas.urban@cepharum.de>",
|
|
6
6
|
"homepage": "https://cepharum-foss.gitlab.io/contextual-gherkin/",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
},
|
|
13
13
|
"keywords": [],
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@cepharum/quoting-db": "^1.
|
|
15
|
+
"@cepharum/quoting-db": "^1.2.0",
|
|
16
16
|
"pluralize": "^8.0.0",
|
|
17
17
|
"semver": "^7.5.0"
|
|
18
18
|
},
|
package/steps/global-action.js
CHANGED
|
@@ -5,8 +5,8 @@ const actAndTrack = async( testController, cardinal, refined, action, input ) =>
|
|
|
5
5
|
const target = await refined.find( "$" + action, false );
|
|
6
6
|
const targetCount = await target.matches.count;
|
|
7
7
|
|
|
8
|
-
await testController.expect( targetCount ).gt( 0, `there is no $${action} target for selected ${cardinal.word} to ${input == null ? action :
|
|
9
|
-
await testController.expect( targetCount ).eql( 1, `there is no single $${action} target for selected ${cardinal.word} to ${input == null ? action :
|
|
8
|
+
await testController.expect( targetCount ).gt( 0, `there is no $${action} target for selected ${cardinal.word} to ${input == null ? action : `enter '${input}' into`}` ); // eslint-disable-line max-len
|
|
9
|
+
await testController.expect( targetCount ).eql( 1, `there is no single $${action} target for selected ${cardinal.word} to ${input == null ? action : `enter '${input}' into`}` ); // eslint-disable-line max-len
|
|
10
10
|
|
|
11
11
|
await refined.detach();
|
|
12
12
|
|
|
@@ -44,7 +44,7 @@ When( "I enter {string-or-word} into {cardinal-word} named {text-or-regexp}", (
|
|
|
44
44
|
* @param {NumberAndWord} cardinal describes what to search
|
|
45
45
|
* @param {string|RegExp} name name of attribute to match
|
|
46
46
|
* @param {string|RegExp} value value of named attribute to match
|
|
47
|
-
* @param {'click'|'hover'} action action to perform on found element
|
|
47
|
+
* @param {'click'|'hover'|'enter'} action action to perform on found element
|
|
48
48
|
* @param {string} input text to enter into selected field (instead of clicking or hovering)
|
|
49
49
|
* @return {Promise<void>} promises step passed
|
|
50
50
|
*/
|
|
@@ -54,11 +54,16 @@ async function globalActionByAttribute( testController, cardinal, name, value, a
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
const matches = await Api.access( testController ).find( cardinal.word );
|
|
57
|
+
|
|
58
|
+
if ( cardinal.cardinality !== "singular" ) {
|
|
59
|
+
await testController.expect( false ).eql( true, `selector is not addressing a single ${cardinal.word} to ${input == null ? action : `enter '${input}' into`}` ); // eslint-disable-line max-len
|
|
60
|
+
}
|
|
61
|
+
|
|
57
62
|
const refined = await matches.withAttribute( name, value );
|
|
58
63
|
const matchCount = await refined.matches.count;
|
|
59
64
|
|
|
60
|
-
await testController.expect( matchCount ).gt( 0, `there is no matching ${cardinal.word} with attribute ${name} == "${value}" to ${input == null ? action :
|
|
61
|
-
await testController.expect( matchCount ).eql( 1, `there is no single matching ${cardinal.word} with attribute ${name} == "${value}" to ${input == null ? action :
|
|
65
|
+
await testController.expect( matchCount ).gt( 0, `there is no matching ${cardinal.word} with attribute ${name} == "${value}" to ${input == null ? action : `enter '${input}' into`}` ); // eslint-disable-line max-len
|
|
66
|
+
await testController.expect( matchCount ).eql( 1, `there is no single matching ${cardinal.word} with attribute ${name} == "${value}" to ${input == null ? action : `enter '${input}' into`}` ); // eslint-disable-line max-len
|
|
62
67
|
|
|
63
68
|
await actAndTrack( testController, cardinal, refined, action, input );
|
|
64
69
|
}
|
|
@@ -79,7 +84,7 @@ When( "I enter {string-or-word} into {cardinal-word} not marked/tagged as {word}
|
|
|
79
84
|
* @param {TestController} testController exposes test controller
|
|
80
85
|
* @param {NumberAndWord} cardinal describes what to search
|
|
81
86
|
* @param {string|RegExp} className class required for match
|
|
82
|
-
* @param {'click'|'hover'} action action to perform on found element
|
|
87
|
+
* @param {'click'|'hover'|'enter'} action action to perform on found element
|
|
83
88
|
* @param {boolean} negated inverts the assertion by means of requiring one or all elements of context not to have selected class
|
|
84
89
|
* @param {string} input text to enter into selected field (instead of clicking or hovering)
|
|
85
90
|
* @return {Promise<void>} promises step passed
|
|
@@ -90,12 +95,17 @@ async function globalActionByClass( testController, cardinal, className, action,
|
|
|
90
95
|
}
|
|
91
96
|
|
|
92
97
|
const matches = await Api.access( testController ).find( cardinal.word );
|
|
98
|
+
|
|
99
|
+
if ( cardinal.cardinality !== "singular" ) {
|
|
100
|
+
await testController.expect( false ).eql( true, `selector is not addressing a single ${cardinal.word} ${negated ? "not " : ""}marked as ${className} to ${input == null ? action : `enter '${input}' into`}` ); // eslint-disable-line max-len
|
|
101
|
+
}
|
|
102
|
+
|
|
93
103
|
const { query: property } = matches.getSelector( "#classList", "classList" );
|
|
94
104
|
const refined = await matches.filterFn( node => node?.[property]?.contains( className ) ^ negated, { property, className, negated } );
|
|
95
105
|
const matchCount = await refined.matches.count;
|
|
96
106
|
|
|
97
|
-
await testController.expect( matchCount ).gt( 0, `there is no matching ${cardinal.word} ${negated ? "not " : ""}marked as ${className} to ${input == null ? action :
|
|
98
|
-
await testController.expect( matchCount ).eql( 1, `there is no single matching ${cardinal.word} ${negated ? "not " : ""}marked as ${className} to ${input == null ? action :
|
|
107
|
+
await testController.expect( matchCount ).gt( 0, `there is no matching ${cardinal.word} ${negated ? "not " : ""}marked as ${className} to ${input == null ? action : `enter '${input}' into`}` );
|
|
108
|
+
await testController.expect( matchCount ).eql( 1, `there is no single matching ${cardinal.word} ${negated ? "not " : ""}marked as ${className} to ${input == null ? action : `enter '${input}' into`}` );
|
|
99
109
|
|
|
100
110
|
await actAndTrack( testController, cardinal, refined, action, input );
|
|
101
111
|
}
|
|
@@ -114,7 +124,7 @@ When( "I enter {string-or-word} into {cardinal-word} with value {text-or-regexp}
|
|
|
114
124
|
* @param {NumberAndWord} cardinal describes what to search
|
|
115
125
|
* @param {string|RegExp} name name of attribute to match
|
|
116
126
|
* @param {string|RegExp} value value of named attribute to match
|
|
117
|
-
* @param {'click'|'hover'} action action to perform on found element
|
|
127
|
+
* @param {'click'|'hover'|'enter'} action action to perform on found element
|
|
118
128
|
* @param {string} input text to enter into selected field (instead of clicking or hovering)
|
|
119
129
|
* @return {Promise<void>} promises step passed
|
|
120
130
|
*/
|
|
@@ -124,11 +134,16 @@ async function globalActionByProperty( testController, cardinal, name, value, ac
|
|
|
124
134
|
}
|
|
125
135
|
|
|
126
136
|
const matches = await Api.access( testController ).find( cardinal.word );
|
|
137
|
+
|
|
138
|
+
if ( cardinal.cardinality !== "singular" ) {
|
|
139
|
+
await testController.expect( false ).eql( true, `selector is not addressing a single ${cardinal.word} with property ${name} == "${value}" to ${input == null ? action : `enter '${input}' into`}` ); // eslint-disable-line max-len
|
|
140
|
+
}
|
|
141
|
+
|
|
127
142
|
const refined = await matches.withProperty( name, value );
|
|
128
143
|
const matchCount = await refined.matches.count;
|
|
129
144
|
|
|
130
|
-
await testController.expect( matchCount ).gt( 0, `there is no matching ${cardinal.word} with property ${name} == "${value}" to ${input == null ? action :
|
|
131
|
-
await testController.expect( matchCount ).eql( 1, `there is no single matching ${cardinal.word} with property ${name} == "${value}" to ${input == null ? action :
|
|
145
|
+
await testController.expect( matchCount ).gt( 0, `there is no matching ${cardinal.word} with property ${name} == "${value}" to ${input == null ? action : `enter '${input}' into`}` ); // eslint-disable-line max-len
|
|
146
|
+
await testController.expect( matchCount ).eql( 1, `there is no single matching ${cardinal.word} with property ${name} == "${value}" to ${input == null ? action : `enter '${input}' into`}` ); // eslint-disable-line max-len
|
|
132
147
|
|
|
133
148
|
await actAndTrack( testController, cardinal, refined, action, input );
|
|
134
149
|
}
|
|
@@ -156,7 +171,7 @@ When( "I enter {string-or-word} into {cardinal-word} partially labelled with {te
|
|
|
156
171
|
* @param {NumberAndWord} cardinal provides cardinal number and word
|
|
157
172
|
* @param {string} label provides required label of matching element(s)
|
|
158
173
|
* @param {boolean} partially if true, provided text does not have to match whole content of matching subs
|
|
159
|
-
* @param {'click'|'hover'} action action to perform on found element
|
|
174
|
+
* @param {'click'|'hover'|'enter'} action action to perform on found element
|
|
160
175
|
* @param {string} input text to enter into selected field (instead of clicking or hovering)
|
|
161
176
|
* @returns {Promise<void>} promises step passed
|
|
162
177
|
*/
|
|
@@ -166,11 +181,16 @@ async function globalActionByLabel( testController, cardinal, label, partially,
|
|
|
166
181
|
}
|
|
167
182
|
|
|
168
183
|
const matches = await Api.access( testController ).find( cardinal.word );
|
|
184
|
+
|
|
185
|
+
if ( cardinal.cardinality !== "singular" ) {
|
|
186
|
+
await testController.expect( false ).eql( true, `selector is not addressing a single ${cardinal.word} with ${partially ? "partial " : ""}label "${label}" to ${input == null ? action : `enter '${input}' into`}` ); // eslint-disable-line max-len
|
|
187
|
+
}
|
|
188
|
+
|
|
169
189
|
const refined = await matches.filterBySubsWithText( "$label", "label", label, partially );
|
|
170
190
|
const matchCount = await refined.matches.count;
|
|
171
191
|
|
|
172
|
-
await testController.expect( matchCount ).gt( 0, `there is no matching ${cardinal.word} with ${partially ? "partial " : ""}label "${label}" to ${input == null ? action :
|
|
173
|
-
await testController.expect( matchCount ).eql( 1, `there is no single matching ${cardinal.word} with ${partially ? "partial " : ""}label "${label}" to ${input == null ? action :
|
|
192
|
+
await testController.expect( matchCount ).gt( 0, `there is no matching ${cardinal.word} with ${partially ? "partial " : ""}label "${label}" to ${input == null ? action : `enter '${input}' into`}` );
|
|
193
|
+
await testController.expect( matchCount ).eql( 1, `there is no single matching ${cardinal.word} with ${partially ? "partial " : ""}label "${label}" to ${input == null ? action : `enter '${input}' into`}` );
|
|
174
194
|
|
|
175
195
|
await actAndTrack( testController, cardinal, refined, action, input );
|
|
176
196
|
}
|
|
@@ -198,7 +218,7 @@ When( "I enter {string-or-word} into {cardinal-word} with partial text {text-or-
|
|
|
198
218
|
* @param {NumberAndWord} cardinal provides cardinal number and word
|
|
199
219
|
* @param {string} text provides text to be found in eventually matching element(s)
|
|
200
220
|
* @param {boolean} partially if true, provided text does not have to match whole content of matching subs
|
|
201
|
-
* @param {'click'|'hover'} action action to perform on found element
|
|
221
|
+
* @param {'click'|'hover'|'enter'} action action to perform on found element
|
|
202
222
|
* @param {string} input text to enter into selected field (instead of clicking or hovering)
|
|
203
223
|
* @returns {Promise<void>} promises step passed
|
|
204
224
|
*/
|
|
@@ -208,11 +228,16 @@ async function globalActionByTextContent( testController, cardinal, text, partia
|
|
|
208
228
|
}
|
|
209
229
|
|
|
210
230
|
const matches = await Api.access( testController ).find( cardinal.word );
|
|
231
|
+
|
|
232
|
+
if ( cardinal.cardinality !== "singular" ) {
|
|
233
|
+
await testController.expect( false ).eql( true, `selector is not addressing a single ${cardinal.word} ${partially ? "partially " : ""}reading "${text}" to ${input == null ? action : `enter '${input}' into`}` ); // eslint-disable-line max-len
|
|
234
|
+
}
|
|
235
|
+
|
|
211
236
|
const refined = await matches.filterBySubsWithText( "$text", false, text, partially );
|
|
212
237
|
const matchCount = await refined.matches.count;
|
|
213
238
|
|
|
214
|
-
await testController.expect( matchCount ).gt( 0, `there is no matching ${cardinal.word} ${partially ? "partially " : ""}reading "${text}" to ${input == null ? action :
|
|
215
|
-
await testController.expect( matchCount ).eql( 1, `there is no single matching ${cardinal.word} ${partially ? "partially " : ""}reading "${text}" to ${input == null ? action :
|
|
239
|
+
await testController.expect( matchCount ).gt( 0, `there is no matching ${cardinal.word} ${partially ? "partially " : ""}reading "${text}" to ${input == null ? action : `enter '${input}' into`}` );
|
|
240
|
+
await testController.expect( matchCount ).eql( 1, `there is no single matching ${cardinal.word} ${partially ? "partially " : ""}reading "${text}" to ${input == null ? action : `enter '${input}' into`}` );
|
|
216
241
|
|
|
217
242
|
await actAndTrack( testController, cardinal, refined, action, input );
|
|
218
243
|
}
|