apify-test-tools 0.2.3 → 0.3.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/lib/lib.ts CHANGED
@@ -173,6 +173,10 @@ interface StandbyTask {
173
173
  taskId: string;
174
174
  }
175
175
 
176
+ const randomInt = (min: number, max: number) => {
177
+ return Math.floor(Math.random() * (max - min + 1)) + min;
178
+ }
179
+
176
180
  /**
177
181
  * Creates a task with specific `build` - either `buildNumber` or default.
178
182
  *
@@ -202,11 +206,15 @@ const createStandbyTask = async (actorNameOrId: string, buildNumber?: string): P
202
206
  }
203
207
 
204
208
  try {
209
+ const title = `Test task - ${build}:${actorNameOrId}`.slice(0, 62);
210
+ // we try to create unique task name containing only `a-z0-9-` characters and at most 63 characters long
211
+ const name = `${randomInt(1, 1_000_000)}${title.toLowerCase().replaceAll(/\s+/g, '').replaceAll(/[^a-z0-9-]+/g, '-')}`.slice(0, 62);
205
212
  const newTask = await apifyClient.tasks().create({
206
213
  actId: actorNameOrId,
207
214
  actorStandby: actorStandbyOptions,
208
215
  description: `Task for testing standby version ${build}`,
209
- title: `Test task - ${build}`,
216
+ title,
217
+ name,
210
218
  }) as Task & { standbyUrl?: string };
211
219
 
212
220
  const { id, standbyUrl } = newTask;
@@ -262,6 +270,7 @@ const createStartRunFn = <T>(actorNameOrId: string, testContext: TestContext) =>
262
270
  task.meta = {
263
271
  runId: run.id,
264
272
  runLink,
273
+ actorName: actorNameOrId,
265
274
  };
266
275
 
267
276
  // waiting for datasetItemCount and chargedEventCounts to sync
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apify-test-tools",
3
- "version": "0.2.3",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
5
  "description": "TBD",
6
6
  "engines": {