fix test 40 for adding contacts (though clipboard is still broken)

This commit is contained in:
2026-01-01 20:25:40 -07:00
parent f64846ae17
commit 4a3b968ee2
2 changed files with 71 additions and 64 deletions

View File

@@ -843,17 +843,14 @@ export default class ContactsView extends Vue {
// Set visibility and get success message // Set visibility and get success message
const addedMessage = await this.handleContactVisibility(newContact); const addedMessage = await this.handleContactVisibility(newContact);
// Show success notification
this.notify.success(addedMessage);
// Clear input field // Clear input field
this.contactInput = ""; this.contactInput = "";
// Handle registration prompt if needed // Handle registration prompt if needed
await this.handleRegistrationPrompt(newContact); await this.handleRegistrationPrompt(newContact);
// Show success notification
this.notify.success(addedMessage);
// Show export data prompt after successful contact addition
await this.showExportDataPrompt();
} catch (err) { } catch (err) {
this.handleContactAddError(err); this.handleContactAddError(err);
} }
@@ -908,30 +905,35 @@ export default class ContactsView extends Vue {
newContact.registered === true // the new contact is already registered newContact.registered === true // the new contact is already registered
) { ) {
// if any of the above are true, we do not want to show the registration prompt // if any of the above are true, we do not want to show the registration prompt
await this.showExportDataPrompt();
return; return;
} }
setTimeout(() => { this.$notify(
this.$notify( {
{ group: "modal",
group: "modal", type: "confirm",
type: "confirm", title: "Register",
title: "Register", text: "Do you want to register them?",
text: "Do you want to register them?", onCancel: async (stopAsking?: boolean) => {
onCancel: async (stopAsking?: boolean) => { await this.handleRegistrationPromptResponse(stopAsking);
await this.handleRegistrationPromptResponse(stopAsking); // Show export prompt after registration prompt is dismissed
}, await this.showExportDataPrompt();
onNo: async (stopAsking?: boolean) => {
await this.handleRegistrationPromptResponse(stopAsking);
},
onYes: async () => {
await this.register(newContact);
},
promptToStopAsking: true,
}, },
-1, onNo: async (stopAsking?: boolean) => {
); await this.handleRegistrationPromptResponse(stopAsking);
}, 1000); // Show export prompt after registration prompt is dismissed
await this.showExportDataPrompt();
},
onYes: async () => {
await this.register(newContact);
// Show export prompt after registration completes
await this.showExportDataPrompt();
},
promptToStopAsking: true,
},
-1,
);
} }
/** /**
@@ -1338,25 +1340,23 @@ export default class ContactsView extends Vue {
* Prompts user to export their contact data as a backup * Prompts user to export their contact data as a backup
*/ */
private async showExportDataPrompt(): Promise<void> { private async showExportDataPrompt(): Promise<void> {
setTimeout(() => { this.$notify(
this.$notify( {
{ group: "modal",
group: "modal", type: "confirm",
type: "confirm", title: NOTIFY_EXPORT_DATA_PROMPT.title,
title: NOTIFY_EXPORT_DATA_PROMPT.title, text: NOTIFY_EXPORT_DATA_PROMPT.message,
text: NOTIFY_EXPORT_DATA_PROMPT.message, onYes: async () => {
onYes: async () => { await this.exportContactData();
await this.exportContactData();
},
yesText: "Export Data",
onNo: async () => {
// User chose not to export - no action needed
},
noText: "Not Now",
}, },
-1, yesText: "Export Data",
); onNo: async () => {
}, 1000); // Small delay to ensure success notification is shown first // User chose not to export - no action needed
},
noText: "Not Yet",
},
-1,
);
} }
/** /**

View File

@@ -92,12 +92,13 @@ test('Add contact, record gift, confirm gift', async ({ page }) => {
await page.goto('./contacts'); await page.goto('./contacts');
await page.getByPlaceholder('URL or DID, Name, Public Key').fill('did:ethr:0x0000694B58C2cC69658993A90D3840C560f2F51F, ' + userName); await page.getByPlaceholder('URL or DID, Name, Public Key').fill('did:ethr:0x0000694B58C2cC69658993A90D3840C560f2F51F, ' + userName);
await page.locator('button > svg.fa-plus').click(); await page.locator('button > svg.fa-plus').click();
// Commenting the following lines because user 00 is already registered await expect(page.getByRole('alert').filter({ hasText: 'Success' })).toBeVisible();
// await expect(page.locator('div[role="alert"] span:has-text("No")')).toBeVisible();
// await page.locator('div[role="alert"] button:has-text("No")').click(); // don't register
await expect(page.locator('div[role="alert"] span:has-text("Success")')).toBeVisible();
await page.locator('div[role="alert"] button > svg.fa-xmark').click(); // dismiss info alert await page.locator('div[role="alert"] button > svg.fa-xmark').click(); // dismiss info alert
await expect(page.locator('div[role="alert"] span:has-text("No")')).toBeVisible(); // register prompt
await page.getByRole('button', { name: 'No', exact: true }).click(); // don't register
await expect(page.locator('div[role="alert"] button > svg.fa-xmark')).toBeHidden(); // ensure alert is gone await expect(page.locator('div[role="alert"] button > svg.fa-xmark')).toBeHidden(); // ensure alert is gone
await expect(page.getByRole('button', { name: 'No, Not Yet', exact: true })).toBeVisible(); // backup prompt
await page.getByRole('button', { name: 'No, Not Yet', exact: true }).click(); // don't backup contacts
// Verify added contact // Verify added contact
await expect(page.locator('li.border-b')).toContainText(userName); await expect(page.locator('li.border-b')).toContainText(userName);
@@ -118,10 +119,10 @@ test('Add contact, record gift, confirm gift', async ({ page }) => {
await page.goto('./'); await page.goto('./');
await page.getByTestId('closeOnboardingAndFinish').click(); await page.getByTestId('closeOnboardingAndFinish').click();
await page.getByRole('button', { name: 'Thank' }).click(); await page.getByRole('button', { name: 'Thank' }).click();
await expect(page.locator('#sectionGiftedGiver').getByRole('listitem').filter({ hasText: contactName })).toBeVisible(); await expect(page.locator('#sectionGiftedGiver').getByRole('listitem').filter({ hasText: contactName }).first()).toBeVisible();
// Record something given by new contact // Record something given by new contact
await page.locator('#sectionGiftedGiver').getByRole('listitem').filter({ hasText: contactName }).click(); await page.locator('#sectionGiftedGiver').getByRole('listitem').filter({ hasText: contactName }).first().click();
await page.getByPlaceholder('What was given').fill(finalTitle); await page.getByPlaceholder('What was given').fill(finalTitle);
await page.getByRole('spinbutton').fill(randomNonZeroNumber.toString()); await page.getByRole('spinbutton').fill(randomNonZeroNumber.toString());
await page.getByRole('button', { name: 'Sign & Send' }).click(); await page.getByRole('button', { name: 'Sign & Send' }).click();
@@ -156,7 +157,7 @@ test('Add contact, record gift, confirm gift', async ({ page }) => {
// Go to home view and look for gift // Go to home view and look for gift
await page.goto('./'); await page.goto('./');
// await page.getByTestId('closeOnboardingAndFinish').click(); await page.getByTestId('closeOnboardingAndFinish').click();
const giftLink = page.locator('li:first-child').filter({ hasText: finalTitle }).locator('[data-testid="circle-info-link"]'); const giftLink = page.locator('li:first-child').filter({ hasText: finalTitle }).locator('[data-testid="circle-info-link"]');
await expect(giftLink).toBeVisible(); await expect(giftLink).toBeVisible();
await giftLink.click(); await giftLink.click();
@@ -179,11 +180,13 @@ test('Without being registered, add contacts without registration', async ({ pag
await page.goto('./contacts'); await page.goto('./contacts');
await page.getByPlaceholder('URL or DID, Name, Public Key').fill('did:ethr:0x111d15564f824D56C7a07b913aA7aDd03382aA39, User #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 page.locator('button > svg.fa-plus').click();
await expect(page.locator('div[role="alert"] span:has-text("Success")')).toBeVisible(); await expect(page.getByRole('alert').filter({ hasText: 'Success' })).toBeVisible();
await page.locator('div[role="alert"] button > svg.fa-xmark').click(); // dismiss info alert await page.locator('div[role="alert"] button > svg.fa-xmark').click(); // dismiss info alert
// wait for the alert to disappear, which also ensures that there is no "Register" button waiting await expect(page.getByRole('button', { name: 'No, Not Yet', exact: true })).toBeVisible(); // backup prompt
await expect(page.locator('div[role="alert"]')).toBeHidden(); await page.getByRole('button', { name: 'No, Not Yet', exact: true }).click(); // don't backup contacts
await expect(page.getByRole('button', { name: 'No, Not Yet', exact: true })).toBeHidden();
// wait for all alerts to disappear
await expect(page.locator('div[role="alert"]')).toHaveCount(0);
}); });
test('Add contact, copy details, delete, and import from paste & from file', async ({ page, context }) => { test('Add contact, copy details, delete, and import from paste & from file', async ({ page, context }) => {
@@ -193,22 +196,26 @@ test('Add contact, copy details, delete, and import from paste & from file', asy
await page.goto('./contacts'); await page.goto('./contacts');
await page.getByPlaceholder('URL or DID, Name, Public Key').fill('did:ethr:0x111d15564f824D56C7a07b913aA7aDd03382aA39, User #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 page.locator('button > svg.fa-plus').click();
await expect(page.locator('div[role="alert"]')).toBeVisible(); await expect(page.locator('div[role="alert"]').first()).toBeVisible();
await expect(page.locator('div[role="alert"] span:has-text("No")')).toBeVisible(); await expect(page.getByRole('alert').filter({ hasText: 'Success' })).toBeVisible();
await page.locator('div[role="alert"] button:has-text("No")').click(); // don't register
await expect(page.locator('div[role="alert"] span:has-text("Success")')).toBeVisible();
await page.locator('div[role="alert"] button > svg.fa-xmark').click(); // dismiss info alert await page.locator('div[role="alert"] button > svg.fa-xmark').click(); // dismiss info alert
await expect(page.getByRole('button', { name: 'No', exact: true })).toBeVisible();
await page.getByRole('button', { name: 'No', exact: true }).click(); // don't register
await expect(page.getByRole('button', { name: 'No, Not Yet', exact: true })).toBeVisible(); // backup prompt
await page.getByRole('button', { name: 'No, Not Yet', exact: true }).click(); // don't backup contacts
// wait for the alert to disappear // wait for the alert to disappear
await expect(page.locator('div[role="alert"]')).toBeHidden(); await expect(page.locator('div[role="alert"]')).toHaveCount(0);
// Add another new contact // Add another new contact
await page.getByPlaceholder('URL or DID, Name, Public Key').fill('did:ethr:0x222BB77E6Ff3774d34c751f3c1260866357B677b, User #222, asdf1234'); await page.getByPlaceholder('URL or DID, Name, Public Key').fill('did:ethr:0x222BB77E6Ff3774d34c751f3c1260866357B677b, User #222, asdf1234');
await page.locator('button > svg.fa-plus').click(); await page.locator('button > svg.fa-plus').click();
await expect(page.locator('div[role="alert"] span:has-text("No")')).toBeVisible(); await expect(page.getByRole('alert').filter({ hasText: 'Success' })).toBeVisible();
await page.locator('div[role="alert"] button:has-text("No")').click(); // don't register
await expect(page.locator('div[role="alert"] span:has-text("Success")')).toBeVisible();
await page.locator('div[role="alert"] button > svg.fa-xmark').click(); // dismiss info alert await page.locator('div[role="alert"] button > svg.fa-xmark').click(); // dismiss info alert
await expect(page.locator('div[role="alert"]')).toBeHidden(); await expect(page.getByRole('button', { name: 'No', exact: true })).toBeVisible();
await page.getByRole('button', { name: 'No', exact: true }).click(); // don't register
await expect(page.getByRole('button', { name: 'No, Not Yet', exact: true })).toBeVisible(); // backup prompt
await page.getByRole('button', { name: 'No, Not Yet', exact: true }).click(); // don't backup contacts
await expect(page.locator('div[role="alert"]')).toHaveCount(0);
await expect(page.getByTestId('contactListItem')).toHaveCount(2); await expect(page.getByTestId('contactListItem')).toHaveCount(2);