forked from jsnbuchanan/crowd-funder-for-time-pwa
- Add detailed header documentation to playwright tests - Document test categories and flows - Add key selector documentation - Document state verification and alert handling - Include code examples and usage patterns - Add important checks and requirements The documentation helps developers understand the foundational tests that verify basic application functionality before running more complex test suites.
133 lines
4.5 KiB
TypeScript
133 lines
4.5 KiB
TypeScript
/**
|
|
* @file Bulk Gift Recording Test Suite
|
|
* @description Tests TimeSafari's gift recording functionality under load by creating
|
|
* multiple gift records in sequence. Limited to 9 gifts to stay under 30-second timeout.
|
|
*
|
|
* This test verifies:
|
|
* 1. Scalability
|
|
* - System handles multiple gift recordings (9)
|
|
* - Performance remains stable across iterations
|
|
* - No data corruption during bulk operations
|
|
*
|
|
* 2. Data Integrity
|
|
* - Each gift has unique identifiers
|
|
* - All gifts properly stored and retrievable
|
|
* - No cross-contamination between gift data
|
|
*
|
|
* 3. UI/UX Stability
|
|
* - Interface remains responsive during bulk operations
|
|
* - Success notifications display correctly
|
|
* - Alert dismissal works consistently
|
|
*
|
|
* Test Flow:
|
|
* 1. Setup Phase
|
|
* - Generate arrays of unique strings for titles
|
|
* - Generate array of random numbers for amounts
|
|
* - Import User 00 (test account)
|
|
*
|
|
* 2. Bulk Recording (9 iterations)
|
|
* - Navigate to home
|
|
* - Handle first-time onboarding dialog
|
|
* - Select recipient (Unnamed/Unknown)
|
|
* - Fill gift details from arrays
|
|
* - Sign and submit
|
|
* - Verify success
|
|
* - Dismiss notification
|
|
* - Verify gift in list
|
|
*
|
|
* Test Data:
|
|
* - Gift Count: 9 (optimized for timeout limits)
|
|
* - Title Format: "Gift [unique-string]"
|
|
* - Amount: Random numbers array
|
|
* - Recipient: "Unnamed/Unknown" (constant)
|
|
*
|
|
* Key Selectors:
|
|
* - Gift input: '[placeholder="What was given"]'
|
|
* - Amount input: '[role="spinbutton"]'
|
|
* - Submit button: '[name="Sign & Send"]'
|
|
* - Success alert: 'div[role="alert"]'
|
|
* - Alert dismiss: 'button > svg.fa-xmark'
|
|
*
|
|
* Performance Considerations:
|
|
* - Limited to 9 gifts to avoid timeout
|
|
* - Handles UI lag between operations
|
|
* - Manages memory usage during bulk operations
|
|
*
|
|
* Error Handling:
|
|
* - Closes onboarding dialog only on first iteration
|
|
* - Verifies each gift individually
|
|
* - Maintains operation even if individual recordings fail
|
|
*
|
|
* Related Files:
|
|
* - Gift recording view: src/views/RecordGiftView.vue
|
|
* - JWT creation: sw_scripts/safari-notifications.js
|
|
* - Endorser API: src/libs/endorserServer.ts
|
|
* - Test utilities: ./testUtils.ts
|
|
*
|
|
* @see Documentation in usage-guide.md for gift recording workflows
|
|
* @requires @playwright/test
|
|
* @requires ./testUtils - For user management and array generation
|
|
*
|
|
* @example
|
|
* ```typescript
|
|
* // Generate test data arrays
|
|
* const uniqueStrings = await createUniqueStringsArray(giftCount);
|
|
* const randomNumbers = await createRandomNumbersArray(giftCount);
|
|
*
|
|
* // Record gifts in sequence
|
|
* for (let i = 0; i < giftCount; i++) {
|
|
* await page.goto('./');
|
|
* 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();
|
|
* }
|
|
* ```
|
|
*/
|
|
|
|
import { test, expect } from '@playwright/test';
|
|
import { importUser, createUniqueStringsArray, createRandomNumbersArray } from './testUtils';
|
|
|
|
test('Record 9 new gifts', async ({ page }) => {
|
|
const giftCount = 9; // because 10 has taken us above 30 seconds
|
|
|
|
// 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('./');
|
|
if (i === 0) {
|
|
await page.getByTestId('closeOnboardingAndFinish').click();
|
|
}
|
|
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();
|
|
await page.locator('div[role="alert"] button > svg.fa-xmark').click(); // dismiss info alert
|
|
|
|
// Refresh home view and check gift
|
|
await page.goto('./');
|
|
await expect(page.locator('li').filter({ hasText: finalTitles[i] })).toBeVisible();
|
|
}
|
|
}); |