hotfix(api): add UUID support to access list endpoints
This commit is contained in:
@@ -344,14 +344,22 @@ export class TestDataManager {
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
// DNS provider IDs must be numeric (backend uses strconv.ParseUint)
|
||||
const id = result.id;
|
||||
if (id !== undefined && typeof id !== 'number') {
|
||||
console.warn(`DNS provider returned non-numeric ID: ${id} (type: ${typeof id}), using as-is`);
|
||||
}
|
||||
const resourceId = String(id ?? result.uuid);
|
||||
|
||||
this.resources.push({
|
||||
id: result.id?.toString() ?? result.uuid,
|
||||
id: resourceId,
|
||||
type: 'dns-provider',
|
||||
namespace: this.namespace,
|
||||
createdAt: new Date(),
|
||||
});
|
||||
|
||||
return { id: result.id?.toString() ?? result.uuid, name: namespacedName };
|
||||
return { id: resourceId, name: namespacedName };
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -39,15 +39,20 @@ export function getToastLocator(
|
||||
): Locator {
|
||||
const { type } = options;
|
||||
|
||||
// Build selector using data-testid to avoid matching generic [role="alert"] elements
|
||||
// Build selector with fallbacks for reliability
|
||||
// Primary: data-testid (custom), Secondary: data-sonner-toast (Sonner), Tertiary: role="alert"
|
||||
let baseLocator: Locator;
|
||||
|
||||
if (type) {
|
||||
// Type-specific toast: match data-testid exactly
|
||||
baseLocator = page.locator(`[data-testid="toast-${type}"]`);
|
||||
// Type-specific toast: match data-testid with fallback to sonner
|
||||
baseLocator = page.locator(`[data-testid="toast-${type}"]`)
|
||||
.or(page.locator('[data-sonner-toast]'))
|
||||
.or(page.getByRole('alert'));
|
||||
} else {
|
||||
// Any toast: match our custom toast container
|
||||
baseLocator = page.locator('[data-testid^="toast-"]').first();
|
||||
// Any toast: match our custom toast container with fallbacks
|
||||
baseLocator = page.locator('[data-testid^="toast-"]')
|
||||
.or(page.locator('[data-sonner-toast]'))
|
||||
.or(page.getByRole('alert'));
|
||||
}
|
||||
|
||||
// Filter by text if provided
|
||||
|
||||
+16
-12
@@ -79,23 +79,27 @@ export async function waitForToast(
|
||||
): Promise<void> {
|
||||
const { timeout = 10000, type } = options;
|
||||
|
||||
// Build selectors prioritizing our custom toast system which uses data-testid
|
||||
// This avoids matching generic [role="alert"] elements like security notices
|
||||
let selector: string;
|
||||
// Build reliable toast locator with multiple fallback selectors
|
||||
// Primary: data-testid (custom), Secondary: data-sonner-toast (Sonner), Tertiary: role="alert"
|
||||
let toast;
|
||||
|
||||
if (type) {
|
||||
// Type-specific toast: match data-testid exactly
|
||||
selector = `[data-testid="toast-${type}"]`;
|
||||
// Type-specific toast with fallbacks
|
||||
toast = page.locator(`[data-testid="toast-${type}"]`)
|
||||
.or(page.locator('[data-sonner-toast]'))
|
||||
.or(page.getByRole('alert'))
|
||||
.filter({ hasText: text })
|
||||
.first();
|
||||
} else {
|
||||
// Any toast: match our custom toast container or react-hot-toast
|
||||
// Avoid matching static [role="alert"] elements by being more specific
|
||||
selector = '[data-testid^="toast-"]:not([data-testid="toast-container"])';
|
||||
// Any toast with fallbacks
|
||||
toast = page.locator('[data-testid^="toast-"]:not([data-testid="toast-container"])')
|
||||
.or(page.locator('[data-sonner-toast]'))
|
||||
.or(page.getByRole('alert'))
|
||||
.filter({ hasText: text })
|
||||
.first();
|
||||
}
|
||||
|
||||
// Use .first() to handle cases where multiple toasts are visible (e.g., after rapid toggles)
|
||||
// The first matching toast is typically the most recent one we care about
|
||||
const toast = page.locator(selector).first();
|
||||
await expect(toast).toContainText(text, { timeout });
|
||||
await expect(toast).toBeVisible({ timeout });
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user