mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-01 20:23:36 +00:00
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:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user