Browse Source

tweak tests for clarity

master
Trent Larson 2 weeks ago
parent
commit
e96617ca0f
  1. 10
      test-playwright/35-record-gift-from-image-share.spec.ts
  2. 1
      test-playwright/40-add-contact.spec.ts
  3. 7
      test-playwright/testUtils.ts

10
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

1
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();

7
test-playwright/testUtils.ts

@ -33,6 +33,13 @@ export async function importUser(page: Page, id?: string): Promise<string> {
return did;
}
export async function importUserAndCloseOnboarding(page: Page, id?: string): Promise<string> {
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<void> {
// This is the direct approach but users have to tap on things so we'll do that instead.

Loading…
Cancel
Save