fix: stabilize e2e test suite and auth configuration

- Standardized E2E base URL to 127.0.0.1 to resolve cookie domain 401 errors
- Updated playwright config to strictly exclude security tests from main shards
- Refactored waitForModal helper to prevent strict mode violations on complex modals
- Fixed leak of crowdsec diagnostics tests into standard chromium project
This commit is contained in:
GitHub Actions
2026-02-06 07:43:26 +00:00
parent 3da7f07eee
commit 11e575d6cc
14 changed files with 138 additions and 30 deletions

View File

@@ -413,27 +413,33 @@ export async function waitForModal(
const { timeout = 10000 } = options;
// Try to find a modal dialog first, then fall back to a slide-out panel with matching heading
const dialogModal = page.locator('[role="dialog"], .modal');
const slideOutPanel = page.locator('h2, h3').filter({ hasText: titleText });
// Use .first() to avoid specific strict mode violations if multiple exist in DOM
const dialogModal = page
.locator('[role="dialog"], .modal')
.filter({ hasText: titleText })
.first();
const slideOutPanel = page
.locator('h2, h3')
.filter({ hasText: titleText })
.first();
// Wait for either the dialog modal or the slide-out panel heading to be visible
try {
await expect(dialogModal.or(slideOutPanel)).toBeVisible({ timeout });
} catch {
// FIX STRICT MODE VIOLATION:
// If we match both the dialog AND the heading inside it, .or() returns 2 elements.
// We strictly want to wait until *at least one* is visible.
// Using .first() on the combined locator prevents 'strict mode violation' when both match.
await expect(dialogModal.or(slideOutPanel).first()).toBeVisible({ timeout });
} catch (e) {
// If neither is found, throw a more helpful error
throw new Error(
`waitForModal: Could not find modal dialog or slide-out panel matching "${titleText}"`
`waitForModal: Could not find visible modal dialog or slide-out panel matching "${titleText}". Error: ${e instanceof Error ? e.message : String(e)}`
);
}
// If dialog modal is visible, verify its title
// If dialog modal is visible, use it
if (await dialogModal.isVisible()) {
if (titleText) {
const titleLocator = dialogModal.locator(
'[role="heading"], .modal-title, .dialog-title, h1, h2, h3'
);
await expect(titleLocator).toContainText(titleText);
}
return dialogModal;
}