artes 1.0.47 → 1.0.48
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/index.js +5 -3
- package/package.json +1 -1
- package/src/helper/imports/commons.js +1 -1
- package/src/helper/pomController/elementController.js +5 -5
- package/src/helper/stepFunctions/APIActions.js +1 -1
- package/src/stepDefinitions/API.steps.js +1 -4
- package/src/stepDefinitions/assertions.steps.js +10 -0
- package/src/stepDefinitions/random.steps.js +18 -17
package/index.js
CHANGED
|
@@ -6,10 +6,11 @@ const {
|
|
|
6
6
|
context,
|
|
7
7
|
element,
|
|
8
8
|
selector,
|
|
9
|
-
saveVar,
|
|
9
|
+
saveVar,
|
|
10
|
+
extractVarsFromResponse,
|
|
10
11
|
page,
|
|
11
12
|
request,
|
|
12
|
-
random
|
|
13
|
+
random,
|
|
13
14
|
} = require("./src/helper/imports/commons");
|
|
14
15
|
const {
|
|
15
16
|
keyboard,
|
|
@@ -26,7 +27,8 @@ module.exports = {
|
|
|
26
27
|
Then,
|
|
27
28
|
element,
|
|
28
29
|
selector,
|
|
29
|
-
saveVar,
|
|
30
|
+
saveVar,
|
|
31
|
+
extractVarsFromResponse,
|
|
30
32
|
context,
|
|
31
33
|
random,
|
|
32
34
|
page,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "artes",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.48",
|
|
4
4
|
"description": "The package provide step definitions and user writes feature files, and the package handles automation, with optional POM files and custom step definitions.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -7,7 +7,7 @@ const {
|
|
|
7
7
|
saveVar,
|
|
8
8
|
resolveVariable,
|
|
9
9
|
} = require("../pomController/elementController");
|
|
10
|
-
const { faker } = require(
|
|
10
|
+
const { faker } = require("@faker-js/faker");
|
|
11
11
|
const { context } = require("../../hooks/context");
|
|
12
12
|
|
|
13
13
|
const element = getElement;
|
|
@@ -87,11 +87,11 @@ class Elements {
|
|
|
87
87
|
|
|
88
88
|
static extractVarsFromResponse(vars, customVarName) {
|
|
89
89
|
const responseBody = context.response.responseBody;
|
|
90
|
-
|
|
90
|
+
|
|
91
91
|
function getValueByPath(obj, path) {
|
|
92
92
|
const keys = path.split(".");
|
|
93
93
|
let current = obj;
|
|
94
|
-
|
|
94
|
+
|
|
95
95
|
for (const key of keys) {
|
|
96
96
|
if (current && typeof current === "object" && key in current) {
|
|
97
97
|
current = current[key];
|
|
@@ -99,15 +99,15 @@ class Elements {
|
|
|
99
99
|
return undefined;
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
|
-
|
|
102
|
+
|
|
103
103
|
return current;
|
|
104
104
|
}
|
|
105
|
-
|
|
105
|
+
|
|
106
106
|
vars.split(",").forEach((v) => {
|
|
107
107
|
const path = v.trim();
|
|
108
108
|
const value = getValueByPath(responseBody, path);
|
|
109
109
|
if (value !== undefined) {
|
|
110
|
-
saveVar(value, customVarName, path);
|
|
110
|
+
this.saveVar(value, customVarName, path);
|
|
111
111
|
}
|
|
112
112
|
});
|
|
113
113
|
}
|
|
@@ -4,13 +4,11 @@ const {
|
|
|
4
4
|
expect,
|
|
5
5
|
selector,
|
|
6
6
|
extractVarsFromResponse,
|
|
7
|
-
saveVar
|
|
7
|
+
saveVar,
|
|
8
8
|
} = require("../helper/imports/commons");
|
|
9
9
|
const { api } = require("../helper/stepFunctions/exporter");
|
|
10
10
|
const Ajv = require("ajv");
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
12
|
When("User sends GET request to {string}", async function (url) {
|
|
15
13
|
await api.get(url);
|
|
16
14
|
});
|
|
@@ -130,7 +128,6 @@ When(
|
|
|
130
128
|
|
|
131
129
|
When("User wants to see saved variables", async function () {
|
|
132
130
|
console.log("\nVariables:", api.vars(), "\n");
|
|
133
|
-
|
|
134
131
|
});
|
|
135
132
|
|
|
136
133
|
When("User wants to see request body", async function () {
|
|
@@ -3,6 +3,7 @@ const {
|
|
|
3
3
|
selector,
|
|
4
4
|
expect,
|
|
5
5
|
element,
|
|
6
|
+
extractVarsFromResponse,
|
|
6
7
|
} = require("../helper/imports/commons");
|
|
7
8
|
const { assert, frame } = require("../helper/stepFunctions/exporter");
|
|
8
9
|
|
|
@@ -813,3 +814,12 @@ Then("User expects should have {int} {string}", async (count, elements) => {
|
|
|
813
814
|
const elementCount = await frame.count(elements);
|
|
814
815
|
expect(elementCount).toEqual(count);
|
|
815
816
|
});
|
|
817
|
+
|
|
818
|
+
Then(
|
|
819
|
+
"User expects that response has {string} field with {string} value",
|
|
820
|
+
async (field, value) => {
|
|
821
|
+
extractVarsFromResponse(field, field);
|
|
822
|
+
|
|
823
|
+
expect(context.vars[field]).toBe(value);
|
|
824
|
+
},
|
|
825
|
+
);
|
|
@@ -1,24 +1,25 @@
|
|
|
1
|
-
const { Given, context, random
|
|
1
|
+
const { Given, context, random } = require("../helper/imports/commons");
|
|
2
2
|
|
|
3
3
|
Given("User sets random words as {string} variable", async (key) => {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
const words = random.lorem.words({ min: 2, max: 5 });
|
|
5
|
+
context.vars[key] = words;
|
|
6
6
|
});
|
|
7
7
|
|
|
8
|
-
Given(
|
|
9
|
-
|
|
8
|
+
Given(
|
|
9
|
+
"User sets random number from {int} to {int} as {string} variable",
|
|
10
|
+
async (from, to, key) => {
|
|
11
|
+
const number = random.number.int({ min: from, max: to });
|
|
10
12
|
context.vars[key] = number;
|
|
11
|
-
}
|
|
13
|
+
},
|
|
14
|
+
);
|
|
12
15
|
|
|
13
|
-
Given(
|
|
14
|
-
|
|
16
|
+
Given(
|
|
17
|
+
"User sends GET request to {string} and save {string} variable as a {string} randomly",
|
|
18
|
+
async (api, varName, variableKey) => {
|
|
19
|
+
const res = await fetch(api);
|
|
15
20
|
const body = await res.json();
|
|
16
|
-
const randomContent =
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
extractVarsFromResponse(field, field);
|
|
22
|
-
|
|
23
|
-
expect(context.vars[field]).toBe(value);
|
|
24
|
-
})
|
|
21
|
+
const randomContent =
|
|
22
|
+
body.content[random.number.int({ min: 0, max: body.content.length - 1 })];
|
|
23
|
+
context.vars[variableKey] = randomContent[varName];
|
|
24
|
+
},
|
|
25
|
+
);
|