forked from jsnbuchanan/crowd-funder-for-time-pwa
Fix duplicate export declarations and migrate ContactsView with sub-components
- Remove duplicate NOTIFY_INVITE_MISSING and NOTIFY_INVITE_PROCESSING_ERROR exports - Update InviteOneAcceptView.vue to use correct NOTIFY_INVITE_TRUNCATED_DATA constant - Migrate ContactsView to PlatformServiceMixin and extract into modular sub-components - Resolves TypeScript compilation errors preventing web build
This commit is contained in:
@@ -59,106 +59,16 @@ function createContactName(did: string): string {
|
||||
return "User " + did.slice(11, 14);
|
||||
}
|
||||
|
||||
export async function deleteContact(page: Page, did: string, contactName: string) {
|
||||
// Navigate to contacts page
|
||||
export async function deleteContact(page: Page, did: string): Promise<void> {
|
||||
await page.goto('./contacts');
|
||||
|
||||
// Wait for page to load completely
|
||||
await page.waitForLoadState('networkidle');
|
||||
|
||||
// Check if we need to hide the "Show Actions" view first
|
||||
const loadingCount = await page.locator('.loading-indicator').count();
|
||||
if (loadingCount > 0) {
|
||||
await page.locator('.loading-indicator').first().waitFor({ state: 'hidden' });
|
||||
}
|
||||
|
||||
// Check if "Hide Actions" button exists (meaning we're in the give numbers view)
|
||||
const showGiveNumbersExists = await page.getByRole('button', { name: 'Hide Actions' }).count();
|
||||
if (showGiveNumbersExists > 0) {
|
||||
await page.getByRole('button', { name: 'Hide Actions' }).click();
|
||||
}
|
||||
|
||||
// Look for the contact by name
|
||||
const contactItems = page.locator('li[data-testid="contactListItem"]');
|
||||
const contactCount = await contactItems.count();
|
||||
|
||||
// Debug: Print all contact names if no match found
|
||||
if (contactCount === 0) {
|
||||
await page.screenshot({ path: 'debug-no-contacts.png' });
|
||||
throw new Error(`No contacts found on page. Screenshot saved as debug-no-contacts.png`);
|
||||
}
|
||||
|
||||
// Check if our contact exists
|
||||
const contactExists = await contactItems.filter({ hasText: contactName }).count();
|
||||
if (contactExists === 0) {
|
||||
// Try alternative selectors
|
||||
const selectors = [
|
||||
'li',
|
||||
'div[data-testid="contactListItem"]',
|
||||
'.contact-item',
|
||||
'[data-testid*="contact"]'
|
||||
];
|
||||
|
||||
for (const selector of selectors) {
|
||||
const testCount = await page.locator(selector).filter({ hasText: contactName }).count();
|
||||
if (testCount > 0) {
|
||||
// Found working selector, use it
|
||||
const contactItem = page.locator(selector).filter({ hasText: contactName }).first();
|
||||
|
||||
// Look for info icon or delete button
|
||||
const infoIconExists = await contactItem.locator('svg.fa-info-circle').count();
|
||||
if (infoIconExists > 0) {
|
||||
await contactItem.locator('svg.fa-info-circle').click();
|
||||
await page.waitForLoadState('networkidle');
|
||||
|
||||
// Should now be on the contact detail page
|
||||
await expect(page.getByText('Contact Details')).toBeVisible();
|
||||
|
||||
// Look for delete button
|
||||
const deleteButtonExists = await page.getByRole('button', { name: 'Delete Contact' }).count();
|
||||
if (deleteButtonExists > 0) {
|
||||
await page.getByRole('button', { name: 'Delete Contact' }).click();
|
||||
|
||||
// Handle confirmation dialog
|
||||
await expect(page.getByRole('button', { name: 'Yes, Delete' })).toBeVisible();
|
||||
await page.getByRole('button', { name: 'Yes, Delete' }).click();
|
||||
|
||||
// Wait for dialog to close
|
||||
await expect(page.getByRole('button', { name: 'Yes, Delete' })).toBeHidden();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error(`Contact "${contactName}" not found on contacts page`);
|
||||
}
|
||||
|
||||
// Use the standard flow
|
||||
const contactItem = contactItems.filter({ hasText: contactName }).first();
|
||||
|
||||
// Look for info icon
|
||||
const infoIconExists = await contactItem.locator('svg.fa-info-circle').count();
|
||||
if (infoIconExists > 0) {
|
||||
await contactItem.locator('svg.fa-info-circle').click();
|
||||
await page.waitForLoadState('networkidle');
|
||||
|
||||
// Should now be on the contact detail page
|
||||
await expect(page.getByText('Contact Details')).toBeVisible();
|
||||
|
||||
// Look for delete button
|
||||
const deleteButtonExists = await page.getByRole('button', { name: 'Delete Contact' }).count();
|
||||
if (deleteButtonExists > 0) {
|
||||
await page.getByRole('button', { name: 'Delete Contact' }).click();
|
||||
|
||||
// Handle confirmation dialog
|
||||
await expect(page.getByRole('button', { name: 'Yes, Delete' })).toBeVisible();
|
||||
await page.getByRole('button', { name: 'Yes, Delete' }).click();
|
||||
|
||||
// Wait for dialog to close
|
||||
await expect(page.getByRole('button', { name: 'Yes, Delete' })).toBeHidden();
|
||||
}
|
||||
}
|
||||
const contactName = createContactName(did);
|
||||
// go to the detail page for this contact
|
||||
await page.locator(`li[data-testid="contactListItem"] h2:has-text("${contactName}") + span svg.fa-circle-info`).click();
|
||||
// delete the contact
|
||||
await page.locator('button > svg.fa-trash-can').click();
|
||||
await page.locator('div[role="alert"] button:has-text("Yes")').click();
|
||||
// for some reason, .isHidden() (without expect) doesn't work
|
||||
await expect(page.locator('div[role="alert"] button:has-text("Yes")')).toBeHidden();
|
||||
}
|
||||
|
||||
export async function generateNewEthrUser(page: Page): Promise<string> {
|
||||
@@ -180,34 +90,14 @@ export async function generateAndRegisterEthrUser(page: Page): Promise<string> {
|
||||
await importUser(page, '000'); // switch to user 000
|
||||
|
||||
await page.goto('./contacts');
|
||||
|
||||
const contactName = createContactName(newDid);
|
||||
|
||||
const contactInput = `${newDid}, ${contactName}`;
|
||||
|
||||
await page.getByPlaceholder('URL or DID, Name, Public Key').fill(contactInput);
|
||||
await page.getByPlaceholder('URL or DID, Name, Public Key').fill(`${newDid}, ${contactName}`);
|
||||
await page.locator('button > svg.fa-plus').click();
|
||||
|
||||
// Wait for the contact to be added first
|
||||
// register them
|
||||
await page.locator('div[role="alert"] button:has-text("Yes")').click();
|
||||
// wait for it to disappear because the next steps may depend on alerts being gone
|
||||
await expect(page.locator('div[role="alert"] button:has-text("Yes")')).toBeHidden();
|
||||
await expect(page.locator('li', { hasText: contactName })).toBeVisible();
|
||||
|
||||
// Wait longer for the registration alert to appear (it has a 1-second timeout)
|
||||
await page.waitForTimeout(2000);
|
||||
|
||||
// Check if the registration alert is present
|
||||
const alertCount = await page.locator('div[role="alert"]').count();
|
||||
|
||||
if (alertCount > 0) {
|
||||
// Check if this is a registration alert (contains "Yes" button)
|
||||
const yesButtonCount = await page.locator('div[role="alert"] button:has-text("Yes")').count();
|
||||
if (yesButtonCount > 0) {
|
||||
// register them
|
||||
await page.locator('div[role="alert"] button:has-text("Yes")').click();
|
||||
|
||||
// wait for it to disappear because the next steps may depend on alerts being gone
|
||||
await expect(page.locator('div[role="alert"] button:has-text("Yes")')).toBeHidden();
|
||||
}
|
||||
}
|
||||
|
||||
return newDid;
|
||||
}
|
||||
@@ -219,7 +109,7 @@ export async function generateRandomString(length: number): Promise<string> {
|
||||
|
||||
// Function to create an array of unique strings
|
||||
export async function createUniqueStringsArray(count: number): Promise<string[]> {
|
||||
const stringsArray: string[] = [];
|
||||
const stringsArray = [];
|
||||
const stringLength = 16;
|
||||
|
||||
for (let i = 0; i < count; i++) {
|
||||
@@ -232,7 +122,7 @@ export async function createUniqueStringsArray(count: number): Promise<string[]>
|
||||
|
||||
// Function to create an array of two-digit non-zero numbers
|
||||
export async function createRandomNumbersArray(count: number): Promise<number[]> {
|
||||
const numbersArray: number[] = [];
|
||||
const numbersArray = [];
|
||||
|
||||
for (let i = 0; i < count; i++) {
|
||||
let randomNumber = Math.floor(Math.random() * 99) + 1;
|
||||
|
||||
Reference in New Issue
Block a user