@serenity-js/rest 3.23.1 → 3.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/lib/screenplay/models/HTTPRequest.d.ts +2 -11
- package/lib/screenplay/models/HTTPRequest.d.ts.map +1 -1
- package/lib/screenplay/models/HTTPRequest.js +6 -21
- package/lib/screenplay/models/HTTPRequest.js.map +1 -1
- package/package.json +6 -6
- package/src/screenplay/models/HTTPRequest.ts +6 -24
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,25 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [3.24.0](https://github.com/serenity-js/serenity-js/compare/v3.23.2...v3.24.0) (2024-06-18)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **core:** support for dynamic descriptions for Questions ([aac9a8f](https://github.com/serenity-js/serenity-js/commit/aac9a8f5dbc5b6f4664373f5462aa171baecdcf8)), closes [#2223](https://github.com/serenity-js/serenity-js/issues/2223)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [3.23.2](https://github.com/serenity-js/serenity-js/compare/v3.23.1...v3.23.2) (2024-05-24)
|
|
18
|
+
|
|
19
|
+
**Note:** Version bump only for package @serenity-js/rest
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
6
25
|
## [3.23.1](https://github.com/serenity-js/serenity-js/compare/v3.23.0...v3.23.1) (2024-05-20)
|
|
7
26
|
|
|
8
27
|
|
|
@@ -11,7 +11,6 @@ export declare abstract class HTTPRequest extends Question<Promise<AxiosRequestC
|
|
|
11
11
|
protected readonly resourceUri?: Answerable<string>;
|
|
12
12
|
protected readonly data?: Answerable<any>;
|
|
13
13
|
protected readonly config?: Answerable<WithAnswerableProperties<AxiosRequestConfig>>;
|
|
14
|
-
private subject;
|
|
15
14
|
/**
|
|
16
15
|
* @param [resourceUri]
|
|
17
16
|
* URL to which the request should be sent
|
|
@@ -28,22 +27,14 @@ export declare abstract class HTTPRequest extends Question<Promise<AxiosRequestC
|
|
|
28
27
|
* @inheritDoc
|
|
29
28
|
*/
|
|
30
29
|
answeredBy(actor: AnswersQuestions & UsesAbilities): Promise<AxiosRequestConfig>;
|
|
31
|
-
/**
|
|
32
|
-
* @inheritDoc
|
|
33
|
-
*/
|
|
34
|
-
describedAs(subject: string): this;
|
|
35
|
-
/**
|
|
36
|
-
* @inheritDoc
|
|
37
|
-
*/
|
|
38
|
-
toString(): string;
|
|
39
30
|
/**
|
|
40
31
|
* Determines the request method based on the name of the request class.
|
|
41
32
|
* For example: GetRequest => GET, PostRequest => POST, etc.
|
|
42
33
|
*/
|
|
43
|
-
private httpMethodName;
|
|
34
|
+
private static httpMethodName;
|
|
44
35
|
/**
|
|
45
36
|
* A human-readable description of the request, such as "a GET request", "an OPTIONS request", etc.
|
|
46
37
|
*/
|
|
47
|
-
private requestDescription;
|
|
38
|
+
private static requestDescription;
|
|
48
39
|
}
|
|
49
40
|
//# sourceMappingURL=HTTPRequest.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HTTPRequest.d.ts","sourceRoot":"","sources":["../../../src/screenplay/models/HTTPRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,aAAa,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC/G,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAEhD;;;;;GAKG;AACH,8BAAsB,WAAY,SAAQ,QAAQ,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"HTTPRequest.d.ts","sourceRoot":"","sources":["../../../src/screenplay/models/HTTPRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,aAAa,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC/G,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAEhD;;;;;GAKG;AACH,8BAAsB,WAAY,SAAQ,QAAQ,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAcvE,SAAS,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,UAAU,CAAC,MAAM,CAAC;IACnD,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,UAAU,CAAC,GAAG,CAAC;IACzC,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC,wBAAwB,CAAC,kBAAkB,CAAC,CAAC;IAdxF;;;;;;;;;;OAUG;IACH,SAAS,aACc,WAAW,CAAC,EAAE,UAAU,CAAC,MAAM,CAAC,EAChC,IAAI,CAAC,EAAE,UAAU,CAAC,GAAG,CAAC,EACtB,MAAM,CAAC,EAAE,UAAU,CAAC,wBAAwB,CAAC,kBAAkB,CAAC,CAAC;IAKxF;;OAEG;IACH,UAAU,CAAC,KAAK,EAAE,gBAAgB,GAAG,aAAa,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA0BhF;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,cAAc;IAI7B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,kBAAkB;CAOpC"}
|
|
@@ -13,7 +13,6 @@ class HTTPRequest extends core_1.Question {
|
|
|
13
13
|
resourceUri;
|
|
14
14
|
data;
|
|
15
15
|
config;
|
|
16
|
-
subject;
|
|
17
16
|
/**
|
|
18
17
|
* @param [resourceUri]
|
|
19
18
|
* URL to which the request should be sent
|
|
@@ -26,11 +25,10 @@ class HTTPRequest extends core_1.Question {
|
|
|
26
25
|
* provided when the {@apilink Ability|ability} to {@apilink CallAnApi} is instantiated
|
|
27
26
|
*/
|
|
28
27
|
constructor(resourceUri, data, config) {
|
|
29
|
-
super();
|
|
28
|
+
super(`${HTTPRequest.requestDescription(new.target.name)} to ${(0, io_1.d) `${resourceUri}`}`);
|
|
30
29
|
this.resourceUri = resourceUri;
|
|
31
30
|
this.data = data;
|
|
32
31
|
this.config = config;
|
|
33
|
-
this.subject = `${this.requestDescription()} to ${(0, io_1.d) `${this.resourceUri}`}`;
|
|
34
32
|
}
|
|
35
33
|
/**
|
|
36
34
|
* @inheritDoc
|
|
@@ -41,7 +39,7 @@ class HTTPRequest extends core_1.Question {
|
|
|
41
39
|
this.config ? actor.answer(this.config) : Promise.resolve({}),
|
|
42
40
|
this.data ? actor.answer(this.data) : Promise.resolve(void 0),
|
|
43
41
|
]).
|
|
44
|
-
then(([url, config, data]) => Object.assign({}, { url, data }, config, { method:
|
|
42
|
+
then(([url, config, data]) => Object.assign({}, { url, data }, config, { method: HTTPRequest.httpMethodName(this.constructor.name) })).
|
|
45
43
|
then(config =>
|
|
46
44
|
// eslint-disable-next-line unicorn/prefer-object-from-entries
|
|
47
45
|
Object.keys(config).reduce((acc, key) => {
|
|
@@ -51,31 +49,18 @@ class HTTPRequest extends core_1.Question {
|
|
|
51
49
|
return acc;
|
|
52
50
|
}, {}));
|
|
53
51
|
}
|
|
54
|
-
/**
|
|
55
|
-
* @inheritDoc
|
|
56
|
-
*/
|
|
57
|
-
describedAs(subject) {
|
|
58
|
-
this.subject = subject;
|
|
59
|
-
return this;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* @inheritDoc
|
|
63
|
-
*/
|
|
64
|
-
toString() {
|
|
65
|
-
return this.subject;
|
|
66
|
-
}
|
|
67
52
|
/**
|
|
68
53
|
* Determines the request method based on the name of the request class.
|
|
69
54
|
* For example: GetRequest => GET, PostRequest => POST, etc.
|
|
70
55
|
*/
|
|
71
|
-
httpMethodName() {
|
|
72
|
-
return
|
|
56
|
+
static httpMethodName(className) {
|
|
57
|
+
return className.replace(/Request/, '').toUpperCase();
|
|
73
58
|
}
|
|
74
59
|
/**
|
|
75
60
|
* A human-readable description of the request, such as "a GET request", "an OPTIONS request", etc.
|
|
76
61
|
*/
|
|
77
|
-
requestDescription() {
|
|
78
|
-
const vowels = ['A', 'E', 'I', 'O', 'U'], method =
|
|
62
|
+
static requestDescription(className) {
|
|
63
|
+
const vowels = ['A', 'E', 'I', 'O', 'U'], method = HTTPRequest.httpMethodName(className);
|
|
79
64
|
return `${~vowels.indexOf(method[0]) ? 'an' : 'a'} ${method} request`;
|
|
80
65
|
}
|
|
81
66
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HTTPRequest.js","sourceRoot":"","sources":["../../../src/screenplay/models/HTTPRequest.ts"],"names":[],"mappings":";;;AACA,4CAA6C;AAC7C,iDAA6C;AAG7C;;;;;GAKG;AACH,MAAsB,WAAY,SAAQ,eAAqC;
|
|
1
|
+
{"version":3,"file":"HTTPRequest.js","sourceRoot":"","sources":["../../../src/screenplay/models/HTTPRequest.ts"],"names":[],"mappings":";;;AACA,4CAA6C;AAC7C,iDAA6C;AAG7C;;;;;GAKG;AACH,MAAsB,WAAY,SAAQ,eAAqC;IAcpD;IACA;IACA;IAdvB;;;;;;;;;;OAUG;IACH,YACuB,WAAgC,EAChC,IAAsB,EACtB,MAAiE;QAEpF,KAAK,CAAC,GAAI,WAAW,CAAC,kBAAkB,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAE,OAAQ,IAAA,MAAC,EAAA,GAAI,WAAY,EAAG,EAAE,CAAC,CAAC;QAJvE,gBAAW,GAAX,WAAW,CAAqB;QAChC,SAAI,GAAJ,IAAI,CAAkB;QACtB,WAAM,GAAN,MAAM,CAA2D;IAGxF,CAAC;IAED;;OAEG;IACH,UAAU,CAAC,KAAuC;QAC9C,OAAO,OAAO,CA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AC,CAAC,WAAW,EAAE,CAAC;IAC1D,CAAC;IAED;;OAEG;IACK,MAAM,CAAC,kBAAkB,CAAC,SAAiB;QAC/C,MACI,MAAM,GAAG,CAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAE,EACpC,MAAM,GAAG,WAAW,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;QAEnD,OAAO,GAAI,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAI,IAAK,MAAO,UAAU,CAAC;IAC9E,CAAC;CACJ;AApED,kCAoEC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@serenity-js/rest",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.24.0",
|
|
4
4
|
"description": "Test REST APIs with Serenity/JS",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Jan Molak",
|
|
@@ -46,9 +46,9 @@
|
|
|
46
46
|
"node": "^16.13 || ^18.12 || ^20"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@serenity-js/core": "3.
|
|
49
|
+
"@serenity-js/core": "3.24.0",
|
|
50
50
|
"agent-base": "7.1.1",
|
|
51
|
-
"axios": "1.7.
|
|
51
|
+
"axios": "1.7.2",
|
|
52
52
|
"http-proxy-agent": "7.0.2",
|
|
53
53
|
"https-proxy-agent": "7.0.4",
|
|
54
54
|
"lru-cache": "10.2.2",
|
|
@@ -57,15 +57,15 @@
|
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@integration/testing-tools": "3.0.0",
|
|
60
|
-
"@serenity-js/assertions": "3.
|
|
60
|
+
"@serenity-js/assertions": "3.24.0",
|
|
61
61
|
"@types/chai": "4.3.16",
|
|
62
62
|
"@types/mocha": "10.0.6",
|
|
63
63
|
"axios-mock-adapter": "1.22.0",
|
|
64
|
-
"c8": "
|
|
64
|
+
"c8": "10.1.2",
|
|
65
65
|
"mocha": "10.4.0",
|
|
66
66
|
"mocha-multi": "1.1.7",
|
|
67
67
|
"ts-node": "10.9.2",
|
|
68
68
|
"typescript": "5.2.2"
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "174876f2ab2b96bce79ac825ba8c784beae2f63c"
|
|
71
71
|
}
|
|
@@ -11,8 +11,6 @@ import type { AxiosRequestConfig } from 'axios';
|
|
|
11
11
|
*/
|
|
12
12
|
export abstract class HTTPRequest extends Question<Promise<AxiosRequestConfig>> {
|
|
13
13
|
|
|
14
|
-
private subject: string;
|
|
15
|
-
|
|
16
14
|
/**
|
|
17
15
|
* @param [resourceUri]
|
|
18
16
|
* URL to which the request should be sent
|
|
@@ -29,8 +27,7 @@ export abstract class HTTPRequest extends Question<Promise<AxiosRequestConfig>>
|
|
|
29
27
|
protected readonly data?: Answerable<any>,
|
|
30
28
|
protected readonly config?: Answerable<WithAnswerableProperties<AxiosRequestConfig>>,
|
|
31
29
|
) {
|
|
32
|
-
super();
|
|
33
|
-
this.subject = `${ this.requestDescription() } to ${ d`${ this.resourceUri }` }`;
|
|
30
|
+
super(`${ HTTPRequest.requestDescription(new.target.name) } to ${ d`${ resourceUri }` }`);
|
|
34
31
|
}
|
|
35
32
|
|
|
36
33
|
/**
|
|
@@ -48,7 +45,7 @@ export abstract class HTTPRequest extends Question<Promise<AxiosRequestConfig>>
|
|
|
48
45
|
{},
|
|
49
46
|
{ url, data },
|
|
50
47
|
config,
|
|
51
|
-
{ method:
|
|
48
|
+
{ method: HTTPRequest.httpMethodName(this.constructor.name) },
|
|
52
49
|
),
|
|
53
50
|
).
|
|
54
51
|
then(config =>
|
|
@@ -62,36 +59,21 @@ export abstract class HTTPRequest extends Question<Promise<AxiosRequestConfig>>
|
|
|
62
59
|
);
|
|
63
60
|
}
|
|
64
61
|
|
|
65
|
-
/**
|
|
66
|
-
* @inheritDoc
|
|
67
|
-
*/
|
|
68
|
-
describedAs(subject: string): this {
|
|
69
|
-
this.subject = subject;
|
|
70
|
-
return this;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* @inheritDoc
|
|
75
|
-
*/
|
|
76
|
-
toString(): string {
|
|
77
|
-
return this.subject;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
62
|
/**
|
|
81
63
|
* Determines the request method based on the name of the request class.
|
|
82
64
|
* For example: GetRequest => GET, PostRequest => POST, etc.
|
|
83
65
|
*/
|
|
84
|
-
private httpMethodName(): string {
|
|
85
|
-
return
|
|
66
|
+
private static httpMethodName(className: string): string {
|
|
67
|
+
return className.replace(/Request/, '').toUpperCase();
|
|
86
68
|
}
|
|
87
69
|
|
|
88
70
|
/**
|
|
89
71
|
* A human-readable description of the request, such as "a GET request", "an OPTIONS request", etc.
|
|
90
72
|
*/
|
|
91
|
-
private requestDescription(): string {
|
|
73
|
+
private static requestDescription(className: string): string {
|
|
92
74
|
const
|
|
93
75
|
vowels = [ 'A', 'E', 'I', 'O', 'U' ],
|
|
94
|
-
method =
|
|
76
|
+
method = HTTPRequest.httpMethodName(className);
|
|
95
77
|
|
|
96
78
|
return `${ ~vowels.indexOf(method[0]) ? 'an' : 'a' } ${ method } request`;
|
|
97
79
|
}
|