diff --git a/test-playwright/20-create-project.spec.ts b/test-playwright/20-create-project.spec.ts index 6d06d3c..af22ff0 100644 --- a/test-playwright/20-create-project.spec.ts +++ b/test-playwright/20-create-project.spec.ts @@ -40,9 +40,15 @@ test('Create new project, then search for it', async ({ page }) => { await expect(page.locator('h2')).toContainText(finalTitle); await expect(page.locator('#Content')).toContainText(finalDescription); - // Search for project that was just created + // Search for newly-created project in /projects + await page.goto('./projects'); + await page.getByRole('link', { name: 'Projects', exact: true }).click(); + await page.waitForTimeout(3000); // Wait for a bit + 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 + + // Search for newly-created project in /discover await page.goto('./discover'); - await page.waitForTimeout(5000); // Wait for a bit + await page.waitForTimeout(3000); // Wait for a bit await page.getByPlaceholder('Search…').fill(finalRandomString); await page.locator('#QuickSearch button').click(); await expect(page.locator('ul#listDiscoverResults li.border-b:nth-child(1)')).toContainText(finalRandomString); diff --git a/test-playwright/40-add-contact.spec.ts b/test-playwright/40-add-contact.spec.ts index 5f7cc92..177cdc0 100644 --- a/test-playwright/40-add-contact.spec.ts +++ b/test-playwright/40-add-contact.spec.ts @@ -2,6 +2,27 @@ import { test, expect } from '@playwright/test'; import { importUser } from './testUtils'; test('Add contact', async ({ page }) => { + // Generate a random string of 16 characters + let randomString = Math.random().toString(36).substring(2, 18); + + // In case the string is shorter than 16 characters, generate more characters until it is 16 characters long + while (randomString.length < 16) { + randomString += Math.random().toString(36).substring(2, 18); + } + const finalRandomString = randomString.substring(0, 16); + + // Generate a random non-zero single-digit number + const randomNonZeroNumber = Math.floor(Math.random() * 99) + 1; + + // Standard title prefix + const standardTitle = "Gift "; + + // Combine title prefix with the random string + const finalTitle = standardTitle + finalRandomString; + + // Contact name + const contactName = 'Contact 00'; + // Import user 01 await importUser(page, '01'); @@ -20,11 +41,23 @@ test('Add contact', async ({ page }) => { // Rename contact await page.locator('li.border-b h2 > button[title="Edit"]').click(); await expect(page.locator('div.dialog-overlay > div.dialog').filter({ hasText: 'Edit Name' })).toBeVisible(); - await page.getByPlaceholder('Name', { exact: true }).fill('Contact 00'); + await page.getByPlaceholder('Name', { exact: true }).fill(contactName); await page.locator('.dialog > .flex > button').first().click(); - // Confirm that home shows contact in "Record Something…" and "Latest Activity" + // Confirm that home shows contact in "Record Something…" + await page.goto('./'); + await expect(page.locator('#sectionRecordSomethingGiven ul li').filter({ hasText: contactName }).nth(0)).toBeVisible(); + + // Record something given by new contact + await page.getByRole('heading', { name: contactName }).click(); + await page.getByPlaceholder('What was given').fill(finalTitle); + await page.getByRole('spinbutton').fill(randomNonZeroNumber.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('#sectionRecordSomethingGiven ul li').filter({ hasText: 'Contact 00' }).nth(0)).toBeVisible(); - await expect(page.locator('ul#listLatestActivity li').filter({ hasText: 'Contact 00 received' }).nth(0)).toBeVisible(); + await page.locator('li').filter({ hasText: finalTitle }).locator('a').click(); + await expect(page.getByRole('heading', { name: 'Verifiable Claim Details' })).toBeVisible(); + await expect(page.getByText(finalTitle, { exact: true })).toBeVisible(); }); \ No newline at end of file