Skip to content

Commit 79b481f

Browse files
mchestrclaude
andcommitted
fix: add data-testid attributes to fix flaky E2E selectors
- Add data-testid="stat-card-wrapped-status" to observability page - Add data-testid="settings-page-heading" to settings page - Update E2E tests to use stable data-testid selectors instead of text matching Fixes strict mode violations where getByText matched multiple elements. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 0e41d7e commit 79b481f

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

app/admin/observability/page.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export default async function ObservabilityPage() {
6060
<Link
6161
href="/admin/users"
6262
className="bg-slate-800/50 backdrop-blur-sm border border-slate-700 rounded-lg p-4 hover:border-cyan-500/50 transition-colors group"
63+
data-testid="stat-card-wrapped-status"
6364
>
6465
<div className="text-sm text-slate-400 mb-1">Wrapped Status</div>
6566
<div className="text-3xl font-bold text-green-400">

app/admin/settings/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export default async function SettingsPage() {
6868
<div className="max-w-7xl mx-auto">
6969
{/* Header */}
7070
<div className="mb-6">
71-
<h1 className="text-2xl sm:text-3xl font-bold text-white mb-2">Settings</h1>
71+
<h1 className="text-2xl sm:text-3xl font-bold text-white mb-2" data-testid="settings-page-heading">Settings</h1>
7272
<p className="text-sm text-slate-400">
7373
Manage application configuration and system settings
7474
</p>

e2e/admin-observability.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ test.describe('Admin Observability Page', () => {
3838
// Verify summary stats cards are present
3939
await expect(adminPage.getByText('Configured Services')).toBeVisible();
4040
await expect(adminPage.getByText('Total Users')).toBeVisible();
41-
await expect(adminPage.getByText('Wrapped Status')).toBeVisible();
41+
await expect(adminPage.getByTestId('stat-card-wrapped-status')).toBeVisible();
4242
await expect(adminPage.getByText('LLM Usage (24h)')).toBeVisible();
4343
});
4444

@@ -248,7 +248,7 @@ test.describe('Admin Observability Page', () => {
248248

249249
// Verify we're on the settings page
250250
await expect(adminPage).toHaveURL(/\/admin\/settings/);
251-
await expect(adminPage.getByRole('heading', { name: 'Settings' })).toBeVisible();
251+
await expect(adminPage.getByTestId('settings-page-heading')).toBeVisible();
252252
});
253253

254254
test('should display secondary stats row with clickable cards', async ({ adminPage }) => {

0 commit comments

Comments
 (0)