Moved common functions to testUtils

This commit is contained in:
Jose Olarte III
2024-08-28 19:12:59 +08:00
parent 2e2705eae8
commit 4228d3c390
3 changed files with 35 additions and 53 deletions

View File

@@ -1,23 +1,5 @@
import { test, expect } from '@playwright/test';
import { importUser } from './testUtils';
// Function to generate a random string of specified length
function generateRandomString(length) {
return Math.random().toString(36).substring(2, 2 + length);
}
// Function to create an array of unique strings
function createUniqueStringsArray(count) {
const stringsArray = [];
const stringLength = 16;
for (let i = 0; i < count; i++) {
let randomString = generateRandomString(stringLength);
stringsArray.push(randomString);
}
return stringsArray;
}
import { importUser, createUniqueStringsArray } from './testUtils';
test('Create 10 new projects', async ({ page }) => {
test.slow(); // Extend the test timeout
@@ -32,7 +14,7 @@ test('Create 10 new projects', async ({ page }) => {
const finalDescriptions = [];
// Create an array of unique strings
const uniqueStrings = createUniqueStringsArray(projectCount);
const uniqueStrings = await createUniqueStringsArray(projectCount);
// Populate arrays with titles and descriptions
for (let i = 0; i < projectCount; i++) {