Files
supabase/e2e/studio/features/auth-user-panel.spec.ts
bd62dec2e2 refactor(studio): share Auth user cards and detail fields (#50841)
Extract shared Auth user cards and copyable detail fields, and use the
shared raw-JSON display in the user panel. The existing Logs view
remains available; unified activity timelines and log-user filtering
arrive separately in #50837.

This includes display-name/initials coverage and the Auth panel's
component and browser tests. The browser test now verifies keyboard
copying and Escape panel dismissal separately: the existing Auth Escape
shortcut closes the details panel, so expecting it to restore focus to a
field was incorrect. Its Raw JSON check reads the copied JSON's fields,
since the code view's text includes line numbers.

`UserCard` is Studio's first `Avatar`, so `vite.config.ts` pins
`avatar.tsx` to its own chunk, like `field`, `drawer` and `slider`.
Otherwise Rolldown pools it into the Auth `users` page chunk that the
`ui` barrel then imports back, a chunk cycle that fails the TanStack
build.

### How to test

1. Open an existing user in Authentication → Users. Check the profile
card, overview fields, and name/avatar fallbacks for a user without
profile metadata.
2. Open a copyable field using both mouse and keyboard (Enter), choose
Copy, and check the clipboard value.
3. Open Raw JSON, scroll, and use the floating copy button. Confirm the
existing Logs tab still opens and Escape closes the user panel.

### Validation

- Final head `f4f8cb22e97fefac56c68b4676184d8358d8080e` targets master
without conflicts.
- Focused local tests: 13 passed across three files, retries disabled,
including independent shuffled seed 5084131. Real panel/MSW tests cover
field copying and complete nested JSON; fallback and Unicode regressions
detect the original broken behavior.
- Browser QA passed on `6b49434339`: nameless profile fallback, overview
fields, mouse/keyboard copying, Raw JSON scrolling/copying, existing
Logs tab, and Escape dismissal. Later commits change only the E2E test;
application code is identical.
- All GitHub checks passed on the final head, including four unit-test
shards, four Next/TanStack E2E shards, typecheck, formatting, lint
ratchet, knip, and Studio Docker build.
- Independent review found no remaining issues; all review threads are
resolved.
- Fresh final-head studio-staging preview is blocked during dependency
installation: the registry returns HTTP 451 for
`react-hook-form@7.72.1`. The earlier matching application preview
passed browser QA; this deployment failure remains visible.

### Stack

Based on the logs table building blocks stack, which merges first:
#50953 → #50954 → #50955 → #50957 → #50958 → #52281. Then merge in
order:

1. #50835 — grouped log overviews and raw JSON
2. #50840 — request correlation queries
3. #50836 — request timeline UI and folding
4. #50841 — shared Auth user details
5. #50837 — log user correlation and Auth activity

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Jordi Enric <jordi.err@gmail.com>
2026-10-29 15:22:12 +01:00

58 lines
2.6 KiB
TypeScript

import { expect } from '@playwright/test'
import { createUserViaUI, deleteUserViaUI, navigateToAuthUsers } from '../utils/auth-helpers.js'
import { expectClipboardValue } from '../utils/clipboard.js'
import { test } from '../utils/test.js'
test('user details support copying fields and raw JSON with mouse and keyboard', async ({
page,
ref,
}) => {
const email = `test-user-panel-${Date.now()}@example.com`
await navigateToAuthUsers(page, ref)
try {
await createUserViaUI(page, ref, email, 'testpassword123')
await page.getByRole('row').filter({ hasText: email }).getByText(email, { exact: true }).click()
const overview = page.getByRole('tabpanel', { name: 'Overview' })
const emailField = overview.getByRole('button', { name: `Email ${email}`, exact: true })
await expect(emailField, 'User overview should show a copyable email field').toBeVisible()
const copyEmail = page.getByRole('menuitem', { name: 'Copy Email', exact: true })
await emailField.focus()
await page.keyboard.press('Enter')
await expect(copyEmail, 'Keyboard activation should open the email copy action').toBeVisible()
await copyEmail.press('Enter')
await expectClipboardValue({ page, value: email })
await expect(copyEmail, 'Keyboard copying should close the email menu').not.toBeVisible()
await emailField.click()
await copyEmail.click()
await expectClipboardValue({ page, value: email })
await expect(copyEmail, 'Mouse copying should close the email menu').not.toBeVisible()
await page.getByRole('tab', { name: 'Raw JSON' }).focus()
await page.keyboard.press('Enter')
const rawPanel = page.getByRole('tabpanel', { name: 'Raw JSON' })
await expect(rawPanel, 'Raw JSON should include the selected user').toContainText(email)
await rawPanel.getByRole('button', { name: 'Copy user as JSON' }).click()
await expectClipboardValue({ page, value: `"email": "${email}"` })
await page.keyboard.press('Escape')
await expect(rawPanel, 'Escape should close the user details panel').not.toBeVisible()
} finally {
if (!page.isClosed()) {
await navigateToAuthUsers(page, ref)
const loadedUsers = page
.getByRole('gridcell')
.first()
.or(page.getByText('No users in your project', { exact: true }))
await expect(
loadedUsers,
'Cleanup should wait for users or the loaded empty state'
).toBeVisible()
const userRow = page.getByRole('row').filter({ hasText: email })
if ((await userRow.count()) > 0) {
await deleteUserViaUI(page, ref, email)
}
}
}
})