test(e2e): fix admin-nav locator + add residential interest API coverage
- 21-role-based-ui: tighten the Settings link locator. The previous
`getByRole('link', { name: /settings/i }).first().or(getByText(/.../) .first())`
chain hit a strict-mode violation once the sidebar Admin section became
default-expanded — both the section header text node and the Settings
link matched. Match the link directly with exact: true.
- 26-residential: extend smoke with two API-driven specs covering the
residential interest pipeline — create+list and detail-page render —
using preferences-string stamp + heading match for assertions.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -8,30 +8,10 @@ test.describe('Role-Based UI', () => {
|
||||
// Give React Query time to resolve permissions
|
||||
await page.waitForTimeout(3_000);
|
||||
|
||||
// Admin section (Settings / Administration) should appear in the sidebar
|
||||
const adminNav = page
|
||||
.getByText(/admin/i)
|
||||
.first()
|
||||
.or(page.getByRole('link', { name: /settings/i }).first())
|
||||
.or(page.getByRole('link', { name: /administration/i }).first());
|
||||
|
||||
const adminNavVisible = await adminNav.isVisible({ timeout: 10_000 }).catch(() => false);
|
||||
|
||||
if (!adminNavVisible) {
|
||||
// Some layouts collapse the admin section behind a toggle — try expanding
|
||||
const adminToggle = page.locator('[data-testid*="admin"], [class*="admin"]').first();
|
||||
if (await adminToggle.isVisible({ timeout: 3_000 }).catch(() => false)) {
|
||||
await adminToggle.click();
|
||||
await page.waitForTimeout(1_000);
|
||||
}
|
||||
}
|
||||
|
||||
// Re-check for admin-related navigation after any expansion attempt
|
||||
const settingsLink = page
|
||||
.getByRole('link', { name: /settings/i })
|
||||
.first()
|
||||
.or(page.getByText(/settings|administration|admin/i).first());
|
||||
|
||||
// Sidebar exposes a Settings link inside the Admin section (visible by
|
||||
// default for super_admin). Match the link directly — earlier OR-fallbacks
|
||||
// ambiguously matched the section header label too.
|
||||
const settingsLink = page.getByRole('link', { name: 'Settings', exact: true }).first();
|
||||
await expect(settingsLink).toBeVisible({ timeout: 10_000 });
|
||||
|
||||
// "+ New" button (or equivalent CTA) should be visible
|
||||
|
||||
Reference in New Issue
Block a user