artes 1.2.17 → 1.2.18
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/README.md +629 -629
- package/cucumber.config.js +171 -171
- package/docs/functionDefinitions.md +2401 -2401
- package/docs/stepDefinitions.md +391 -391
- package/executer.js +161 -161
- package/index.js +48 -48
- package/package.json +52 -51
- package/src/helper/contextManager/browserManager.js +63 -63
- package/src/helper/contextManager/requestManager.js +23 -23
- package/src/helper/controller/elementController.js +182 -182
- package/src/helper/controller/pomCollector.js +25 -25
- package/src/helper/executers/cleaner.js +19 -19
- package/src/helper/executers/exporter.js +15 -15
- package/src/helper/executers/helper.js +95 -95
- package/src/helper/executers/projectCreator.js +198 -198
- package/src/helper/executers/reportGenerator.js +58 -58
- package/src/helper/executers/testRunner.js +30 -30
- package/src/helper/executers/versionChecker.js +31 -31
- package/src/helper/imports/commons.js +56 -56
- package/src/helper/stepFunctions/APIActions.js +362 -362
- package/src/helper/stepFunctions/assertions.js +523 -523
- package/src/helper/stepFunctions/browserActions.js +22 -22
- package/src/helper/stepFunctions/elementInteractions.js +38 -38
- package/src/helper/stepFunctions/exporter.js +19 -19
- package/src/helper/stepFunctions/frameActions.js +50 -50
- package/src/helper/stepFunctions/keyboardActions.js +41 -41
- package/src/helper/stepFunctions/mouseActions.js +145 -145
- package/src/helper/stepFunctions/pageActions.js +27 -27
- package/src/hooks/context.js +15 -15
- package/src/hooks/hooks.js +257 -257
- package/src/stepDefinitions/API.steps.js +299 -299
- package/src/stepDefinitions/assertions.steps.js +861 -861
- package/src/stepDefinitions/browser.steps.js +7 -7
- package/src/stepDefinitions/frameActions.steps.js +76 -76
- package/src/stepDefinitions/keyboardActions.steps.js +226 -226
- package/src/stepDefinitions/mouseActions.steps.js +275 -275
- package/src/stepDefinitions/page.steps.js +71 -71
- package/src/stepDefinitions/random.steps.js +158 -158
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
const { When, context, selector } = require("../helper/imports/commons");
|
|
2
|
-
const { page, assert, mouse } = require("../helper/stepFunctions/exporter");
|
|
3
|
-
|
|
4
|
-
When("User navigates to {string} page", async function (url) {
|
|
5
|
-
const URL = await selector(url);
|
|
6
|
-
await page.navigateTo(URL);
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
When("User is on {string} page", async function (url) {
|
|
10
|
-
const URL = await selector(url);
|
|
11
|
-
await assert.shouldPageHaveURL(URL);
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
When("User navigates previous page", async function () {
|
|
15
|
-
await page.navigateBack();
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
When("User navigates next page", async function () {
|
|
19
|
-
await page.navigateForward();
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
When("User gets URL of page", async function () {
|
|
23
|
-
await page.getURL();
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
When("User reloads the page", async function () {
|
|
27
|
-
await page.reload();
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
When(`User waits {int} seconds`, async (sec) => {
|
|
31
|
-
await page.wait(sec * 1000);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
When(`User waits {int} milliseconds`, async (sec) => {
|
|
35
|
-
await page.wait(sec);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
When(`User waits {int} minutes`, async (sec) => {
|
|
39
|
-
await page.wait(sec * 1000 * 60);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
When("User clicks {string} and confirms alert", async (button) => {
|
|
43
|
-
context.page.on("dialog", async (dialog) => {
|
|
44
|
-
await dialog.accept();
|
|
45
|
-
});
|
|
46
|
-
await mouse.click(button);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
When("User clicks {string} and confirms popup", async (button) => {
|
|
50
|
-
context.page.on("dialog", async (dialog) => {
|
|
51
|
-
await dialog.accept();
|
|
52
|
-
});
|
|
53
|
-
await mouse.click(button);
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
When("User clicks {string} and dismisses popup", async (button) => {
|
|
57
|
-
context.page.on("dialog", async (dialog) => {
|
|
58
|
-
await dialog.dismiss();
|
|
59
|
-
});
|
|
60
|
-
await mouse.click(button);
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
When(
|
|
64
|
-
"User clicks {string} and types {string} in prompt",
|
|
65
|
-
async (button, prompt) => {
|
|
66
|
-
context.page.on("dialog", async (dialog) => {
|
|
67
|
-
await dialog.accept(prompt);
|
|
68
|
-
});
|
|
69
|
-
await mouse.click(button);
|
|
70
|
-
},
|
|
71
|
-
);
|
|
1
|
+
const { When, context, selector } = require("../helper/imports/commons");
|
|
2
|
+
const { page, assert, mouse } = require("../helper/stepFunctions/exporter");
|
|
3
|
+
|
|
4
|
+
When("User navigates to {string} page", async function (url) {
|
|
5
|
+
const URL = await selector(url);
|
|
6
|
+
await page.navigateTo(URL);
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
When("User is on {string} page", async function (url) {
|
|
10
|
+
const URL = await selector(url);
|
|
11
|
+
await assert.shouldPageHaveURL(URL);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
When("User navigates previous page", async function () {
|
|
15
|
+
await page.navigateBack();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
When("User navigates next page", async function () {
|
|
19
|
+
await page.navigateForward();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
When("User gets URL of page", async function () {
|
|
23
|
+
await page.getURL();
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
When("User reloads the page", async function () {
|
|
27
|
+
await page.reload();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
When(`User waits {int} seconds`, async (sec) => {
|
|
31
|
+
await page.wait(sec * 1000);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
When(`User waits {int} milliseconds`, async (sec) => {
|
|
35
|
+
await page.wait(sec);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
When(`User waits {int} minutes`, async (sec) => {
|
|
39
|
+
await page.wait(sec * 1000 * 60);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
When("User clicks {string} and confirms alert", async (button) => {
|
|
43
|
+
context.page.on("dialog", async (dialog) => {
|
|
44
|
+
await dialog.accept();
|
|
45
|
+
});
|
|
46
|
+
await mouse.click(button);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
When("User clicks {string} and confirms popup", async (button) => {
|
|
50
|
+
context.page.on("dialog", async (dialog) => {
|
|
51
|
+
await dialog.accept();
|
|
52
|
+
});
|
|
53
|
+
await mouse.click(button);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
When("User clicks {string} and dismisses popup", async (button) => {
|
|
57
|
+
context.page.on("dialog", async (dialog) => {
|
|
58
|
+
await dialog.dismiss();
|
|
59
|
+
});
|
|
60
|
+
await mouse.click(button);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
When(
|
|
64
|
+
"User clicks {string} and types {string} in prompt",
|
|
65
|
+
async (button, prompt) => {
|
|
66
|
+
context.page.on("dialog", async (dialog) => {
|
|
67
|
+
await dialog.accept(prompt);
|
|
68
|
+
});
|
|
69
|
+
await mouse.click(button);
|
|
70
|
+
},
|
|
71
|
+
);
|
|
@@ -1,159 +1,159 @@
|
|
|
1
|
-
const { Given, context, random, time } = require("../helper/imports/commons");
|
|
2
|
-
const { api } = require("../helper/stepFunctions/exporter");
|
|
3
|
-
|
|
4
|
-
Given("User sets random word as {string}", async (key) => {
|
|
5
|
-
const word = random.lorem.word();
|
|
6
|
-
context.vars[key] = word;
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
Given(
|
|
10
|
-
"User sets random word that has {int} character as {string}",
|
|
11
|
-
async (key, count) => {
|
|
12
|
-
const word = random.lorem.word(count);
|
|
13
|
-
context.vars[key] = word;
|
|
14
|
-
},
|
|
15
|
-
);
|
|
16
|
-
|
|
17
|
-
Given(
|
|
18
|
-
"User sets random word that has character between {int} and {int} as {string}",
|
|
19
|
-
async (from, to, key) => {
|
|
20
|
-
const word = random.lorem.word({ min: from, max: to });
|
|
21
|
-
context.vars[key] = word;
|
|
22
|
-
},
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
Given("User sets random words as {string}", async (key) => {
|
|
26
|
-
const words = random.lorem.words();
|
|
27
|
-
context.vars[key] = words;
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
Given(
|
|
31
|
-
"User sets random {int} words as {string}",
|
|
32
|
-
async (key, count) => {
|
|
33
|
-
const words = random.lorem.words({ wordCount: count });
|
|
34
|
-
context.vars[key] = words;
|
|
35
|
-
},
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
Given(
|
|
39
|
-
"User sets random words that range between {int} and {int} as {string}",
|
|
40
|
-
async (from, to, key) => {
|
|
41
|
-
const words = random.lorem.words({ min: from, max: to });
|
|
42
|
-
context.vars[key] = words;
|
|
43
|
-
},
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
Given('User sets random number as {string}', async (key) => {
|
|
47
|
-
const randomNumber = random.number.int();
|
|
48
|
-
context.vars[key] = randomNumber;
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
Given(
|
|
52
|
-
"User sets random number from {int} to {int} as {string}",
|
|
53
|
-
async (from, to, key) => {
|
|
54
|
-
const number = random.number.int({ min: from, max: to });
|
|
55
|
-
context.vars[key] = number;
|
|
56
|
-
},
|
|
57
|
-
);
|
|
58
|
-
|
|
59
|
-
Given(
|
|
60
|
-
"User sends GET request to {string} and save {string} variable from {string} array as {string} randomly",
|
|
61
|
-
async (endPoint, varName, fromArray, variableKey) => {
|
|
62
|
-
await api.get(endPoint);
|
|
63
|
-
let responseBody;
|
|
64
|
-
if (fromArray == "[]") {
|
|
65
|
-
responseBody = await context.response["Response Body"];
|
|
66
|
-
} else {
|
|
67
|
-
responseBody = await context.response["Response Body"][fromArray];
|
|
68
|
-
}
|
|
69
|
-
const randomContent =
|
|
70
|
-
responseBody[random.number.int({ min: 0, max: responseBody.length - 1 })];
|
|
71
|
-
context.vars[variableKey] = randomContent[varName];
|
|
72
|
-
},
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
Given("User sets random email as {string}", (key) => {
|
|
76
|
-
const email = random.internet.email();
|
|
77
|
-
context.vars[key] = email;
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
Given('User sets random url as {string}', (urlName) => {
|
|
81
|
-
const randomUrl = random.internet.url();
|
|
82
|
-
context.vars[urlName] = randomUrl;
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
Given('User sets random sentences that has {int} paragraph as {string}', (count, variable) => {
|
|
86
|
-
const sentences = random.lorem.paragraph(count);
|
|
87
|
-
context.vars[variable] = sentences;
|
|
88
|
-
})
|
|
89
|
-
|
|
90
|
-
Given("User sets random value from given {string} array as {string}", async (array, key) => {
|
|
91
|
-
const parsedArray = JSON.parse(array.replace(/'/g, '"'));
|
|
92
|
-
const randomValue = parsedArray[Math.floor(Math.random() * parsedArray.length)];
|
|
93
|
-
context.vars[key] = randomValue;
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
Given('User sets random paragraph as {string}', async (key) => {
|
|
97
|
-
const randomParagraph = random.lorem.paragraph();
|
|
98
|
-
context.vars[key] = randomParagraph;
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
Given(
|
|
102
|
-
"User sets random paragraph that range between {int} and {int} as {string}",
|
|
103
|
-
async (from, to, key) => {
|
|
104
|
-
const words = random.lorem.paragraph({ min: from, max: to });
|
|
105
|
-
context.vars[key] = words;
|
|
106
|
-
},
|
|
107
|
-
);
|
|
108
|
-
|
|
109
|
-
Given('User sets random characters from {string} as {string}', async (chars, key) => {
|
|
110
|
-
const randomCharacters = random.string.fromCharacters(chars,10);
|
|
111
|
-
context.vars[key] = randomCharacters;
|
|
112
|
-
})
|
|
113
|
-
|
|
114
|
-
Given('User sets random alphanumeric in range from {int} to {int} as {string}', async (from,to, key) => {
|
|
115
|
-
const randomWords = await random.string.alphanumeric({ min: from, max: to })
|
|
116
|
-
context.vars[key] = randomWords;
|
|
117
|
-
})
|
|
118
|
-
|
|
119
|
-
Given('User sets random fullname as {string}', async (key) => {
|
|
120
|
-
const randomFirstName = await random.person.firstName()
|
|
121
|
-
const randomLastName = await random.person.lastName()
|
|
122
|
-
context.vars[key] = `${randomFirstName} ${randomLastName}`
|
|
123
|
-
})
|
|
124
|
-
|
|
125
|
-
Given('User sets random first name as {string}', async (key) => {
|
|
126
|
-
const randomFirstName = await random.person.firstName()
|
|
127
|
-
context.vars[key] = randomFirstName;
|
|
128
|
-
})
|
|
129
|
-
|
|
130
|
-
Given('User sets random last name as {string}', async (key) => {
|
|
131
|
-
const randomLastName = await random.person.lastName()
|
|
132
|
-
context.vars[key] = randomLastName;
|
|
133
|
-
})
|
|
134
|
-
|
|
135
|
-
Given('User sets random middle name as {string}', async (key) => {
|
|
136
|
-
const randomMiddleName = await random.person.middleName()
|
|
137
|
-
context.vars[key] = randomMiddleName;
|
|
138
|
-
})
|
|
139
|
-
|
|
140
|
-
Given('User sets random date between {int} and {int} as {string}', async (fromYear, toYear, key) => {
|
|
141
|
-
const year = Math.floor(Math.random() * (toYear - fromYear + 1)) + fromYear
|
|
142
|
-
const month = Math.floor(Math.random() * 12) + 1
|
|
143
|
-
const day = Math.floor(Math.random() * 28) + 1
|
|
144
|
-
const pad = (num) => num.toString().padStart(2, '0')
|
|
145
|
-
const dateStr = `${pad(day)}.${pad(month)}.${year}`
|
|
146
|
-
context.vars[key] = dateStr;
|
|
147
|
-
})
|
|
148
|
-
|
|
149
|
-
Given('User sets date {int} days after today as {string}', async (day, key) => {
|
|
150
|
-
const now = new time();
|
|
151
|
-
const afterDate = now.add(day, 'day').format("DD-MM-YYYY");
|
|
152
|
-
context.vars[key] = afterDate;
|
|
153
|
-
})
|
|
154
|
-
|
|
155
|
-
Given('User sets date {int} days before today as {string}', async (day, key) => {
|
|
156
|
-
const now = new time();
|
|
157
|
-
const beforeDate = now.subtract(day, 'day').format("DD-MM-YYYY");
|
|
158
|
-
context.vars[key] = beforeDate;
|
|
1
|
+
const { Given, context, random, time } = require("../helper/imports/commons");
|
|
2
|
+
const { api } = require("../helper/stepFunctions/exporter");
|
|
3
|
+
|
|
4
|
+
Given("User sets random word as {string}", async (key) => {
|
|
5
|
+
const word = random.lorem.word();
|
|
6
|
+
context.vars[key] = word;
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
Given(
|
|
10
|
+
"User sets random word that has {int} character as {string}",
|
|
11
|
+
async (key, count) => {
|
|
12
|
+
const word = random.lorem.word(count);
|
|
13
|
+
context.vars[key] = word;
|
|
14
|
+
},
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
Given(
|
|
18
|
+
"User sets random word that has character between {int} and {int} as {string}",
|
|
19
|
+
async (from, to, key) => {
|
|
20
|
+
const word = random.lorem.word({ min: from, max: to });
|
|
21
|
+
context.vars[key] = word;
|
|
22
|
+
},
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
Given("User sets random words as {string}", async (key) => {
|
|
26
|
+
const words = random.lorem.words();
|
|
27
|
+
context.vars[key] = words;
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
Given(
|
|
31
|
+
"User sets random {int} words as {string}",
|
|
32
|
+
async (key, count) => {
|
|
33
|
+
const words = random.lorem.words({ wordCount: count });
|
|
34
|
+
context.vars[key] = words;
|
|
35
|
+
},
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
Given(
|
|
39
|
+
"User sets random words that range between {int} and {int} as {string}",
|
|
40
|
+
async (from, to, key) => {
|
|
41
|
+
const words = random.lorem.words({ min: from, max: to });
|
|
42
|
+
context.vars[key] = words;
|
|
43
|
+
},
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
Given('User sets random number as {string}', async (key) => {
|
|
47
|
+
const randomNumber = random.number.int();
|
|
48
|
+
context.vars[key] = randomNumber;
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
Given(
|
|
52
|
+
"User sets random number from {int} to {int} as {string}",
|
|
53
|
+
async (from, to, key) => {
|
|
54
|
+
const number = random.number.int({ min: from, max: to });
|
|
55
|
+
context.vars[key] = number;
|
|
56
|
+
},
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
Given(
|
|
60
|
+
"User sends GET request to {string} and save {string} variable from {string} array as {string} randomly",
|
|
61
|
+
async (endPoint, varName, fromArray, variableKey) => {
|
|
62
|
+
await api.get(endPoint);
|
|
63
|
+
let responseBody;
|
|
64
|
+
if (fromArray == "[]") {
|
|
65
|
+
responseBody = await context.response["Response Body"];
|
|
66
|
+
} else {
|
|
67
|
+
responseBody = await context.response["Response Body"][fromArray];
|
|
68
|
+
}
|
|
69
|
+
const randomContent =
|
|
70
|
+
responseBody[random.number.int({ min: 0, max: responseBody.length - 1 })];
|
|
71
|
+
context.vars[variableKey] = randomContent[varName];
|
|
72
|
+
},
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
Given("User sets random email as {string}", (key) => {
|
|
76
|
+
const email = random.internet.email();
|
|
77
|
+
context.vars[key] = email;
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
Given('User sets random url as {string}', (urlName) => {
|
|
81
|
+
const randomUrl = random.internet.url();
|
|
82
|
+
context.vars[urlName] = randomUrl;
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
Given('User sets random sentences that has {int} paragraph as {string}', (count, variable) => {
|
|
86
|
+
const sentences = random.lorem.paragraph(count);
|
|
87
|
+
context.vars[variable] = sentences;
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
Given("User sets random value from given {string} array as {string}", async (array, key) => {
|
|
91
|
+
const parsedArray = JSON.parse(array.replace(/'/g, '"'));
|
|
92
|
+
const randomValue = parsedArray[Math.floor(Math.random() * parsedArray.length)];
|
|
93
|
+
context.vars[key] = randomValue;
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
Given('User sets random paragraph as {string}', async (key) => {
|
|
97
|
+
const randomParagraph = random.lorem.paragraph();
|
|
98
|
+
context.vars[key] = randomParagraph;
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
Given(
|
|
102
|
+
"User sets random paragraph that range between {int} and {int} as {string}",
|
|
103
|
+
async (from, to, key) => {
|
|
104
|
+
const words = random.lorem.paragraph({ min: from, max: to });
|
|
105
|
+
context.vars[key] = words;
|
|
106
|
+
},
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
Given('User sets random characters from {string} as {string}', async (chars, key) => {
|
|
110
|
+
const randomCharacters = random.string.fromCharacters(chars,10);
|
|
111
|
+
context.vars[key] = randomCharacters;
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
Given('User sets random alphanumeric in range from {int} to {int} as {string}', async (from,to, key) => {
|
|
115
|
+
const randomWords = await random.string.alphanumeric({ min: from, max: to })
|
|
116
|
+
context.vars[key] = randomWords;
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
Given('User sets random fullname as {string}', async (key) => {
|
|
120
|
+
const randomFirstName = await random.person.firstName()
|
|
121
|
+
const randomLastName = await random.person.lastName()
|
|
122
|
+
context.vars[key] = `${randomFirstName} ${randomLastName}`
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
Given('User sets random first name as {string}', async (key) => {
|
|
126
|
+
const randomFirstName = await random.person.firstName()
|
|
127
|
+
context.vars[key] = randomFirstName;
|
|
128
|
+
})
|
|
129
|
+
|
|
130
|
+
Given('User sets random last name as {string}', async (key) => {
|
|
131
|
+
const randomLastName = await random.person.lastName()
|
|
132
|
+
context.vars[key] = randomLastName;
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
Given('User sets random middle name as {string}', async (key) => {
|
|
136
|
+
const randomMiddleName = await random.person.middleName()
|
|
137
|
+
context.vars[key] = randomMiddleName;
|
|
138
|
+
})
|
|
139
|
+
|
|
140
|
+
Given('User sets random date between {int} and {int} as {string}', async (fromYear, toYear, key) => {
|
|
141
|
+
const year = Math.floor(Math.random() * (toYear - fromYear + 1)) + fromYear
|
|
142
|
+
const month = Math.floor(Math.random() * 12) + 1
|
|
143
|
+
const day = Math.floor(Math.random() * 28) + 1
|
|
144
|
+
const pad = (num) => num.toString().padStart(2, '0')
|
|
145
|
+
const dateStr = `${pad(day)}.${pad(month)}.${year}`
|
|
146
|
+
context.vars[key] = dateStr;
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
Given('User sets date {int} days after today as {string}', async (day, key) => {
|
|
150
|
+
const now = new time();
|
|
151
|
+
const afterDate = now.add(day, 'day').format("DD-MM-YYYY");
|
|
152
|
+
context.vars[key] = afterDate;
|
|
153
|
+
})
|
|
154
|
+
|
|
155
|
+
Given('User sets date {int} days before today as {string}', async (day, key) => {
|
|
156
|
+
const now = new time();
|
|
157
|
+
const beforeDate = now.subtract(day, 'day').format("DD-MM-YYYY");
|
|
158
|
+
context.vars[key] = beforeDate;
|
|
159
159
|
})
|