Compare commits

...

3 Commits

Author SHA1 Message Date
Jose Olarte III 69473a826f Removed test.slow() 3 months ago
Jose Olarte III 51eb45353e Moved common functions to testUtils 3 months ago
Jose Olarte III b1875b5812 Remove unneeded timeouts 3 months ago
  1. 3
      test-playwright/20-create-project.spec.ts
  2. 27
      test-playwright/25-create-project-x10.spec.ts
  3. 40
      test-playwright/33-record-gift-x10.spec.ts
  4. 30
      test-playwright/testUtils.ts

3
test-playwright/20-create-project.spec.ts

@ -22,9 +22,6 @@ test('Create new project, then search for it', async ({ page }) => {
// Import user 00
await importUser(page, '00');
// Pause for 5 seconds
await page.waitForTimeout(5000); // I have to wait, otherwise the (+) button to add a new project doesn't appear
// Create new project
await page.goto('./projects');
await page.getByRole('link', { name: 'Projects', exact: true }).click();

27
test-playwright/25-create-project-x10.spec.ts

@ -1,26 +1,7 @@
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
const projectCount = 10;
// Standard texts
@ -32,7 +13,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++) {
@ -45,9 +26,6 @@ test('Create 10 new projects', async ({ page }) => {
// Import user 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
for (let i = 0; i < projectCount; i++) {
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 Time').fill('12:00');
await page.getByRole('button', { name: 'Save Project' }).click();
await page.waitForTimeout(1000); // Compensate for delay in loading Idea Name heading
// Check texts
await expect(page.locator('h2')).toContainText(finalTitles[i]);

40
test-playwright/33-record-gift-x10.spec.ts

@ -1,38 +1,7 @@
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;
}
// Function to create an array of two-digit non-zero numbers
function createRandomNumbersArray(count) {
const numbersArray = [];
for (let i = 0; i < count; i++) {
let randomNumber = Math.floor(Math.random() * 99) + 1;
numbersArray.push(randomNumber);
}
return numbersArray;
}
import { importUser, createUniqueStringsArray, createRandomNumbersArray } from './testUtils';
test('Record 10 new gifts', async ({ page }) => {
test.slow(); // Extend the test timeout
const giftCount = 10;
// Standard text
@ -43,8 +12,8 @@ test('Record 10 new gifts', async ({ page }) => {
const finalNumbers = [];
// Create arrays for field input
const uniqueStrings = createUniqueStringsArray(giftCount);
const randomNumbers = createRandomNumbersArray(giftCount);
const uniqueStrings = await createUniqueStringsArray(giftCount);
const randomNumbers = await createRandomNumbersArray(giftCount);
// Populate array with titles
for (let i = 0; i < giftCount; i++) {
@ -57,9 +26,6 @@ test('Record 10 new gifts', async ({ page }) => {
// Import user 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
// Record new gifts
for (let i = 0; i < giftCount; i++) {
// Record something given

30
test-playwright/testUtils.ts

@ -66,3 +66,33 @@ export async function generateEthrUser(page: Page): Promise<string> {
return newDid;
}
// Function to generate a random string of specified length
export async function generateRandomString(length: number): Promise<string> {
return Math.random().toString(36).substring(2, 2 + length);
}
// Function to create an array of unique strings
export async function createUniqueStringsArray(count: number): Promise<string[]> {
const stringsArray = [];
const stringLength = 16;
for (let i = 0; i < count; i++) {
let randomString = await generateRandomString(stringLength);
stringsArray.push(randomString);
}
return stringsArray;
}
// Function to create an array of two-digit non-zero numbers
export async function createRandomNumbersArray(count: number): Promise<number[]> {
const numbersArray = [];
for (let i = 0; i < count; i++) {
let randomNumber = Math.floor(Math.random() * 99) + 1;
numbersArray.push(randomNumber);
}
return numbersArray;
}
Loading…
Cancel
Save