|
@ -1,26 +1,7 @@ |
|
|
import { test, expect } from '@playwright/test'; |
|
|
import { test, expect } from '@playwright/test'; |
|
|
import { importUser } from './testUtils'; |
|
|
import { importUser, createUniqueStringsArray } 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; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
test('Create 10 new projects', async ({ page }) => { |
|
|
test('Create 10 new projects', async ({ page }) => { |
|
|
test.slow(); // Extend the test timeout
|
|
|
|
|
|
const projectCount = 10; |
|
|
const projectCount = 10; |
|
|
|
|
|
|
|
|
// Standard texts
|
|
|
// Standard texts
|
|
@ -32,7 +13,7 @@ test('Create 10 new projects', async ({ page }) => { |
|
|
const finalDescriptions = []; |
|
|
const finalDescriptions = []; |
|
|
|
|
|
|
|
|
// Create an array of unique strings
|
|
|
// Create an array of unique strings
|
|
|
const uniqueStrings = createUniqueStringsArray(projectCount); |
|
|
const uniqueStrings = await createUniqueStringsArray(projectCount); |
|
|
|
|
|
|
|
|
// Populate arrays with titles and descriptions
|
|
|
// Populate arrays with titles and descriptions
|
|
|
for (let i = 0; i < projectCount; i++) { |
|
|
for (let i = 0; i < projectCount; i++) { |
|
@ -45,9 +26,6 @@ test('Create 10 new projects', async ({ page }) => { |
|
|
// Import user 00
|
|
|
// Import user 00
|
|
|
await importUser(page, '00'); |
|
|
await importUser(page, '00'); |
|
|
|
|
|
|
|
|
// Pause a bit
|
|
|
|
|
|
await page.waitForTimeout(3000); // I have to wait, otherwise the (+) button to add a new project doesn't appear
|
|
|
|
|
|
|
|
|
|
|
|
// Create new projects
|
|
|
// Create new projects
|
|
|
for (let i = 0; i < projectCount; i++) { |
|
|
for (let i = 0; i < projectCount; i++) { |
|
|
await page.goto('./projects'); |
|
|
await page.goto('./projects'); |
|
@ -59,7 +37,6 @@ test('Create 10 new projects', async ({ page }) => { |
|
|
await page.getByPlaceholder('Start Date').fill('2025-12-01'); |
|
|
await page.getByPlaceholder('Start Date').fill('2025-12-01'); |
|
|
await page.getByPlaceholder('Start Time').fill('12:00'); |
|
|
await page.getByPlaceholder('Start Time').fill('12:00'); |
|
|
await page.getByRole('button', { name: 'Save Project' }).click(); |
|
|
await page.getByRole('button', { name: 'Save Project' }).click(); |
|
|
await page.waitForTimeout(1000); // Compensate for delay in loading Idea Name heading
|
|
|
|
|
|
|
|
|
|
|
|
// Check texts
|
|
|
// Check texts
|
|
|
await expect(page.locator('h2')).toContainText(finalTitles[i]); |
|
|
await expect(page.locator('h2')).toContainText(finalTitles[i]); |
|
|