@serenity-js/core 2.32.7 → 3.0.0-rc.10
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 +350 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.js +6 -1
- package/lib/index.js.map +1 -1
- package/lib/io/ErrorSerialiser.js +4 -1
- package/lib/io/ErrorSerialiser.js.map +1 -1
- package/lib/io/asyncMap.d.ts +8 -0
- package/lib/io/asyncMap.js +18 -0
- package/lib/io/asyncMap.js.map +1 -0
- package/lib/io/format.d.ts +39 -0
- package/lib/io/format.js +51 -0
- package/lib/io/format.js.map +1 -0
- package/lib/io/formatted.d.ts +5 -1
- package/lib/io/formatted.js +6 -13
- package/lib/io/formatted.js.map +1 -1
- package/lib/io/index.d.ts +2 -1
- package/lib/io/index.js +2 -1
- package/lib/io/index.js.map +1 -1
- package/lib/io/inspected.d.ts +9 -1
- package/lib/io/inspected.js +52 -15
- package/lib/io/inspected.js.map +1 -1
- package/lib/model/Timestamp.d.ts +4 -2
- package/lib/model/Timestamp.js +8 -2
- package/lib/model/Timestamp.js.map +1 -1
- package/lib/screenplay/Optional.d.ts +29 -0
- package/lib/{io/collections/reducible.js → screenplay/Optional.js} +1 -1
- package/lib/screenplay/Optional.js.map +1 -0
- package/lib/screenplay/Question.d.ts +41 -82
- package/lib/screenplay/Question.js +132 -100
- package/lib/screenplay/Question.js.map +1 -1
- package/lib/screenplay/actor/Actor.js +2 -2
- package/lib/screenplay/actor/Actor.js.map +1 -1
- package/lib/screenplay/index.d.ts +1 -1
- package/lib/screenplay/index.js +1 -1
- package/lib/screenplay/index.js.map +1 -1
- package/lib/screenplay/interactions/index.d.ts +0 -1
- package/lib/screenplay/interactions/index.js +0 -1
- package/lib/screenplay/interactions/index.js.map +1 -1
- package/lib/screenplay/questions/Check.d.ts +3 -3
- package/lib/screenplay/questions/Check.js +5 -7
- package/lib/screenplay/questions/Check.js.map +1 -1
- package/lib/screenplay/questions/Expectation.d.ts +15 -10
- package/lib/screenplay/questions/Expectation.js +28 -37
- package/lib/screenplay/questions/Expectation.js.map +1 -1
- package/lib/screenplay/questions/List.d.ts +22 -192
- package/lib/screenplay/questions/List.js +160 -208
- package/lib/screenplay/questions/List.js.map +1 -1
- package/lib/screenplay/questions/Note.d.ts +10 -0
- package/lib/screenplay/questions/Note.js +17 -1
- package/lib/screenplay/questions/Note.js.map +1 -1
- package/lib/screenplay/questions/index.d.ts +0 -3
- package/lib/screenplay/questions/index.js +0 -5
- package/lib/screenplay/questions/index.js.map +1 -1
- package/lib/stage/index.d.ts +0 -2
- package/lib/stage/index.js +0 -2
- package/lib/stage/index.js.map +1 -1
- package/package.json +7 -7
- package/src/index.ts +2 -1
- package/src/io/ErrorSerialiser.ts +5 -1
- package/src/io/asyncMap.ts +18 -0
- package/src/io/format.ts +49 -0
- package/src/io/formatted.ts +7 -15
- package/src/io/index.ts +2 -1
- package/src/io/inspected.ts +68 -15
- package/src/model/Timestamp.ts +10 -2
- package/src/screenplay/Optional.ts +30 -0
- package/src/screenplay/Question.ts +206 -124
- package/src/screenplay/actor/Actor.ts +2 -2
- package/src/screenplay/index.ts +1 -1
- package/src/screenplay/interactions/index.ts +0 -1
- package/src/screenplay/questions/Check.ts +10 -15
- package/src/screenplay/questions/Expectation.ts +48 -55
- package/src/screenplay/questions/List.ts +224 -233
- package/src/screenplay/questions/Note.ts +21 -1
- package/src/screenplay/questions/index.ts +0 -3
- package/src/stage/index.ts +0 -2
- package/lib/io/collections/index.d.ts +0 -2
- package/lib/io/collections/index.js +0 -15
- package/lib/io/collections/index.js.map +0 -1
- package/lib/io/collections/mappable.d.ts +0 -52
- package/lib/io/collections/mappable.js +0 -28
- package/lib/io/collections/mappable.js.map +0 -1
- package/lib/io/collections/reducible.d.ts +0 -16
- package/lib/io/collections/reducible.js.map +0 -1
- package/lib/screenplay/interactions/See.d.ts +0 -31
- package/lib/screenplay/interactions/See.js +0 -43
- package/lib/screenplay/interactions/See.js.map +0 -1
- package/lib/screenplay/questions/Property.d.ts +0 -91
- package/lib/screenplay/questions/Property.js +0 -99
- package/lib/screenplay/questions/Property.js.map +0 -1
- package/lib/screenplay/questions/Transform.d.ts +0 -31
- package/lib/screenplay/questions/Transform.js +0 -46
- package/lib/screenplay/questions/Transform.js.map +0 -1
- package/lib/screenplay/questions/lists/ArrayListAdapter.d.ts +0 -88
- package/lib/screenplay/questions/lists/ArrayListAdapter.js +0 -152
- package/lib/screenplay/questions/lists/ArrayListAdapter.js.map +0 -1
- package/lib/screenplay/questions/lists/ListAdapter.d.ts +0 -20
- package/lib/screenplay/questions/lists/ListAdapter.js +0 -3
- package/lib/screenplay/questions/lists/ListAdapter.js.map +0 -1
- package/lib/screenplay/questions/lists/index.d.ts +0 -2
- package/lib/screenplay/questions/lists/index.js +0 -15
- package/lib/screenplay/questions/lists/index.js.map +0 -1
- package/lib/screenplay/questions/mappings/AnswerMappingFunction.d.ts +0 -11
- package/lib/screenplay/questions/mappings/AnswerMappingFunction.js +0 -3
- package/lib/screenplay/questions/mappings/AnswerMappingFunction.js.map +0 -1
- package/lib/screenplay/questions/mappings/index.d.ts +0 -2
- package/lib/screenplay/questions/mappings/index.js +0 -15
- package/lib/screenplay/questions/mappings/index.js.map +0 -1
- package/lib/screenplay/questions/mappings/string/append.d.ts +0 -14
- package/lib/screenplay/questions/mappings/string/append.js +0 -25
- package/lib/screenplay/questions/mappings/string/append.js.map +0 -1
- package/lib/screenplay/questions/mappings/string/index.d.ts +0 -11
- package/lib/screenplay/questions/mappings/string/index.js +0 -24
- package/lib/screenplay/questions/mappings/string/index.js.map +0 -1
- package/lib/screenplay/questions/mappings/string/normalize.d.ts +0 -20
- package/lib/screenplay/questions/mappings/string/normalize.js +0 -30
- package/lib/screenplay/questions/mappings/string/normalize.js.map +0 -1
- package/lib/screenplay/questions/mappings/string/replace.d.ts +0 -17
- package/lib/screenplay/questions/mappings/string/replace.js +0 -30
- package/lib/screenplay/questions/mappings/string/replace.js.map +0 -1
- package/lib/screenplay/questions/mappings/string/slice.d.ts +0 -28
- package/lib/screenplay/questions/mappings/string/slice.js +0 -47
- package/lib/screenplay/questions/mappings/string/slice.js.map +0 -1
- package/lib/screenplay/questions/mappings/string/split.d.ts +0 -19
- package/lib/screenplay/questions/mappings/string/split.js +0 -36
- package/lib/screenplay/questions/mappings/string/split.js.map +0 -1
- package/lib/screenplay/questions/mappings/string/toLocaleLowerCase.d.ts +0 -17
- package/lib/screenplay/questions/mappings/string/toLocaleLowerCase.js +0 -28
- package/lib/screenplay/questions/mappings/string/toLocaleLowerCase.js.map +0 -1
- package/lib/screenplay/questions/mappings/string/toLocaleUpperCase.d.ts +0 -17
- package/lib/screenplay/questions/mappings/string/toLocaleUpperCase.js +0 -29
- package/lib/screenplay/questions/mappings/string/toLocaleUpperCase.js.map +0 -1
- package/lib/screenplay/questions/mappings/string/toLowerCase.d.ts +0 -10
- package/lib/screenplay/questions/mappings/string/toLowerCase.js +0 -19
- package/lib/screenplay/questions/mappings/string/toLowerCase.js.map +0 -1
- package/lib/screenplay/questions/mappings/string/toNumber.d.ts +0 -10
- package/lib/screenplay/questions/mappings/string/toNumber.js +0 -18
- package/lib/screenplay/questions/mappings/string/toNumber.js.map +0 -1
- package/lib/screenplay/questions/mappings/string/toUpperCase.d.ts +0 -10
- package/lib/screenplay/questions/mappings/string/toUpperCase.js +0 -19
- package/lib/screenplay/questions/mappings/string/toUpperCase.js.map +0 -1
- package/lib/screenplay/questions/mappings/string/trim.d.ts +0 -12
- package/lib/screenplay/questions/mappings/string/trim.js +0 -21
- package/lib/screenplay/questions/mappings/string/trim.js.map +0 -1
- package/lib/screenplay/questions/proxies/PropertyPathKey.d.ts +0 -4
- package/lib/screenplay/questions/proxies/PropertyPathKey.js +0 -3
- package/lib/screenplay/questions/proxies/PropertyPathKey.js.map +0 -1
- package/lib/screenplay/questions/proxies/createMetaQuestionProxy.d.ts +0 -14
- package/lib/screenplay/questions/proxies/createMetaQuestionProxy.js +0 -35
- package/lib/screenplay/questions/proxies/createMetaQuestionProxy.js.map +0 -1
- package/lib/screenplay/questions/proxies/createQuestionProxy.d.ts +0 -13
- package/lib/screenplay/questions/proxies/createQuestionProxy.js +0 -34
- package/lib/screenplay/questions/proxies/createQuestionProxy.js.map +0 -1
- package/lib/screenplay/questions/proxies/describePath.d.ts +0 -5
- package/lib/screenplay/questions/proxies/describePath.js +0 -19
- package/lib/screenplay/questions/proxies/describePath.js.map +0 -1
- package/lib/screenplay/questions/proxies/index.d.ts +0 -2
- package/lib/screenplay/questions/proxies/index.js +0 -15
- package/lib/screenplay/questions/proxies/index.js.map +0 -1
- package/lib/screenplay/questions/proxies/key.d.ts +0 -8
- package/lib/screenplay/questions/proxies/key.js +0 -16
- package/lib/screenplay/questions/proxies/key.js.map +0 -1
- package/lib/screenplay/tasks/Loop.d.ts +0 -198
- package/lib/screenplay/tasks/Loop.js +0 -222
- package/lib/screenplay/tasks/Loop.js.map +0 -1
- package/lib/screenplay/tasks/index.d.ts +0 -1
- package/lib/screenplay/tasks/index.js +0 -14
- package/lib/screenplay/tasks/index.js.map +0 -1
- package/lib/stage/DressingRoom.d.ts +0 -37
- package/lib/stage/DressingRoom.js +0 -53
- package/lib/stage/DressingRoom.js.map +0 -1
- package/lib/stage/WithStage.d.ts +0 -51
- package/lib/stage/WithStage.js +0 -3
- package/lib/stage/WithStage.js.map +0 -1
- package/src/io/collections/index.ts +0 -2
- package/src/io/collections/mappable.ts +0 -60
- package/src/io/collections/reducible.ts +0 -16
- package/src/screenplay/interactions/See.ts +0 -45
- package/src/screenplay/questions/Property.ts +0 -98
- package/src/screenplay/questions/Transform.ts +0 -51
- package/src/screenplay/questions/lists/ArrayListAdapter.ts +0 -186
- package/src/screenplay/questions/lists/ListAdapter.ts +0 -33
- package/src/screenplay/questions/lists/index.ts +0 -2
- package/src/screenplay/questions/mappings/AnswerMappingFunction.ts +0 -13
- package/src/screenplay/questions/mappings/index.ts +0 -2
- package/src/screenplay/questions/mappings/string/append.ts +0 -28
- package/src/screenplay/questions/mappings/string/index.ts +0 -11
- package/src/screenplay/questions/mappings/string/normalize.ts +0 -33
- package/src/screenplay/questions/mappings/string/replace.ts +0 -34
- package/src/screenplay/questions/mappings/string/slice.ts +0 -53
- package/src/screenplay/questions/mappings/string/split.ts +0 -38
- package/src/screenplay/questions/mappings/string/toLocaleLowerCase.ts +0 -31
- package/src/screenplay/questions/mappings/string/toLocaleUpperCase.ts +0 -30
- package/src/screenplay/questions/mappings/string/toLowerCase.ts +0 -20
- package/src/screenplay/questions/mappings/string/toNumber.ts +0 -19
- package/src/screenplay/questions/mappings/string/toUpperCase.ts +0 -20
- package/src/screenplay/questions/mappings/string/trim.ts +0 -22
- package/src/screenplay/questions/proxies/PropertyPathKey.ts +0 -4
- package/src/screenplay/questions/proxies/createMetaQuestionProxy.ts +0 -51
- package/src/screenplay/questions/proxies/createQuestionProxy.ts +0 -49
- package/src/screenplay/questions/proxies/describePath.ts +0 -23
- package/src/screenplay/questions/proxies/index.ts +0 -2
- package/src/screenplay/questions/proxies/key.ts +0 -14
- package/src/screenplay/tasks/Loop.ts +0 -240
- package/src/screenplay/tasks/index.ts +0 -1
- package/src/stage/DressingRoom.ts +0 -53
- package/src/stage/WithStage.ts +0 -52
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Loop = void 0;
|
|
4
|
-
const io_1 = require("../../io");
|
|
5
|
-
const Question_1 = require("../Question");
|
|
6
|
-
const Task_1 = require("../Task");
|
|
7
|
-
/**
|
|
8
|
-
* @desc
|
|
9
|
-
* Enables the {@link Actor} to iterate over a list of items produced by any {@link Answerable}.
|
|
10
|
-
*
|
|
11
|
-
* You can think of `Loop` as a more sophisticated Screenplay-style equivalent of
|
|
12
|
-
* [`Array.forEach`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach).
|
|
13
|
-
* `Loop` is capable of working with both synchronous data structures,
|
|
14
|
-
* such as [`Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)
|
|
15
|
-
* and `Question<Array<T>>`,
|
|
16
|
-
* as well as asynchronous ones, so `Promise<Array<T>>` and `Question<Promise<Array<T>>>`.
|
|
17
|
-
*
|
|
18
|
-
* Use {@link Loop.item} to access the current item being processed by {@link Loop}, and {@link Loop.index}
|
|
19
|
-
* to access the index of {@link Loop.item} in the list.
|
|
20
|
-
*
|
|
21
|
-
* @example <caption>Basic scenario - Iterating over a static list of items</caption>
|
|
22
|
-
* import { actorCalled, Loop, Log } from '@serenity-js/core';
|
|
23
|
-
*
|
|
24
|
-
* actorCalled('Joe').attemptsTo(
|
|
25
|
-
* Loop.over([ 'apple', 'banana', 'candy' ]).to(
|
|
26
|
-
* Log.the('current element', Loop.item<string>()),
|
|
27
|
-
* Log.the('current index', Loop.index()),
|
|
28
|
-
* ),
|
|
29
|
-
* );
|
|
30
|
-
*
|
|
31
|
-
* @example <caption>API scenario - Iterating over items in an API response</caption>
|
|
32
|
-
*
|
|
33
|
-
* import { actorCalled, Loop } from '@serenity-js/core';
|
|
34
|
-
* import { Send, GetRequest, CallAnApi, LastResponse } from '@serenity-js/rest';
|
|
35
|
-
* import { Ensure, property, isGreaterThan } from '@serenity-js/assertions';
|
|
36
|
-
*
|
|
37
|
-
* interface TodoItem {
|
|
38
|
-
* userId: number;
|
|
39
|
-
* id: number;
|
|
40
|
-
* title: string;
|
|
41
|
-
* completed: boolean;
|
|
42
|
-
* }
|
|
43
|
-
*
|
|
44
|
-
* actorCalled('Joe').whoCan(
|
|
45
|
-
* CallAnApi.at('https://jsonplaceholder.typicode.com')
|
|
46
|
-
* ).attemptsTo(
|
|
47
|
-
* Send.a(GetRequest.to('/todos')),
|
|
48
|
-
* Loop.over(LastResponse.body<TodoItem[]>()).to(
|
|
49
|
-
* Ensure.that(
|
|
50
|
-
* Loop.item<TodoItem>(),
|
|
51
|
-
* property('userId', isGreaterThan(0)),
|
|
52
|
-
* ),
|
|
53
|
-
* )
|
|
54
|
-
* );
|
|
55
|
-
*
|
|
56
|
-
* @example <caption>UI scenario - Example widget</caption>
|
|
57
|
-
* <nav>
|
|
58
|
-
* <div data-test="cookies">
|
|
59
|
-
* <label for="functional-cookies">
|
|
60
|
-
* <input type="checkbox" id="functional-cookies" />Allow functional cookies
|
|
61
|
-
* </label>
|
|
62
|
-
* <label for="performance-cookies">
|
|
63
|
-
* <input type="checkbox" id="performance-cookies" />Allow performance cookies
|
|
64
|
-
* </label>
|
|
65
|
-
* <label for="advertising-cookies">
|
|
66
|
-
* <input type="checkbox" id="advertising-cookies" />Allow advertising cookies
|
|
67
|
-
* </label>
|
|
68
|
-
* </div>
|
|
69
|
-
* </nav>
|
|
70
|
-
*
|
|
71
|
-
* @example <caption>UI scenario - Lean Page Object</caption>
|
|
72
|
-
* import { Target } from '@serenity-js/protractor';
|
|
73
|
-
* import { browser, by } from 'protractor';
|
|
74
|
-
*
|
|
75
|
-
* class Cookies {
|
|
76
|
-
* static labels = Target.all('cookie options')
|
|
77
|
-
* .located(by.css('[data-test="cookies"]'));
|
|
78
|
-
*
|
|
79
|
-
* static checkbox = Target.the('checkbox')
|
|
80
|
-
* .located(by.tagName('input')),
|
|
81
|
-
* }
|
|
82
|
-
*
|
|
83
|
-
* @example <caption>UI scenario - Performing the same set of activities with each element</caption>
|
|
84
|
-
* import { actorCalled, Loop } from '@serenity-js/core';
|
|
85
|
-
* import { Click, Text, isSelected } from '@serenity-js/protractor';
|
|
86
|
-
* import { Ensure, startsWith } from '@serenity-js/assertions';
|
|
87
|
-
* import { protractor } from 'protractor';
|
|
88
|
-
*
|
|
89
|
-
* actorCalled('Joe')
|
|
90
|
-
* .whoCan(BrowseTheWeb.using(protractor.browser))
|
|
91
|
-
* .attemptsTo(
|
|
92
|
-
* Loop.over(Cookies.labels).to(
|
|
93
|
-
* Ensure.that(
|
|
94
|
-
* Text.of(Loop.item<ElementFinder>()),
|
|
95
|
-
* startsWith('Allow'),
|
|
96
|
-
* ),
|
|
97
|
-
*
|
|
98
|
-
* Click.on(Loop.item<ElementFinder>()),
|
|
99
|
-
* Ensure.that(
|
|
100
|
-
* Cookies.checkbox.of(Loop.item<ElementFinder>()),
|
|
101
|
-
* isSelected(),
|
|
102
|
-
* ),
|
|
103
|
-
* ),
|
|
104
|
-
* );
|
|
105
|
-
*
|
|
106
|
-
* @extends {Task}
|
|
107
|
-
*
|
|
108
|
-
* @see {@link Loop.item}
|
|
109
|
-
* @see {@link Loop.index}
|
|
110
|
-
* @see {@link Question}
|
|
111
|
-
*/
|
|
112
|
-
class Loop extends Task_1.Task {
|
|
113
|
-
/**
|
|
114
|
-
* @param {Answerable<Reducible>} items
|
|
115
|
-
* @param {Activity[]} activities
|
|
116
|
-
*/
|
|
117
|
-
constructor(items, activities) {
|
|
118
|
-
super();
|
|
119
|
-
this.items = items;
|
|
120
|
-
this.activities = activities;
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* @desc
|
|
124
|
-
* Instantiates a {@link Task} to {@link Loop}
|
|
125
|
-
* that enables the {@link Actor} to iterate over `items`
|
|
126
|
-
* to perform some `activities`.
|
|
127
|
-
*
|
|
128
|
-
* @param {items: Answerable<ReducibleCollection>} items
|
|
129
|
-
* @returns {LoopBuilder}
|
|
130
|
-
*/
|
|
131
|
-
static over(items) {
|
|
132
|
-
return {
|
|
133
|
-
to: (...activities) => new Loop(items, activities)
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* @desc
|
|
138
|
-
* Returns the current item being processed by {@link Loop.over}.
|
|
139
|
-
*
|
|
140
|
-
* **Please note** that in order for the TypeScript transpiler to understand the exact `ExpectedType`
|
|
141
|
-
* of the {@link Question} produced by this method you can optionally configure it with
|
|
142
|
-
* a [_type variable_](https://www.typescriptlang.org/docs/handbook/generics.html).
|
|
143
|
-
*
|
|
144
|
-
* For example, configuring the method with type variable of `string`, so `Loop.item<string>()`,
|
|
145
|
-
* tells the transpiler that a `Question<string>` will be returned.
|
|
146
|
-
*
|
|
147
|
-
* If the type variable is not configured, the transpiler assumes that returned type is a
|
|
148
|
-
* `Question<any>`. This means that while your code could still work, you'd miss out
|
|
149
|
-
* on checking provided by TypeScript.
|
|
150
|
-
*
|
|
151
|
-
* @returns {Question<ExpectedType>}
|
|
152
|
-
*/
|
|
153
|
-
static item() {
|
|
154
|
-
return Question_1.Question.about(`current loop item`, actor => Loop.currentItem);
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* @desc
|
|
158
|
-
* Returns the index of current {@link Loop.item} in the `Answerable<Array>` given to {@link Loop.over}.
|
|
159
|
-
*
|
|
160
|
-
* The index starts at `0`.
|
|
161
|
-
*
|
|
162
|
-
* @returns {Question<number>}
|
|
163
|
-
*/
|
|
164
|
-
static index() {
|
|
165
|
-
return Question_1.Question.about(`current loop index`, actor => Loop.currentIndex);
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* @desc
|
|
169
|
-
* Makes the provided {@link Actor}
|
|
170
|
-
* perform this {@link Task}.
|
|
171
|
-
*
|
|
172
|
-
* @param {PerformsActivities & UsesAbilities & AnswersQuestions} actor
|
|
173
|
-
* @returns {Promise<void>}
|
|
174
|
-
*
|
|
175
|
-
* @see {@link Actor}
|
|
176
|
-
* @see {@link PerformsActivities}
|
|
177
|
-
* @see {@link UsesAbilities}
|
|
178
|
-
* @see {@link AnswersQuestions}
|
|
179
|
-
*/
|
|
180
|
-
performAs(actor) {
|
|
181
|
-
return actor.answer(this.items)
|
|
182
|
-
.then(items => items.reduce((previous, current, index) => {
|
|
183
|
-
return previous.then(() => {
|
|
184
|
-
Loop.currentIndex = index;
|
|
185
|
-
Loop.currentItem = current;
|
|
186
|
-
return actor.attemptsTo(...this.activities);
|
|
187
|
-
});
|
|
188
|
-
}, Promise.resolve(void 0)));
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* @desc
|
|
192
|
-
* Generates a description to be used when reporting this {@link Activity}.
|
|
193
|
-
*
|
|
194
|
-
* @returns {string}
|
|
195
|
-
*/
|
|
196
|
-
toString() {
|
|
197
|
-
const description = Array.isArray(this.items)
|
|
198
|
-
? `a list of ${this.items.length} item${this.items.length !== 1 ? 's' : ''}`
|
|
199
|
-
: (0, io_1.formatted) `${this.items}`;
|
|
200
|
-
return `#actor loops over ${description}`;
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
exports.Loop = Loop;
|
|
204
|
-
Loop.currentItem = undefined;
|
|
205
|
-
Loop.currentIndex = 0;
|
|
206
|
-
/**
|
|
207
|
-
* @typedef {Object} LoopBuilder
|
|
208
|
-
* @property {function(...activities: Activity[]): Loop} to
|
|
209
|
-
*
|
|
210
|
-
* @example <caption>Basic scenario - Iterating over a static list of items</caption>
|
|
211
|
-
* import { actorCalled, Loop, Log } from '@serenity-js/core';
|
|
212
|
-
*
|
|
213
|
-
* actorCalled('Joe').attemptsTo(
|
|
214
|
-
* Loop.over([ 'apple', 'banana', 'candy' ]).to(
|
|
215
|
-
* Log.the('current element', Loop.item<string>()),
|
|
216
|
-
* ),
|
|
217
|
-
* );
|
|
218
|
-
*
|
|
219
|
-
* @see {@link Loop}
|
|
220
|
-
* @see {@link Loop.over}
|
|
221
|
-
*/
|
|
222
|
-
//# sourceMappingURL=Loop.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Loop.js","sourceRoot":"","sources":["../../../src/screenplay/tasks/Loop.ts"],"names":[],"mappings":";;;AAAA,iCAAgD;AAIhD,0CAAuC;AACvC,kCAA+B;AAE/B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwGG;AACH,MAAa,IAAW,SAAQ,WAAI;IAyDhC;;;OAGG;IACH,YACqB,KAA4B,EAC5B,UAAsB;QAEvC,KAAK,EAAE,CAAC;QAHS,UAAK,GAAL,KAAK,CAAuB;QAC5B,eAAU,GAAV,UAAU,CAAY;IAG3C,CAAC;IA9DD;;;;;;;;OAQG;IACH,MAAM,CAAC,IAAI,CAAI,KAA4B;QACvC,OAAO;YACH,EAAE,EAAE,CAAC,GAAG,UAAsB,EAAE,EAAE,CAC9B,IAAI,IAAI,CAAI,KAAK,EAAE,UAAU,CAAC;SACrC,CAAA;IACL,CAAC;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,MAAM,CAAC,IAAI;QACP,OAAO,mBAAQ,CAAC,KAAK,CAAe,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAC7D,IAAI,CAAC,WAA2B,CACnC,CAAC;IACN,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,KAAK;QACR,OAAO,mBAAQ,CAAC,KAAK,CAAS,oBAAoB,EAAE,KAAK,CAAC,EAAE,CACxD,IAAI,CAAC,YAAY,CACpB,CAAC;IACN,CAAC;IAaD;;;;;;;;;;;;OAYG;IACH,SAAS,CAAC,KAA4D;QAClE,OAAO,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;aAC1B,IAAI,CAAC,KAAK,CAAC,EAAE,CACV,KAAK,CAAC,MAAM,CAAC,CAAC,QAAuB,EAAE,OAAa,EAAE,KAAa,EAAE,EAAE;YACnE,OAAO,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE;gBACtB,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;gBAC1B,IAAI,CAAC,WAAW,GAAI,OAAO,CAAC;gBAE5B,OAAO,KAAK,CAAC,UAAU,CACnB,GAAG,IAAI,CAAC,UAAU,CACrB,CAAC;YACN,CAAC,CAAC,CAAC;QACP,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAC9B,CAAC;IACV,CAAC;IAED;;;;;OAKG;IACH,QAAQ;QACJ,MAAM,WAAW,GAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC;YAC1C,CAAC,CAAC,aAAc,IAAI,CAAC,KAAK,CAAC,MAAO,QAAS,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAG,EAAE;YAChF,CAAC,CAAC,IAAA,cAAS,EAAC,GAAI,IAAI,CAAC,KAAM,EAAE,CAAC;QAElC,OAAO,qBAAsB,WAAY,EAAE,CAAC;IAChD,CAAC;;AA7GL,oBA8GC;AA7GkB,gBAAW,GAAY,SAAS,CAAC;AACjC,iBAAY,GAAG,CAAC,CAAC;AA8GpC;;;;;;;;;;;;;;;GAeG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './Loop';
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
-
};
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
__exportStar(require("./Loop"), exports);
|
|
14
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/screenplay/tasks/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAuB"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { Ability, Actor } from '../screenplay';
|
|
2
|
-
/**
|
|
3
|
-
* @desc
|
|
4
|
-
* Prepares the {@link Actor} for the performance.
|
|
5
|
-
*
|
|
6
|
-
* @example <caption>A dressing room for actors interacting with a Web UI</caption>
|
|
7
|
-
*
|
|
8
|
-
* import { serenity, Actor, DressingRoom } from '@serenity-js/core'
|
|
9
|
-
* import { BrowseTheWeb } from '@serenity-js/protractor'
|
|
10
|
-
* import { protractor } from 'protractor'
|
|
11
|
-
*
|
|
12
|
-
* class UIActors implements DressingRoom {
|
|
13
|
-
* prepare(actor: Actor) {
|
|
14
|
-
* return actor.whoCan(BrowseTheWeb.using(protractor.browser));
|
|
15
|
-
* }
|
|
16
|
-
* }
|
|
17
|
-
*
|
|
18
|
-
* const stage = serenity.callToStageFor(new UIActors());
|
|
19
|
-
*
|
|
20
|
-
* @see {@link Stage}
|
|
21
|
-
* @see {@link Cast}
|
|
22
|
-
* @interface
|
|
23
|
-
*
|
|
24
|
-
* @deprecated Please use the Cast instead
|
|
25
|
-
*/
|
|
26
|
-
export declare abstract class DressingRoom {
|
|
27
|
-
/**
|
|
28
|
-
* @desc
|
|
29
|
-
* Creates a generic `DressingRoom` implementation, where every actor
|
|
30
|
-
* is given all the abilities specified when the method is called.
|
|
31
|
-
*
|
|
32
|
-
* @param {Ability[]} abilities
|
|
33
|
-
* @returns {DressingRoom}
|
|
34
|
-
*/
|
|
35
|
-
static whereEveryoneCan(...abilities: Ability[]): DressingRoom;
|
|
36
|
-
abstract prepare(actor: Actor): Actor;
|
|
37
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DressingRoom = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* @desc
|
|
6
|
-
* Prepares the {@link Actor} for the performance.
|
|
7
|
-
*
|
|
8
|
-
* @example <caption>A dressing room for actors interacting with a Web UI</caption>
|
|
9
|
-
*
|
|
10
|
-
* import { serenity, Actor, DressingRoom } from '@serenity-js/core'
|
|
11
|
-
* import { BrowseTheWeb } from '@serenity-js/protractor'
|
|
12
|
-
* import { protractor } from 'protractor'
|
|
13
|
-
*
|
|
14
|
-
* class UIActors implements DressingRoom {
|
|
15
|
-
* prepare(actor: Actor) {
|
|
16
|
-
* return actor.whoCan(BrowseTheWeb.using(protractor.browser));
|
|
17
|
-
* }
|
|
18
|
-
* }
|
|
19
|
-
*
|
|
20
|
-
* const stage = serenity.callToStageFor(new UIActors());
|
|
21
|
-
*
|
|
22
|
-
* @see {@link Stage}
|
|
23
|
-
* @see {@link Cast}
|
|
24
|
-
* @interface
|
|
25
|
-
*
|
|
26
|
-
* @deprecated Please use the Cast instead
|
|
27
|
-
*/
|
|
28
|
-
class DressingRoom {
|
|
29
|
-
/**
|
|
30
|
-
* @desc
|
|
31
|
-
* Creates a generic `DressingRoom` implementation, where every actor
|
|
32
|
-
* is given all the abilities specified when the method is called.
|
|
33
|
-
*
|
|
34
|
-
* @param {Ability[]} abilities
|
|
35
|
-
* @returns {DressingRoom}
|
|
36
|
-
*/
|
|
37
|
-
static whereEveryoneCan(...abilities) {
|
|
38
|
-
return new GenericDressingRoom(abilities);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
exports.DressingRoom = DressingRoom;
|
|
42
|
-
/**
|
|
43
|
-
* @package
|
|
44
|
-
*/
|
|
45
|
-
class GenericDressingRoom {
|
|
46
|
-
constructor(abilities) {
|
|
47
|
-
this.abilities = abilities;
|
|
48
|
-
}
|
|
49
|
-
prepare(actor) {
|
|
50
|
-
return actor.whoCan(...this.abilities);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
//# sourceMappingURL=DressingRoom.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DressingRoom.js","sourceRoot":"","sources":["../../src/stage/DressingRoom.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAsB,YAAY;IAC9B;;;;;;;OAOG;IACH,MAAM,CAAC,gBAAgB,CAAC,GAAG,SAAoB;QAC3C,OAAO,IAAI,mBAAmB,CAAC,SAAS,CAAC,CAAC;IAC9C,CAAC;CAGJ;AAdD,oCAcC;AAED;;GAEG;AACH,MAAM,mBAAmB;IACrB,YAA6B,SAAoB;QAApB,cAAS,GAAT,SAAS,CAAW;IACjD,CAAC;IAED,OAAO,CAAC,KAAY;QAChB,OAAO,KAAK,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC;IAC3C,CAAC;CACJ"}
|
package/lib/stage/WithStage.d.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { Stage } from './Stage';
|
|
2
|
-
/**
|
|
3
|
-
* @desc Makes the {@link Stage} object setup in your test runner configuration visible
|
|
4
|
-
* to test steps or test scenarios.
|
|
5
|
-
*
|
|
6
|
-
* When using Cucumber, the {@link Stage} is typically set up using the Cucumber World Constructor.
|
|
7
|
-
* When using Jasmine, the {@link Stage} is typically set up in the `beforeEach` step.
|
|
8
|
-
*
|
|
9
|
-
* @see https://github.com/cucumber/cucumber-js/blob/v5.0.1/docs/support_files/api_reference.md
|
|
10
|
-
* @see https://github.com/cucumber/cucumber-js/blob/v5.0.1/docs/support_files/step_definitions.md
|
|
11
|
-
* @see https://www.typescriptlang.org/docs/handbook/functions.html#this-parameters
|
|
12
|
-
*
|
|
13
|
-
* @example <caption>Usage with Cucumber.js</caption>
|
|
14
|
-
* // features/support/configure_serenity.ts
|
|
15
|
-
* import { WithStage } from '@serenity-js/core';
|
|
16
|
-
* import { setWorldConstructor } from 'cucumber';
|
|
17
|
-
*
|
|
18
|
-
* setWorldConstructor(function (this: WithStage, { parameters }) {
|
|
19
|
-
* this.stage = serenity.callToStageFor(new SomeImplementationOfTheCastInterface());
|
|
20
|
-
* });
|
|
21
|
-
*
|
|
22
|
-
* // features/step_definitions/some.steps.ts
|
|
23
|
-
* import { WithStage } from '@serenity-js/cucumber';
|
|
24
|
-
*
|
|
25
|
-
* Given(/(.*?) is a registered customer/, function (this: WithStage, actorName: string) {
|
|
26
|
-
* return this.stage.actor(actorName).attemptsTo(
|
|
27
|
-
*
|
|
28
|
-
* );
|
|
29
|
-
* });
|
|
30
|
-
*
|
|
31
|
-
* @example <caption>Usage with Jasmine</caption>
|
|
32
|
-
* // spec/some.spec.ts
|
|
33
|
-
* import { serenity, WithStage } from '@serenity-js/core';
|
|
34
|
-
*
|
|
35
|
-
* describe('Using the Stage', () => {
|
|
36
|
-
* beforeEach(function (this: WithStage) {
|
|
37
|
-
* this.stage = serenity.callToStageFor(new SomeImplementationOfTheCastInterface());
|
|
38
|
-
* });
|
|
39
|
-
*
|
|
40
|
-
* it('makes it easy to access the Actors', function(this: WithStage) {
|
|
41
|
-
* return this.stage.theActorCalled('Barry').attemptsTo(
|
|
42
|
-
* // tasks
|
|
43
|
-
* );
|
|
44
|
-
* })
|
|
45
|
-
* });
|
|
46
|
-
*
|
|
47
|
-
* @deprecated Please use serenity.actor() and serenity.actorInTheSpotlight() instead
|
|
48
|
-
*/
|
|
49
|
-
export interface WithStage {
|
|
50
|
-
stage: Stage;
|
|
51
|
-
}
|
package/lib/stage/WithStage.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WithStage.js","sourceRoot":"","sources":["../../src/stage/WithStage.ts"],"names":[],"mappings":""}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @desc
|
|
3
|
-
* Describes a collection providing
|
|
4
|
-
* a [`map`-like interface](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map).
|
|
5
|
-
*
|
|
6
|
-
* @interface
|
|
7
|
-
*
|
|
8
|
-
* @see {@link Question#map}
|
|
9
|
-
* @see {@link ElementArrayFinder}
|
|
10
|
-
*/
|
|
11
|
-
export interface Mappable<Item> {
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @desc
|
|
15
|
-
* Applies a {@link MappingFunction} function to each element of a {@link Mappable} collection.
|
|
16
|
-
*
|
|
17
|
-
* The callback receives an item from the collection as the first argument
|
|
18
|
-
* and its index as the second argument.
|
|
19
|
-
*
|
|
20
|
-
* @abstract
|
|
21
|
-
*
|
|
22
|
-
* @type {function<U>(callback: (item?: Item, index?: number) => U): PromiseLike<U[]> | U[]}
|
|
23
|
-
*/
|
|
24
|
-
map: <U>(callback: (item?: Item, index?: number) => U) => PromiseLike<U[]> | U[];
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* @desc
|
|
29
|
-
* A mapping function converting one type into another.
|
|
30
|
-
*
|
|
31
|
-
* @public
|
|
32
|
-
*
|
|
33
|
-
* @typedef {function(item?: V, index?: number) => Promise<O> | O} Mapping<V,O>
|
|
34
|
-
*/
|
|
35
|
-
export type MappingFunction<V, O> =
|
|
36
|
-
(item?: V, index?: number) => O;
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* @desc
|
|
40
|
-
* Checks if the value is a {@link Mappable} collection of items.
|
|
41
|
-
*
|
|
42
|
-
* @example <caption>An Array</caption>
|
|
43
|
-
* import { Mappable } from '@serenity-js/core/lib/io';
|
|
44
|
-
*
|
|
45
|
-
* Mappable.isMappable([ 1, 2, 3 ]) === true
|
|
46
|
-
*
|
|
47
|
-
* @example <caption>Protractor's ElementArrayFinder</caption>
|
|
48
|
-
* import { Mappable } from '@serenity-js/core/lib/io';
|
|
49
|
-
* import { element } from 'protractor';
|
|
50
|
-
*
|
|
51
|
-
* Mappable.isMappable(element.all(by.tagName('li')) === true
|
|
52
|
-
*
|
|
53
|
-
* @param {Mappable<Item> | any} maybeCollection
|
|
54
|
-
* @returns {boolean}
|
|
55
|
-
*/
|
|
56
|
-
export function isMappable<Item>(maybeCollection: Mappable<Item> | any): maybeCollection is Mappable<Item> {
|
|
57
|
-
return !! maybeCollection
|
|
58
|
-
&& !! maybeCollection.map
|
|
59
|
-
&& typeof maybeCollection.map === 'function';
|
|
60
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @desc
|
|
3
|
-
* Describes a collection providing
|
|
4
|
-
* a [`reduce`-like interface](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce).
|
|
5
|
-
*
|
|
6
|
-
* @interface
|
|
7
|
-
*
|
|
8
|
-
* @see {@link ElementArrayFinder}
|
|
9
|
-
* @see {@link Loop}
|
|
10
|
-
*/
|
|
11
|
-
export interface Reducible {
|
|
12
|
-
/**
|
|
13
|
-
* @type {function<T,A>(callback: (accumulator: A, currentValue: T, index: number) => A, initialValue: A): PromiseLike<A> | A}
|
|
14
|
-
*/
|
|
15
|
-
reduce: <T, A>(fn: (accumulator: A, currentValue: T, index: number) => A, initialValue: A) => PromiseLike<A> | A;
|
|
16
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { AnswersQuestions, Interaction, Question } from '..';
|
|
2
|
-
|
|
3
|
-
export type Assertion<A> = (actual: A) => void;
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @deprecated
|
|
7
|
-
* Use the <a href="/modules/assertions"><code>@serenity-js/assertions</code> module</a> instead
|
|
8
|
-
*/
|
|
9
|
-
export class See<S> extends Interaction {
|
|
10
|
-
static if<T>(question: Question<T>, assertion: Assertion<T>): Interaction {
|
|
11
|
-
return new See<T>(question, assertion);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
constructor(
|
|
15
|
-
private question: Question<S>,
|
|
16
|
-
private assert: Assertion<S>,
|
|
17
|
-
) {
|
|
18
|
-
super();
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* @desc
|
|
23
|
-
* Makes the provided {@link Actor}
|
|
24
|
-
* perform this {@link Interaction}.
|
|
25
|
-
*
|
|
26
|
-
* @param {AnswersQuestions} actor
|
|
27
|
-
* @returns {Promise<void>}
|
|
28
|
-
*
|
|
29
|
-
* @see {@link Actor}
|
|
30
|
-
* @see {@link AnswersQuestions}
|
|
31
|
-
*/
|
|
32
|
-
performAs(actor: AnswersQuestions): PromiseLike<void> {
|
|
33
|
-
return actor.answer(this.question).then(this.assert);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* @desc
|
|
38
|
-
* Generates a description to be used when reporting this {@link Activity}.
|
|
39
|
-
*
|
|
40
|
-
* @returns {string}
|
|
41
|
-
*/
|
|
42
|
-
toString(): string {
|
|
43
|
-
return `#actor checks ${this.question}`;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { Answerable } from '../Answerable';
|
|
2
|
-
import { createMetaQuestionProxy, createQuestionProxy, WithPropertiesAsMetaQuestions, WithPropertiesAsQuestions } from './proxies';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @desc
|
|
6
|
-
* Enables easy access to properties of the value of a given {@link Answerable}.
|
|
7
|
-
*
|
|
8
|
-
* @example <caption>Example API response</caption>
|
|
9
|
-
* interface EnvironmentDetails {
|
|
10
|
-
* name: string;
|
|
11
|
-
* url: string;
|
|
12
|
-
* }
|
|
13
|
-
*
|
|
14
|
-
* interface EnvironmentsResponse {
|
|
15
|
-
* environments: EnvironmentDetails[];
|
|
16
|
-
* }
|
|
17
|
-
*
|
|
18
|
-
* const response: EnvironmentsResponse = {
|
|
19
|
-
* "environments": [
|
|
20
|
-
* {
|
|
21
|
-
* "name": "dev",
|
|
22
|
-
* "url": "https://dev.example.com"
|
|
23
|
-
* },
|
|
24
|
-
* {
|
|
25
|
-
* "name": "sit",
|
|
26
|
-
* "url": "https://sit.example.com"
|
|
27
|
-
* }
|
|
28
|
-
* ]
|
|
29
|
-
* }
|
|
30
|
-
*
|
|
31
|
-
* @example <caption>Combining Property.of and Property.at</caption>
|
|
32
|
-
* import { actorCalled, List, Property } from '@serenity-js/core';
|
|
33
|
-
* import { Ensure, equals } from '@serenity-js/assertions';
|
|
34
|
-
*
|
|
35
|
-
* actorCalled('Lisa').attemptsTo(
|
|
36
|
-
* Ensure.that(
|
|
37
|
-
* Property.of(
|
|
38
|
-
* List.of(response.environments)
|
|
39
|
-
* .where(Property.at<EnvironmentDetails>().name, equals('dev'))
|
|
40
|
-
* .first(),
|
|
41
|
-
* ).url,
|
|
42
|
-
* equals('https://dev.example.com')
|
|
43
|
-
* )
|
|
44
|
-
* )
|
|
45
|
-
*
|
|
46
|
-
* @see {@link Question}
|
|
47
|
-
* @see {@link List}
|
|
48
|
-
*/
|
|
49
|
-
export class Property {
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* @desc
|
|
53
|
-
* Generates a {@link Proxy} around a given {@link Answerable} `subject`
|
|
54
|
-
* to turn the properties of the value it will resolve to into {@link Question}s.
|
|
55
|
-
*
|
|
56
|
-
* @example <caption>Reading a property</caption>
|
|
57
|
-
* import { actorCalled, Property } from '@serenity-js/core';
|
|
58
|
-
* import { Ensure, equals } from '@serenity-js/assertions';
|
|
59
|
-
*
|
|
60
|
-
* actorCalled('Lisa').attemptsTo(
|
|
61
|
-
* Ensure.that(
|
|
62
|
-
* Property.of(response).environments[0].name,
|
|
63
|
-
* equals('dev')
|
|
64
|
-
* )
|
|
65
|
-
* )
|
|
66
|
-
*
|
|
67
|
-
* @param {Answerable<Subject>} subject
|
|
68
|
-
* @returns {Proxy<Subject>}
|
|
69
|
-
*/
|
|
70
|
-
static of<Subject extends object>(subject: Answerable<Subject>): WithPropertiesAsQuestions<Subject> { // eslint-disable-line @typescript-eslint/ban-types
|
|
71
|
-
return createQuestionProxy<Subject>(subject);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* @desc
|
|
76
|
-
* Generates a {@link Proxy} around a given {@link Answerable} `subject`
|
|
77
|
-
* to turn any of its properties into {@link MetaQuestion}s
|
|
78
|
-
* to be used when filtering a {@link List},
|
|
79
|
-
*
|
|
80
|
-
* @example <caption>Reading a property</caption>
|
|
81
|
-
* import { actorCalled, Property } from '@serenity-js/core';
|
|
82
|
-
* import { Ensure, equals } from '@serenity-js/assertions';
|
|
83
|
-
*
|
|
84
|
-
* actorCalled('Lisa').attemptsTo(
|
|
85
|
-
* Ensure.that(
|
|
86
|
-
* List.of(response.environments)
|
|
87
|
-
* .where(Property.at<EnvironmentDetails>().name, equals('dev'))
|
|
88
|
-
* .first(),
|
|
89
|
-
* equals(response.environments[0])
|
|
90
|
-
* )
|
|
91
|
-
* )
|
|
92
|
-
*
|
|
93
|
-
* @returns {Proxy<Subject>}
|
|
94
|
-
*/
|
|
95
|
-
static at<Subject extends object>(): WithPropertiesAsMetaQuestions<Subject> { // eslint-disable-line @typescript-eslint/ban-types
|
|
96
|
-
return createMetaQuestionProxy<Subject>();
|
|
97
|
-
}
|
|
98
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-unnecessary-type-constraint */
|
|
2
|
-
import { AnswersQuestions, UsesAbilities } from '../actor';
|
|
3
|
-
import { Answerable } from '../Answerable';
|
|
4
|
-
import { Question } from '../Question';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @experimental
|
|
8
|
-
*/
|
|
9
|
-
export class Transform<Answer_Type extends any, Output_Type> extends Question<Promise<Output_Type>> {
|
|
10
|
-
static the<AT extends any, OT>(questions: Answerable<AT> | Array<Answerable<AT>>, transformation: (...answers: AT[]) => OT): Transform<AT, OT> {
|
|
11
|
-
return new Transform<AT, OT>([].concat(questions), transformation);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
constructor(
|
|
15
|
-
private readonly questions: Array<Answerable<Answer_Type>>,
|
|
16
|
-
private readonly transformation: (...answers: Answer_Type[]) => Output_Type,
|
|
17
|
-
private readonly description: string = `a transformed answer`,
|
|
18
|
-
) {
|
|
19
|
-
super(description);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* @deprecated
|
|
24
|
-
* Please use {@link Transform#describedAs} instead
|
|
25
|
-
*
|
|
26
|
-
* @desc
|
|
27
|
-
* Overrides the default {@link Transform#toString} representation of this object.
|
|
28
|
-
*
|
|
29
|
-
* @param {string} description
|
|
30
|
-
* @returns {Transform<Answer_Type, Output_Type>}
|
|
31
|
-
*/
|
|
32
|
-
as(description: string): Transform<Answer_Type, Output_Type> {
|
|
33
|
-
return this.describedAs(description);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Changes the description of this question's subject.
|
|
38
|
-
*
|
|
39
|
-
* @param subject
|
|
40
|
-
*/
|
|
41
|
-
describedAs(subject: string): this {
|
|
42
|
-
this.subject = subject;
|
|
43
|
-
|
|
44
|
-
return this;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
answeredBy(actor: AnswersQuestions & UsesAbilities): Promise<Output_Type> {
|
|
48
|
-
return Promise.all(this.questions.map(question => actor.answer(question)))
|
|
49
|
-
.then(answers => this.transformation(...answers));
|
|
50
|
-
}
|
|
51
|
-
}
|