You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.4 KiB
43 lines
1.4 KiB
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();
|
|
}
|
|
});
|