Compare commits
15 Commits
46ebd95394
...
03a3964cbd
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
03a3964cbd | ||
| acf04792be | |||
|
|
3262f0ee64 | ||
|
|
69473a826f | ||
|
|
51eb45353e | ||
|
|
b1875b5812 | ||
|
|
bd27d8a10f | ||
|
|
c076ce5b44 | ||
|
|
915d51dc2f | ||
|
|
b1d61251dc | ||
|
|
a9aeeeb51e | ||
|
|
d679d0c804 | ||
|
|
c4a8026276 | ||
|
|
10fad9c167 | ||
|
|
084fb09971 |
@@ -2,6 +2,8 @@ import { test, expect } from '@playwright/test';
|
|||||||
import { importUser } from './testUtils';
|
import { importUser } from './testUtils';
|
||||||
|
|
||||||
test('Create new project, then search for it', async ({ page }) => {
|
test('Create new project, then search for it', async ({ page }) => {
|
||||||
|
test.slow();
|
||||||
|
|
||||||
// Generate a random string of 16 characters
|
// Generate a random string of 16 characters
|
||||||
let randomString = Math.random().toString(36).substring(2, 18);
|
let randomString = Math.random().toString(36).substring(2, 18);
|
||||||
|
|
||||||
@@ -14,26 +16,45 @@ test('Create new project, then search for it', async ({ page }) => {
|
|||||||
// Standard texts
|
// Standard texts
|
||||||
const standardTitle = 'Idea ';
|
const standardTitle = 'Idea ';
|
||||||
const standardDescription = 'Description of Idea ';
|
const standardDescription = 'Description of Idea ';
|
||||||
|
const standardEdit = ' EDITED';
|
||||||
|
const standardWebsite = 'https://example.com';
|
||||||
|
const editedWebsite = 'https://example.com/edited';
|
||||||
|
|
||||||
|
// Set dates
|
||||||
|
const today = new Date();
|
||||||
|
const oneMonthAhead = new Date(today.setDate(today.getDate() + 30));
|
||||||
|
const twoMonthsAhead = new Date(today.setDate(today.getDate() + 30));
|
||||||
|
const finalDate = oneMonthAhead.toISOString().split('T')[0];
|
||||||
|
const editedDate = twoMonthsAhead.toISOString().split('T')[0];
|
||||||
|
|
||||||
|
// Set times
|
||||||
|
const now = new Date();
|
||||||
|
const oneHourAhead = new Date(now.setHours(now.getHours() + 1));
|
||||||
|
const twoHoursAhead = new Date(now.setHours(now.getHours() + 1));
|
||||||
|
const finalHour = oneHourAhead.getHours().toString().padStart(2, '0');
|
||||||
|
const editedHour = twoHoursAhead.getHours().toString().padStart(2, '0');
|
||||||
|
const finalMinute = oneHourAhead.getMinutes().toString().padStart(2, '0');
|
||||||
|
const finalTime = `${finalHour}:${finalMinute}`;
|
||||||
|
const editedTime = `${editedHour}:${finalMinute}`;
|
||||||
|
|
||||||
// Combine texts with the random string
|
// Combine texts with the random string
|
||||||
const finalTitle = standardTitle + finalRandomString;
|
const finalTitle = standardTitle + finalRandomString;
|
||||||
const finalDescription = standardDescription + finalRandomString;
|
const finalDescription = standardDescription + finalRandomString;
|
||||||
|
const editedTitle = finalTitle + standardEdit;
|
||||||
|
const editedDescription = finalDescription + standardEdit;
|
||||||
|
|
||||||
// Import user 00
|
// Import user 00
|
||||||
await importUser(page, '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
|
// Create new project
|
||||||
await page.goto('./projects');
|
await page.goto('./projects');
|
||||||
await page.getByRole('link', { name: 'Projects', exact: true }).click();
|
await page.getByRole('link', { name: 'Projects', exact: true }).click();
|
||||||
await page.getByRole('button').click();
|
await page.getByRole('button').click();
|
||||||
await page.getByPlaceholder('Idea Name').fill(finalTitle); // Add random suffix
|
await page.getByPlaceholder('Idea Name').fill(finalTitle);
|
||||||
await page.getByPlaceholder('Description').fill(finalDescription);
|
await page.getByPlaceholder('Description').fill(finalDescription);
|
||||||
await page.getByPlaceholder('Website').fill('https://example.com');
|
await page.getByPlaceholder('Website').fill(standardWebsite);
|
||||||
await page.getByPlaceholder('Start Date').fill('2025-12-01');
|
await page.getByPlaceholder('Start Date').fill(finalDate);
|
||||||
await page.getByPlaceholder('Start Time').fill('12:00');
|
await page.getByPlaceholder('Start Time').fill(finalTime);
|
||||||
await page.getByRole('button', { name: 'Save Project' }).click();
|
await page.getByRole('button', { name: 'Save Project' }).click();
|
||||||
|
|
||||||
// Check texts
|
// Check texts
|
||||||
@@ -43,11 +64,27 @@ test('Create new project, then search for it', async ({ page }) => {
|
|||||||
// Search for newly-created project in /projects
|
// Search for newly-created project in /projects
|
||||||
await page.goto('./projects');
|
await page.goto('./projects');
|
||||||
await page.getByRole('link', { name: 'Projects', exact: true }).click();
|
await page.getByRole('link', { name: 'Projects', exact: true }).click();
|
||||||
await expect(page.locator('ul#listProjects li.border-b:nth-child(1)')).toContainText(finalRandomString); // Assumes newest project always appears first in the Projects tab list
|
await expect(page.locator('ul#listProjects li').filter({ hasText: finalTitle })).toBeVisible();
|
||||||
|
|
||||||
// Search for newly-created project in /discover
|
// Search for newly-created project in /discover
|
||||||
await page.goto('./discover');
|
await page.goto('./discover');
|
||||||
await page.getByPlaceholder('Search…').fill(finalRandomString);
|
await page.getByPlaceholder('Search…').fill(finalRandomString);
|
||||||
await page.locator('#QuickSearch button').click();
|
await page.locator('#QuickSearch button').click();
|
||||||
await expect(page.locator('ul#listDiscoverResults li.border-b:nth-child(1)')).toContainText(finalRandomString);
|
await expect(page.locator('ul#listDiscoverResults li').filter({ hasText: finalTitle })).toBeVisible();
|
||||||
|
|
||||||
|
// Edit the project
|
||||||
|
await page.locator('a').filter({ hasText: finalTitle }).first().click();
|
||||||
|
await page.getByRole('button', { name: 'Edit' }).click();
|
||||||
|
await expect(page.getByPlaceholder('Idea Name')).toHaveValue(finalTitle); // Check that textfield value has loaded before proceeding
|
||||||
|
await page.getByPlaceholder('Idea Name').fill(editedTitle);
|
||||||
|
await page.getByPlaceholder('Description').fill(editedDescription);
|
||||||
|
await page.getByPlaceholder('Website').fill(editedWebsite);
|
||||||
|
await page.getByPlaceholder('Start Date').fill(editedDate);
|
||||||
|
await page.getByPlaceholder('Start Time').fill(editedTime);
|
||||||
|
await page.getByRole('button', { name: 'Save Project' }).click();
|
||||||
|
|
||||||
|
// Check edits
|
||||||
|
await expect(page.locator('h2')).toContainText(editedTitle);
|
||||||
|
await page.getByText('Read More').click();
|
||||||
|
await expect(page.locator('#Content')).toContainText(editedDescription);
|
||||||
});
|
});
|
||||||
45
test-playwright/25-create-project-x10.spec.ts
Normal file
45
test-playwright/25-create-project-x10.spec.ts
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
import { test, expect } from '@playwright/test';
|
||||||
|
import { importUser, createUniqueStringsArray } from './testUtils';
|
||||||
|
|
||||||
|
test('Create 10 new projects', async ({ page }) => {
|
||||||
|
const projectCount = 10;
|
||||||
|
|
||||||
|
// Standard texts
|
||||||
|
const standardTitle = "Idea ";
|
||||||
|
const standardDescription = "Description of Idea ";
|
||||||
|
|
||||||
|
// Title and description arrays
|
||||||
|
const finalTitles = [];
|
||||||
|
const finalDescriptions = [];
|
||||||
|
|
||||||
|
// Create an array of unique strings
|
||||||
|
const uniqueStrings = await createUniqueStringsArray(projectCount);
|
||||||
|
|
||||||
|
// Populate arrays with titles and descriptions
|
||||||
|
for (let i = 0; i < projectCount; i++) {
|
||||||
|
let loopTitle = standardTitle + uniqueStrings[i];
|
||||||
|
finalTitles.push(loopTitle);
|
||||||
|
let loopDescription = standardDescription + uniqueStrings[i];
|
||||||
|
finalDescriptions.push(loopDescription);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Import user 00
|
||||||
|
await importUser(page, '00');
|
||||||
|
|
||||||
|
// Create new projects
|
||||||
|
for (let i = 0; i < projectCount; i++) {
|
||||||
|
await page.goto('./projects');
|
||||||
|
await page.getByRole('link', { name: 'Projects', exact: true }).click();
|
||||||
|
await page.getByRole('button').click();
|
||||||
|
await page.getByPlaceholder('Idea Name').fill(finalTitles[i]); // Add random suffix
|
||||||
|
await page.getByPlaceholder('Description').fill(finalDescriptions[i]);
|
||||||
|
await page.getByPlaceholder('Website').fill('https://example.com');
|
||||||
|
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();
|
||||||
|
|
||||||
|
// Check texts
|
||||||
|
await expect(page.locator('h2')).toContainText(finalTitles[i]);
|
||||||
|
await expect(page.locator('#Content')).toContainText(finalDescriptions[i]);
|
||||||
|
}
|
||||||
|
});
|
||||||
43
test-playwright/33-record-gift-x10.spec.ts
Normal file
43
test-playwright/33-record-gift-x10.spec.ts
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
import { test, expect } from '@playwright/test';
|
||||||
|
import { importUser, createUniqueStringsArray, createRandomNumbersArray } from './testUtils';
|
||||||
|
|
||||||
|
test('Record 10 new gifts', async ({ page }) => {
|
||||||
|
const giftCount = 10;
|
||||||
|
|
||||||
|
// Standard text
|
||||||
|
const standardTitle = "Gift ";
|
||||||
|
|
||||||
|
// Field value arrays
|
||||||
|
const finalTitles = [];
|
||||||
|
const finalNumbers = [];
|
||||||
|
|
||||||
|
// Create arrays for field input
|
||||||
|
const uniqueStrings = await createUniqueStringsArray(giftCount);
|
||||||
|
const randomNumbers = await createRandomNumbersArray(giftCount);
|
||||||
|
|
||||||
|
// Populate array with titles
|
||||||
|
for (let i = 0; i < giftCount; i++) {
|
||||||
|
let loopTitle = standardTitle + uniqueStrings[i];
|
||||||
|
finalTitles.push(loopTitle);
|
||||||
|
let loopNumber = randomNumbers[i];
|
||||||
|
finalNumbers.push(loopNumber);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Import user 00
|
||||||
|
await importUser(page, '00');
|
||||||
|
|
||||||
|
// Record new gifts
|
||||||
|
for (let i = 0; i < giftCount; i++) {
|
||||||
|
// Record something given
|
||||||
|
await page.goto('./');
|
||||||
|
await page.getByRole('heading', { name: 'Unnamed/Unknown' }).click();
|
||||||
|
await page.getByPlaceholder('What was given').fill(finalTitles[i]);
|
||||||
|
await page.getByRole('spinbutton').fill(finalNumbers[i].toString());
|
||||||
|
await page.getByRole('button', { name: 'Sign & Send' }).click();
|
||||||
|
await expect(page.getByText('That gift was recorded.')).toBeVisible();
|
||||||
|
|
||||||
|
// Refresh home view and check gift
|
||||||
|
await page.goto('./');
|
||||||
|
await expect(page.locator('li').filter({ hasText: finalTitles[i] })).toBeVisible();
|
||||||
|
}
|
||||||
|
});
|
||||||
@@ -65,4 +65,34 @@ export async function generateEthrUser(page: Page): Promise<string> {
|
|||||||
await expect(page.locator('div[role="alert"] button:has-text("Yes")')).toBeHidden();
|
await expect(page.locator('div[role="alert"] button:has-text("Yes")')).toBeHidden();
|
||||||
|
|
||||||
return newDid;
|
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;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user