Improve registration dialog handling in contact import tests
- Update safeCloseAlert function to use specific registration dialog selectors
- Replace generic dialog selectors with targeted 'button.bg-yellow-600:has-text("No")'
- Add final registration dialog check before navigation in contact editing tests
- Use 'div.absolute.inset-0.h-screen' for dialog visibility detection
- Maintain 27/36 test pass rate with improved modal handling
This commit is contained in:
@@ -361,6 +361,18 @@ async function safeCloseAlert(page: any, alertSelector: string = 'div[role="aler
|
||||
} catch (error) {
|
||||
// If click fails due to blocking dialog, try to close the dialog first
|
||||
try {
|
||||
// First check for registration dialog specifically
|
||||
const hasRegistrationDialog = await page.locator('span.font-semibold.text-lg:has-text("Register")').isVisible().catch(() => false);
|
||||
if (hasRegistrationDialog) {
|
||||
// Click "No" to dismiss registration dialog - use the specific button class
|
||||
await page.locator('button.bg-yellow-600:has-text("No")').click();
|
||||
await page.locator('div.absolute.inset-0.h-screen').waitFor({ state: 'hidden', timeout: 5000 });
|
||||
// Now try to close the alert again
|
||||
await page.locator(alertSelector).first().click();
|
||||
return;
|
||||
}
|
||||
|
||||
// Then check for other dialogs
|
||||
const dialog = page.locator('div[role="dialog"]');
|
||||
if (await dialog.isVisible({ timeout: 1000 })) {
|
||||
await dialog.locator('button:has-text("No"), button:has-text("Cancel"), button > svg.fa-xmark').first().click();
|
||||
@@ -490,6 +502,31 @@ test.describe('Contact Import Functionality', () => {
|
||||
|
||||
// Verify success message is displayed
|
||||
await expect(page.locator('div[role="alert"] span:has-text("Success")')).toBeVisible();
|
||||
|
||||
// Aggressive modal clearing before dismissing alert
|
||||
await page.waitForTimeout(1000);
|
||||
|
||||
// Check for and dismiss any visible modals
|
||||
const modalSelectors = [
|
||||
'div.absolute.inset-0.h-screen',
|
||||
'div.fixed.z-\\[90\\]',
|
||||
'div.fixed.z-\\[100\\]',
|
||||
'div[role="dialog"]'
|
||||
];
|
||||
|
||||
for (const selector of modalSelectors) {
|
||||
const hasModal = await page.locator(selector).isVisible().catch(() => false);
|
||||
if (hasModal) {
|
||||
try {
|
||||
// Try clicking outside the modal first
|
||||
await page.locator(selector).click({ position: { x: 10, y: 10 }, force: true });
|
||||
await page.waitForTimeout(500);
|
||||
} catch (error) {
|
||||
// Modal dismissal failed, continue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await page.locator('div[role="alert"] button > svg.fa-xmark').first().click();
|
||||
|
||||
// Verify contacts appear in the contacts list
|
||||
@@ -530,6 +567,31 @@ test.describe('Contact Import Functionality', () => {
|
||||
|
||||
// Verify success feedback
|
||||
await expect(page.locator('div[role="alert"] span:has-text("Success")').first()).toBeVisible();
|
||||
|
||||
// Aggressive modal clearing before dismissing alert
|
||||
await page.waitForTimeout(1000);
|
||||
|
||||
// Check for and dismiss any visible modals
|
||||
const modalSelectors = [
|
||||
'div.absolute.inset-0.h-screen',
|
||||
'div.fixed.z-\\[90\\]',
|
||||
'div.fixed.z-\\[100\\]',
|
||||
'div[role="dialog"]'
|
||||
];
|
||||
|
||||
for (const selector of modalSelectors) {
|
||||
const hasModal = await page.locator(selector).isVisible().catch(() => false);
|
||||
if (hasModal) {
|
||||
try {
|
||||
// Try clicking outside the modal first
|
||||
await page.locator(selector).click({ position: { x: 10, y: 10 }, force: true });
|
||||
await page.waitForTimeout(500);
|
||||
} catch (error) {
|
||||
// Modal dismissal failed, continue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await page.locator('div[role="alert"] button > svg.fa-xmark').first().click();
|
||||
|
||||
// Verify all contacts appear in the final list
|
||||
@@ -1801,7 +1863,49 @@ test.describe('Contact Import Functionality', () => {
|
||||
}
|
||||
|
||||
await expect(page.locator('div[role="alert"] span:has-text("Success")')).toBeVisible();
|
||||
await page.locator('div[role="alert"] button > svg.fa-xmark').first().click();
|
||||
|
||||
// Aggressive modal clearing before dismissing alert
|
||||
await perfMonitor.measureAsync('aggressive modal clearing before alert dismissal', async () => {
|
||||
await page.waitForTimeout(1000);
|
||||
|
||||
// Check for and dismiss any visible modals
|
||||
const modalSelectors = [
|
||||
'div.absolute.inset-0.h-screen',
|
||||
'div.fixed.z-\\[90\\]',
|
||||
'div.fixed.z-\\[100\\]',
|
||||
'div[role="dialog"]'
|
||||
];
|
||||
|
||||
for (const selector of modalSelectors) {
|
||||
const hasModal = await page.locator(selector).isVisible().catch(() => false);
|
||||
if (hasModal) {
|
||||
try {
|
||||
// Try clicking outside the modal first
|
||||
await page.locator(selector).click({ position: { x: 10, y: 10 }, force: true });
|
||||
await page.waitForTimeout(500);
|
||||
} catch (error) {
|
||||
perfMonitor.checkpoint(`modal dismissal failed for ${selector}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
await safeCloseAlert(page);
|
||||
});
|
||||
|
||||
// Check for and handle any registration dialogs before navigating
|
||||
await perfMonitor.measureAsync('final registration dialog check before navigation', async () => {
|
||||
try {
|
||||
const hasRegistrationDialog = await page.locator('span.font-semibold.text-lg:has-text("Register")').isVisible().catch(() => false);
|
||||
if (hasRegistrationDialog) {
|
||||
await page.locator('button.bg-yellow-600:has-text("No")').click();
|
||||
await page.locator('div.absolute.inset-0.h-screen').waitFor({ state: 'hidden', timeout: 5000 });
|
||||
perfMonitor.checkpoint('final registration dialog dismissed');
|
||||
await page.waitForTimeout(1000);
|
||||
}
|
||||
} catch (error) {
|
||||
perfMonitor.checkpoint('final registration dialog check failed');
|
||||
}
|
||||
});
|
||||
|
||||
// Navigate directly to the contact edit page using the contact DID
|
||||
@@ -1877,7 +1981,34 @@ test.describe('Contact Import Functionality', () => {
|
||||
}
|
||||
|
||||
await expect(page.locator('div[role="alert"] span:has-text("Success")')).toBeVisible();
|
||||
await page.locator('div[role="alert"] button > svg.fa-xmark').first().click();
|
||||
|
||||
// Aggressive modal clearing before dismissing alert
|
||||
await perfMonitor.measureAsync('aggressive modal clearing before alert dismissal', async () => {
|
||||
await page.waitForTimeout(1000);
|
||||
|
||||
// Check for and dismiss any visible modals
|
||||
const modalSelectors = [
|
||||
'div.absolute.inset-0.h-screen',
|
||||
'div.fixed.z-\\[90\\]',
|
||||
'div.fixed.z-\\[100\\]',
|
||||
'div[role="dialog"]'
|
||||
];
|
||||
|
||||
for (const selector of modalSelectors) {
|
||||
const hasModal = await page.locator(selector).isVisible().catch(() => false);
|
||||
if (hasModal) {
|
||||
try {
|
||||
// Try clicking outside the modal first
|
||||
await page.locator(selector).click({ position: { x: 10, y: 10 }, force: true });
|
||||
await page.waitForTimeout(500);
|
||||
} catch (error) {
|
||||
perfMonitor.checkpoint(`modal dismissal failed for ${selector}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
await safeCloseAlert(page);
|
||||
});
|
||||
|
||||
// Navigate directly to the contact edit page
|
||||
|
||||
Reference in New Issue
Block a user