@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.
Files changed (207) hide show
  1. package/CHANGELOG.md +350 -0
  2. package/lib/index.d.ts +2 -1
  3. package/lib/index.js +6 -1
  4. package/lib/index.js.map +1 -1
  5. package/lib/io/ErrorSerialiser.js +4 -1
  6. package/lib/io/ErrorSerialiser.js.map +1 -1
  7. package/lib/io/asyncMap.d.ts +8 -0
  8. package/lib/io/asyncMap.js +18 -0
  9. package/lib/io/asyncMap.js.map +1 -0
  10. package/lib/io/format.d.ts +39 -0
  11. package/lib/io/format.js +51 -0
  12. package/lib/io/format.js.map +1 -0
  13. package/lib/io/formatted.d.ts +5 -1
  14. package/lib/io/formatted.js +6 -13
  15. package/lib/io/formatted.js.map +1 -1
  16. package/lib/io/index.d.ts +2 -1
  17. package/lib/io/index.js +2 -1
  18. package/lib/io/index.js.map +1 -1
  19. package/lib/io/inspected.d.ts +9 -1
  20. package/lib/io/inspected.js +52 -15
  21. package/lib/io/inspected.js.map +1 -1
  22. package/lib/model/Timestamp.d.ts +4 -2
  23. package/lib/model/Timestamp.js +8 -2
  24. package/lib/model/Timestamp.js.map +1 -1
  25. package/lib/screenplay/Optional.d.ts +29 -0
  26. package/lib/{io/collections/reducible.js → screenplay/Optional.js} +1 -1
  27. package/lib/screenplay/Optional.js.map +1 -0
  28. package/lib/screenplay/Question.d.ts +41 -82
  29. package/lib/screenplay/Question.js +132 -100
  30. package/lib/screenplay/Question.js.map +1 -1
  31. package/lib/screenplay/actor/Actor.js +2 -2
  32. package/lib/screenplay/actor/Actor.js.map +1 -1
  33. package/lib/screenplay/index.d.ts +1 -1
  34. package/lib/screenplay/index.js +1 -1
  35. package/lib/screenplay/index.js.map +1 -1
  36. package/lib/screenplay/interactions/index.d.ts +0 -1
  37. package/lib/screenplay/interactions/index.js +0 -1
  38. package/lib/screenplay/interactions/index.js.map +1 -1
  39. package/lib/screenplay/questions/Check.d.ts +3 -3
  40. package/lib/screenplay/questions/Check.js +5 -7
  41. package/lib/screenplay/questions/Check.js.map +1 -1
  42. package/lib/screenplay/questions/Expectation.d.ts +15 -10
  43. package/lib/screenplay/questions/Expectation.js +28 -37
  44. package/lib/screenplay/questions/Expectation.js.map +1 -1
  45. package/lib/screenplay/questions/List.d.ts +22 -192
  46. package/lib/screenplay/questions/List.js +160 -208
  47. package/lib/screenplay/questions/List.js.map +1 -1
  48. package/lib/screenplay/questions/Note.d.ts +10 -0
  49. package/lib/screenplay/questions/Note.js +17 -1
  50. package/lib/screenplay/questions/Note.js.map +1 -1
  51. package/lib/screenplay/questions/index.d.ts +0 -3
  52. package/lib/screenplay/questions/index.js +0 -5
  53. package/lib/screenplay/questions/index.js.map +1 -1
  54. package/lib/stage/index.d.ts +0 -2
  55. package/lib/stage/index.js +0 -2
  56. package/lib/stage/index.js.map +1 -1
  57. package/package.json +7 -7
  58. package/src/index.ts +2 -1
  59. package/src/io/ErrorSerialiser.ts +5 -1
  60. package/src/io/asyncMap.ts +18 -0
  61. package/src/io/format.ts +49 -0
  62. package/src/io/formatted.ts +7 -15
  63. package/src/io/index.ts +2 -1
  64. package/src/io/inspected.ts +68 -15
  65. package/src/model/Timestamp.ts +10 -2
  66. package/src/screenplay/Optional.ts +30 -0
  67. package/src/screenplay/Question.ts +206 -124
  68. package/src/screenplay/actor/Actor.ts +2 -2
  69. package/src/screenplay/index.ts +1 -1
  70. package/src/screenplay/interactions/index.ts +0 -1
  71. package/src/screenplay/questions/Check.ts +10 -15
  72. package/src/screenplay/questions/Expectation.ts +48 -55
  73. package/src/screenplay/questions/List.ts +224 -233
  74. package/src/screenplay/questions/Note.ts +21 -1
  75. package/src/screenplay/questions/index.ts +0 -3
  76. package/src/stage/index.ts +0 -2
  77. package/lib/io/collections/index.d.ts +0 -2
  78. package/lib/io/collections/index.js +0 -15
  79. package/lib/io/collections/index.js.map +0 -1
  80. package/lib/io/collections/mappable.d.ts +0 -52
  81. package/lib/io/collections/mappable.js +0 -28
  82. package/lib/io/collections/mappable.js.map +0 -1
  83. package/lib/io/collections/reducible.d.ts +0 -16
  84. package/lib/io/collections/reducible.js.map +0 -1
  85. package/lib/screenplay/interactions/See.d.ts +0 -31
  86. package/lib/screenplay/interactions/See.js +0 -43
  87. package/lib/screenplay/interactions/See.js.map +0 -1
  88. package/lib/screenplay/questions/Property.d.ts +0 -91
  89. package/lib/screenplay/questions/Property.js +0 -99
  90. package/lib/screenplay/questions/Property.js.map +0 -1
  91. package/lib/screenplay/questions/Transform.d.ts +0 -31
  92. package/lib/screenplay/questions/Transform.js +0 -46
  93. package/lib/screenplay/questions/Transform.js.map +0 -1
  94. package/lib/screenplay/questions/lists/ArrayListAdapter.d.ts +0 -88
  95. package/lib/screenplay/questions/lists/ArrayListAdapter.js +0 -152
  96. package/lib/screenplay/questions/lists/ArrayListAdapter.js.map +0 -1
  97. package/lib/screenplay/questions/lists/ListAdapter.d.ts +0 -20
  98. package/lib/screenplay/questions/lists/ListAdapter.js +0 -3
  99. package/lib/screenplay/questions/lists/ListAdapter.js.map +0 -1
  100. package/lib/screenplay/questions/lists/index.d.ts +0 -2
  101. package/lib/screenplay/questions/lists/index.js +0 -15
  102. package/lib/screenplay/questions/lists/index.js.map +0 -1
  103. package/lib/screenplay/questions/mappings/AnswerMappingFunction.d.ts +0 -11
  104. package/lib/screenplay/questions/mappings/AnswerMappingFunction.js +0 -3
  105. package/lib/screenplay/questions/mappings/AnswerMappingFunction.js.map +0 -1
  106. package/lib/screenplay/questions/mappings/index.d.ts +0 -2
  107. package/lib/screenplay/questions/mappings/index.js +0 -15
  108. package/lib/screenplay/questions/mappings/index.js.map +0 -1
  109. package/lib/screenplay/questions/mappings/string/append.d.ts +0 -14
  110. package/lib/screenplay/questions/mappings/string/append.js +0 -25
  111. package/lib/screenplay/questions/mappings/string/append.js.map +0 -1
  112. package/lib/screenplay/questions/mappings/string/index.d.ts +0 -11
  113. package/lib/screenplay/questions/mappings/string/index.js +0 -24
  114. package/lib/screenplay/questions/mappings/string/index.js.map +0 -1
  115. package/lib/screenplay/questions/mappings/string/normalize.d.ts +0 -20
  116. package/lib/screenplay/questions/mappings/string/normalize.js +0 -30
  117. package/lib/screenplay/questions/mappings/string/normalize.js.map +0 -1
  118. package/lib/screenplay/questions/mappings/string/replace.d.ts +0 -17
  119. package/lib/screenplay/questions/mappings/string/replace.js +0 -30
  120. package/lib/screenplay/questions/mappings/string/replace.js.map +0 -1
  121. package/lib/screenplay/questions/mappings/string/slice.d.ts +0 -28
  122. package/lib/screenplay/questions/mappings/string/slice.js +0 -47
  123. package/lib/screenplay/questions/mappings/string/slice.js.map +0 -1
  124. package/lib/screenplay/questions/mappings/string/split.d.ts +0 -19
  125. package/lib/screenplay/questions/mappings/string/split.js +0 -36
  126. package/lib/screenplay/questions/mappings/string/split.js.map +0 -1
  127. package/lib/screenplay/questions/mappings/string/toLocaleLowerCase.d.ts +0 -17
  128. package/lib/screenplay/questions/mappings/string/toLocaleLowerCase.js +0 -28
  129. package/lib/screenplay/questions/mappings/string/toLocaleLowerCase.js.map +0 -1
  130. package/lib/screenplay/questions/mappings/string/toLocaleUpperCase.d.ts +0 -17
  131. package/lib/screenplay/questions/mappings/string/toLocaleUpperCase.js +0 -29
  132. package/lib/screenplay/questions/mappings/string/toLocaleUpperCase.js.map +0 -1
  133. package/lib/screenplay/questions/mappings/string/toLowerCase.d.ts +0 -10
  134. package/lib/screenplay/questions/mappings/string/toLowerCase.js +0 -19
  135. package/lib/screenplay/questions/mappings/string/toLowerCase.js.map +0 -1
  136. package/lib/screenplay/questions/mappings/string/toNumber.d.ts +0 -10
  137. package/lib/screenplay/questions/mappings/string/toNumber.js +0 -18
  138. package/lib/screenplay/questions/mappings/string/toNumber.js.map +0 -1
  139. package/lib/screenplay/questions/mappings/string/toUpperCase.d.ts +0 -10
  140. package/lib/screenplay/questions/mappings/string/toUpperCase.js +0 -19
  141. package/lib/screenplay/questions/mappings/string/toUpperCase.js.map +0 -1
  142. package/lib/screenplay/questions/mappings/string/trim.d.ts +0 -12
  143. package/lib/screenplay/questions/mappings/string/trim.js +0 -21
  144. package/lib/screenplay/questions/mappings/string/trim.js.map +0 -1
  145. package/lib/screenplay/questions/proxies/PropertyPathKey.d.ts +0 -4
  146. package/lib/screenplay/questions/proxies/PropertyPathKey.js +0 -3
  147. package/lib/screenplay/questions/proxies/PropertyPathKey.js.map +0 -1
  148. package/lib/screenplay/questions/proxies/createMetaQuestionProxy.d.ts +0 -14
  149. package/lib/screenplay/questions/proxies/createMetaQuestionProxy.js +0 -35
  150. package/lib/screenplay/questions/proxies/createMetaQuestionProxy.js.map +0 -1
  151. package/lib/screenplay/questions/proxies/createQuestionProxy.d.ts +0 -13
  152. package/lib/screenplay/questions/proxies/createQuestionProxy.js +0 -34
  153. package/lib/screenplay/questions/proxies/createQuestionProxy.js.map +0 -1
  154. package/lib/screenplay/questions/proxies/describePath.d.ts +0 -5
  155. package/lib/screenplay/questions/proxies/describePath.js +0 -19
  156. package/lib/screenplay/questions/proxies/describePath.js.map +0 -1
  157. package/lib/screenplay/questions/proxies/index.d.ts +0 -2
  158. package/lib/screenplay/questions/proxies/index.js +0 -15
  159. package/lib/screenplay/questions/proxies/index.js.map +0 -1
  160. package/lib/screenplay/questions/proxies/key.d.ts +0 -8
  161. package/lib/screenplay/questions/proxies/key.js +0 -16
  162. package/lib/screenplay/questions/proxies/key.js.map +0 -1
  163. package/lib/screenplay/tasks/Loop.d.ts +0 -198
  164. package/lib/screenplay/tasks/Loop.js +0 -222
  165. package/lib/screenplay/tasks/Loop.js.map +0 -1
  166. package/lib/screenplay/tasks/index.d.ts +0 -1
  167. package/lib/screenplay/tasks/index.js +0 -14
  168. package/lib/screenplay/tasks/index.js.map +0 -1
  169. package/lib/stage/DressingRoom.d.ts +0 -37
  170. package/lib/stage/DressingRoom.js +0 -53
  171. package/lib/stage/DressingRoom.js.map +0 -1
  172. package/lib/stage/WithStage.d.ts +0 -51
  173. package/lib/stage/WithStage.js +0 -3
  174. package/lib/stage/WithStage.js.map +0 -1
  175. package/src/io/collections/index.ts +0 -2
  176. package/src/io/collections/mappable.ts +0 -60
  177. package/src/io/collections/reducible.ts +0 -16
  178. package/src/screenplay/interactions/See.ts +0 -45
  179. package/src/screenplay/questions/Property.ts +0 -98
  180. package/src/screenplay/questions/Transform.ts +0 -51
  181. package/src/screenplay/questions/lists/ArrayListAdapter.ts +0 -186
  182. package/src/screenplay/questions/lists/ListAdapter.ts +0 -33
  183. package/src/screenplay/questions/lists/index.ts +0 -2
  184. package/src/screenplay/questions/mappings/AnswerMappingFunction.ts +0 -13
  185. package/src/screenplay/questions/mappings/index.ts +0 -2
  186. package/src/screenplay/questions/mappings/string/append.ts +0 -28
  187. package/src/screenplay/questions/mappings/string/index.ts +0 -11
  188. package/src/screenplay/questions/mappings/string/normalize.ts +0 -33
  189. package/src/screenplay/questions/mappings/string/replace.ts +0 -34
  190. package/src/screenplay/questions/mappings/string/slice.ts +0 -53
  191. package/src/screenplay/questions/mappings/string/split.ts +0 -38
  192. package/src/screenplay/questions/mappings/string/toLocaleLowerCase.ts +0 -31
  193. package/src/screenplay/questions/mappings/string/toLocaleUpperCase.ts +0 -30
  194. package/src/screenplay/questions/mappings/string/toLowerCase.ts +0 -20
  195. package/src/screenplay/questions/mappings/string/toNumber.ts +0 -19
  196. package/src/screenplay/questions/mappings/string/toUpperCase.ts +0 -20
  197. package/src/screenplay/questions/mappings/string/trim.ts +0 -22
  198. package/src/screenplay/questions/proxies/PropertyPathKey.ts +0 -4
  199. package/src/screenplay/questions/proxies/createMetaQuestionProxy.ts +0 -51
  200. package/src/screenplay/questions/proxies/createQuestionProxy.ts +0 -49
  201. package/src/screenplay/questions/proxies/describePath.ts +0 -23
  202. package/src/screenplay/questions/proxies/index.ts +0 -2
  203. package/src/screenplay/questions/proxies/key.ts +0 -14
  204. package/src/screenplay/tasks/Loop.ts +0 -240
  205. package/src/screenplay/tasks/index.ts +0 -1
  206. package/src/stage/DressingRoom.ts +0 -53
  207. package/src/stage/WithStage.ts +0 -52
@@ -1,196 +1,26 @@
1
- import { AnswersQuestions, UsesAbilities } from '../actor';
1
+ import { Actor, AnswersQuestions, UsesAbilities } from '../actor';
2
2
  import { Answerable } from '../Answerable';
3
- import { Question } from '../Question';
3
+ import { Question, QuestionAdapter } from '../Question';
4
+ import { Task } from '../Task';
4
5
  import { Expectation } from './Expectation';
5
- import { ArrayListAdapter, ListAdapter } from './lists';
6
6
  import { MetaQuestion } from './MetaQuestion';
7
- /**
8
- * @desc
9
- * Filters an {@link Answerable} list of items based on the criteria provided.
10
- * Instantiate via {@link List.of}
11
- *
12
- * @example <caption>Example data structure</caption>
13
- * interface TestAccount {
14
- * username: string;
15
- * role: string;
16
- * environments: string[];
17
- * }
18
- *
19
- * const testAccounts: TestAccount[] = [
20
- * {
21
- * "username": "tester.one@example.com",
22
- * "role": "test-automation"
23
- * "environments": [ "dev", "sit" ],
24
- * },
25
- * {
26
- * "username": "tester.two@example.com",
27
- * "role": "test-automation"
28
- * "environments": [ "dev", "sit", "prod" ],
29
- * },
30
- * {
31
- * "username": "release.bot@example.com",
32
- * "role": "release-automation"
33
- * "environments": [ "dev", "sit", "prod" ],
34
- * }
35
- * ]
36
- *
37
- * @example <caption>Using with Property</caption>
38
- * import { actorCalled, List, Property } from '@serenity-js/core';
39
- * import { contain, Ensure, equals } from '@serenity-js/assertions';
40
- *
41
- * actorCalled('Lisa').attemptsTo(
42
- * Ensure.that(
43
- * Property.of(
44
- * List.of(testAccounts)
45
- * .where(Property.at<TestAccount>().environments, contain('prod'))
46
- * .where(Property.at<TestAccount>().role, equals('test-automation'))
47
- * .first()
48
- * ).username,
49
- * equals('tester.two@example.com')
50
- * )
51
- * )
52
- *
53
- * @extends {Question}
54
- * @see {@link MetaQuestion}
55
- */
56
- export declare class List<List_Adapter_Type extends ListAdapter<Item_Type, Collection_Type, Item_Return_Type, Collection_Return_Type>, Item_Type, Collection_Type, Item_Return_Type = Item_Type, Collection_Return_Type = Collection_Type> extends Question<Collection_Return_Type> {
57
- private readonly collection;
58
- /**
59
- * @desc
60
- * Instantiates a new {@link List} configured to support standard {@link Array}.
61
- *
62
- * **Please note:** Don't use `List.of` to wrap `Question<ElementArrayFinder>` returned by
63
- * [`Target.all`](/modules/protractor/class/src/screenplay/questions/targets/Target.ts~Target.html#static-method-all).
64
- * Instead, use [`Target.all(...).located(...).where(...)`](/modules/protractor/class/src/screenplay/questions/targets/Target.ts~Target.html),
65
- * which uses a Protractor-specific {@link ListAdapter}.
66
- *
67
- * @param {Answerable<Item_Type[]>} items
68
- *
69
- * @returns {List<ArrayListAdapter<Item_Type>, Item_Type, Item_Type[], Promise<Item_Type>, Promise<Item_Type[]>>}
70
- */
71
- static of<Item_Type>(items: Answerable<Item_Type[]>): List<ArrayListAdapter<Item_Type>, Item_Type, Item_Type[], Promise<Item_Type>, Promise<Item_Type[]>>;
72
- /**
73
- * @param {List_Adapter_Type} collection
74
- */
75
- constructor(collection: List_Adapter_Type);
76
- /**
77
- * @desc
78
- * Returns the number of items left after applying any filters,
79
- *
80
- * @example <caption>Counting items</caption>
81
- * import { actorCalled, List } from '@serenity-js/core';
82
- * import { Ensure, equals, property } from '@serenity-js/assertions';
83
- *
84
- * actorCalled('Lisa').attemptsTo(
85
- * Ensure.that(
86
- * List.of(testAccounts).count(),
87
- * equals(3)
88
- * )
89
- * )
90
- *
91
- * @returns {Question<Promise<number>>}
92
- *
93
- * @see {@link List#where}
94
- */
95
- count(): Question<Promise<number>>;
96
- /**
97
- * @desc
98
- * Returns the first of items left after applying any filters,
99
- *
100
- * @example <caption>Retrieving the first item</caption>
101
- * import { actorCalled, List } from '@serenity-js/core';
102
- * import { Ensure, equals, property } from '@serenity-js/assertions';
103
- *
104
- * actorCalled('Lisa').attemptsTo(
105
- * Ensure.that(
106
- * List.of(testAccounts).first(),
107
- * property('username', equals('tester.one@example.com'))
108
- * )
109
- * )
110
- *
111
- * @returns {Question<Item_Return_Type>}
112
- *
113
- * @see {@link List#where}
114
- */
115
- first(): Question<Item_Return_Type>;
116
- /**
117
- * @desc
118
- * Returns the last of items left after applying any filters,
119
- *
120
- * @example <caption>Retrieving the last item</caption>
121
- * import { actorCalled, List } from '@serenity-js/core';
122
- * import { Ensure, equals, property } from '@serenity-js/assertions';
123
- *
124
- * actorCalled('Lisa').attemptsTo(
125
- * Ensure.that(
126
- * List.of(testAccounts).last(),
127
- * property('username', equals('release.bot@example.com'))
128
- * )
129
- * )
130
- *
131
- * @returns {Question<Item_Return_Type>}
132
- *
133
- * @see {@link List#where}
134
- */
135
- last(): Question<Item_Return_Type>;
136
- /**
137
- * @desc
138
- * Returns the nth of the items left after applying any filters,
139
- *
140
- * @example <caption>Retrieving the nth item</caption>
141
- * import { actorCalled, List } from '@serenity-js/core';
142
- * import { Ensure, equals, property } from '@serenity-js/assertions';
143
- *
144
- * actorCalled('Lisa').attemptsTo(
145
- * Ensure.that(
146
- * List.of(testAccounts).get(1),
147
- * property('username', equals('tester.two@example.com'))
148
- * )
149
- * )
150
- *
151
- * @param {number} index
152
- * Zero-based index of the item to return
153
- *
154
- * @returns {Question<Item_Return_Type>}
155
- *
156
- * @see {@link List#where}
157
- */
158
- get(index: number): Question<Item_Return_Type>;
159
- /**
160
- * @desc
161
- * Filters the underlying collection so that the result contains only those elements that meet the {@link Expectation}
162
- *
163
- * @example <caption>Filtering a list</caption>
164
- * import { actorCalled, List, Property } from '@serenity-js/core';
165
- * import { contain, Ensure, equals, property } from '@serenity-js/assertions';
166
- *
167
- * actorCalled('Lisa').attemptsTo(
168
- * Ensure.that(
169
- * List.of(testAccounts)
170
- * .where(Property.at<TestAccount>().environments, contain('prod'))
171
- * .where(Property.at<TestAccount>().role, equals('test-automation'))
172
- * .first(),
173
- * property('username', equals('tester.two@example.com'))
174
- * )
175
- * )
176
- *
177
- * @param {MetaQuestion<Item_Type, Promise<Answer_Type> | Answer_Type>} question
178
- * @param {Expectation<any, Answer_Type>} expectation
179
- *
180
- * @returns {List<List_Adapter_Type, Item_Type, Collection_Type, Item_Return_Type, Collection_Return_Type>}
181
- */
182
- where<Answer_Type>(question: MetaQuestion<Item_Type, Promise<Answer_Type> | Answer_Type>, expectation: Expectation<any, Answer_Type>): List<List_Adapter_Type, Item_Type, Collection_Type, Item_Return_Type, Collection_Return_Type>;
183
- /**
184
- * @desc
185
- * Makes the provided {@link Actor} answer this {@link Question} and return the underlying collection.
186
- *
187
- * @param {AnswersQuestions & UsesAbilities} actor
188
- * @returns {Collection_Return_Type}
189
- *
190
- * @see {@link Actor}
191
- * @see {@link AnswersQuestions}
192
- * @see {@link UsesAbilities}
193
- */
194
- answeredBy(actor: AnswersQuestions & UsesAbilities): Collection_Return_Type;
195
- private static ordinalSuffixOf;
7
+ export declare class List<Item_Type> extends Question<Promise<Item_Type[]>> {
8
+ protected readonly collection: Answerable<Array<Item_Type>>;
9
+ private subject;
10
+ static of<IT>(collection: Answerable<Array<IT>>): List<IT>;
11
+ constructor(collection: Answerable<Array<Item_Type>>);
12
+ eachMappedTo<Mapped_Item_Type>(question: MetaQuestion<Item_Type, Promise<Mapped_Item_Type> | Mapped_Item_Type>): List<Mapped_Item_Type>;
13
+ forEach(callback: (current: CurrentItem<Item_Type>, index: number, items: Array<Item_Type>) => Promise<void> | void): Task;
14
+ where<Answer_Type>(question: MetaQuestion<Item_Type, Promise<Answer_Type> | Answer_Type>, expectation: Expectation<Answer_Type>): this;
15
+ count(): QuestionAdapter<number>;
16
+ first(): QuestionAdapter<Item_Type>;
17
+ last(): QuestionAdapter<Item_Type>;
18
+ get(index: number): QuestionAdapter<Item_Type>;
19
+ answeredBy(actor: AnswersQuestions & UsesAbilities): Promise<Array<Item_Type>>;
20
+ describedAs(subject: string): this;
21
+ toString(): string;
22
+ }
23
+ export interface CurrentItem<Item_Type> {
24
+ item: Item_Type;
25
+ actor: Actor;
196
26
  }
@@ -1,226 +1,178 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.List = void 0;
4
+ const errors_1 = require("../../errors");
4
5
  const io_1 = require("../../io");
5
6
  const Question_1 = require("../Question");
6
- const lists_1 = require("./lists");
7
- /**
8
- * @desc
9
- * Filters an {@link Answerable} list of items based on the criteria provided.
10
- * Instantiate via {@link List.of}
11
- *
12
- * @example <caption>Example data structure</caption>
13
- * interface TestAccount {
14
- * username: string;
15
- * role: string;
16
- * environments: string[];
17
- * }
18
- *
19
- * const testAccounts: TestAccount[] = [
20
- * {
21
- * "username": "tester.one@example.com",
22
- * "role": "test-automation"
23
- * "environments": [ "dev", "sit" ],
24
- * },
25
- * {
26
- * "username": "tester.two@example.com",
27
- * "role": "test-automation"
28
- * "environments": [ "dev", "sit", "prod" ],
29
- * },
30
- * {
31
- * "username": "release.bot@example.com",
32
- * "role": "release-automation"
33
- * "environments": [ "dev", "sit", "prod" ],
34
- * }
35
- * ]
36
- *
37
- * @example <caption>Using with Property</caption>
38
- * import { actorCalled, List, Property } from '@serenity-js/core';
39
- * import { contain, Ensure, equals } from '@serenity-js/assertions';
40
- *
41
- * actorCalled('Lisa').attemptsTo(
42
- * Ensure.that(
43
- * Property.of(
44
- * List.of(testAccounts)
45
- * .where(Property.at<TestAccount>().environments, contain('prod'))
46
- * .where(Property.at<TestAccount>().role, equals('test-automation'))
47
- * .first()
48
- * ).username,
49
- * equals('tester.two@example.com')
50
- * )
51
- * )
52
- *
53
- * @extends {Question}
54
- * @see {@link MetaQuestion}
55
- */
7
+ const Task_1 = require("../Task");
8
+ const expectations_1 = require("./expectations");
56
9
  class List extends Question_1.Question {
57
- /**
58
- * @param {List_Adapter_Type} collection
59
- */
60
10
  constructor(collection) {
61
- super((0, io_1.formatted) `${collection}`);
11
+ super();
62
12
  this.collection = collection;
13
+ this.subject = (0, io_1.d) `${collection}`;
14
+ }
15
+ static of(collection) {
16
+ return new List(collection);
17
+ }
18
+ eachMappedTo(question) {
19
+ return new List(new EachMappedTo(this.collection, question, this.subject));
20
+ }
21
+ forEach(callback) {
22
+ return new ForEachLoop(this.collection, this.subject, callback);
23
+ }
24
+ where(question, expectation) {
25
+ return new List(new Where(this.collection, question, expectation, this.subject));
63
26
  }
64
- /**
65
- * @desc
66
- * Instantiates a new {@link List} configured to support standard {@link Array}.
67
- *
68
- * **Please note:** Don't use `List.of` to wrap `Question<ElementArrayFinder>` returned by
69
- * [`Target.all`](/modules/protractor/class/src/screenplay/questions/targets/Target.ts~Target.html#static-method-all).
70
- * Instead, use [`Target.all(...).located(...).where(...)`](/modules/protractor/class/src/screenplay/questions/targets/Target.ts~Target.html),
71
- * which uses a Protractor-specific {@link ListAdapter}.
72
- *
73
- * @param {Answerable<Item_Type[]>} items
74
- *
75
- * @returns {List<ArrayListAdapter<Item_Type>, Item_Type, Item_Type[], Promise<Item_Type>, Promise<Item_Type[]>>}
76
- */
77
- static of(items) {
78
- return new List(new lists_1.ArrayListAdapter(items));
79
- }
80
- /**
81
- * @desc
82
- * Returns the number of items left after applying any filters,
83
- *
84
- * @example <caption>Counting items</caption>
85
- * import { actorCalled, List } from '@serenity-js/core';
86
- * import { Ensure, equals, property } from '@serenity-js/assertions';
87
- *
88
- * actorCalled('Lisa').attemptsTo(
89
- * Ensure.that(
90
- * List.of(testAccounts).count(),
91
- * equals(3)
92
- * )
93
- * )
94
- *
95
- * @returns {Question<Promise<number>>}
96
- *
97
- * @see {@link List#where}
98
- */
99
27
  count() {
100
- return Question_1.Question.about(`the number of ${this.collection.toString()}`, actor => this.collection.count(actor));
101
- }
102
- /**
103
- * @desc
104
- * Returns the first of items left after applying any filters,
105
- *
106
- * @example <caption>Retrieving the first item</caption>
107
- * import { actorCalled, List } from '@serenity-js/core';
108
- * import { Ensure, equals, property } from '@serenity-js/assertions';
109
- *
110
- * actorCalled('Lisa').attemptsTo(
111
- * Ensure.that(
112
- * List.of(testAccounts).first(),
113
- * property('username', equals('tester.one@example.com'))
114
- * )
115
- * )
116
- *
117
- * @returns {Question<Item_Return_Type>}
118
- *
119
- * @see {@link List#where}
120
- */
28
+ return Question_1.Question.about(`the number of ${this.subject}`, async (actor) => {
29
+ const items = await this.answeredBy(actor);
30
+ return items.length;
31
+ });
32
+ }
121
33
  first() {
122
- return Question_1.Question.about(`the first of ${this.collection.toString()}`, actor => this.collection.first(actor));
123
- }
124
- /**
125
- * @desc
126
- * Returns the last of items left after applying any filters,
127
- *
128
- * @example <caption>Retrieving the last item</caption>
129
- * import { actorCalled, List } from '@serenity-js/core';
130
- * import { Ensure, equals, property } from '@serenity-js/assertions';
131
- *
132
- * actorCalled('Lisa').attemptsTo(
133
- * Ensure.that(
134
- * List.of(testAccounts).last(),
135
- * property('username', equals('release.bot@example.com'))
136
- * )
137
- * )
138
- *
139
- * @returns {Question<Item_Return_Type>}
140
- *
141
- * @see {@link List#where}
142
- */
34
+ return Question_1.Question.about(`the first of ${this.subject}`, async (actor) => {
35
+ const items = await this.answeredBy(actor);
36
+ if (items.length === 0) {
37
+ throw new errors_1.LogicError((0, io_1.d) `Can't retrieve the first item from a list with 0 items: ${items}`);
38
+ }
39
+ return items[0];
40
+ });
41
+ }
143
42
  last() {
144
- return Question_1.Question.about(`the last of ${this.collection.toString()}`, actor => this.collection.last(actor));
145
- }
146
- /**
147
- * @desc
148
- * Returns the nth of the items left after applying any filters,
149
- *
150
- * @example <caption>Retrieving the nth item</caption>
151
- * import { actorCalled, List } from '@serenity-js/core';
152
- * import { Ensure, equals, property } from '@serenity-js/assertions';
153
- *
154
- * actorCalled('Lisa').attemptsTo(
155
- * Ensure.that(
156
- * List.of(testAccounts).get(1),
157
- * property('username', equals('tester.two@example.com'))
158
- * )
159
- * )
160
- *
161
- * @param {number} index
162
- * Zero-based index of the item to return
163
- *
164
- * @returns {Question<Item_Return_Type>}
165
- *
166
- * @see {@link List#where}
167
- */
43
+ return Question_1.Question.about(`the last of ${this.subject}`, async (actor) => {
44
+ const items = await this.answeredBy(actor);
45
+ if (items.length === 0) {
46
+ throw new errors_1.LogicError((0, io_1.d) `Can't retrieve the last item from a list with 0 items: ${items}`);
47
+ }
48
+ return items[items.length - 1];
49
+ });
50
+ }
168
51
  get(index) {
169
- return Question_1.Question.about(`the ${List.ordinalSuffixOf(index + 1)} of ${this.collection}`, actor => this.collection.get(actor, index));
170
- }
171
- /**
172
- * @desc
173
- * Filters the underlying collection so that the result contains only those elements that meet the {@link Expectation}
174
- *
175
- * @example <caption>Filtering a list</caption>
176
- * import { actorCalled, List, Property } from '@serenity-js/core';
177
- * import { contain, Ensure, equals, property } from '@serenity-js/assertions';
178
- *
179
- * actorCalled('Lisa').attemptsTo(
180
- * Ensure.that(
181
- * List.of(testAccounts)
182
- * .where(Property.at<TestAccount>().environments, contain('prod'))
183
- * .where(Property.at<TestAccount>().role, equals('test-automation'))
184
- * .first(),
185
- * property('username', equals('tester.two@example.com'))
186
- * )
187
- * )
188
- *
189
- * @param {MetaQuestion<Item_Type, Promise<Answer_Type> | Answer_Type>} question
190
- * @param {Expectation<any, Answer_Type>} expectation
191
- *
192
- * @returns {List<List_Adapter_Type, Item_Type, Collection_Type, Item_Return_Type, Collection_Return_Type>}
193
- */
194
- where(question, expectation) {
195
- return new List(this.collection.withFilter(question, expectation));
196
- }
197
- /**
198
- * @desc
199
- * Makes the provided {@link Actor} answer this {@link Question} and return the underlying collection.
200
- *
201
- * @param {AnswersQuestions & UsesAbilities} actor
202
- * @returns {Collection_Return_Type}
203
- *
204
- * @see {@link Actor}
205
- * @see {@link AnswersQuestions}
206
- * @see {@link UsesAbilities}
207
- */
208
- answeredBy(actor) {
209
- return this.collection.items(actor);
210
- }
211
- static ordinalSuffixOf(index) {
212
- const lastDigit = index % 10, lastTwoDigits = index % 100;
213
- switch (true) {
214
- case (lastDigit === 1 && lastTwoDigits !== 11):
215
- return index + 'st';
216
- case (lastDigit === 2 && lastTwoDigits !== 12):
217
- return index + 'nd';
218
- case (lastDigit === 3 && lastTwoDigits !== 13):
219
- return index + 'rd';
220
- default:
221
- return index + 'th';
52
+ return Question_1.Question.about(`the ${ordinal(index + 1)} of ${this.subject}`, async (actor) => {
53
+ const items = await this.answeredBy(actor);
54
+ if (index < 0 || items.length <= index) {
55
+ throw new errors_1.LogicError(`Can't retrieve the ${ordinal(index)} item from a list with ${items.length} items: ` + (0, io_1.d) `${items}`);
56
+ }
57
+ return items[index];
58
+ });
59
+ }
60
+ async answeredBy(actor) {
61
+ const collection = await actor.answer(this.collection);
62
+ if (!Array.isArray(collection)) {
63
+ throw new errors_1.LogicError((0, io_1.d) `A List has to wrap an Array-compatible object. ${collection} given.`);
222
64
  }
65
+ return collection;
66
+ }
67
+ describedAs(subject) {
68
+ this.subject = subject;
69
+ return this;
70
+ }
71
+ toString() {
72
+ return this.subject;
223
73
  }
224
74
  }
225
75
  exports.List = List;
76
+ /**
77
+ * @package
78
+ * @param {number} index
79
+ */
80
+ function ordinal(index) {
81
+ const lastDigit = Math.abs(index) % 10, lastTwoDigits = Math.abs(index) % 100;
82
+ switch (true) {
83
+ case (lastDigit === 1 && lastTwoDigits !== 11):
84
+ return index + 'st';
85
+ case (lastDigit === 2 && lastTwoDigits !== 12):
86
+ return index + 'nd';
87
+ case (lastDigit === 3 && lastTwoDigits !== 13):
88
+ return index + 'rd';
89
+ default:
90
+ return index + 'th';
91
+ }
92
+ }
93
+ /**
94
+ * @package
95
+ */
96
+ class Where extends Question_1.Question {
97
+ constructor(collection, question, expectation, originalSubject) {
98
+ super();
99
+ this.collection = collection;
100
+ this.question = question;
101
+ this.expectation = expectation;
102
+ const prefix = this.collection instanceof Where
103
+ ? ' and'
104
+ : ' where';
105
+ this.subject = originalSubject + prefix + (0, io_1.d) ` ${question} does ${expectation}`;
106
+ }
107
+ async answeredBy(actor) {
108
+ try {
109
+ const collection = await actor.answer(this.collection);
110
+ const results = [];
111
+ for (const item of collection) {
112
+ const actual = this.question.of(item);
113
+ const expectationOutcome = await actor.answer(this.expectation.isMetFor(actual));
114
+ if (expectationOutcome instanceof expectations_1.ExpectationMet) {
115
+ results.push(item);
116
+ }
117
+ }
118
+ return results;
119
+ }
120
+ catch (error) {
121
+ 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);
122
+ }
123
+ }
124
+ describedAs(subject) {
125
+ this.subject = subject;
126
+ return this;
127
+ }
128
+ toString() {
129
+ return this.subject;
130
+ }
131
+ }
132
+ /**
133
+ * @package
134
+ */
135
+ class EachMappedTo extends Question_1.Question {
136
+ constructor(collection, mapping, originalSubject) {
137
+ super();
138
+ this.collection = collection;
139
+ this.mapping = mapping;
140
+ this.subject = originalSubject + (0, io_1.d) ` mapped to ${this.mapping}`;
141
+ }
142
+ async answeredBy(actor) {
143
+ const collection = await actor.answer(this.collection);
144
+ const mapped = [];
145
+ for (const item of collection) {
146
+ mapped.push(await actor.answer(this.mapping.of(item)));
147
+ }
148
+ return mapped;
149
+ }
150
+ describedAs(subject) {
151
+ this.subject = subject;
152
+ return this;
153
+ }
154
+ toString() {
155
+ return this.subject;
156
+ }
157
+ }
158
+ /**
159
+ * @package
160
+ */
161
+ class ForEachLoop extends Task_1.Task {
162
+ constructor(collection, subject, fn) {
163
+ super();
164
+ this.collection = collection;
165
+ this.subject = subject;
166
+ this.fn = fn;
167
+ }
168
+ async performAs(actor) {
169
+ const collection = await actor.answer(this.collection);
170
+ for (const [index, item] of collection.entries()) {
171
+ await this.fn({ actor, item }, index, collection);
172
+ }
173
+ }
174
+ toString() {
175
+ return `#actor iterates over ${this.subject}`;
176
+ }
177
+ }
226
178
  //# sourceMappingURL=List.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"List.js","sourceRoot":"","sources":["../../../src/screenplay/questions/List.ts"],"names":[],"mappings":";;;AAAA,iCAAqC;AAGrC,0CAAuC;AAEvC,mCAAwD;AAGxD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,MAAa,IAOT,SAAQ,mBAAgC;IAsBxC;;OAEG;IACH,YAA6B,UAA6B;QACtD,KAAK,CAAC,IAAA,cAAS,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<Answer>> {
42
42
  private readonly topic;
43
+ private subject;
43
44
  /**
44
45
  * @desc
45
46
  * Retrieves the previously recorded answer to a given {@link Question}
@@ -66,4 +67,13 @@ export declare class Note<Answer> extends Question<Promise<Answer>> {
66
67
  * @see {@link UsesAbilities}
67
68
  */
68
69
  answeredBy(actor: AnswersQuestions & UsesAbilities): Promise<Answer>;
70
+ /**
71
+ * @desc
72
+ * Changes the description of this question's subject.
73
+ *
74
+ * @param {string} subject
75
+ * @returns {Question<T>}
76
+ */
77
+ describedAs(subject: string): this;
78
+ toString(): string;
69
79
  }