|
|
@ -1,4 +1,5 @@ |
|
|
|
import { expect, Page } from "@playwright/test"; |
|
|
|
import { UNNAMED_ENTITY_NAME } from '../src/constants/entities'; |
|
|
|
|
|
|
|
// Get test user data based on the ID.
|
|
|
|
// '01' -> user 111
|
|
|
@ -215,3 +216,44 @@ export function isResourceIntensiveTest(testPath: string): boolean { |
|
|
|
testPath.includes("40-add-contact") |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Create a gift record from the front page |
|
|
|
* @param page - Playwright page object |
|
|
|
* @param giftTitle - Optional custom title, defaults to "Gift " + random string |
|
|
|
* @param amount - Optional amount, defaults to random 1-99 |
|
|
|
* @returns Promise resolving to the created gift title |
|
|
|
*/ |
|
|
|
export async function createGiftFromFrontPageForNewUser( |
|
|
|
page: Page, |
|
|
|
giftTitle?: string, |
|
|
|
amount?: number |
|
|
|
): Promise<void> { |
|
|
|
// Generate random values if not provided
|
|
|
|
const randomString = Math.random().toString(36).substring(2, 6); |
|
|
|
const finalTitle = giftTitle || `Gift ${randomString}`; |
|
|
|
const finalAmount = amount || Math.floor(Math.random() * 99) + 1; |
|
|
|
|
|
|
|
// Navigate to home page and close onboarding
|
|
|
|
await page.goto('./'); |
|
|
|
await page.getByTestId('closeOnboardingAndFinish').click(); |
|
|
|
|
|
|
|
// Start gift creation flow
|
|
|
|
await page.getByRole('button', { name: 'Person' }).click(); |
|
|
|
await page.getByRole('listitem').filter({ hasText: UNNAMED_ENTITY_NAME }).locator('svg').click(); |
|
|
|
|
|
|
|
// Fill gift details
|
|
|
|
await page.getByPlaceholder('What was given').fill(finalTitle); |
|
|
|
await page.getByRole('spinbutton').fill(finalAmount.toString()); |
|
|
|
|
|
|
|
// Submit gift
|
|
|
|
await page.getByRole('button', { name: 'Sign & Send' }).click(); |
|
|
|
|
|
|
|
// Verify success
|
|
|
|
await expect(page.getByText('That gift was recorded.')).toBeVisible(); |
|
|
|
await page.locator('div[role="alert"] button > svg.fa-xmark').click(); // dismiss info alert
|
|
|
|
|
|
|
|
// Verify the gift appears in the home view
|
|
|
|
await page.goto('./'); |
|
|
|
await expect(page.locator('ul#listLatestActivity li').filter({ hasText: giftTitle })).toBeVisible(); |
|
|
|
} |
|
|
|