feat: add comprehensive tests for AI profiles view

- Introduced a new test suite for the AI profiles view, covering profile creation, editing, deletion, and reordering functionalities.
- Implemented tests for form validation, including checks for empty and whitespace-only profile names.
- Enhanced utility functions for profile interactions, including profile card retrieval and dialog management.
- Improved error handling in toast notifications for better test reliability.
- Updated test utilities to support the new profiles view structure.
This commit is contained in:
Kacper
2025-12-15 14:59:27 +01:00
parent 9f9bcaff65
commit 7d8670ff1f
6 changed files with 1791 additions and 11 deletions

View File

@@ -25,17 +25,29 @@ export async function waitForErrorToast(
titleText?: string,
options?: { timeout?: number }
): Promise<Locator> {
// Sonner toasts use data-sonner-toast and data-type="error" for error toasts
const toastSelector = titleText
? `[data-sonner-toast][data-type="error"]:has-text("${titleText}")`
: '[data-sonner-toast][data-type="error"]';
// Try multiple selectors for error toasts since Sonner versions may differ
// 1. Try with data-type="error" attribute
// 2. Fallback to any toast with the text (error styling might vary)
const timeout = options?.timeout ?? 5000;
const toast = page.locator(toastSelector).first();
await toast.waitFor({
timeout: options?.timeout ?? 5000,
state: "visible",
});
return toast;
if (titleText) {
// First try specific error type, then fallback to any toast with text
const errorToast = page.locator(
`[data-sonner-toast][data-type="error"]:has-text("${titleText}"), [data-sonner-toast]:has-text("${titleText}")`
).first();
await errorToast.waitFor({
timeout,
state: "visible",
});
return errorToast;
} else {
const errorToast = page.locator('[data-sonner-toast][data-type="error"]').first();
await errorToast.waitFor({
timeout,
state: "visible",
});
return errorToast;
}
}
/**