|
|
@ -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(); |
|
|
|
}); |
|
|
|