@serenity-js/core 3.42.2 → 3.43.1
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/esm/Serenity.d.ts +3 -1
- package/esm/Serenity.d.ts.map +1 -1
- package/esm/Serenity.js +4 -3
- package/esm/Serenity.js.map +1 -1
- package/esm/config/SerenityConfig.d.ts +1 -1
- package/esm/config/SerenityConfig.js +1 -1
- package/esm/events/SceneFinishes.d.ts +1 -1
- package/esm/events/SceneFinishes.js +1 -1
- package/esm/events/actor/ActorStageExitCompleted.d.ts +1 -1
- package/esm/events/actor/ActorStageExitCompleted.js +1 -1
- package/esm/events/actor/ActorStageExitFailed.d.ts +1 -1
- package/esm/events/actor/ActorStageExitFailed.js +1 -1
- package/esm/events/actor/ActorStageExitStarts.d.ts +1 -1
- package/esm/events/actor/ActorStageExitStarts.js +1 -1
- package/esm/screenplay/Actor.d.ts +3 -3
- package/esm/screenplay/Actor.d.ts.map +1 -1
- package/esm/screenplay/Actor.js +7 -8
- package/esm/screenplay/Actor.js.map +1 -1
- package/esm/screenplay/abilities/Ability.d.ts +6 -6
- package/esm/screenplay/abilities/Ability.js +6 -6
- package/esm/screenplay/abilities/Discardable.d.ts +5 -4
- package/esm/screenplay/abilities/Discardable.d.ts.map +1 -1
- package/esm/screenplay/abilities/Discardable.js +25 -1
- package/esm/screenplay/abilities/Discardable.js.map +1 -1
- package/esm/screenplay/abilities/Initialisable.d.ts +9 -8
- package/esm/screenplay/abilities/Initialisable.d.ts.map +1 -1
- package/esm/screenplay/abilities/Initialisable.js +22 -1
- package/esm/screenplay/abilities/Initialisable.js.map +1 -1
- package/esm/stage/ActorLifecycleManager.d.ts +191 -0
- package/esm/stage/ActorLifecycleManager.d.ts.map +1 -0
- package/esm/stage/ActorLifecycleManager.js +255 -0
- package/esm/stage/ActorLifecycleManager.js.map +1 -0
- package/esm/stage/Stage.d.ts +22 -38
- package/esm/stage/Stage.d.ts.map +1 -1
- package/esm/stage/Stage.js +61 -117
- package/esm/stage/Stage.js.map +1 -1
- package/esm/stage/StageManager.d.ts +2 -4
- package/esm/stage/StageManager.d.ts.map +1 -1
- package/esm/stage/StageManager.js +0 -5
- package/esm/stage/StageManager.js.map +1 -1
- package/esm/stage/index.d.ts +1 -0
- package/esm/stage/index.d.ts.map +1 -1
- package/esm/stage/index.js +1 -0
- package/esm/stage/index.js.map +1 -1
- package/lib/Serenity.d.ts +3 -1
- package/lib/Serenity.d.ts.map +1 -1
- package/lib/Serenity.js +4 -3
- package/lib/Serenity.js.map +1 -1
- package/lib/config/SerenityConfig.d.ts +1 -1
- package/lib/config/SerenityConfig.js +1 -1
- package/lib/events/SceneFinishes.d.ts +1 -1
- package/lib/events/SceneFinishes.js +1 -1
- package/lib/events/actor/ActorStageExitCompleted.d.ts +1 -1
- package/lib/events/actor/ActorStageExitCompleted.js +1 -1
- package/lib/events/actor/ActorStageExitFailed.d.ts +1 -1
- package/lib/events/actor/ActorStageExitFailed.js +1 -1
- package/lib/events/actor/ActorStageExitStarts.d.ts +1 -1
- package/lib/events/actor/ActorStageExitStarts.js +1 -1
- package/lib/screenplay/Actor.d.ts +3 -3
- package/lib/screenplay/Actor.d.ts.map +1 -1
- package/lib/screenplay/Actor.js +6 -7
- package/lib/screenplay/Actor.js.map +1 -1
- package/lib/screenplay/abilities/Ability.d.ts +6 -6
- package/lib/screenplay/abilities/Ability.js +6 -6
- package/lib/screenplay/abilities/Discardable.d.ts +5 -4
- package/lib/screenplay/abilities/Discardable.d.ts.map +1 -1
- package/lib/screenplay/abilities/Discardable.js +27 -0
- package/lib/screenplay/abilities/Discardable.js.map +1 -1
- package/lib/screenplay/abilities/Initialisable.d.ts +9 -8
- package/lib/screenplay/abilities/Initialisable.d.ts.map +1 -1
- package/lib/screenplay/abilities/Initialisable.js +24 -0
- package/lib/screenplay/abilities/Initialisable.js.map +1 -1
- package/lib/stage/ActorLifecycleManager.d.ts +191 -0
- package/lib/stage/ActorLifecycleManager.d.ts.map +1 -0
- package/lib/stage/ActorLifecycleManager.js +259 -0
- package/lib/stage/ActorLifecycleManager.js.map +1 -0
- package/lib/stage/Stage.d.ts +22 -38
- package/lib/stage/Stage.d.ts.map +1 -1
- package/lib/stage/Stage.js +57 -113
- package/lib/stage/Stage.js.map +1 -1
- package/lib/stage/StageManager.d.ts +2 -4
- package/lib/stage/StageManager.d.ts.map +1 -1
- package/lib/stage/StageManager.js +0 -5
- package/lib/stage/StageManager.js.map +1 -1
- package/lib/stage/index.d.ts +1 -0
- package/lib/stage/index.d.ts.map +1 -1
- package/lib/stage/index.js +1 -0
- package/lib/stage/index.js.map +1 -1
- package/package.json +3 -3
- package/src/Serenity.ts +5 -2
- package/src/config/SerenityConfig.ts +1 -1
- package/src/events/SceneFinishes.ts +1 -1
- package/src/events/actor/ActorStageExitCompleted.ts +1 -1
- package/src/events/actor/ActorStageExitFailed.ts +1 -1
- package/src/events/actor/ActorStageExitStarts.ts +1 -1
- package/src/screenplay/Actor.ts +8 -11
- package/src/screenplay/abilities/Ability.ts +6 -6
- package/src/screenplay/abilities/Discardable.ts +9 -4
- package/src/screenplay/abilities/Initialisable.ts +15 -8
- package/src/stage/ActorLifecycleManager.ts +314 -0
- package/src/stage/Stage.ts +87 -165
- package/src/stage/StageManager.ts +3 -7
- package/src/stage/index.ts +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Actor.d.ts","sourceRoot":"","sources":["../../src/screenplay/Actor.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAG,MAAM,mBAAmB,CAAC;AAC1C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"Actor.d.ts","sourceRoot":"","sources":["../../src/screenplay/Actor.ts"],"names":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AAC,GAAG,CAAC;IAc5D;;;;;;OAMG;IACH,UAAU,CAAC,GAAG,UAAU,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAQpD;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,GAAG,SAAS,EAAE,OAAO,EAAE,GAAG,KAAK;IAMtC;;;;;;OAMG;IACH,MAAM,CAAC,CAAC,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAIhD;;OAEG;IACH,OAAO,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAUvD;;OAEG;IACH,WAAW,IAAI,SAAS;IAIxB;;;OAGG;IACH,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IASxB;;;;OAIG;IACH,QAAQ,IAAI,MAAM;IAMlB;;;;;OAKG;IACH,MAAM,IAAI,eAAe;IAOzB,OAAO,CAAC,mBAAmB;IAc3B,OAAO,CAAC,kBAAkB;IAQ1B,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,cAAc;IAQtB;;;;;OAKG;IACH,OAAO,CAAC,QAAQ;CAKnB"}
|
package/lib/screenplay/Actor.js
CHANGED
|
@@ -157,11 +157,11 @@ class Actor {
|
|
|
157
157
|
return this.stage.currentTime();
|
|
158
158
|
}
|
|
159
159
|
/**
|
|
160
|
-
* Instructs the actor to invoke [`Discardable.discard`](https://serenity-js.org/api/core/
|
|
161
|
-
* [discardable](https://serenity-js.org/api/core/
|
|
160
|
+
* Instructs the actor to invoke [`Discardable.discard`](https://serenity-js.org/api/core/class/Discardable/#discard) method on any
|
|
161
|
+
* [discardable](https://serenity-js.org/api/core/class/Discardable/) [ability](https://serenity-js.org/api/core/class/Ability/) it's been configured with.
|
|
162
162
|
*/
|
|
163
163
|
dismiss() {
|
|
164
|
-
return this.
|
|
164
|
+
return this.findAbilitiesWhere(index_js_5.Discardable.isDiscardable)
|
|
165
165
|
.reduce((previous, ability) => previous.then(() => ability.discard()), Promise.resolve(void 0));
|
|
166
166
|
}
|
|
167
167
|
/**
|
|
@@ -186,7 +186,7 @@ class Actor {
|
|
|
186
186
|
};
|
|
187
187
|
}
|
|
188
188
|
initialiseAbilities() {
|
|
189
|
-
return this.
|
|
189
|
+
return this.findAbilitiesWhere(index_js_5.Initialisable.isInitialisable)
|
|
190
190
|
.filter(ability => !ability.isInitialised())
|
|
191
191
|
.reduce((previous, ability) => previous
|
|
192
192
|
.then(() => ability.initialise())
|
|
@@ -194,11 +194,10 @@ class Actor {
|
|
|
194
194
|
throw new index_js_1.TestCompromisedError(`${this.name} couldn't initialise the ability to ${ability.constructor.name}`, error);
|
|
195
195
|
}), Promise.resolve(void 0));
|
|
196
196
|
}
|
|
197
|
-
|
|
197
|
+
findAbilitiesWhere(filter) {
|
|
198
198
|
const abilitiesFrom = (map) => Array.from(map.values());
|
|
199
|
-
const abilitiesWithDesiredMethods = (ability) => methodNames.every(methodName => typeof (ability[methodName]) === 'function');
|
|
200
199
|
return abilitiesFrom(this.abilities)
|
|
201
|
-
.filter(
|
|
200
|
+
.filter(filter);
|
|
202
201
|
}
|
|
203
202
|
findAbilityTo(doSomething) {
|
|
204
203
|
return this.abilities.get(doSomething.abilityType().name);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Actor.js","sourceRoot":"","sources":["../../src/screenplay/Actor.ts"],"names":[],"mappings":";;;AAAA,iDAA8E;AAC9E,iDAAsE;AACtE,6CAAgD;AAEhD,gDAA0C;AAG1C,
|
|
1
|
+
{"version":3,"file":"Actor.js","sourceRoot":"","sources":["../../src/screenplay/Actor.ts"],"names":[],"mappings":";;;AAAA,iDAA8E;AAC9E,iDAAsE;AACtE,6CAAgD;AAEhD,gDAA0C;AAG1C,mDAA+G;AAS/G;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AACH,MAAa,KAAK;I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a,CAAoB,WAA2B;QAChE,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,WAAW,CAAC,WAAW,EAAE,CAAC,IAAI,CAAM,CAAC;IACnE,CAAC;IAEO,cAAc,CAAC,OAAgB;QACnC,IAAI,CAAC,CAAC,OAAO,YAAY,kBAAO,CAAC,EAAE,CAAC;YAChC,MAAM,IAAI,6BAAkB,CAAC,2EAA4E,yBAAc,CAAC,MAAM,CAAC,OAAO,CAAE,EAAE,CAAC,CAAC;QAChJ,CAAC;QAED,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC5D,CAAC;IAED;;;;;OAKG;IACK,QAAQ,CAAC,SAAwB;QACrC,OAAO,OAAO,SAAS,KAAK,QAAQ;YAChC,CAAC,CAAC,IAAI,eAAI,CAAC,SAAS,CAAC;YACrB,CAAC,CAAC,SAAS,CAAC;IACpB,CAAC;CACJ;AAtMD,sBAsMC"}
|
|
@@ -42,8 +42,8 @@ import type { UsesAbilities } from './UsesAbilities.js';
|
|
|
42
42
|
* From the technical perspective, an **ability** is an [adapter](https://en.wikipedia.org/wiki/Adapter_pattern)
|
|
43
43
|
* around an interface-specific integration library, such as a web browser driver, an HTTP client, a database client, and so on.
|
|
44
44
|
* You give an actor an ability, and it's the ability's responsibility to provide a consistent API around the integration library and deal with any of its quirks.
|
|
45
|
-
* Abilities **encapsulate integration libraries** and handle their [configuration and initialisation](https://serenity-js.org/api/core/
|
|
46
|
-
* the process of [freeing up any resources](https://serenity-js.org/api/core/
|
|
45
|
+
* Abilities **encapsulate integration libraries** and handle their [configuration and initialisation](https://serenity-js.org/api/core/class/Initialisable/),
|
|
46
|
+
* the process of [freeing up any resources](https://serenity-js.org/api/core/class/Discardable/) they hold,
|
|
47
47
|
* as well as managing any state associated with the library.
|
|
48
48
|
*
|
|
49
49
|
* ### Portable interactions with web interfaces
|
|
@@ -268,8 +268,8 @@ import type { UsesAbilities } from './UsesAbilities.js';
|
|
|
268
268
|
*
|
|
269
269
|
* Abilities that rely on resources that need to be initialised before they can be used,
|
|
270
270
|
* or discarded before the actor is dismissed can implement
|
|
271
|
-
* the [`Initialisable`](https://serenity-js.org/api/core/
|
|
272
|
-
* or [`Discardable`](https://serenity-js.org/api/core/
|
|
271
|
+
* the [`Initialisable`](https://serenity-js.org/api/core/class/Initialisable/)
|
|
272
|
+
* or [`Discardable`](https://serenity-js.org/api/core/class/Discardable/) interfaces, respectively.
|
|
273
273
|
*
|
|
274
274
|
* ### Defining a custom ability to `QueryPostgresDB`
|
|
275
275
|
*
|
|
@@ -351,8 +351,8 @@ import type { UsesAbilities } from './UsesAbilities.js';
|
|
|
351
351
|
*
|
|
352
352
|
* ## Learn more
|
|
353
353
|
* - [`AbilityType`](https://serenity-js.org/api/core/#AbilityType)
|
|
354
|
-
* - [`Initialisable`](https://serenity-js.org/api/core/
|
|
355
|
-
* - [`Discardable`](https://serenity-js.org/api/core/
|
|
354
|
+
* - [`Initialisable`](https://serenity-js.org/api/core/class/Initialisable/)
|
|
355
|
+
* - [`Discardable`](https://serenity-js.org/api/core/class/Discardable/)
|
|
356
356
|
* - [`BrowseTheWeb`](https://serenity-js.org/api/web/class/BrowseTheWeb/)
|
|
357
357
|
* - [`CallAnApi`](https://serenity-js.org/api/rest/class/CallAnApi/)
|
|
358
358
|
* - [`TakeNotes`](https://serenity-js.org/api/core/class/TakeNotes/)
|
|
@@ -42,8 +42,8 @@ exports.Ability = void 0;
|
|
|
42
42
|
* From the technical perspective, an **ability** is an [adapter](https://en.wikipedia.org/wiki/Adapter_pattern)
|
|
43
43
|
* around an interface-specific integration library, such as a web browser driver, an HTTP client, a database client, and so on.
|
|
44
44
|
* You give an actor an ability, and it's the ability's responsibility to provide a consistent API around the integration library and deal with any of its quirks.
|
|
45
|
-
* Abilities **encapsulate integration libraries** and handle their [configuration and initialisation](https://serenity-js.org/api/core/
|
|
46
|
-
* the process of [freeing up any resources](https://serenity-js.org/api/core/
|
|
45
|
+
* Abilities **encapsulate integration libraries** and handle their [configuration and initialisation](https://serenity-js.org/api/core/class/Initialisable/),
|
|
46
|
+
* the process of [freeing up any resources](https://serenity-js.org/api/core/class/Discardable/) they hold,
|
|
47
47
|
* as well as managing any state associated with the library.
|
|
48
48
|
*
|
|
49
49
|
* ### Portable interactions with web interfaces
|
|
@@ -268,8 +268,8 @@ exports.Ability = void 0;
|
|
|
268
268
|
*
|
|
269
269
|
* Abilities that rely on resources that need to be initialised before they can be used,
|
|
270
270
|
* or discarded before the actor is dismissed can implement
|
|
271
|
-
* the [`Initialisable`](https://serenity-js.org/api/core/
|
|
272
|
-
* or [`Discardable`](https://serenity-js.org/api/core/
|
|
271
|
+
* the [`Initialisable`](https://serenity-js.org/api/core/class/Initialisable/)
|
|
272
|
+
* or [`Discardable`](https://serenity-js.org/api/core/class/Discardable/) interfaces, respectively.
|
|
273
273
|
*
|
|
274
274
|
* ### Defining a custom ability to `QueryPostgresDB`
|
|
275
275
|
*
|
|
@@ -351,8 +351,8 @@ exports.Ability = void 0;
|
|
|
351
351
|
*
|
|
352
352
|
* ## Learn more
|
|
353
353
|
* - [`AbilityType`](https://serenity-js.org/api/core/#AbilityType)
|
|
354
|
-
* - [`Initialisable`](https://serenity-js.org/api/core/
|
|
355
|
-
* - [`Discardable`](https://serenity-js.org/api/core/
|
|
354
|
+
* - [`Initialisable`](https://serenity-js.org/api/core/class/Initialisable/)
|
|
355
|
+
* - [`Discardable`](https://serenity-js.org/api/core/class/Discardable/)
|
|
356
356
|
* - [`BrowseTheWeb`](https://serenity-js.org/api/web/class/BrowseTheWeb/)
|
|
357
357
|
* - [`CallAnApi`](https://serenity-js.org/api/rest/class/CallAnApi/)
|
|
358
358
|
* - [`TakeNotes`](https://serenity-js.org/api/core/class/TakeNotes/)
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* An interface to be implemented by any [`Ability`](https://serenity-js.org/api/core/class/Ability/) that needs to free up
|
|
3
3
|
* the resources it uses, e.g. disconnect from a database.
|
|
4
4
|
*
|
|
5
|
-
* This [`Discardable.discard`](https://serenity-js.org/api/core/
|
|
5
|
+
* This [`Discardable.discard`](https://serenity-js.org/api/core/class/Discardable/#discard) method is invoked directly by the [actor](https://serenity-js.org/api/core/class/Actor/), and indirectly by the [stage](https://serenity-js.org/api/core/class/Stage/):
|
|
6
6
|
* - when [SceneFinishes](https://serenity-js.org/api/core-events/class/SceneFinishes/), for actors instantiated after [SceneStarts](https://serenity-js.org/api/core-events/class/SceneStarts/) - e.g. within a test scenario or in a "before each" hook
|
|
7
7
|
* - when [`TestRunFinishes`](https://serenity-js.org/api/core-events/class/TestRunFinishes/), for actors instantiated before [SceneStarts](https://serenity-js.org/api/core-events/class/SceneStarts/) - e.g. in a "before all" hook
|
|
8
8
|
*
|
|
@@ -13,14 +13,15 @@
|
|
|
13
13
|
* ## Learn more
|
|
14
14
|
* - [`Ability`](https://serenity-js.org/api/core/class/Ability/)
|
|
15
15
|
* - [`AbilityType`](https://serenity-js.org/api/core/#AbilityType)
|
|
16
|
-
* - [`Initialisable`](https://serenity-js.org/api/core/
|
|
16
|
+
* - [`Initialisable`](https://serenity-js.org/api/core/class/Initialisable/)
|
|
17
17
|
*
|
|
18
18
|
* @group Abilities
|
|
19
19
|
*/
|
|
20
|
-
export
|
|
20
|
+
export declare abstract class Discardable {
|
|
21
|
+
static isDiscardable<T>(value: T): value is T & Discardable;
|
|
21
22
|
/**
|
|
22
23
|
* Discards the resources associated with this ability.
|
|
23
24
|
*/
|
|
24
|
-
discard(): Promise<void> | void;
|
|
25
|
+
abstract discard(): Promise<void> | void;
|
|
25
26
|
}
|
|
26
27
|
//# sourceMappingURL=Discardable.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Discardable.d.ts","sourceRoot":"","sources":["../../../src/screenplay/abilities/Discardable.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,
|
|
1
|
+
{"version":3,"file":"Discardable.d.ts","sourceRoot":"","sources":["../../../src/screenplay/abilities/Discardable.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,8BAAsB,WAAW;IAE7B,MAAM,CAAC,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,KAAK,IAAI,CAAC,GAAG,WAAW;IAK3D;;OAEG;IACH,QAAQ,CAAC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;CAC3C"}
|
|
@@ -1,3 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Discardable = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* An interface to be implemented by any [`Ability`](https://serenity-js.org/api/core/class/Ability/) that needs to free up
|
|
6
|
+
* the resources it uses, e.g. disconnect from a database.
|
|
7
|
+
*
|
|
8
|
+
* This [`Discardable.discard`](https://serenity-js.org/api/core/class/Discardable/#discard) method is invoked directly by the [actor](https://serenity-js.org/api/core/class/Actor/), and indirectly by the [stage](https://serenity-js.org/api/core/class/Stage/):
|
|
9
|
+
* - when [SceneFinishes](https://serenity-js.org/api/core-events/class/SceneFinishes/), for actors instantiated after [SceneStarts](https://serenity-js.org/api/core-events/class/SceneStarts/) - e.g. within a test scenario or in a "before each" hook
|
|
10
|
+
* - when [`TestRunFinishes`](https://serenity-js.org/api/core-events/class/TestRunFinishes/), for actors instantiated before [SceneStarts](https://serenity-js.org/api/core-events/class/SceneStarts/) - e.g. in a "before all" hook
|
|
11
|
+
*
|
|
12
|
+
* Note that events such as [SceneFinishes](https://serenity-js.org/api/core-events/class/SceneFinishes/) and [`TestRunFinishes`](https://serenity-js.org/api/core-events/class/TestRunFinishes/) are emitted by Serenity/JS test runner adapters,
|
|
13
|
+
* such as `@serenity-js/cucumber`, `@serenity-js/mocha`, `@serenity-js/jasmine`, and so on.
|
|
14
|
+
* Consult their respective readmes to learn how to register them with your test runner of choice.
|
|
15
|
+
*
|
|
16
|
+
* ## Learn more
|
|
17
|
+
* - [`Ability`](https://serenity-js.org/api/core/class/Ability/)
|
|
18
|
+
* - [`AbilityType`](https://serenity-js.org/api/core/#AbilityType)
|
|
19
|
+
* - [`Initialisable`](https://serenity-js.org/api/core/class/Initialisable/)
|
|
20
|
+
*
|
|
21
|
+
* @group Abilities
|
|
22
|
+
*/
|
|
23
|
+
class Discardable {
|
|
24
|
+
static isDiscardable(value) {
|
|
25
|
+
return typeof (value['discard']) === 'function'
|
|
26
|
+
&& value['discard'].length === 0;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.Discardable = Discardable;
|
|
3
30
|
//# sourceMappingURL=Discardable.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Discardable.js","sourceRoot":"","sources":["../../../src/screenplay/abilities/Discardable.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"Discardable.js","sourceRoot":"","sources":["../../../src/screenplay/abilities/Discardable.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAsB,WAAW;IAE7B,MAAM,CAAC,aAAa,CAAI,KAAQ;QAC5B,OAAO,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,KAAK,UAAU;eACxC,KAAK,CAAC,SAAS,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC;IACzC,CAAC;CAMJ;AAXD,kCAWC"}
|
|
@@ -2,25 +2,26 @@
|
|
|
2
2
|
* An interface to be implemented by any [`Ability`](https://serenity-js.org/api/core/class/Ability/) that needs to initialise
|
|
3
3
|
* the resources it uses, e.g. establish a database connection.
|
|
4
4
|
*
|
|
5
|
-
* The [`Initialisable.initialise`](https://serenity-js.org/api/core/
|
|
6
|
-
* but **only when** [`Initialisable.isInitialised`](https://serenity-js.org/api/core/
|
|
5
|
+
* The [`Initialisable.initialise`](https://serenity-js.org/api/core/class/Initialisable/#initialise) method is invoked whenever [`Actor.attemptsTo`](https://serenity-js.org/api/core/class/Actor/#attemptsTo) method is called,
|
|
6
|
+
* but **only when** [`Initialisable.isInitialised`](https://serenity-js.org/api/core/class/Initialisable/#isInitialised) returns false. This is to avoid initialising abilities more than once.
|
|
7
7
|
*
|
|
8
8
|
* ## Learn more
|
|
9
9
|
* - [`Ability`](https://serenity-js.org/api/core/class/Ability/)
|
|
10
10
|
* - [`AbilityType`](https://serenity-js.org/api/core/#AbilityType)
|
|
11
|
-
* - [`Discardable`](https://serenity-js.org/api/core/
|
|
11
|
+
* - [`Discardable`](https://serenity-js.org/api/core/class/Discardable/)
|
|
12
12
|
*
|
|
13
13
|
* @group Abilities
|
|
14
14
|
*/
|
|
15
|
-
export
|
|
15
|
+
export declare abstract class Initialisable {
|
|
16
|
+
static isInitialisable<T>(value: T): value is T & Initialisable;
|
|
16
17
|
/**
|
|
17
18
|
* Initialises the ability. Invoked whenever [`Actor.attemptsTo`](https://serenity-js.org/api/core/class/Actor/#attemptsTo) method is called,
|
|
18
|
-
* but **only when** [`Initialisable.isInitialised`](https://serenity-js.org/api/core/
|
|
19
|
+
* but **only when** [`Initialisable.isInitialised`](https://serenity-js.org/api/core/class/Initialisable/#isInitialised) returns false.
|
|
19
20
|
*
|
|
20
|
-
* Make sure to implement [`Initialisable.isInitialised`](https://serenity-js.org/api/core/
|
|
21
|
+
* Make sure to implement [`Initialisable.isInitialised`](https://serenity-js.org/api/core/class/Initialisable/#isInitialised) so that it returns `true`
|
|
21
22
|
* when the ability has been successfully initialised.
|
|
22
23
|
*/
|
|
23
|
-
initialise(): Promise<void> | void;
|
|
24
|
+
abstract initialise(): Promise<void> | void;
|
|
24
25
|
/**
|
|
25
26
|
* Should return `true` when all the resources that the given ability needs
|
|
26
27
|
* have been initialised. Should return `false` if the [`Actor`](https://serenity-js.org/api/core/class/Actor/) should
|
|
@@ -28,6 +29,6 @@ export interface Initialisable {
|
|
|
28
29
|
*
|
|
29
30
|
* @returns {boolean}
|
|
30
31
|
*/
|
|
31
|
-
isInitialised(): boolean;
|
|
32
|
+
abstract isInitialised(): boolean;
|
|
32
33
|
}
|
|
33
34
|
//# sourceMappingURL=Initialisable.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Initialisable.d.ts","sourceRoot":"","sources":["../../../src/screenplay/abilities/Initialisable.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,
|
|
1
|
+
{"version":3,"file":"Initialisable.d.ts","sourceRoot":"","sources":["../../../src/screenplay/abilities/Initialisable.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,8BAAsB,aAAa;IAE/B,MAAM,CAAC,eAAe,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,KAAK,IAAI,CAAC,GAAG,aAAa;IAO/D;;;;;;OAMG;IACH,QAAQ,CAAC,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;IAE3C;;;;;;OAMG;IACH,QAAQ,CAAC,aAAa,IAAI,OAAO;CACpC"}
|
|
@@ -1,3 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Initialisable = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* An interface to be implemented by any [`Ability`](https://serenity-js.org/api/core/class/Ability/) that needs to initialise
|
|
6
|
+
* the resources it uses, e.g. establish a database connection.
|
|
7
|
+
*
|
|
8
|
+
* The [`Initialisable.initialise`](https://serenity-js.org/api/core/class/Initialisable/#initialise) method is invoked whenever [`Actor.attemptsTo`](https://serenity-js.org/api/core/class/Actor/#attemptsTo) method is called,
|
|
9
|
+
* but **only when** [`Initialisable.isInitialised`](https://serenity-js.org/api/core/class/Initialisable/#isInitialised) returns false. This is to avoid initialising abilities more than once.
|
|
10
|
+
*
|
|
11
|
+
* ## Learn more
|
|
12
|
+
* - [`Ability`](https://serenity-js.org/api/core/class/Ability/)
|
|
13
|
+
* - [`AbilityType`](https://serenity-js.org/api/core/#AbilityType)
|
|
14
|
+
* - [`Discardable`](https://serenity-js.org/api/core/class/Discardable/)
|
|
15
|
+
*
|
|
16
|
+
* @group Abilities
|
|
17
|
+
*/
|
|
18
|
+
class Initialisable {
|
|
19
|
+
static isInitialisable(value) {
|
|
20
|
+
return typeof (value['initialise']) === 'function'
|
|
21
|
+
&& value['initialise'].length === 0
|
|
22
|
+
&& typeof value['isInitialised'] === 'function'
|
|
23
|
+
&& value['isInitialised'].length === 0;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.Initialisable = Initialisable;
|
|
3
27
|
//# sourceMappingURL=Initialisable.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Initialisable.js","sourceRoot":"","sources":["../../../src/screenplay/abilities/Initialisable.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"Initialisable.js","sourceRoot":"","sources":["../../../src/screenplay/abilities/Initialisable.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;GAaG;AACH,MAAsB,aAAa;IAE/B,MAAM,CAAC,eAAe,CAAI,KAAQ;QAC9B,OAAO,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,KAAK,UAAU;eAC3C,KAAK,CAAC,YAAY,CAAC,CAAC,MAAM,KAAK,CAAC;eAChC,OAAO,KAAK,CAAC,eAAe,CAAC,KAAK,UAAU;eAC5C,KAAK,CAAC,eAAe,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC;IAC/C,CAAC;CAmBJ;AA1BD,sCA0BC"}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import type { Clock, Duration } from '../screenplay/index.js';
|
|
2
|
+
import { Actor } from '../screenplay/index.js';
|
|
3
|
+
import type { Cast } from './Cast.js';
|
|
4
|
+
import type { Stage } from './Stage.js';
|
|
5
|
+
/**
|
|
6
|
+
* Represents the focus area where actors are tracked.
|
|
7
|
+
*
|
|
8
|
+
* - `'foreground'` - Scene-scoped actors that are dismissed when a scene finishes
|
|
9
|
+
* - `'background'` - Test run-scoped actors that persist across scenes and are dismissed when the test run finishes
|
|
10
|
+
*
|
|
11
|
+
* @group Stage
|
|
12
|
+
*/
|
|
13
|
+
export type StageFocus = 'foreground' | 'background';
|
|
14
|
+
/**
|
|
15
|
+
* Manages the lifecycle of [actors](https://serenity-js.org/api/core/class/Actor/) on the [stage](https://serenity-js.org/api/core/class/Stage/),
|
|
16
|
+
* including their creation, retrieval, and tracking of which actors are in the foreground (scene-scoped)
|
|
17
|
+
* versus background (test run-scoped).
|
|
18
|
+
*
|
|
19
|
+
* The `ActorLifecycleManager` is responsible for:
|
|
20
|
+
* - Instantiating and caching actors via the configured [cast](https://serenity-js.org/api/core/class/Cast/)
|
|
21
|
+
* - Tracking which actor is currently in the spotlight (active)
|
|
22
|
+
* - Managing the focus area (foreground vs background) where new actors are created
|
|
23
|
+
* - Providing access to actors for dismissal when scenes or test runs finish
|
|
24
|
+
*
|
|
25
|
+
* ## Default behaviour
|
|
26
|
+
*
|
|
27
|
+
* By default, actors created before the actual test scenario starts, e.g. in beforeAll hooks, are placed in the `'background'` focus area.
|
|
28
|
+
* When a [`SceneStarts`](https://serenity-js.org/api/core-events/class/SceneStarts/) event is announced,
|
|
29
|
+
* the focus switches to `'foreground'`. When a [`SceneFinishes`](https://serenity-js.org/api/core-events/class/SceneFinishes/)
|
|
30
|
+
* event is announced, foreground actors are dismissed, their abilities [discarded](https://serenity-js.org/api/core/class/Discardable/)
|
|
31
|
+
* and focus returns to `'background'`.
|
|
32
|
+
*
|
|
33
|
+
* ## Custom lifecycle management
|
|
34
|
+
*
|
|
35
|
+
* Test runner adapters like [`@serenity-js/playwright-test`](https://serenity-js.org/api/playwright-test/),
|
|
36
|
+
* where test execution and reporting happen in separate processes, can inject a custom `ActorLifecycleManager` instance
|
|
37
|
+
* to control actor lifecycle programmatically.
|
|
38
|
+
*
|
|
39
|
+
* ```typescript
|
|
40
|
+
* const actorLifecycleManager = new ActorLifecycleManager(cast, clock, interactionTimeout);
|
|
41
|
+
* const serenity = new Serenity(clock, cueTimeout, actorLifecycleManager);
|
|
42
|
+
*
|
|
43
|
+
* // At the start of each test:
|
|
44
|
+
* actorLifecycleManager.switchFocus('foreground');
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* ## Learn more
|
|
48
|
+
* - [`Stage`](https://serenity-js.org/api/core/class/Stage/)
|
|
49
|
+
* - [`Cast`](https://serenity-js.org/api/core/class/Cast/)
|
|
50
|
+
* - [`Actor`](https://serenity-js.org/api/core/class/Actor/)
|
|
51
|
+
*
|
|
52
|
+
* @group Stage
|
|
53
|
+
*/
|
|
54
|
+
export declare class ActorLifecycleManager {
|
|
55
|
+
protected cast: Cast;
|
|
56
|
+
protected readonly clock: Clock;
|
|
57
|
+
protected interactionTimeout: Duration;
|
|
58
|
+
/**
|
|
59
|
+
* The most recent actor referenced via the {@apilink actor} method
|
|
60
|
+
*/
|
|
61
|
+
private currentActor?;
|
|
62
|
+
/**
|
|
63
|
+
* The scene in which the spotlight was last set.
|
|
64
|
+
* Used to detect when the spotlight shifts to a different scene context.
|
|
65
|
+
*/
|
|
66
|
+
private currentActorScene;
|
|
67
|
+
private currentFocusValue;
|
|
68
|
+
private actors;
|
|
69
|
+
protected stage: Stage;
|
|
70
|
+
constructor(cast: Cast, clock: Clock, interactionTimeout: Duration);
|
|
71
|
+
/**
|
|
72
|
+
* Configures the manager with new settings.
|
|
73
|
+
*
|
|
74
|
+
* @param options - Configuration options
|
|
75
|
+
* @param options.interactionTimeout - The maximum time to wait for an interaction to complete
|
|
76
|
+
*/
|
|
77
|
+
configure({ interactionTimeout }: {
|
|
78
|
+
interactionTimeout: Duration;
|
|
79
|
+
}): void;
|
|
80
|
+
/**
|
|
81
|
+
* Associates this manager with a [`Stage`](https://serenity-js.org/api/core/class/Stage/) instance.
|
|
82
|
+
*
|
|
83
|
+
* This method is called automatically by the `Stage` during construction.
|
|
84
|
+
* It establishes the bidirectional relationship between the manager and the stage,
|
|
85
|
+
* allowing the manager to emit [domain events](https://serenity-js.org/api/core-events/class/DomainEvent/)
|
|
86
|
+
* when actors enter the stage or are spotlighted.
|
|
87
|
+
*
|
|
88
|
+
* @param stage - The Stage instance to associate with this manager
|
|
89
|
+
*/
|
|
90
|
+
assignTo(stage: Stage): void;
|
|
91
|
+
/**
|
|
92
|
+
* Configures the manager to use the provided [cast](https://serenity-js.org/api/core/class/Cast/) for preparing actors.
|
|
93
|
+
*
|
|
94
|
+
* @param actors - The cast to use for preparing new actors
|
|
95
|
+
*
|
|
96
|
+
* @throws [`ConfigurationError`](https://serenity-js.org/api/core/class/ConfigurationError/)
|
|
97
|
+
* If the provided cast is not defined or doesn't have a `prepare` method
|
|
98
|
+
*/
|
|
99
|
+
engage(actors: Cast): void;
|
|
100
|
+
/**
|
|
101
|
+
* Returns the current [cast](https://serenity-js.org/api/core/class/Cast/) used for preparing actors.
|
|
102
|
+
*
|
|
103
|
+
* @returns The currently configured cast
|
|
104
|
+
*/
|
|
105
|
+
currentCast(): Cast;
|
|
106
|
+
/**
|
|
107
|
+
* Instantiates a new [`Actor`](https://serenity-js.org/api/core/class/Actor/) or fetches an existing one
|
|
108
|
+
* identified by their name if they've already been instantiated.
|
|
109
|
+
*
|
|
110
|
+
* When a new actor is instantiated, an [`ActorEntersStage`](https://serenity-js.org/api/core-events/class/ActorEntersStage/)
|
|
111
|
+
* event is announced. When the spotlight shifts to a different actor (or the same actor in a different scene),
|
|
112
|
+
* an [`ActorSpotlighted`](https://serenity-js.org/api/core-events/class/ActorSpotlighted/) event is announced.
|
|
113
|
+
*
|
|
114
|
+
* Actors are first looked up in the `'background'` focus area, then in `'foreground'`.
|
|
115
|
+
* New actors are always created in the current focus area.
|
|
116
|
+
*
|
|
117
|
+
* @param name - Case-sensitive name of the Actor, e.g. `Alice`
|
|
118
|
+
* @returns The actor with the given name
|
|
119
|
+
*/
|
|
120
|
+
actor(name: string): Actor;
|
|
121
|
+
private prepareActor;
|
|
122
|
+
private typeOf;
|
|
123
|
+
private existingActorCalled;
|
|
124
|
+
/**
|
|
125
|
+
* Returns `true` if there is an [`Actor`](https://serenity-js.org/api/core/class/Actor/) in the spotlight, `false` otherwise.
|
|
126
|
+
*
|
|
127
|
+
* @returns `true` if an actor is currently spotlighted
|
|
128
|
+
*/
|
|
129
|
+
hasActorInTheSpotlight(): boolean;
|
|
130
|
+
/**
|
|
131
|
+
* Returns the last [`Actor`](https://serenity-js.org/api/core/class/Actor/) instantiated
|
|
132
|
+
* via [`actor`](https://serenity-js.org/api/core/class/ActorLifecycleManager/#actor).
|
|
133
|
+
*
|
|
134
|
+
* @returns The currently spotlighted actor
|
|
135
|
+
*
|
|
136
|
+
* @throws [`LogicError`](https://serenity-js.org/api/core/class/LogicError/)
|
|
137
|
+
* If no [`Actor`](https://serenity-js.org/api/core/class/Actor/) has been activated yet
|
|
138
|
+
*/
|
|
139
|
+
actorInTheSpotlight(): Actor;
|
|
140
|
+
/**
|
|
141
|
+
* Switches the focus to the specified stage area.
|
|
142
|
+
*
|
|
143
|
+
* Actors created after this call will be added to the specified area.
|
|
144
|
+
* This method is typically called automatically by the [`Stage`](https://serenity-js.org/api/core/class/Stage/)
|
|
145
|
+
* in response to [`SceneStarts`](https://serenity-js.org/api/core-events/class/SceneStarts/) and
|
|
146
|
+
* [`SceneFinishes`](https://serenity-js.org/api/core-events/class/SceneFinishes/) events.
|
|
147
|
+
*
|
|
148
|
+
* Test runner adapters can also call this method directly to control actor lifecycle
|
|
149
|
+
* when scene events are not available (e.g., in Playwright Test where the reporter
|
|
150
|
+
* runs in a separate process).
|
|
151
|
+
*
|
|
152
|
+
* @param focus - The focus area to switch to: `'foreground'` for scene-scoped actors,
|
|
153
|
+
* `'background'` for test run-scoped actors
|
|
154
|
+
*/
|
|
155
|
+
switchFocus(focus: StageFocus): void;
|
|
156
|
+
/**
|
|
157
|
+
* Returns the current focus area.
|
|
158
|
+
*
|
|
159
|
+
* @returns The current focus: `'foreground'` or `'background'`
|
|
160
|
+
*/
|
|
161
|
+
currentFocus(): StageFocus;
|
|
162
|
+
/**
|
|
163
|
+
* Returns all actors in the specified focus area.
|
|
164
|
+
*
|
|
165
|
+
* This method is used by the [`Stage`](https://serenity-js.org/api/core/class/Stage/) to retrieve
|
|
166
|
+
* actors for dismissal when scenes or test runs finish.
|
|
167
|
+
*
|
|
168
|
+
* @param focus - The focus area to retrieve actors from
|
|
169
|
+
* @returns An array of actors in the specified focus area
|
|
170
|
+
*/
|
|
171
|
+
actorsIn(focus: StageFocus): Actor[];
|
|
172
|
+
/**
|
|
173
|
+
* Clears the spotlight if the current actor is in the specified focus area.
|
|
174
|
+
*
|
|
175
|
+
* This ensures that after actors in a focus area are dismissed, the spotlight
|
|
176
|
+
* doesn't reference a dismissed actor.
|
|
177
|
+
*
|
|
178
|
+
* @param focus - The focus area to check
|
|
179
|
+
*/
|
|
180
|
+
clearSpotlightIfIn(focus: StageFocus): void;
|
|
181
|
+
/**
|
|
182
|
+
* Clears all actors from the specified focus area.
|
|
183
|
+
*
|
|
184
|
+
* This method is called by the [`Stage`](https://serenity-js.org/api/core/class/Stage/) after
|
|
185
|
+
* actors have been dismissed to remove them from the internal tracking maps.
|
|
186
|
+
*
|
|
187
|
+
* @param focus - The focus area to clear
|
|
188
|
+
*/
|
|
189
|
+
clearActorsIn(focus: StageFocus): void;
|
|
190
|
+
}
|
|
191
|
+
//# sourceMappingURL=ActorLifecycleManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ActorLifecycleManager.d.ts","sourceRoot":"","sources":["../../src/stage/ActorLifecycleManager.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,KAAK,EAAgB,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,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