forked from trent_larson/crowd-funder-for-time-pwa
add test that copies contact-import JWT to clipboard and imports from it
This commit is contained in:
@@ -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
|
## [0.3.45] - 2025.01.01 - 65402dc68ce69ccc6cb9aa8d2e7a9249bf4298e0
|
||||||
### Fixed
|
### Fixed
|
||||||
- Previous project links stayed when following a link
|
- Previous project links stayed when following a link.
|
||||||
|
|
||||||
|
|
||||||
## [0.3.44] - 2024.12.31 - 694b22987b05482e4527c2478bbe15e6b6f3b532
|
## [0.3.44] - 2024.12.31 - 694b22987b05482e4527c2478bbe15e6b6f3b532
|
||||||
|
|||||||
@@ -1269,10 +1269,10 @@ export default class ContactsView extends Vue {
|
|||||||
const selectedContacts = this.contacts.filter((c) =>
|
const selectedContacts = this.contacts.filter((c) =>
|
||||||
this.contactsSelected.includes(c.did),
|
this.contactsSelected.includes(c.did),
|
||||||
);
|
);
|
||||||
console.log(
|
// console.log(
|
||||||
"Array of selected contacts:",
|
// "Array of selected contacts:",
|
||||||
JSON.stringify(selectedContacts),
|
// JSON.stringify(selectedContacts),
|
||||||
);
|
// );
|
||||||
const contactsJwt = await createEndorserJwtForDid(this.activeDid, {
|
const contactsJwt = await createEndorserJwtForDid(this.activeDid, {
|
||||||
contacts: selectedContacts,
|
contacts: selectedContacts,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ import { test, expect } from '@playwright/test';
|
|||||||
import { deleteContact, generateNewEthrUser, generateRandomString, importUser, switchToUser } from './testUtils';
|
import { deleteContact, generateNewEthrUser, generateRandomString, importUser, switchToUser } from './testUtils';
|
||||||
|
|
||||||
test('Check User 0 can invite someone', async ({ page }) => {
|
test('Check User 0 can invite someone', async ({ page }) => {
|
||||||
const newDid = await generateNewEthrUser(page);
|
|
||||||
|
|
||||||
await importUser(page, '00');
|
await importUser(page, '00');
|
||||||
await page.goto('./invite-one');
|
await page.goto('./invite-one');
|
||||||
await page.locator('button > svg.fa-plus').click();
|
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();
|
expect(inviteLink).not.toBeNull();
|
||||||
|
|
||||||
// become the new user and accept the invite
|
// become the new user and accept the invite
|
||||||
|
const newDid = await generateNewEthrUser(page);
|
||||||
await switchToUser(page, newDid);
|
await switchToUser(page, newDid);
|
||||||
await page.goto(inviteLink as string);
|
await page.goto(inviteLink as string);
|
||||||
await page.getByPlaceholder('Name', { exact: true }).fill(`My pal User #0`);
|
await page.getByPlaceholder('Name', { exact: true }).fill(`My pal User #0`);
|
||||||
|
|||||||
@@ -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 page.locator('div[role="alert"] button > svg.fa-xmark').click(); // dismiss alert
|
||||||
await expect(page.locator('div[role="alert"]')).toBeHidden();
|
await expect(page.locator('div[role="alert"]')).toBeHidden();
|
||||||
// I would prefer to copy from the clipboard, but the recommended approaches don't work.
|
// I would prefer to copy from the clipboard, but the recommended approaches don't work.
|
||||||
// this seems to fail in non-chromium browsers
|
// See a different clipboard solution below.
|
||||||
//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 contact details on the second contact
|
// see contact details on the second contact
|
||||||
await page.getByTestId('contactListItem').nth(1).locator('a').click();
|
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.goto('./account');
|
||||||
await page.getByRole('heading', { name: 'Advanced' }).click();
|
await page.getByRole('heading', { name: 'Advanced' }).click();
|
||||||
const fileSelect = await page.locator('input[type="file"]')
|
const fileSelect = await page.locator('input[type="file"]')
|
||||||
//fileSelect.click();
|
|
||||||
fileSelect.setInputFiles('./test-playwright/exported-data.json');
|
fileSelect.setInputFiles('./test-playwright/exported-data.json');
|
||||||
await page.locator('button', { hasText: 'Import Only Contacts' }).click();
|
await page.locator('button', { hasText: 'Import Only Contacts' }).click();
|
||||||
// we're on the contact-import page
|
// 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.
|
// 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();
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user