diff --git a/test-playwright/00-noid-tests.spec.ts b/test-playwright/00-noid-tests.spec.ts index 24a3d879..9dc88306 100644 --- a/test-playwright/00-noid-tests.spec.ts +++ b/test-playwright/00-noid-tests.spec.ts @@ -253,7 +253,13 @@ test('Check User 0 can register a random person', async ({ page }) => { await page.goto('./'); await page.getByTestId('closeOnboardingAndFinish').click(); - await page.getByRole('heading', { name: 'Unnamed/Unknown' }).click(); + + // Click the "Person" button to open the gift recording dialog + await page.getByRole('button', { name: 'Person' }).click(); + + // In the dialog, click on "Unnamed" to select it as the giver + await page.getByRole('heading', { name: 'Unnamed' }).first().click(); + await page.getByPlaceholder('What was given').fill('Gave me access!'); await page.getByRole('button', { name: 'Sign & Send' }).click(); await expect(page.getByText('That gift was recorded.')).toBeVisible(); diff --git a/test-playwright/30-record-gift.spec.ts b/test-playwright/30-record-gift.spec.ts index 76084f45..40d4d422 100644 --- a/test-playwright/30-record-gift.spec.ts +++ b/test-playwright/30-record-gift.spec.ts @@ -100,7 +100,15 @@ test('Record something given', async ({ page }) => { // Record something given await page.goto('./'); await page.getByTestId('closeOnboardingAndFinish').click(); - await page.getByRole('heading', { name: 'Unnamed/Unknown' }).click(); + + // Click the "Person" button to open the gift recording dialog + await page.getByRole('button', { name: 'Person' }).click(); + + // In the dialog, click on "Unnamed" to select it as the giver + // Use the first "Unnamed" element which should be in the entity grid + await page.getByRole('heading', { name: 'Unnamed' }).first().click(); + + // Fill in the gift details await page.getByPlaceholder('What was given').fill(finalTitle); await page.getByRole('spinbutton').fill(randomNonZeroNumber.toString()); await page.getByRole('button', { name: 'Sign & Send' }).click(); @@ -110,7 +118,7 @@ test('Record something given', async ({ page }) => { // Refresh home view and check gift await page.goto('./'); const item = await page.locator('li').filter({ hasText: finalTitle }); - await item.locator('[data-testid="circle-info-link"]').click(); + await item.locator('[data-testid="circle-info-link"]').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'); diff --git a/test-playwright/33-record-gift-x10.spec.ts b/test-playwright/33-record-gift-x10.spec.ts index 3366a24d..16aecc71 100644 --- a/test-playwright/33-record-gift-x10.spec.ts +++ b/test-playwright/33-record-gift-x10.spec.ts @@ -115,7 +115,13 @@ test('Record 9 new gifts', async ({ page }) => { if (i === 0) { await page.getByTestId('closeOnboardingAndFinish').click(); } - await page.getByRole('heading', { name: 'Unnamed/Unknown' }).click(); + + // Click the "Person" button to open the gift recording dialog + await page.getByRole('button', { name: 'Person' }).click(); + + // In the dialog, click on "Unnamed" to select it as the giver + await page.getByRole('heading', { name: 'Unnamed' }).first().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(); diff --git a/test-playwright/testUtils.ts b/test-playwright/testUtils.ts index aa3b320b..c4d2bcdb 100644 --- a/test-playwright/testUtils.ts +++ b/test-playwright/testUtils.ts @@ -213,13 +213,26 @@ export async function generateAndRegisterEthrUser(page: Page): Promise { await page.getByPlaceholder('URL or DID, Name, Public Key').fill(contactInput); await page.locator('button > svg.fa-plus').click(); - // register them - await page.locator('div[role="alert"] button:has-text("Yes")').click(); + // Wait for the contact to be added first + await expect(page.locator('li', { hasText: contactName })).toBeVisible(); - // wait for it to disappear because the next steps may depend on alerts being gone - await expect(page.locator('div[role="alert"] button:has-text("Yes")')).toBeHidden(); + // Wait longer for the registration alert to appear (it has a 1-second timeout) + await page.waitForTimeout(2000); - await expect(page.locator('li', { hasText: contactName })).toBeVisible(); + // Check if the registration alert is present + const alertCount = await page.locator('div[role="alert"]').count(); + + if (alertCount > 0) { + // Check if this is a registration alert (contains "Yes" button) + const yesButtonCount = await page.locator('div[role="alert"] button:has-text("Yes")').count(); + if (yesButtonCount > 0) { + // register them + await page.locator('div[role="alert"] button:has-text("Yes")').click(); + + // wait for it to disappear because the next steps may depend on alerts being gone + await expect(page.locator('div[role="alert"] button:has-text("Yes")')).toBeHidden(); + } + } return newDid; }