@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"List.js","sourceRoot":"","sources":["../../../src/screenplay/questions/List.ts"],"names":[],"mappings":";;;AAAA,yCAAiE;AACjE,iCAA6B;AAK7B,0CAAuC;AAEvC,kCAA+B;AAE/B,iDAAgD;
|
|
1
|
+
{"version":3,"file":"List.js","sourceRoot":"","sources":["../../../src/screenplay/questions/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AAO,EAAE,EAAE;YAC9C,MAAM,IAAI,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC;SACrD;IACL,CAAC;CACJ"}
|
|
@@ -15,14 +15,14 @@ import type { Question } from '../Question';
|
|
|
15
15
|
*
|
|
16
16
|
* @group Questions
|
|
17
17
|
*/
|
|
18
|
-
export interface MetaQuestion<Supported_Context_Type,
|
|
18
|
+
export interface MetaQuestion<Supported_Context_Type, Returned_Question_Type extends Question<unknown>> {
|
|
19
19
|
/**
|
|
20
20
|
* Answers the given `MetaQuestion` in the context of another {@apilink Answerable}.
|
|
21
21
|
*
|
|
22
22
|
* #### Learn more
|
|
23
23
|
* - {@apilink List}
|
|
24
24
|
*/
|
|
25
|
-
of(context: Answerable<Supported_Context_Type>):
|
|
25
|
+
of(context: Answerable<Supported_Context_Type>): Returned_Question_Type;
|
|
26
26
|
/**
|
|
27
27
|
* Human-readable description of this {@apilink MetaQuestion},
|
|
28
28
|
* typically involving the description of the subject.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MetaQuestion.d.ts","sourceRoot":"","sources":["../../../src/screenplay/questions/MetaQuestion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,YAAY,CAAC,sBAAsB,EAAE,
|
|
1
|
+
{"version":3,"file":"MetaQuestion.d.ts","sourceRoot":"","sources":["../../../src/screenplay/questions/MetaQuestion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,YAAY,CAAC,sBAAsB,EAAE,sBAAsB,SAAS,QAAQ,CAAC,OAAO,CAAC;IAElG;;;;;OAKG;IACH,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC,sBAAsB,CAAC,GAAG,sBAAsB,CAAC;IAExE;;;;;;OAMG;IACH,QAAQ,IAAI,MAAM,CAAC;CACtB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/screenplay/questions/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,KAAK,CAAC;AACpB,cAAc,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/screenplay/questions/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,KAAK,CAAC;AACpB,cAAc,cAAc,CAAC"}
|
|
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./AnswersQuestions"), exports);
|
|
18
|
+
__exportStar(require("./ChainableMetaQuestion"), exports);
|
|
18
19
|
__exportStar(require("./Check"), exports);
|
|
19
20
|
__exportStar(require("./Expectation"), exports);
|
|
20
21
|
__exportStar(require("./expectations"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/screenplay/questions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC;AACnC,0CAAwB;AACxB,gDAA8B;AAC9B,iDAA+B;AAC/B,yCAAuB;AACvB,iDAA+B;AAC/B,sCAAoB;AACpB,+CAA6B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/screenplay/questions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC;AACnC,0DAAwC;AACxC,0CAAwB;AACxB,gDAA8B;AAC9B,iDAA+B;AAC/B,yCAAuB;AACvB,iDAA+B;AAC/B,sCAAoB;AACpB,+CAA6B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@serenity-js/core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.10.0",
|
|
4
4
|
"description": "Serenity/JS Screenplay, reporting engine and core interfaces.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Jan Molak",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"compile": "rimraf lib && tsc --project tsconfig.build.json"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@paralleldrive/cuid2": "^2.2.
|
|
35
|
+
"@paralleldrive/cuid2": "^2.2.2",
|
|
36
36
|
"chalk": "^4.1.2",
|
|
37
37
|
"diff": "^5.1.0",
|
|
38
38
|
"error-stack-parser": "2.1.4",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"@types/validate-npm-package-name": "^4.0.0",
|
|
55
55
|
"assertion-error-formatter": "^3.0.0",
|
|
56
56
|
"c8": "8.0.1",
|
|
57
|
-
"memfs": "^4.2.
|
|
57
|
+
"memfs": "^4.2.1",
|
|
58
58
|
"mocha": "^10.2.0",
|
|
59
59
|
"mocha-multi": "^1.1.7",
|
|
60
60
|
"ts-node": "^10.9.1",
|
|
@@ -71,5 +71,5 @@
|
|
|
71
71
|
"engines": {
|
|
72
72
|
"node": "^16.13 || ^18.12 || ^20"
|
|
73
73
|
},
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "06ae5d8a702be0be2890e989c120715c32f6578a"
|
|
75
75
|
}
|
|
@@ -12,7 +12,7 @@ export class CorrelationId extends TinyType {
|
|
|
12
12
|
|
|
13
13
|
constructor(public readonly value: string) {
|
|
14
14
|
super();
|
|
15
|
-
ensure(this.constructor.name, value, or(isACuid(), matches(/^[\
|
|
15
|
+
ensure(this.constructor.name, value, or(isACuid(), matches(/^[\d.A-Za-z-]+$/)));
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
|
|
@@ -204,14 +204,15 @@ export abstract class Question<T> {
|
|
|
204
204
|
* )
|
|
205
205
|
* )
|
|
206
206
|
* );
|
|
207
|
-
*
|
|
208
|
-
* @param source
|
|
209
|
-
* @param overrides
|
|
207
|
+
* ```
|
|
210
208
|
*
|
|
211
209
|
* #### Learn more
|
|
212
210
|
* - {@apilink WithAnswerableProperties}
|
|
213
211
|
* - {@apilink RecursivelyAnswered}
|
|
214
212
|
* - {@apilink Answerable}
|
|
213
|
+
*
|
|
214
|
+
* @param source
|
|
215
|
+
* @param overrides
|
|
215
216
|
*/
|
|
216
217
|
static fromObject<Source_Type extends object>(
|
|
217
218
|
source: Answerable<WithAnswerableProperties<Source_Type>>,
|
|
@@ -245,6 +246,18 @@ export abstract class Question<T> {
|
|
|
245
246
|
&& typeof (maybeQuestion as any).answeredBy === 'function';
|
|
246
247
|
}
|
|
247
248
|
|
|
249
|
+
/**
|
|
250
|
+
* Checks if the value is a {@apilink MetaQuestion}.
|
|
251
|
+
*
|
|
252
|
+
* @param maybeMetaQuestion
|
|
253
|
+
* The value to check
|
|
254
|
+
*/
|
|
255
|
+
static isAMetaQuestion<CT, RQT extends Question<unknown>>(maybeMetaQuestion: unknown): maybeMetaQuestion is MetaQuestion<CT, RQT> {
|
|
256
|
+
return !! maybeMetaQuestion
|
|
257
|
+
&& typeof maybeMetaQuestion['of'] === 'function'
|
|
258
|
+
&& maybeMetaQuestion['of'].length === 1; // arity of 1
|
|
259
|
+
}
|
|
260
|
+
|
|
248
261
|
protected static createAdapter<AT>(statement: Question<AT>): QuestionAdapter<Awaited<AT>> {
|
|
249
262
|
function getStatement() {
|
|
250
263
|
return statement;
|
|
@@ -466,7 +479,7 @@ export type QuestionAdapter<Answer_Type> =
|
|
|
466
479
|
*/
|
|
467
480
|
export type MetaQuestionAdapter<Context_Type, Answer_Type> =
|
|
468
481
|
& QuestionAdapter<Answer_Type>
|
|
469
|
-
& MetaQuestion<Context_Type, Answer_Type
|
|
482
|
+
& MetaQuestion<Context_Type, QuestionAdapter<Answer_Type>>
|
|
470
483
|
|
|
471
484
|
/**
|
|
472
485
|
* @package
|
|
@@ -531,7 +544,7 @@ class QuestionStatement<Answer_Type> extends Interaction implements Question<Pro
|
|
|
531
544
|
*/
|
|
532
545
|
class MetaQuestionStatement<Answer_Type, Supported_Context_Type extends Answerable<any>>
|
|
533
546
|
extends QuestionStatement<Answer_Type>
|
|
534
|
-
implements MetaQuestion<Supported_Context_Type, Answer_Type
|
|
547
|
+
implements MetaQuestion<Supported_Context_Type, QuestionAdapter<Answer_Type>>
|
|
535
548
|
{
|
|
536
549
|
constructor(
|
|
537
550
|
subject: string,
|
|
@@ -541,9 +554,9 @@ class MetaQuestionStatement<Answer_Type, Supported_Context_Type extends Answerab
|
|
|
541
554
|
super(subject, body);
|
|
542
555
|
}
|
|
543
556
|
|
|
544
|
-
of(answerable: Answerable<Supported_Context_Type>):
|
|
557
|
+
of(answerable: Answerable<Supported_Context_Type>): QuestionAdapter<Answer_Type> {
|
|
545
558
|
return Question.about(
|
|
546
|
-
|
|
559
|
+
this.toString() + d` of ${ answerable }`,
|
|
547
560
|
actor => actor.answer(this.metaQuestionBody(answerable))
|
|
548
561
|
);
|
|
549
562
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Answerable } from '../Answerable';
|
|
2
|
+
import type { Question } from '../Question';
|
|
3
|
+
import type { MetaQuestion } from './MetaQuestion';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A chainable meta-question is a {@apilink MetaQuestion} that can be answered
|
|
7
|
+
* in the context of another {@apilink Answerable},
|
|
8
|
+
* and form a chain of transformations.
|
|
9
|
+
*
|
|
10
|
+
* {@apilink MetaQuestion|Meta questions} are typically used when filtering a {@apilink List}.
|
|
11
|
+
*
|
|
12
|
+
* ## Learn more
|
|
13
|
+
* - {@apilink List}
|
|
14
|
+
*
|
|
15
|
+
* @group Questions
|
|
16
|
+
*/
|
|
17
|
+
export interface ChainableMetaQuestion<
|
|
18
|
+
Supported_Context_Type,
|
|
19
|
+
Returned_Question_Type extends Question<unknown>
|
|
20
|
+
> extends MetaQuestion<Supported_Context_Type, Returned_Question_Type & ChainableMetaQuestion<Supported_Context_Type, Returned_Question_Type>> {
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Answers the given `ChainableMetaQuestion` in the context of another {@apilink Answerable}
|
|
24
|
+
* and returns another `ChainableMetaQuestion` ready for further chaining.
|
|
25
|
+
*
|
|
26
|
+
* #### Learn more
|
|
27
|
+
* - {@apilink List}
|
|
28
|
+
*/
|
|
29
|
+
of(context: Answerable<Supported_Context_Type>): Returned_Question_Type & ChainableMetaQuestion<Supported_Context_Type, Returned_Question_Type>;
|
|
30
|
+
}
|
|
@@ -3,13 +3,12 @@ import { d } from '../../io';
|
|
|
3
3
|
import type { UsesAbilities } from '../abilities';
|
|
4
4
|
import type { Actor } from '../Actor';
|
|
5
5
|
import type { Answerable } from '../Answerable';
|
|
6
|
-
import type { QuestionAdapter } from '../Question';
|
|
6
|
+
import type { MetaQuestionAdapter, QuestionAdapter } from '../Question';
|
|
7
7
|
import { Question } from '../Question';
|
|
8
|
-
import type { AnswersQuestions } from '../questions';
|
|
8
|
+
import type { AnswersQuestions, ChainableMetaQuestion, MetaQuestion } from '../questions';
|
|
9
9
|
import { Task } from '../Task';
|
|
10
10
|
import type { Expectation } from './Expectation';
|
|
11
11
|
import { ExpectationMet } from './expectations';
|
|
12
|
-
import type { MetaQuestion } from './MetaQuestion';
|
|
13
12
|
|
|
14
13
|
/**
|
|
15
14
|
* Serenity/JS Screenplay Pattern-style wrapper around {@apilink Array}
|
|
@@ -17,50 +16,115 @@ import type { MetaQuestion } from './MetaQuestion';
|
|
|
17
16
|
*
|
|
18
17
|
* @group Questions
|
|
19
18
|
*/
|
|
20
|
-
export class List<Item_Type> extends Question<Promise<Item_Type[]>> {
|
|
21
|
-
|
|
19
|
+
export abstract class List<Item_Type> extends Question<Promise<Item_Type[]>> {
|
|
20
|
+
protected subject?: string;
|
|
21
|
+
|
|
22
|
+
static of<IT, CT, RQT extends (Question<Promise<Array<IT>>> | Question<Array<IT>>)>(collection: Answerable<Array<IT>> & ChainableMetaQuestion<CT, RQT>): MetaList<CT, IT>;
|
|
23
|
+
static of<IT>(collection: Answerable<Array<IT>>): List<IT>;
|
|
24
|
+
static of<IT>(collection: unknown): unknown {
|
|
25
|
+
if (Question.isAMetaQuestion<unknown, Question<Array<IT>>>(collection)) {
|
|
26
|
+
return new MetaList(collection as Answerable<Array<IT>> & ChainableMetaQuestion<unknown, Question<Array<IT>>>);
|
|
27
|
+
}
|
|
22
28
|
|
|
23
|
-
|
|
24
|
-
return new List<IT>(collection);
|
|
29
|
+
return new ArrayList<IT>(collection as Answerable<Array<IT>>);
|
|
25
30
|
}
|
|
26
31
|
|
|
27
|
-
constructor(
|
|
28
|
-
protected readonly collection: Answerable<Array<Item_Type>>,
|
|
29
|
-
) {
|
|
32
|
+
constructor(protected readonly collection: Answerable<Array<Item_Type>>) {
|
|
30
33
|
super();
|
|
31
|
-
this.subject = d`${ collection }`;
|
|
32
34
|
}
|
|
33
35
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
): List<Mapped_Item_Type> {
|
|
37
|
-
return new List(
|
|
38
|
-
new EachMappedTo(this.collection, question, this.subject)
|
|
39
|
-
);
|
|
36
|
+
forEach(callback: (current: CurrentItem<Item_Type>, index: number, items: Array<Item_Type>) => Promise<void> | void): Task {
|
|
37
|
+
return new ForEachLoop(this.collection, this.toString(), callback);
|
|
40
38
|
}
|
|
41
39
|
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
abstract eachMappedTo<Mapped_Item_Type>(
|
|
41
|
+
question: MetaQuestion<Item_Type, Question<Promise<Mapped_Item_Type> | Mapped_Item_Type>>
|
|
42
|
+
): List<Mapped_Item_Type>;
|
|
43
|
+
|
|
44
|
+
abstract where<Answer_Type>(
|
|
45
|
+
question: MetaQuestion<Item_Type, Question<Promise<Answer_Type> | Answer_Type>>,
|
|
46
|
+
expectation: Expectation<Answer_Type>
|
|
47
|
+
): List<Item_Type>;
|
|
48
|
+
|
|
49
|
+
abstract count(): QuestionAdapter<number>;
|
|
50
|
+
|
|
51
|
+
abstract first(): QuestionAdapter<Item_Type>;
|
|
52
|
+
|
|
53
|
+
abstract last(): QuestionAdapter<Item_Type>;
|
|
54
|
+
|
|
55
|
+
abstract nth(index: number): QuestionAdapter<Item_Type>;
|
|
56
|
+
|
|
57
|
+
async answeredBy(actor: AnswersQuestions & UsesAbilities): Promise<Array<Item_Type>> {
|
|
58
|
+
const collection = await actor.answer(this.collection);
|
|
59
|
+
|
|
60
|
+
if (! Array.isArray(collection)) {
|
|
61
|
+
throw new LogicError(d`A List has to wrap an Array-compatible object. ${ collection } given.`);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return collection;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
describedAs(subject: string): this {
|
|
68
|
+
this.subject = subject;
|
|
69
|
+
return this;
|
|
44
70
|
}
|
|
45
71
|
|
|
46
|
-
|
|
47
|
-
|
|
72
|
+
toString(): string {
|
|
73
|
+
return this.subject ?? d`${ this.collection }`;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* @param {number} index
|
|
78
|
+
*/
|
|
79
|
+
protected ordinal(index: number): string {
|
|
80
|
+
const
|
|
81
|
+
lastDigit = Math.abs(index) % 10,
|
|
82
|
+
lastTwoDigits = Math.abs(index) % 100;
|
|
83
|
+
|
|
84
|
+
switch (true) {
|
|
85
|
+
case (lastDigit === 1 && lastTwoDigits !== 11):
|
|
86
|
+
return index + 'st';
|
|
87
|
+
case (lastDigit === 2 && lastTwoDigits !== 12):
|
|
88
|
+
return index + 'nd';
|
|
89
|
+
case (lastDigit === 3 && lastTwoDigits !== 13):
|
|
90
|
+
return index + 'rd';
|
|
91
|
+
default:
|
|
92
|
+
return index + 'th';
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* @package
|
|
99
|
+
*/
|
|
100
|
+
class ArrayList<Item_Type> extends List<Item_Type> {
|
|
101
|
+
|
|
102
|
+
override eachMappedTo<Mapped_Item_Type>(
|
|
103
|
+
question: MetaQuestion<Item_Type, Question<Promise<Mapped_Item_Type> | Mapped_Item_Type>>,
|
|
104
|
+
): List<Mapped_Item_Type> {
|
|
105
|
+
return new ArrayList(
|
|
106
|
+
new EachMappedTo(this.collection, question, this.toString())
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
override where<Answer_Type>(
|
|
111
|
+
question: MetaQuestion<Item_Type, Question<Promise<Answer_Type> | Answer_Type>>,
|
|
48
112
|
expectation: Expectation<Answer_Type>
|
|
49
|
-
):
|
|
50
|
-
return new
|
|
51
|
-
new Where(this.collection, question, expectation, this.
|
|
113
|
+
): List<Item_Type> {
|
|
114
|
+
return new ArrayList<Item_Type>(
|
|
115
|
+
new Where(this.collection, question, expectation, this.toString())
|
|
52
116
|
) as this;
|
|
53
117
|
}
|
|
54
118
|
|
|
55
|
-
count(): QuestionAdapter<number> {
|
|
56
|
-
return Question.about(`the number of ${ this.
|
|
119
|
+
override count(): QuestionAdapter<number> {
|
|
120
|
+
return Question.about(`the number of ${ this.toString() }`, async actor => {
|
|
57
121
|
const items = await this.answeredBy(actor);
|
|
58
122
|
return items.length;
|
|
59
123
|
});
|
|
60
124
|
}
|
|
61
125
|
|
|
62
|
-
first(): QuestionAdapter<Item_Type> {
|
|
63
|
-
return Question.about(`the first of ${ this.
|
|
126
|
+
override first(): QuestionAdapter<Item_Type> {
|
|
127
|
+
return Question.about(`the first of ${ this.toString() }`, async actor => {
|
|
64
128
|
const items = await this.answeredBy(actor);
|
|
65
129
|
|
|
66
130
|
if (items.length === 0) {
|
|
@@ -71,8 +135,8 @@ export class List<Item_Type> extends Question<Promise<Item_Type[]>> {
|
|
|
71
135
|
});
|
|
72
136
|
}
|
|
73
137
|
|
|
74
|
-
last(): QuestionAdapter<Item_Type> {
|
|
75
|
-
return Question.about(`the last of ${ this.
|
|
138
|
+
override last(): QuestionAdapter<Item_Type> {
|
|
139
|
+
return Question.about(`the last of ${ this.toString() }`, async actor => {
|
|
76
140
|
const items = await this.answeredBy(actor);
|
|
77
141
|
|
|
78
142
|
if (items.length === 0) {
|
|
@@ -83,56 +147,137 @@ export class List<Item_Type> extends Question<Promise<Item_Type[]>> {
|
|
|
83
147
|
});
|
|
84
148
|
}
|
|
85
149
|
|
|
86
|
-
nth(index: number): QuestionAdapter<Item_Type> {
|
|
87
|
-
return Question.about(`the ${ ordinal(index + 1) } of ${ this.
|
|
150
|
+
override nth(index: number): QuestionAdapter<Item_Type> {
|
|
151
|
+
return Question.about(`the ${ this.ordinal(index + 1) } of ${ this.toString() }`, async actor => {
|
|
88
152
|
const items = await this.answeredBy(actor);
|
|
89
153
|
|
|
90
154
|
if (index < 0 || items.length <= index) {
|
|
91
|
-
throw new ListItemNotFoundError(`Can't retrieve the ${ ordinal(index) } item from a list with ${ items.length } items: ` + d`${ items }`)
|
|
155
|
+
throw new ListItemNotFoundError(`Can't retrieve the ${ this.ordinal(index) } item from a list with ${ items.length } items: ` + d`${ items }`)
|
|
92
156
|
}
|
|
93
157
|
|
|
94
158
|
return items[index];
|
|
95
159
|
});
|
|
96
160
|
}
|
|
161
|
+
}
|
|
97
162
|
|
|
98
|
-
|
|
99
|
-
|
|
163
|
+
/**
|
|
164
|
+
* Serenity/JS Screenplay Pattern-style wrapper around
|
|
165
|
+
* a {@apilink ChainableMetaQuestion} representing a collection
|
|
166
|
+
* that can be resolved in `Supported_Context_Type` of another {@apilink Question}.
|
|
167
|
+
*
|
|
168
|
+
* For example, {@apilink PageElements.located} returns `MetaList<PageElement>`,
|
|
169
|
+
* which allows for the collection of page elements to be resolved in the context
|
|
170
|
+
* of dynamically-provided root element.
|
|
171
|
+
*
|
|
172
|
+
* ```typescript
|
|
173
|
+
* import { By, PageElements, PageElement } from '@serenity-js/web'
|
|
174
|
+
*
|
|
175
|
+
* const firstLabel = () =>
|
|
176
|
+
* PageElements.located(By.css('label'))
|
|
177
|
+
* .first()
|
|
178
|
+
* .describedAs('first label')
|
|
179
|
+
*
|
|
180
|
+
* const exampleForm = () =>
|
|
181
|
+
* PageElement.located(By.css('form#example1'))
|
|
182
|
+
* .describedAs('example form')
|
|
183
|
+
*
|
|
184
|
+
* const anotherExampleForm = () =>
|
|
185
|
+
* PageElement.located(By.css('form#example2'))
|
|
186
|
+
* .describedAs('another example form')
|
|
187
|
+
*
|
|
188
|
+
* // Next, you can compose the above questions dynamically with various "contexts":
|
|
189
|
+
* // firstLabel().of(exampleForm())
|
|
190
|
+
* // firstLabel().of(anotherExampleForm())
|
|
191
|
+
* ```
|
|
192
|
+
*
|
|
193
|
+
* @group Questions
|
|
194
|
+
*/
|
|
195
|
+
export class MetaList<Supported_Context_Type, Item_Type>
|
|
196
|
+
extends List<Item_Type>
|
|
197
|
+
implements ChainableMetaQuestion<Supported_Context_Type, MetaList<Supported_Context_Type, Item_Type>>
|
|
198
|
+
{
|
|
199
|
+
constructor(
|
|
200
|
+
protected override readonly collection: Answerable<Array<Item_Type>> & ChainableMetaQuestion<Supported_Context_Type, Question<Promise<Array<Item_Type>>> | Question<Array<Item_Type>>>
|
|
201
|
+
) {
|
|
202
|
+
super(collection);
|
|
203
|
+
}
|
|
100
204
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
205
|
+
of(context: Answerable<Supported_Context_Type>): MetaList<Supported_Context_Type, Item_Type> {
|
|
206
|
+
return new MetaList<Supported_Context_Type, Item_Type>(
|
|
207
|
+
this.collection.of(context)
|
|
208
|
+
).describedAs(this.toString() + d` of ${ context }`)
|
|
209
|
+
}
|
|
104
210
|
|
|
105
|
-
|
|
211
|
+
override eachMappedTo<Mapped_Item_Type>(
|
|
212
|
+
question: MetaQuestion<Item_Type, Question<Promise<Mapped_Item_Type> | Mapped_Item_Type>>,
|
|
213
|
+
): MetaList<Supported_Context_Type, Mapped_Item_Type> {
|
|
214
|
+
return new MetaList(
|
|
215
|
+
new MetaEachMappedTo(this.collection, question, this.toString()),
|
|
216
|
+
);
|
|
106
217
|
}
|
|
107
218
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
219
|
+
override where<Answer_Type>(
|
|
220
|
+
question: MetaQuestion<Item_Type, Question<Promise<Answer_Type> | Answer_Type>>,
|
|
221
|
+
expectation: Expectation<Answer_Type>
|
|
222
|
+
): MetaList<Supported_Context_Type, Item_Type> {
|
|
223
|
+
return new MetaList<Supported_Context_Type, Item_Type>(
|
|
224
|
+
new MetaWhere(this.collection, question, expectation, this.toString())
|
|
225
|
+
) as this;
|
|
111
226
|
}
|
|
112
227
|
|
|
113
|
-
|
|
114
|
-
return this.
|
|
228
|
+
override count(): MetaQuestionAdapter<Supported_Context_Type, number> {
|
|
229
|
+
return Question.about(`the number of ${ this.toString() }`,
|
|
230
|
+
async actor => {
|
|
231
|
+
const items = await this.answeredBy(actor);
|
|
232
|
+
return items.length;
|
|
233
|
+
},
|
|
234
|
+
(parent: Answerable<Supported_Context_Type>) => this.of(parent).count()
|
|
235
|
+
);
|
|
115
236
|
}
|
|
116
|
-
}
|
|
117
237
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
238
|
+
override first(): MetaQuestionAdapter<Supported_Context_Type, Item_Type> {
|
|
239
|
+
return Question.about(`the first of ${ this.toString() }`,
|
|
240
|
+
async actor => {
|
|
241
|
+
const items = await this.answeredBy(actor);
|
|
242
|
+
|
|
243
|
+
if (items.length === 0) {
|
|
244
|
+
throw new ListItemNotFoundError(d`Can't retrieve the first item from a list with 0 items: ${ items }`)
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
return items[0];
|
|
248
|
+
},
|
|
249
|
+
(parent: Answerable<Supported_Context_Type>) => this.of(parent).first()
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
override last(): MetaQuestionAdapter<Supported_Context_Type, Item_Type> {
|
|
254
|
+
return Question.about(`the last of ${ this.toString() }`,
|
|
255
|
+
async actor => {
|
|
256
|
+
const items = await this.answeredBy(actor);
|
|
257
|
+
|
|
258
|
+
if (items.length === 0) {
|
|
259
|
+
throw new ListItemNotFoundError(d`Can't retrieve the last item from a list with 0 items: ${ items }`)
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
return items.at(-1);
|
|
263
|
+
},
|
|
264
|
+
(parent: Answerable<Supported_Context_Type>) => this.of(parent).last()
|
|
265
|
+
);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
override nth(index: number): MetaQuestionAdapter<Supported_Context_Type, Item_Type> {
|
|
269
|
+
return Question.about(`the ${ this.ordinal(index + 1) } of ${ this.toString() }`,
|
|
270
|
+
async actor => {
|
|
271
|
+
const items = await this.answeredBy(actor);
|
|
272
|
+
|
|
273
|
+
if (index < 0 || items.length <= index) {
|
|
274
|
+
throw new ListItemNotFoundError(`Can't retrieve the ${ this.ordinal(index) } item from a list with ${ items.length } items: ` + d`${ items }`)
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
return items[index];
|
|
278
|
+
},
|
|
279
|
+
(parent: Answerable<Supported_Context_Type>) => this.of(parent).nth(index)
|
|
280
|
+
);
|
|
136
281
|
}
|
|
137
282
|
}
|
|
138
283
|
|
|
@@ -145,9 +290,9 @@ class Where<Item_Type, Answer_Type>
|
|
|
145
290
|
private subject: string;
|
|
146
291
|
|
|
147
292
|
constructor(
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
293
|
+
protected readonly collection: Answerable<Array<Item_Type>>,
|
|
294
|
+
protected readonly question: MetaQuestion<Item_Type, Question<Promise<Answer_Type> | Answer_Type>>,
|
|
295
|
+
protected readonly expectation: Expectation<Answer_Type>,
|
|
151
296
|
originalSubject: string,
|
|
152
297
|
) {
|
|
153
298
|
super();
|
|
@@ -175,7 +320,7 @@ class Where<Item_Type, Answer_Type>
|
|
|
175
320
|
|
|
176
321
|
return results;
|
|
177
322
|
} catch (error) {
|
|
178
|
-
throw new LogicError(d`Couldn't check if ${ this.question } of an item of ${ this.collection } does ${ this.expectation }
|
|
323
|
+
throw new LogicError(d`Couldn't check if ${ this.question } of an item of ${ this.collection } does ${ this.expectation }: ` + error.message, error);
|
|
179
324
|
}
|
|
180
325
|
}
|
|
181
326
|
|
|
@@ -189,6 +334,25 @@ class Where<Item_Type, Answer_Type>
|
|
|
189
334
|
}
|
|
190
335
|
}
|
|
191
336
|
|
|
337
|
+
/**
|
|
338
|
+
* @package
|
|
339
|
+
*/
|
|
340
|
+
class MetaWhere<Supported_Context_Type, Item_Type, Answer_Type>
|
|
341
|
+
extends Where<Item_Type, Answer_Type>
|
|
342
|
+
implements ChainableMetaQuestion<Supported_Context_Type, Question<Promise<Array<Item_Type>>> | Question<Array<Item_Type>>>
|
|
343
|
+
{
|
|
344
|
+
protected override readonly collection: Answerable<Array<Item_Type>> & ChainableMetaQuestion<Supported_Context_Type, Question<Promise<Array<Item_Type>>> | Question<Array<Item_Type>>>;
|
|
345
|
+
|
|
346
|
+
of(context: Answerable<Supported_Context_Type>): MetaWhere<Supported_Context_Type, Item_Type, Answer_Type> {
|
|
347
|
+
return new MetaWhere<Supported_Context_Type, Item_Type, Answer_Type>(
|
|
348
|
+
this.collection.of(context),
|
|
349
|
+
this.question,
|
|
350
|
+
this.expectation,
|
|
351
|
+
this.toString()
|
|
352
|
+
);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
192
356
|
/**
|
|
193
357
|
* @package
|
|
194
358
|
*/
|
|
@@ -197,8 +361,8 @@ class EachMappedTo<Item_Type, Mapped_Item_Type> extends Question<Promise<Array<M
|
|
|
197
361
|
private subject: string;
|
|
198
362
|
|
|
199
363
|
constructor(
|
|
200
|
-
|
|
201
|
-
|
|
364
|
+
protected readonly collection: Answerable<Array<Item_Type>>,
|
|
365
|
+
protected readonly mapping: MetaQuestion<Item_Type, Question<Promise<Mapped_Item_Type> | Mapped_Item_Type>>,
|
|
202
366
|
originalSubject: string,
|
|
203
367
|
) {
|
|
204
368
|
super();
|
|
@@ -228,6 +392,19 @@ class EachMappedTo<Item_Type, Mapped_Item_Type> extends Question<Promise<Array<M
|
|
|
228
392
|
}
|
|
229
393
|
}
|
|
230
394
|
|
|
395
|
+
/**
|
|
396
|
+
* @package
|
|
397
|
+
*/
|
|
398
|
+
class MetaEachMappedTo<Supported_Context_Type, Item_Type, Mapped_Item_Type>
|
|
399
|
+
extends EachMappedTo<Item_Type, Mapped_Item_Type>
|
|
400
|
+
{
|
|
401
|
+
protected override readonly collection: Answerable<Array<Item_Type>> & ChainableMetaQuestion<Supported_Context_Type, Question<Promise<Array<Item_Type>>> | Question<Array<Item_Type>>>;
|
|
402
|
+
|
|
403
|
+
of(context: Answerable<Supported_Context_Type>): MetaEachMappedTo<Supported_Context_Type, Item_Type, Mapped_Item_Type> {
|
|
404
|
+
return new MetaEachMappedTo<Supported_Context_Type, Item_Type, Mapped_Item_Type>(this.collection.of(context), this.mapping, this.toString());
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
|
|
231
408
|
/**
|
|
232
409
|
* @package
|
|
233
410
|
*/
|