|
|
|
import { test, expect } from '@playwright/test';
|
|
|
|
import { importUser } from './testUtils';
|
|
|
|
|
|
|
|
test('Record an offer', async ({ page }) => {
|
|
|
|
// Generate a random string of 6 characters, skipping the "0." at the beginning
|
|
|
|
const randomString = Math.random().toString(36).substring(2, 8);
|
|
|
|
// Standard title prefix
|
|
|
|
const finalTitle = `Offering of ${randomString}`;
|
|
|
|
const randomNonZeroNumber = Math.floor(Math.random() * 999) + 1;
|
|
|
|
|
|
|
|
// Create new ID for default user
|
|
|
|
await importUser(page);
|
|
|
|
|
|
|
|
// Select a project
|
|
|
|
await page.goto('./discover');
|
|
|
|
await page.locator('ul#listDiscoverResults li:nth-child(1)').click();
|
|
|
|
|
|
|
|
// Record an offer
|
|
|
|
await page.getByTestId('offerButton').click();
|
|
|
|
await page.getByTestId('inputDescription').fill(finalTitle);
|
|
|
|
await page.getByTestId('inputOfferAmount').fill(randomNonZeroNumber.toString());
|
|
|
|
await page.getByRole('button', { name: 'Sign & Send' }).click();
|
|
|
|
await expect(page.getByText('That offer was recorded.')).toBeVisible();
|
|
|
|
|
|
|
|
// Refresh home view and check gift
|
|
|
|
await page.goto('./projects');
|
|
|
|
await page.locator('li').filter({ hasText: finalTitle }).locator('a').first().click();
|
|
|
|
await expect(page.getByRole('heading', { name: 'Verifiable Claim Details' })).toBeVisible();
|
|
|
|
await expect(page.getByText(finalTitle, { exact: true })).toBeVisible();
|
|
|
|
const page1Promise = page.waitForEvent('popup');
|
|
|
|
await page.getByRole('link', { name: 'View on the Public Server' }).click();
|
|
|
|
const page1 = await page1Promise;
|
|
|
|
});
|