From e96617ca0fa1f7b2fab8c50282ca0f7e43da8276 Mon Sep 17 00:00:00 2001 From: Trent Larson Date: Fri, 28 Feb 2025 12:17:22 -0700 Subject: [PATCH] tweak tests for clarity --- .../35-record-gift-from-image-share.spec.ts | 10 ++++------ test-playwright/40-add-contact.spec.ts | 1 - test-playwright/testUtils.ts | 7 +++++++ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/test-playwright/35-record-gift-from-image-share.spec.ts b/test-playwright/35-record-gift-from-image-share.spec.ts index bdece66..f1de7fb 100644 --- a/test-playwright/35-record-gift-from-image-share.spec.ts +++ b/test-playwright/35-record-gift-from-image-share.spec.ts @@ -48,7 +48,7 @@ */ import path from 'path'; import { test, expect } from '@playwright/test'; -import { importUser } from './testUtils'; +import { importUserAndCloseOnboarding } from './testUtils'; /** * Note: by default, this test uses the test image API server. @@ -65,7 +65,7 @@ test('Record item given from image-share', async ({ page }) => { // Combine title prefix with the random string const finalTitle = `Gift ${randomString} from image-share`; - await importUser(page, '00'); + await importUserAndCloseOnboarding(page, '00'); // Record something given await page.goto('./test'); @@ -84,10 +84,8 @@ test('Record item given from image-share', async ({ page }) => { await page.getByRole('spinbutton').fill('2'); await page.getByRole('button', { name: 'Sign & Send' }).click(); - // we end up on a page with the onboarding info - await page.getByTestId('closeOnboardingAndFinish').click(); - - await expect(page.getByText('That gift was recorded.')).toBeVisible(); + // const recorded = await page.getByText('That gift was recorded.'); + await expect(await page.getByText('That gift was recorded.')).toBeVisible(); await page.locator('div[role="alert"] button > svg.fa-xmark').click(); // dismiss info alert // Refresh home view and check gift diff --git a/test-playwright/40-add-contact.spec.ts b/test-playwright/40-add-contact.spec.ts index 8d5416a..5f2fe1e 100644 --- a/test-playwright/40-add-contact.spec.ts +++ b/test-playwright/40-add-contact.spec.ts @@ -207,7 +207,6 @@ test('Add contact, copy details, delete, and import from paste & from file', asy // Add another new contact await page.getByPlaceholder('URL or DID, Name, Public Key').fill('did:ethr:0x222BB77E6Ff3774d34c751f3c1260866357B677b, User #222, asdf1234'); await page.locator('button > svg.fa-plus').click(); - await expect(page.locator('div[role="alert"]')).toBeVisible(); await expect(page.locator('div[role="alert"] span:has-text("No")')).toBeVisible(); await page.locator('div[role="alert"] button:has-text("No")').click(); // don't register await expect(page.locator('div[role="alert"] span:has-text("Contact Added")')).toBeVisible(); diff --git a/test-playwright/testUtils.ts b/test-playwright/testUtils.ts index 654f0c8..13cced1 100644 --- a/test-playwright/testUtils.ts +++ b/test-playwright/testUtils.ts @@ -33,6 +33,13 @@ export async function importUser(page: Page, id?: string): Promise { return did; } +export async function importUserAndCloseOnboarding(page: Page, id?: string): Promise { + const did = await importUser(page, id); + await page.goto('./'); + await page.getByTestId('closeOnboardingAndFinish').click(); + return did; +} + // This is to switch to someone already in the identity table. It doesn't include registration. export async function switchToUser(page: Page, did: string): Promise { // This is the direct approach but users have to tap on things so we'll do that instead.