diff --git a/CHANGELOG.md b/CHANGELOG.md index 91c189a..3c10f20 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [0.3.45] - 2025.01.01 - 65402dc68ce69ccc6cb9aa8d2e7a9249bf4298e0 ### Fixed -- Previous project links stayed when following a link +- Previous project links stayed when following a link. ## [0.3.44] - 2024.12.31 - 694b22987b05482e4527c2478bbe15e6b6f3b532 diff --git a/src/views/ContactsView.vue b/src/views/ContactsView.vue index a69eba1..6f91815 100644 --- a/src/views/ContactsView.vue +++ b/src/views/ContactsView.vue @@ -1269,10 +1269,10 @@ export default class ContactsView extends Vue { const selectedContacts = this.contacts.filter((c) => this.contactsSelected.includes(c.did), ); - console.log( - "Array of selected contacts:", - JSON.stringify(selectedContacts), - ); + // console.log( + // "Array of selected contacts:", + // JSON.stringify(selectedContacts), + // ); const contactsJwt = await createEndorserJwtForDid(this.activeDid, { contacts: selectedContacts, }); diff --git a/test-playwright/05-invite.spec.ts b/test-playwright/05-invite.spec.ts index 37b1d49..114bffc 100644 --- a/test-playwright/05-invite.spec.ts +++ b/test-playwright/05-invite.spec.ts @@ -2,8 +2,6 @@ import { test, expect } from '@playwright/test'; import { deleteContact, generateNewEthrUser, generateRandomString, importUser, switchToUser } from './testUtils'; test('Check User 0 can invite someone', async ({ page }) => { - const newDid = await generateNewEthrUser(page); - await importUser(page, '00'); await page.goto('./invite-one'); await page.locator('button > svg.fa-plus').click(); @@ -23,6 +21,7 @@ test('Check User 0 can invite someone', async ({ page }) => { expect(inviteLink).not.toBeNull(); // become the new user and accept the invite + const newDid = await generateNewEthrUser(page); await switchToUser(page, newDid); await page.goto(inviteLink as string); await page.getByPlaceholder('Name', { exact: true }).fill(`My pal User #0`); diff --git a/test-playwright/40-add-contact.spec.ts b/test-playwright/40-add-contact.spec.ts index 0826700..8fa791e 100644 --- a/test-playwright/40-add-contact.spec.ts +++ b/test-playwright/40-add-contact.spec.ts @@ -145,10 +145,7 @@ test('Add contact, copy details, delete, and import from paste & from file', asy await page.locator('div[role="alert"] button > svg.fa-xmark').click(); // dismiss alert await expect(page.locator('div[role="alert"]')).toBeHidden(); // I would prefer to copy from the clipboard, but the recommended approaches don't work. - // this seems to fail in non-chromium browsers - //await context.grantPermissions(['clipboard-read', 'clipboard-write']); - // this seems to fail in chromium (at least) where clipboard is undefined - //const contactData = await navigator.clipboard.readText(); + // See a different clipboard solution below. // see contact details on the second contact await page.getByTestId('contactListItem').nth(1).locator('a').click(); @@ -185,7 +182,6 @@ test('Add contact, copy details, delete, and import from paste & from file', asy await page.goto('./account'); await page.getByRole('heading', { name: 'Advanced' }).click(); const fileSelect = await page.locator('input[type="file"]') - //fileSelect.click(); fileSelect.setInputFiles('./test-playwright/exported-data.json'); await page.locator('button', { hasText: 'Import Only Contacts' }).click(); // we're on the contact-import page @@ -199,3 +195,59 @@ test('Add contact, copy details, delete, and import from paste & from file', asy // But it should only show that one, for User #000. }); + +test('Copy contact to clipboard, then import ', async ({ page, context }) => { + await importUser(page, '00'); + + await page.goto('./account'); + await page.getByRole('heading', { name: 'Advanced' }).click(); + const fileSelect = await page.locator('input[type="file"]') + fileSelect.setInputFiles('./test-playwright/exported-data.json'); + await page.locator('button', { hasText: 'Import Only Contacts' }).click(); + // we're on the contact-import page + await expect(page.getByRole('heading', { name: "Contact Import" })).toBeVisible(); + await page.locator('button', { hasText: 'Import' }).click(); + + await page.goto('./contacts'); + // Copy contact details + await page.getByTestId('contactCheckAllTop').click(); + + // // There's a crazy amount of overlap in all the userAgent values. Ug. + // const agent = await page.evaluate(() => { + // return navigator.userAgent; + // }); + // console.log("agent: ", agent); + + const isFirefox = await page.evaluate(() => { + return navigator.userAgent.includes('Firefox'); + }); + if (isFirefox) { + // Firefox doesn't grant permissions like this but it works anyway. + } else { + await context.grantPermissions(['clipboard-read']); + } + + const isWebkit = await page.evaluate(() => { + return navigator.userAgent.includes('Macintosh') || navigator.userAgent.includes('iPhone'); + }); + if (isWebkit) { + console.log("Haven't found a way to access clipboard text in Webkit. Skipping."); + return; + } + + console.log("Running test that copies contact details to clipboard."); + await page.getByTestId('copySelectedContactsButtonTop').click(); + const clipboardText = await page.evaluate(async () => { + return navigator.clipboard.readText(); + }); + const PATH_PART = "http://localhost:8080/contact-import/"; + expect(clipboardText).toContain(PATH_PART); + + await page.locator('div[role="alert"] button > svg.fa-xmark').click(); // dismiss alert + await expect(page.locator('div[role="alert"]')).toBeHidden(); + + await page.goto(clipboardText); + // we're on the contact-import page + await expect(page.getByRole('heading', { name: "Contact Import" })).toBeVisible(); + await expect(page.locator('span', { hasText: '4 contacts are the same' })).toBeVisible(); +});