artes 1.1.47 → 1.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "artes",
3
- "version": "1.1.47",
3
+ "version": "1.1.48",
4
4
  "description": "The simplest way to automate UI and API tests using Cucumber-style steps.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,4 +1,4 @@
1
- const { Given, context, random } = require("../helper/imports/commons");
1
+ const { Given, context, random, time } = require("../helper/imports/commons");
2
2
  const { api } = require("../helper/stepFunctions/exporter");
3
3
 
4
4
  Given("User sets random word as {string}", async (key) => {
@@ -16,8 +16,8 @@ Given(
16
16
 
17
17
  Given(
18
18
  "User sets random word that has character between {int} and {int} as {string}",
19
- async (key, from, to) => {
20
- const word = random.lorem.word({ length: { min: from, max: to } });
19
+ async (from, to, key) => {
20
+ const word = random.lorem.word({ min: from, max: to });
21
21
  context.vars[key] = word;
22
22
  },
23
23
  );
@@ -37,12 +37,17 @@ Given(
37
37
 
38
38
  Given(
39
39
  "User sets random words that range between {int} and {int} as {string}",
40
- async (key, from, to) => {
40
+ async (from, to, key) => {
41
41
  const words = random.lorem.words({ min: from, max: to });
42
42
  context.vars[key] = words;
43
43
  },
44
44
  );
45
45
 
46
+ Given('User sets random number as {string}', async (key) => {
47
+ const randomNumber = random.number.int();
48
+ context.vars[key] = randomNumber;
49
+ });
50
+
46
51
  Given(
47
52
  "User sets random number from {int} to {int} as {string}",
48
53
  async (from, to, key) => {
@@ -86,4 +91,69 @@ Given("User sets random value from given {string} array as {string}", async (arr
86
91
  const parsedArray = JSON.parse(array.replace(/'/g, '"'));
87
92
  const randomValue = parsedArray[Math.floor(Math.random() * parsedArray.length)];
88
93
  context.vars[key] = randomValue;
89
- });
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
+ })