@serenity-js/core 3.9.0 → 3.10.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/CHANGELOG.md +23 -0
- package/lib/model/CorrelationId.js +1 -1
- package/lib/model/CorrelationId.js.map +1 -1
- package/lib/screenplay/Question.d.ts +12 -4
- package/lib/screenplay/Question.d.ts.map +1 -1
- package/lib/screenplay/Question.js +16 -4
- package/lib/screenplay/Question.js.map +1 -1
- package/lib/screenplay/questions/ChainableMetaQuestion.d.ts +26 -0
- package/lib/screenplay/questions/ChainableMetaQuestion.d.ts.map +1 -0
- package/lib/screenplay/questions/ChainableMetaQuestion.js +3 -0
- package/lib/screenplay/questions/ChainableMetaQuestion.js.map +1 -0
- package/lib/screenplay/questions/List.d.ts +58 -11
- package/lib/screenplay/questions/List.d.ts.map +1 -1
- package/lib/screenplay/questions/List.js +145 -42
- package/lib/screenplay/questions/List.js.map +1 -1
- package/lib/screenplay/questions/MetaQuestion.d.ts +2 -2
- package/lib/screenplay/questions/MetaQuestion.d.ts.map +1 -1
- package/lib/screenplay/questions/index.d.ts +1 -0
- package/lib/screenplay/questions/index.d.ts.map +1 -1
- package/lib/screenplay/questions/index.js +1 -0
- package/lib/screenplay/questions/index.js.map +1 -1
- package/package.json +4 -4
- package/src/model/CorrelationId.ts +1 -1
- package/src/screenplay/Question.ts +20 -7
- package/src/screenplay/questions/ChainableMetaQuestion.ts +30 -0
- package/src/screenplay/questions/List.ts +246 -69
- package/src/screenplay/questions/MetaQuestion.ts +2 -2
- package/src/screenplay/questions/index.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,29 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [3.10.0](https://github.com/serenity-js/serenity-js/compare/v3.9.1...v3.10.0) (2023-08-23)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **web:** chainable `PageElements` ([#1864](https://github.com/serenity-js/serenity-js/issues/1864)) ([4d0c7eb](https://github.com/serenity-js/serenity-js/commit/4d0c7eb97c24fe3ae1eed702773cf3b80f104947))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [3.9.1](https://github.com/serenity-js/serenity-js/compare/v3.9.0...v3.9.1) (2023-08-18)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* **core:** support iOS window handles in CorrelationId ([4e15e1a](https://github.com/serenity-js/serenity-js/commit/4e15e1aac28bf2952bf578edbf972968c6892270))
|
|
23
|
+
* **deps:** update dependency @paralleldrive/cuid2 to ^2.2.2 ([1bec9da](https://github.com/serenity-js/serenity-js/commit/1bec9da27a44dd6f7fed3c68c03e346d87e77cbd))
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
6
29
|
# [3.9.0](https://github.com/serenity-js/serenity-js/compare/v3.8.0...v3.9.0) (2023-08-04)
|
|
7
30
|
|
|
8
31
|
|
|
@@ -13,7 +13,7 @@ class CorrelationId extends tiny_types_1.TinyType {
|
|
|
13
13
|
constructor(value) {
|
|
14
14
|
super();
|
|
15
15
|
this.value = value;
|
|
16
|
-
(0, tiny_types_1.ensure)(this.constructor.name, value, (0, tiny_types_1.or)(isACuid(), (0, tiny_types_1.matches)(/^[\
|
|
16
|
+
(0, tiny_types_1.ensure)(this.constructor.name, value, (0, tiny_types_1.or)(isACuid(), (0, tiny_types_1.matches)(/^[\d.A-Za-z-]+$/)));
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
exports.CorrelationId = CorrelationId;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CorrelationId.js","sourceRoot":"","sources":["../../src/model/CorrelationId.ts"],"names":[],"mappings":";;;AAA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14 +176,15 @@ export declare abstract class Question<T> {
|
|
|
176
176
|
* )
|
|
177
177
|
* )
|
|
178
178
|
* );
|
|
179
|
-
*
|
|
180
|
-
* @param source
|
|
181
|
-
* @param overrides
|
|
179
|
+
* ```
|
|
182
180
|
*
|
|
183
181
|
* #### Learn more
|
|
184
182
|
* - {@apilink WithAnswerableProperties}
|
|
185
183
|
* - {@apilink RecursivelyAnswered}
|
|
186
184
|
* - {@apilink Answerable}
|
|
185
|
+
*
|
|
186
|
+
* @param source
|
|
187
|
+
* @param overrides
|
|
187
188
|
*/
|
|
188
189
|
static fromObject<Source_Type extends object>(source: Answerable<WithAnswerableProperties<Source_Type>>, ...overrides: Array<Answerable<Partial<WithAnswerableProperties<Source_Type>>>>): QuestionAdapter<RecursivelyAnswered<Source_Type>>;
|
|
189
190
|
/**
|
|
@@ -193,6 +194,13 @@ export declare abstract class Question<T> {
|
|
|
193
194
|
* The value to check
|
|
194
195
|
*/
|
|
195
196
|
static isAQuestion<T>(maybeQuestion: unknown): maybeQuestion is Question<T>;
|
|
197
|
+
/**
|
|
198
|
+
* Checks if the value is a {@apilink MetaQuestion}.
|
|
199
|
+
*
|
|
200
|
+
* @param maybeMetaQuestion
|
|
201
|
+
* The value to check
|
|
202
|
+
*/
|
|
203
|
+
static isAMetaQuestion<CT, RQT extends Question<unknown>>(maybeMetaQuestion: unknown): maybeMetaQuestion is MetaQuestion<CT, RQT>;
|
|
196
204
|
protected static createAdapter<AT>(statement: Question<AT>): QuestionAdapter<Awaited<AT>>;
|
|
197
205
|
private static fieldDescription;
|
|
198
206
|
private static methodDescription;
|
|
@@ -257,7 +265,7 @@ export type QuestionAdapter<Answer_Type> = Question<Promise<Answer_Type>> & Inte
|
|
|
257
265
|
*
|
|
258
266
|
* @group Questions
|
|
259
267
|
*/
|
|
260
|
-
export type MetaQuestionAdapter<Context_Type, Answer_Type> = QuestionAdapter<Answer_Type> & MetaQuestion<Context_Type, Answer_Type
|
|
268
|
+
export type MetaQuestionAdapter<Context_Type, Answer_Type> = QuestionAdapter<Answer_Type> & MetaQuestion<Context_Type, QuestionAdapter<Answer_Type>>;
|
|
261
269
|
/**
|
|
262
270
|
* @package
|
|
263
271
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Question.d.ts","sourceRoot":"","sources":["../../src/screenplay/Question.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAG7B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAEhD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAE7D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAE3E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8FG;AACH,8BAAsB,QAAQ,CAAC,CAAC;IAE5B;;;;;;;;;;;;;;;OAeG;IACH,MAAM,CAAC,KAAK,CAAC,WAAW,EAAE,sBAAsB,EAC5C,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,CAAC,KAAK,EAAE,gBAAgB,GAAG,aAAa,KAAK,OAAO,CAAC,WAAW,CAAC,GAAG,WAAW,EACrF,gBAAgB,EAAE,CAAC,UAAU,EAAE,UAAU,CAAC,sBAAsB,CAAC,KAAK,QAAQ,CAAC,OAAO,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,aAAa,GAAG,OAAO,CAAC,WAAW,CAAC;IAKzE,SAAS,CAAC,KAAK,EAAE,aAAa,GAAG,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IAIvE,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,sBAAsB,EAAE,OAAO,EAAE,OAAO,IAAI,CAAC,OAAO,GAAG,MAAM;IAIhH,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAKzB,QAAQ,IAAI,MAAM;IAI3B,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC;CAWzF"}
|
|
@@ -185,14 +185,15 @@ class Question {
|
|
|
185
185
|
* )
|
|
186
186
|
* )
|
|
187
187
|
* );
|
|
188
|
-
*
|
|
189
|
-
* @param source
|
|
190
|
-
* @param overrides
|
|
188
|
+
* ```
|
|
191
189
|
*
|
|
192
190
|
* #### Learn more
|
|
193
191
|
* - {@apilink WithAnswerableProperties}
|
|
194
192
|
* - {@apilink RecursivelyAnswered}
|
|
195
193
|
* - {@apilink Answerable}
|
|
194
|
+
*
|
|
195
|
+
* @param source
|
|
196
|
+
* @param overrides
|
|
196
197
|
*/
|
|
197
198
|
static fromObject(source, ...overrides) {
|
|
198
199
|
return Question.about('value', async (actor) => {
|
|
@@ -216,6 +217,17 @@ class Question {
|
|
|
216
217
|
return !!maybeQuestion
|
|
217
218
|
&& typeof maybeQuestion.answeredBy === 'function';
|
|
218
219
|
}
|
|
220
|
+
/**
|
|
221
|
+
* Checks if the value is a {@apilink MetaQuestion}.
|
|
222
|
+
*
|
|
223
|
+
* @param maybeMetaQuestion
|
|
224
|
+
* The value to check
|
|
225
|
+
*/
|
|
226
|
+
static isAMetaQuestion(maybeMetaQuestion) {
|
|
227
|
+
return !!maybeMetaQuestion
|
|
228
|
+
&& typeof maybeMetaQuestion['of'] === 'function'
|
|
229
|
+
&& maybeMetaQuestion['of'].length === 1; // arity of 1
|
|
230
|
+
}
|
|
219
231
|
static createAdapter(statement) {
|
|
220
232
|
function getStatement() {
|
|
221
233
|
return statement;
|
|
@@ -383,7 +395,7 @@ class MetaQuestionStatement extends QuestionStatement {
|
|
|
383
395
|
this.metaQuestionBody = metaQuestionBody;
|
|
384
396
|
}
|
|
385
397
|
of(answerable) {
|
|
386
|
-
return Question.about((0, io_1.d)
|
|
398
|
+
return Question.about(this.toString() + (0, io_1.d) ` of ${answerable}`, actor => actor.answer(this.metaQuestionBody(answerable)));
|
|
387
399
|
}
|
|
388
400
|
}
|
|
389
401
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Question.js","sourceRoot":"","sources":["../../src/screenplay/Question.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAkD;AAClD,2CAA6B,CAAC,2CAA2C;AAEzE,sCAAuC;AAEvC,8BAA8C;AAG9C,+CAA4C;AAI5C,uDAAoD;AAIpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8FG;AACH,MAAsB,QAAQ;IA6B1B,MAAM,CAAC,KAAK,CACR,WAAmB,EACnB,IAAqF,EACrF,gBAAuF;QAGvF,MAAM,SAAS,GAAG,OAAO,gBAAgB,KAAK,UAAU;YACpD,CAAC,CAAC,IAAI,qBAAqB,CAAC,WAAW,EAAE,IAAI,EAAE,gBAAgB,CAAC;YAChE,CAAC,CAAC,IAAI,iBAAiB,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;QAE/C,OAAO,QAAQ,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;IAC7C,CAAC;IAED
|
|
1
|
+
{"version":3,"file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AO,MAAM,CAAC,WAAW,CAAC,eAAe,CAAiB,CAAC;KAC9D;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QACvB,MAAM,eAAe,GAAa,EAAE,CAAC;QAErC,KAAK,MAAM,IAAI,IAAI,MAAM,EAAE;YACvB,eAAe,CAAC,IAAI,CAAC,MAAM,iBAAiB,CAAC,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,gBAAgB,GAAG,CAAC,CAAM,CAAC,CAAC;SACtG;QAED,OAAO,eAA0C,CAAC;KACrD;IAED,OAAO,MAAsB,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Answerable } from '../Answerable';
|
|
2
|
+
import type { Question } from '../Question';
|
|
3
|
+
import type { MetaQuestion } from './MetaQuestion';
|
|
4
|
+
/**
|
|
5
|
+
* A chainable meta-question is a {@apilink MetaQuestion} that can be answered
|
|
6
|
+
* in the context of another {@apilink Answerable},
|
|
7
|
+
* and form a chain of transformations.
|
|
8
|
+
*
|
|
9
|
+
* {@apilink MetaQuestion|Meta questions} are typically used when filtering a {@apilink List}.
|
|
10
|
+
*
|
|
11
|
+
* ## Learn more
|
|
12
|
+
* - {@apilink List}
|
|
13
|
+
*
|
|
14
|
+
* @group Questions
|
|
15
|
+
*/
|
|
16
|
+
export interface ChainableMetaQuestion<Supported_Context_Type, Returned_Question_Type extends Question<unknown>> extends MetaQuestion<Supported_Context_Type, Returned_Question_Type & ChainableMetaQuestion<Supported_Context_Type, Returned_Question_Type>> {
|
|
17
|
+
/**
|
|
18
|
+
* Answers the given `ChainableMetaQuestion` in the context of another {@apilink Answerable}
|
|
19
|
+
* and returns another `ChainableMetaQuestion` ready for further chaining.
|
|
20
|
+
*
|
|
21
|
+
* #### Learn more
|
|
22
|
+
* - {@apilink List}
|
|
23
|
+
*/
|
|
24
|
+
of(context: Answerable<Supported_Context_Type>): Returned_Question_Type & ChainableMetaQuestion<Supported_Context_Type, Returned_Question_Type>;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=ChainableMetaQuestion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChainableMetaQuestion.d.ts","sourceRoot":"","sources":["../../../src/screenplay/questions/ChainableMetaQuestion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,qBAAqB,CAClC,sBAAsB,EACtB,sBAAsB,SAAS,QAAQ,CAAC,OAAO,CAAC,CAClD,SAAQ,YAAY,CAAC,sBAAsB,EAAE,sBAAsB,GAAG,qBAAqB,CAAC,sBAAsB,EAAE,sBAAsB,CAAC,CAAC;IAE1I;;;;;;OAMG;IACH,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC,sBAAsB,CAAC,GAAG,sBAAsB,GAAG,qBAAqB,CAAC,sBAAsB,EAAE,sBAAsB,CAAC,CAAC;CACnJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChainableMetaQuestion.js","sourceRoot":"","sources":["../../../src/screenplay/questions/ChainableMetaQuestion.ts"],"names":[],"mappings":""}
|
|
@@ -1,33 +1,80 @@
|
|
|
1
1
|
import type { UsesAbilities } from '../abilities';
|
|
2
2
|
import type { Actor } from '../Actor';
|
|
3
3
|
import type { Answerable } from '../Answerable';
|
|
4
|
-
import type { QuestionAdapter } from '../Question';
|
|
4
|
+
import type { MetaQuestionAdapter, QuestionAdapter } from '../Question';
|
|
5
5
|
import { Question } from '../Question';
|
|
6
|
-
import type { AnswersQuestions } from '../questions';
|
|
6
|
+
import type { AnswersQuestions, ChainableMetaQuestion, MetaQuestion } from '../questions';
|
|
7
7
|
import { Task } from '../Task';
|
|
8
8
|
import type { Expectation } from './Expectation';
|
|
9
|
-
import type { MetaQuestion } from './MetaQuestion';
|
|
10
9
|
/**
|
|
11
10
|
* Serenity/JS Screenplay Pattern-style wrapper around {@apilink Array}
|
|
12
11
|
* and array-like structures - see {@apilink PageElements}.
|
|
13
12
|
*
|
|
14
13
|
* @group Questions
|
|
15
14
|
*/
|
|
16
|
-
export declare class List<Item_Type> extends Question<Promise<Item_Type[]>> {
|
|
15
|
+
export declare abstract class List<Item_Type> extends Question<Promise<Item_Type[]>> {
|
|
17
16
|
protected readonly collection: Answerable<Array<Item_Type>>;
|
|
18
|
-
|
|
17
|
+
protected subject?: string;
|
|
18
|
+
static of<IT, CT, RQT extends (Question<Promise<Array<IT>>> | Question<Array<IT>>)>(collection: Answerable<Array<IT>> & ChainableMetaQuestion<CT, RQT>): MetaList<CT, IT>;
|
|
19
19
|
static of<IT>(collection: Answerable<Array<IT>>): List<IT>;
|
|
20
20
|
constructor(collection: Answerable<Array<Item_Type>>);
|
|
21
|
-
eachMappedTo<Mapped_Item_Type>(question: MetaQuestion<Item_Type, Promise<Mapped_Item_Type> | Mapped_Item_Type>): List<Mapped_Item_Type>;
|
|
22
21
|
forEach(callback: (current: CurrentItem<Item_Type>, index: number, items: Array<Item_Type>) => Promise<void> | void): Task;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
abstract eachMappedTo<Mapped_Item_Type>(question: MetaQuestion<Item_Type, Question<Promise<Mapped_Item_Type> | Mapped_Item_Type>>): List<Mapped_Item_Type>;
|
|
23
|
+
abstract where<Answer_Type>(question: MetaQuestion<Item_Type, Question<Promise<Answer_Type> | Answer_Type>>, expectation: Expectation<Answer_Type>): List<Item_Type>;
|
|
24
|
+
abstract count(): QuestionAdapter<number>;
|
|
25
|
+
abstract first(): QuestionAdapter<Item_Type>;
|
|
26
|
+
abstract last(): QuestionAdapter<Item_Type>;
|
|
27
|
+
abstract nth(index: number): QuestionAdapter<Item_Type>;
|
|
28
28
|
answeredBy(actor: AnswersQuestions & UsesAbilities): Promise<Array<Item_Type>>;
|
|
29
29
|
describedAs(subject: string): this;
|
|
30
30
|
toString(): string;
|
|
31
|
+
/**
|
|
32
|
+
* @param {number} index
|
|
33
|
+
*/
|
|
34
|
+
protected ordinal(index: number): string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Serenity/JS Screenplay Pattern-style wrapper around
|
|
38
|
+
* a {@apilink ChainableMetaQuestion} representing a collection
|
|
39
|
+
* that can be resolved in `Supported_Context_Type` of another {@apilink Question}.
|
|
40
|
+
*
|
|
41
|
+
* For example, {@apilink PageElements.located} returns `MetaList<PageElement>`,
|
|
42
|
+
* which allows for the collection of page elements to be resolved in the context
|
|
43
|
+
* of dynamically-provided root element.
|
|
44
|
+
*
|
|
45
|
+
* ```typescript
|
|
46
|
+
* import { By, PageElements, PageElement } from '@serenity-js/web'
|
|
47
|
+
*
|
|
48
|
+
* const firstLabel = () =>
|
|
49
|
+
* PageElements.located(By.css('label'))
|
|
50
|
+
* .first()
|
|
51
|
+
* .describedAs('first label')
|
|
52
|
+
*
|
|
53
|
+
* const exampleForm = () =>
|
|
54
|
+
* PageElement.located(By.css('form#example1'))
|
|
55
|
+
* .describedAs('example form')
|
|
56
|
+
*
|
|
57
|
+
* const anotherExampleForm = () =>
|
|
58
|
+
* PageElement.located(By.css('form#example2'))
|
|
59
|
+
* .describedAs('another example form')
|
|
60
|
+
*
|
|
61
|
+
* // Next, you can compose the above questions dynamically with various "contexts":
|
|
62
|
+
* // firstLabel().of(exampleForm())
|
|
63
|
+
* // firstLabel().of(anotherExampleForm())
|
|
64
|
+
* ```
|
|
65
|
+
*
|
|
66
|
+
* @group Questions
|
|
67
|
+
*/
|
|
68
|
+
export declare class MetaList<Supported_Context_Type, Item_Type> extends List<Item_Type> implements ChainableMetaQuestion<Supported_Context_Type, MetaList<Supported_Context_Type, Item_Type>> {
|
|
69
|
+
protected readonly collection: Answerable<Array<Item_Type>> & ChainableMetaQuestion<Supported_Context_Type, Question<Promise<Array<Item_Type>>> | Question<Array<Item_Type>>>;
|
|
70
|
+
constructor(collection: Answerable<Array<Item_Type>> & ChainableMetaQuestion<Supported_Context_Type, Question<Promise<Array<Item_Type>>> | Question<Array<Item_Type>>>);
|
|
71
|
+
of(context: Answerable<Supported_Context_Type>): MetaList<Supported_Context_Type, Item_Type>;
|
|
72
|
+
eachMappedTo<Mapped_Item_Type>(question: MetaQuestion<Item_Type, Question<Promise<Mapped_Item_Type> | Mapped_Item_Type>>): MetaList<Supported_Context_Type, Mapped_Item_Type>;
|
|
73
|
+
where<Answer_Type>(question: MetaQuestion<Item_Type, Question<Promise<Answer_Type> | Answer_Type>>, expectation: Expectation<Answer_Type>): MetaList<Supported_Context_Type, Item_Type>;
|
|
74
|
+
count(): MetaQuestionAdapter<Supported_Context_Type, number>;
|
|
75
|
+
first(): MetaQuestionAdapter<Supported_Context_Type, Item_Type>;
|
|
76
|
+
last(): MetaQuestionAdapter<Supported_Context_Type, Item_Type>;
|
|
77
|
+
nth(index: number): MetaQuestionAdapter<Supported_Context_Type, Item_Type>;
|
|
31
78
|
}
|
|
32
79
|
/**
|
|
33
80
|
* @group Questions
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"List.d.ts","sourceRoot":"","sources":["../../../src/screenplay/questions/List.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"List.d.ts","sourceRoot":"","sources":["../../../src/screenplay/questions/List.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,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JD;;GAEG;AACH,MAAM,WAAW,WAAW,CAAC,SAAS;IAClC,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,EAAE,KAAK,CAAC;CAChB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.List = void 0;
|
|
3
|
+
exports.MetaList = exports.List = void 0;
|
|
4
4
|
const errors_1 = require("../../errors");
|
|
5
5
|
const io_1 = require("../../io");
|
|
6
6
|
const Question_1 = require("../Question");
|
|
@@ -14,30 +14,68 @@ const expectations_1 = require("./expectations");
|
|
|
14
14
|
*/
|
|
15
15
|
class List extends Question_1.Question {
|
|
16
16
|
static of(collection) {
|
|
17
|
-
|
|
17
|
+
if (Question_1.Question.isAMetaQuestion(collection)) {
|
|
18
|
+
return new MetaList(collection);
|
|
19
|
+
}
|
|
20
|
+
return new ArrayList(collection);
|
|
18
21
|
}
|
|
19
22
|
constructor(collection) {
|
|
20
23
|
super();
|
|
21
24
|
this.collection = collection;
|
|
22
|
-
this.subject = (0, io_1.d) `${collection}`;
|
|
23
|
-
}
|
|
24
|
-
eachMappedTo(question) {
|
|
25
|
-
return new List(new EachMappedTo(this.collection, question, this.subject));
|
|
26
25
|
}
|
|
27
26
|
forEach(callback) {
|
|
28
|
-
return new ForEachLoop(this.collection, this.
|
|
27
|
+
return new ForEachLoop(this.collection, this.toString(), callback);
|
|
28
|
+
}
|
|
29
|
+
async answeredBy(actor) {
|
|
30
|
+
const collection = await actor.answer(this.collection);
|
|
31
|
+
if (!Array.isArray(collection)) {
|
|
32
|
+
throw new errors_1.LogicError((0, io_1.d) `A List has to wrap an Array-compatible object. ${collection} given.`);
|
|
33
|
+
}
|
|
34
|
+
return collection;
|
|
35
|
+
}
|
|
36
|
+
describedAs(subject) {
|
|
37
|
+
this.subject = subject;
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
40
|
+
toString() {
|
|
41
|
+
return this.subject ?? (0, io_1.d) `${this.collection}`;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* @param {number} index
|
|
45
|
+
*/
|
|
46
|
+
ordinal(index) {
|
|
47
|
+
const lastDigit = Math.abs(index) % 10, lastTwoDigits = Math.abs(index) % 100;
|
|
48
|
+
switch (true) {
|
|
49
|
+
case (lastDigit === 1 && lastTwoDigits !== 11):
|
|
50
|
+
return index + 'st';
|
|
51
|
+
case (lastDigit === 2 && lastTwoDigits !== 12):
|
|
52
|
+
return index + 'nd';
|
|
53
|
+
case (lastDigit === 3 && lastTwoDigits !== 13):
|
|
54
|
+
return index + 'rd';
|
|
55
|
+
default:
|
|
56
|
+
return index + 'th';
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.List = List;
|
|
61
|
+
/**
|
|
62
|
+
* @package
|
|
63
|
+
*/
|
|
64
|
+
class ArrayList extends List {
|
|
65
|
+
eachMappedTo(question) {
|
|
66
|
+
return new ArrayList(new EachMappedTo(this.collection, question, this.toString()));
|
|
29
67
|
}
|
|
30
68
|
where(question, expectation) {
|
|
31
|
-
return new
|
|
69
|
+
return new ArrayList(new Where(this.collection, question, expectation, this.toString()));
|
|
32
70
|
}
|
|
33
71
|
count() {
|
|
34
|
-
return Question_1.Question.about(`the number of ${this.
|
|
72
|
+
return Question_1.Question.about(`the number of ${this.toString()}`, async (actor) => {
|
|
35
73
|
const items = await this.answeredBy(actor);
|
|
36
74
|
return items.length;
|
|
37
75
|
});
|
|
38
76
|
}
|
|
39
77
|
first() {
|
|
40
|
-
return Question_1.Question.about(`the first of ${this.
|
|
78
|
+
return Question_1.Question.about(`the first of ${this.toString()}`, async (actor) => {
|
|
41
79
|
const items = await this.answeredBy(actor);
|
|
42
80
|
if (items.length === 0) {
|
|
43
81
|
throw new errors_1.ListItemNotFoundError((0, io_1.d) `Can't retrieve the first item from a list with 0 items: ${items}`);
|
|
@@ -46,7 +84,7 @@ class List extends Question_1.Question {
|
|
|
46
84
|
});
|
|
47
85
|
}
|
|
48
86
|
last() {
|
|
49
|
-
return Question_1.Question.about(`the last of ${this.
|
|
87
|
+
return Question_1.Question.about(`the last of ${this.toString()}`, async (actor) => {
|
|
50
88
|
const items = await this.answeredBy(actor);
|
|
51
89
|
if (items.length === 0) {
|
|
52
90
|
throw new errors_1.ListItemNotFoundError((0, io_1.d) `Can't retrieve the last item from a list with 0 items: ${items}`);
|
|
@@ -55,47 +93,96 @@ class List extends Question_1.Question {
|
|
|
55
93
|
});
|
|
56
94
|
}
|
|
57
95
|
nth(index) {
|
|
58
|
-
return Question_1.Question.about(`the ${ordinal(index + 1)} of ${this.
|
|
96
|
+
return Question_1.Question.about(`the ${this.ordinal(index + 1)} of ${this.toString()}`, async (actor) => {
|
|
59
97
|
const items = await this.answeredBy(actor);
|
|
60
98
|
if (index < 0 || items.length <= index) {
|
|
61
|
-
throw new errors_1.ListItemNotFoundError(`Can't retrieve the ${ordinal(index)} item from a list with ${items.length} items: ` + (0, io_1.d) `${items}`);
|
|
99
|
+
throw new errors_1.ListItemNotFoundError(`Can't retrieve the ${this.ordinal(index)} item from a list with ${items.length} items: ` + (0, io_1.d) `${items}`);
|
|
62
100
|
}
|
|
63
101
|
return items[index];
|
|
64
102
|
});
|
|
65
103
|
}
|
|
66
|
-
async answeredBy(actor) {
|
|
67
|
-
const collection = await actor.answer(this.collection);
|
|
68
|
-
if (!Array.isArray(collection)) {
|
|
69
|
-
throw new errors_1.LogicError((0, io_1.d) `A List has to wrap an Array-compatible object. ${collection} given.`);
|
|
70
|
-
}
|
|
71
|
-
return collection;
|
|
72
|
-
}
|
|
73
|
-
describedAs(subject) {
|
|
74
|
-
this.subject = subject;
|
|
75
|
-
return this;
|
|
76
|
-
}
|
|
77
|
-
toString() {
|
|
78
|
-
return this.subject;
|
|
79
|
-
}
|
|
80
104
|
}
|
|
81
|
-
exports.List = List;
|
|
82
105
|
/**
|
|
83
|
-
*
|
|
84
|
-
* @
|
|
106
|
+
* Serenity/JS Screenplay Pattern-style wrapper around
|
|
107
|
+
* a {@apilink ChainableMetaQuestion} representing a collection
|
|
108
|
+
* that can be resolved in `Supported_Context_Type` of another {@apilink Question}.
|
|
109
|
+
*
|
|
110
|
+
* For example, {@apilink PageElements.located} returns `MetaList<PageElement>`,
|
|
111
|
+
* which allows for the collection of page elements to be resolved in the context
|
|
112
|
+
* of dynamically-provided root element.
|
|
113
|
+
*
|
|
114
|
+
* ```typescript
|
|
115
|
+
* import { By, PageElements, PageElement } from '@serenity-js/web'
|
|
116
|
+
*
|
|
117
|
+
* const firstLabel = () =>
|
|
118
|
+
* PageElements.located(By.css('label'))
|
|
119
|
+
* .first()
|
|
120
|
+
* .describedAs('first label')
|
|
121
|
+
*
|
|
122
|
+
* const exampleForm = () =>
|
|
123
|
+
* PageElement.located(By.css('form#example1'))
|
|
124
|
+
* .describedAs('example form')
|
|
125
|
+
*
|
|
126
|
+
* const anotherExampleForm = () =>
|
|
127
|
+
* PageElement.located(By.css('form#example2'))
|
|
128
|
+
* .describedAs('another example form')
|
|
129
|
+
*
|
|
130
|
+
* // Next, you can compose the above questions dynamically with various "contexts":
|
|
131
|
+
* // firstLabel().of(exampleForm())
|
|
132
|
+
* // firstLabel().of(anotherExampleForm())
|
|
133
|
+
* ```
|
|
134
|
+
*
|
|
135
|
+
* @group Questions
|
|
85
136
|
*/
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
137
|
+
class MetaList extends List {
|
|
138
|
+
constructor(collection) {
|
|
139
|
+
super(collection);
|
|
140
|
+
this.collection = collection;
|
|
141
|
+
}
|
|
142
|
+
of(context) {
|
|
143
|
+
return new MetaList(this.collection.of(context)).describedAs(this.toString() + (0, io_1.d) ` of ${context}`);
|
|
144
|
+
}
|
|
145
|
+
eachMappedTo(question) {
|
|
146
|
+
return new MetaList(new MetaEachMappedTo(this.collection, question, this.toString()));
|
|
147
|
+
}
|
|
148
|
+
where(question, expectation) {
|
|
149
|
+
return new MetaList(new MetaWhere(this.collection, question, expectation, this.toString()));
|
|
150
|
+
}
|
|
151
|
+
count() {
|
|
152
|
+
return Question_1.Question.about(`the number of ${this.toString()}`, async (actor) => {
|
|
153
|
+
const items = await this.answeredBy(actor);
|
|
154
|
+
return items.length;
|
|
155
|
+
}, (parent) => this.of(parent).count());
|
|
156
|
+
}
|
|
157
|
+
first() {
|
|
158
|
+
return Question_1.Question.about(`the first of ${this.toString()}`, async (actor) => {
|
|
159
|
+
const items = await this.answeredBy(actor);
|
|
160
|
+
if (items.length === 0) {
|
|
161
|
+
throw new errors_1.ListItemNotFoundError((0, io_1.d) `Can't retrieve the first item from a list with 0 items: ${items}`);
|
|
162
|
+
}
|
|
163
|
+
return items[0];
|
|
164
|
+
}, (parent) => this.of(parent).first());
|
|
165
|
+
}
|
|
166
|
+
last() {
|
|
167
|
+
return Question_1.Question.about(`the last of ${this.toString()}`, async (actor) => {
|
|
168
|
+
const items = await this.answeredBy(actor);
|
|
169
|
+
if (items.length === 0) {
|
|
170
|
+
throw new errors_1.ListItemNotFoundError((0, io_1.d) `Can't retrieve the last item from a list with 0 items: ${items}`);
|
|
171
|
+
}
|
|
172
|
+
return items.at(-1);
|
|
173
|
+
}, (parent) => this.of(parent).last());
|
|
174
|
+
}
|
|
175
|
+
nth(index) {
|
|
176
|
+
return Question_1.Question.about(`the ${this.ordinal(index + 1)} of ${this.toString()}`, async (actor) => {
|
|
177
|
+
const items = await this.answeredBy(actor);
|
|
178
|
+
if (index < 0 || items.length <= index) {
|
|
179
|
+
throw new errors_1.ListItemNotFoundError(`Can't retrieve the ${this.ordinal(index)} item from a list with ${items.length} items: ` + (0, io_1.d) `${items}`);
|
|
180
|
+
}
|
|
181
|
+
return items[index];
|
|
182
|
+
}, (parent) => this.of(parent).nth(index));
|
|
97
183
|
}
|
|
98
184
|
}
|
|
185
|
+
exports.MetaList = MetaList;
|
|
99
186
|
/**
|
|
100
187
|
* @package
|
|
101
188
|
*/
|
|
@@ -124,7 +211,7 @@ class Where extends Question_1.Question {
|
|
|
124
211
|
return results;
|
|
125
212
|
}
|
|
126
213
|
catch (error) {
|
|
127
|
-
throw new errors_1.LogicError((0, io_1.d) `Couldn't check if ${this.question} of an item of ${this.collection} does ${this.expectation}
|
|
214
|
+
throw new errors_1.LogicError((0, io_1.d) `Couldn't check if ${this.question} of an item of ${this.collection} does ${this.expectation}: ` + error.message, error);
|
|
128
215
|
}
|
|
129
216
|
}
|
|
130
217
|
describedAs(subject) {
|
|
@@ -135,6 +222,14 @@ class Where extends Question_1.Question {
|
|
|
135
222
|
return this.subject;
|
|
136
223
|
}
|
|
137
224
|
}
|
|
225
|
+
/**
|
|
226
|
+
* @package
|
|
227
|
+
*/
|
|
228
|
+
class MetaWhere extends Where {
|
|
229
|
+
of(context) {
|
|
230
|
+
return new MetaWhere(this.collection.of(context), this.question, this.expectation, this.toString());
|
|
231
|
+
}
|
|
232
|
+
}
|
|
138
233
|
/**
|
|
139
234
|
* @package
|
|
140
235
|
*/
|
|
@@ -161,6 +256,14 @@ class EachMappedTo extends Question_1.Question {
|
|
|
161
256
|
return this.subject;
|
|
162
257
|
}
|
|
163
258
|
}
|
|
259
|
+
/**
|
|
260
|
+
* @package
|
|
261
|
+
*/
|
|
262
|
+
class MetaEachMappedTo extends EachMappedTo {
|
|
263
|
+
of(context) {
|
|
264
|
+
return new MetaEachMappedTo(this.collection.of(context), this.mapping, this.toString());
|
|
265
|
+
}
|
|
266
|
+
}
|
|
164
267
|
/**
|
|
165
268
|
* @package
|
|
166
269
|
*/
|