diff --git a/playwright.config-local.ts b/playwright.config-local.ts index 29f4cf64..5bb6d780 100644 --- a/playwright.config-local.ts +++ b/playwright.config-local.ts @@ -36,19 +36,12 @@ export default defineConfig({ /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ trace: "retain-on-failure", - - // Add request logging - logger: { - isEnabled: (name, severity) => severity === 'error' || name === 'api', - log: (name, severity, message, args) => console.log(`${severity}: ${message}`, args) - } }, /* Configure projects for major browsers */ projects: [ // { // name: 'chromium-serial', - // testMatch: /.*\/(35-record-gift-from-image-share|40-add-contact)\.spec\.ts/, // use: { // ...devices['Desktop Chrome'], // permissions: ["clipboard-read"], @@ -57,13 +50,11 @@ export default defineConfig({ // }, // { // name: 'firefox-serial', - // testMatch: /.*\/(35-record-gift-from-image-share|40-add-contact)\.spec\.ts/, // use: { ...devices['Desktop Firefox'] }, // workers: 1, // }, { name: 'chromium', - testMatch: /^(?!.*\/(35-record-gift-from-image-share|40-add-contact)\.spec\.ts).+\.spec\.ts$/, use: { ...devices['Desktop Chrome'], permissions: ["clipboard-read"], @@ -71,7 +62,6 @@ export default defineConfig({ }, { name: 'firefox', - testMatch: /^(?!.*\/(35-record-gift-from-image-share|40-add-contact)\.spec\.ts).+\.spec\.ts$/, use: { ...devices['Desktop Firefox'] }, }, diff --git a/test-playwright/30-record-gift.spec.ts b/test-playwright/30-record-gift.spec.ts index 76084f45..9dce00d0 100644 --- a/test-playwright/30-record-gift.spec.ts +++ b/test-playwright/30-record-gift.spec.ts @@ -110,7 +110,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.getByTestId('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/35-record-gift-from-image-share.spec.ts b/test-playwright/35-record-gift-from-image-share.spec.ts index f1de7fb5..50762408 100644 --- a/test-playwright/35-record-gift-from-image-share.spec.ts +++ b/test-playwright/35-record-gift-from-image-share.spec.ts @@ -90,7 +90,7 @@ test('Record item given from image-share', async ({ page }) => { // Refresh home view and check gift await page.goto('./'); - const item1 = page.locator('li').filter({ hasText: finalTitle }); + const item1 = page.locator('li').filter({ hasText: finalTitle }).first(); await expect(item1.getByRole('img')).toBeVisible(); }); diff --git a/test-playwright/40-add-contact.spec.ts b/test-playwright/40-add-contact.spec.ts index 5f2fe1e8..6a90f19b 100644 --- a/test-playwright/40-add-contact.spec.ts +++ b/test-playwright/40-add-contact.spec.ts @@ -102,7 +102,7 @@ test('Add contact, record gift, confirm gift', async ({ page }) => { await expect(page.locator('li.border-b')).toContainText(userName); // Rename contact - await page.locator(`li[data-testid="contactListItem"] h2:has-text("${userName}") + span svg.fa-circle-info`).click(); + await page.getByTestId(`contactListItem`).locator(`h2 a:has-text("${userName}")`).click(); // now on the DID view page await page.locator('h2 svg.fa-pen').click(); // now on the contact edit page @@ -116,10 +116,11 @@ test('Add contact, record gift, confirm gift', async ({ page }) => { // Confirm that home shows contact in "Record Something…" await page.goto('./'); await page.getByTestId('closeOnboardingAndFinish').click(); - await expect(page.locator('#sectionRecordSomethingGiven ul li').filter({ hasText: contactName }).nth(0)).toBeVisible(); + const userGaveLink = page.locator('#sectionRecordSomethingGiven ul li').filter({ hasText: contactName }).nth(0); + await expect(userGaveLink).toBeVisible(); + await userGaveLink.click(); // 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(); @@ -130,7 +131,7 @@ test('Add contact, record gift, confirm gift', async ({ page }) => { // Firefox complains on load the initial feed here when we use the test server. // It may be similar to the CORS problem below. - await page.locator('li').filter({ hasText: finalTitle }).locator('a').click(); + await page.locator('li').filter({ hasText: finalTitle }).getByTestId('circle-info-link').click(); await expect(page.getByRole('heading', { name: 'Verifiable Claim Details' })).toBeVisible(); await expect(page.getByText(finalTitle, { exact: true })).toBeVisible(); @@ -154,7 +155,7 @@ test('Add contact, record gift, confirm gift', async ({ page }) => { // Go to home view and look for gift await page.goto('./'); await page.getByTestId('closeOnboardingAndFinish').click(); - const giftLink = page.locator('li').filter({ hasText: finalTitle }).locator('a'); + const giftLink = page.locator('li').filter({ hasText: finalTitle }).getByTestId('circle-info-link').first(); await expect(giftLink).toBeVisible(); await giftLink.click(); @@ -226,7 +227,7 @@ test('Add contact, copy details, delete, and import from paste & from file', asy // See a different clipboard solution below. // see contact details on the second contact - await page.getByTestId('contactListItem').nth(1).locator('a').click(); + await page.getByTestId('contactListItem').nth(1).locator(`h2 a)`).click(); await page.getByRole('heading', { name: 'Identifier Details' }).isVisible(); // remove contact await page.locator('button > svg.fa-trash-can').click(); diff --git a/test-playwright/testUtils.ts b/test-playwright/testUtils.ts index 13cced1f..8f300664 100644 --- a/test-playwright/testUtils.ts +++ b/test-playwright/testUtils.ts @@ -63,7 +63,7 @@ export async function deleteContact(page: Page, did: string): Promise { await page.goto('./contacts'); const contactName = createContactName(did); // go to the detail page for this contact - await page.locator(`li[data-testid="contactListItem"] h2:has-text("${contactName}") + span svg.fa-circle-info`).click(); + await page.getByTestId(`contactListItem`).locator(`h2 a:has-text("${contactName}")`).click(); // delete the contact await page.locator('button > svg.fa-trash-can').click(); await page.locator('div[role="alert"] button:has-text("Yes")').click(); @@ -82,7 +82,7 @@ export async function generateNewEthrUser(page: Page): Promise { return newDid; } -// Generate a new random user and register them. +// Generate a new random user, register them, and add them as a contact with name from createContactName. // Note that this makes 000 the active user. Use switchToUser to switch to this DID. export async function generateAndRegisterEthrUser(page: Page): Promise { const newDid = await generateNewEthrUser(page); @@ -109,7 +109,7 @@ export async function generateRandomString(length: number): Promise { // Function to create an array of unique strings export async function createUniqueStringsArray(count: number): Promise { - const stringsArray = []; + const stringsArray: string[] = []; const stringLength = 16; for (let i = 0; i < count; i++) { @@ -122,7 +122,7 @@ export async function createUniqueStringsArray(count: number): Promise // Function to create an array of two-digit non-zero numbers export async function createRandomNumbersArray(count: number): Promise { - const numbersArray = []; + const numbersArray: number[] = []; for (let i = 0; i < count; i++) { let randomNumber = Math.floor(Math.random() * 99) + 1;