fix & enhance web tests for new contact import functionality
This commit is contained in:
@@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
|
||||
## [1.3.7]
|
||||
### Fixed
|
||||
- Contact deep-links clicked or pasted act consistenly
|
||||
|
||||
|
||||
## [1.3.5] - 2026.02.22
|
||||
### Fixed
|
||||
- SQL error on startup (contact_labels -> contacts foreign key)
|
||||
|
||||
@@ -290,8 +290,8 @@ test('Copy contact to clipboard, then import ', async ({ page, context }, testIn
|
||||
await page.locator('button', { hasText: 'Import' }).click();
|
||||
|
||||
await page.goto('./contacts');
|
||||
// Copy contact details
|
||||
await page.getByTestId('contactCheckAllTop').click();
|
||||
// Select and copy exactly one contact (single-contact deep link flow)
|
||||
await page.getByTestId('contactCheckOne').first().click();
|
||||
|
||||
const isChromium = await page.evaluate(() => {
|
||||
return navigator.userAgent.includes('Chrome') || navigator.userAgent.includes('Chromium');
|
||||
@@ -333,8 +333,89 @@ test('Copy contact to clipboard, then import ', async ({ page, context }, testIn
|
||||
await expect(page.locator('div[role="alert"]')).toBeHidden({ timeout: 7000 });
|
||||
|
||||
await page.goto(clipboardText);
|
||||
// we're on the contact-import page
|
||||
await expect(page.getByRole('heading', { name: "Contact Import" })).toBeVisible();
|
||||
// For some reason, Chromium shows 1 contact the same but Firefox shows 4.
|
||||
await expect(page.locator('span', { hasText: 'the same as' })).toBeVisible();
|
||||
// single-contact payload now auto-adds and routes to contact-edit
|
||||
await expect(page).toHaveURL(/\/contact-edit\//);
|
||||
await expect(page.getByTestId('contactName').locator('input')).toBeVisible();
|
||||
});
|
||||
|
||||
test('Copied deep link with multiple contacts opens Contact Import', async ({ page, context }, testInfo) => {
|
||||
await importUser(page, '00');
|
||||
|
||||
await page.goto('./contacts');
|
||||
|
||||
// Add contact #111
|
||||
await page
|
||||
.getByPlaceholder('URL or DID, Name, Public Key')
|
||||
.fill('did:ethr:0x111d15564f824D56C7a07b913aA7aDd03382aA39, User #111');
|
||||
await page.locator('button > svg.fa-plus').click();
|
||||
await expect(page.getByRole('alert').filter({ hasText: 'Success' })).toBeVisible();
|
||||
await page.locator('div[role="alert"] button > svg.fa-xmark').click();
|
||||
await expect(page.getByRole('button', { name: 'No', exact: true })).toBeVisible();
|
||||
await page.getByRole('button', { name: 'No', exact: true }).click();
|
||||
await expect(page.getByRole('button', { name: 'No, Not Yet', exact: true })).toBeVisible();
|
||||
await page.getByRole('button', { name: 'No, Not Yet', exact: true }).click();
|
||||
await expect(page.locator('div[role="alert"]')).toHaveCount(0);
|
||||
|
||||
// Add contact #222
|
||||
await page
|
||||
.getByPlaceholder('URL or DID, Name, Public Key')
|
||||
.fill('did:ethr:0x222BB77E6Ff3774d34c751f3c1260866357B677b, User #222');
|
||||
await page.locator('button > svg.fa-plus').click();
|
||||
await expect(page.getByRole('alert').filter({ hasText: 'Success' })).toBeVisible();
|
||||
await page.locator('div[role="alert"] button > svg.fa-xmark').click();
|
||||
await expect(page.getByRole('button', { name: 'No', exact: true })).toBeVisible();
|
||||
await page.getByRole('button', { name: 'No', exact: true }).click();
|
||||
await expect(page.getByRole('button', { name: 'No, Not Yet', exact: true })).toBeVisible();
|
||||
await page.getByRole('button', { name: 'No, Not Yet', exact: true }).click();
|
||||
await expect(page.locator('div[role="alert"]')).toHaveCount(0);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
const isChromium = await page.evaluate(() => {
|
||||
return navigator.userAgent.includes('Chrome') || navigator.userAgent.includes('Chromium');
|
||||
});
|
||||
if (isChromium) {
|
||||
await context.grantPermissions(['clipboard-read']);
|
||||
}
|
||||
|
||||
await expect(page.getByTestId('contactListItem')).toHaveCount(2);
|
||||
await page.getByTestId('contactCheckAllTop').click();
|
||||
await page.getByTestId('copySelectedContactsButtonTop').click();
|
||||
await page.waitForTimeout(100);
|
||||
|
||||
const clipboardText = await page.evaluate(async () => {
|
||||
try {
|
||||
return await navigator.clipboard.readText();
|
||||
} catch (error) {
|
||||
console.error('Clipboard read failed:', error);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
const webServer = testInfo.config.webServer;
|
||||
const clientServerUrl = webServer?.url;
|
||||
const PATH_PART = clientServerUrl + '/deep-link/contact-import/';
|
||||
await expect(clipboardText).toContain(PATH_PART);
|
||||
|
||||
// Delete one contact so import has at least one new contact
|
||||
await page.getByTestId('contactListItem').nth(1).locator('h2 > a').click();
|
||||
await expect(page.getByRole('heading', { name: 'Identifier Details' })).toBeVisible();
|
||||
await page.locator('button > svg.fa-trash-can').click();
|
||||
await page.locator('div[role="alert"] button:has-text("Yes")').click();
|
||||
await expect(page.locator('div[role="alert"] button:has-text("Yes")')).toBeHidden();
|
||||
await page.locator('div[role="alert"] button > svg.fa-xmark').click();
|
||||
await page.goto('./contacts');
|
||||
await expect(page.getByTestId('contactListItem')).toHaveCount(1);
|
||||
|
||||
await page.goto(clipboardText as string);
|
||||
await expect(page.getByRole('heading', { name: 'Contact Import' })).toBeVisible();
|
||||
await expect(page.locator('button', { hasText: 'Import Contacts' })).toBeVisible();
|
||||
await page.locator('button', { hasText: 'Import Contacts' }).click();
|
||||
await expect(page.getByTestId('contactListItem')).toHaveCount(2);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user