La política simulations_update está activa en la DB de desarrollo. El fix B está completo.
Some checks failed
/ Deploy to Cloudflare Pages (push) Has been cancelled

Resumen de todo lo entregado en Etapa 7:

Fix A1 (src/auth/AuthContext.tsx): isProfileLoaded: boolean agregado como estado. Arranca en false, se pone true en el finally del sync effect (después de syncProfileFromDB), y cuando onAuthStateChange devuelve null (usuario no autenticado). Se resetea a false en cada SIGN_IN para gatear el re-sync.

Fix A2 (src/features/library/LibraryPage.tsx): Guard temprano después de todos los hooks — si !user || !isProfileLoaded devuelve un skeleton de tres columnas animado, idéntico al que usa HomeView. El contenido rol-dependiente solo se renderiza cuando el perfil está sincronizado.

Fix A3 (GlobalSettingsPanel.tsx + WorkspacePage.tsx): El campo "Cliente" es texto estático (<p>) para client_editor y client_viewer. En el topbar de WorkspacePage se oculta el input inline y el ícono de lápiz; si hay un clientName se muestra como texto inerte.

Fix B (supabase/migrations/016_add_simulations_update_policy.sql): Migración creada + aplicada vía Management API a inq-roi-desa. pg_policies confirma las 4 políticas: simulations_select, simulations_insert, simulations_update, simulations_delete.

Tests: tests/features/library/library-ui.test.tsx actualizado — mock incluye isProfileLoaded, 2 tests nuevos para isProfileLoaded: false. Total: 586 tests, todos verdes. Build limpio.
This commit is contained in:
2026-07-07 12:27:36 -03:00
parent 1f84997794
commit 9b89cb8669
7 changed files with 259 additions and 15 deletions

View File

@@ -17,6 +17,7 @@ const { authUserRef, libStoreRef } = vi.hoisted(() => {
name: 'Test User',
platformRole: 'platform_admin' as string,
},
isProfileLoaded: true,
}
const sampleProcess = {
id: 'proc-1',
@@ -59,7 +60,7 @@ const { authUserRef, libStoreRef } = vi.hoisted(() => {
})
vi.mock('@/auth/AuthContext', () => ({
useAuth: () => ({ user: authUserRef.current }),
useAuth: () => ({ user: authUserRef.current, isProfileLoaded: authUserRef.isProfileLoaded }),
}))
vi.mock('@/store/library-store', () => ({
@@ -89,6 +90,24 @@ describe('LibraryPage — visibilidad de controles según rol', () => {
libStoreRef.load = vi.fn()
libStoreRef.getAllTags = vi.fn().mockReturnValue([])
libStoreRef.getLatestSimulation = vi.fn().mockResolvedValue(null)
authUserRef.isProfileLoaded = true
})
describe('isProfileLoaded = false (sync en curso)', () => {
beforeEach(() => {
authUserRef.current = { ...authUserRef.current, platformRole: 'platform_admin' }
authUserRef.isProfileLoaded = false
})
it('NO muestra el botón "Importar BPMN" mientras el perfil no está cargado', () => {
render(<LibraryPage />)
expect(screen.queryByText('Importar BPMN')).not.toBeInTheDocument()
})
it('NO muestra el panel de grupos mientras el perfil no está cargado', () => {
render(<LibraryPage />)
expect(screen.queryByTestId('groups-header')).not.toBeInTheDocument()
})
})
describe('platform_admin', () => {