import { fireEvent, screen } from '@testing-library/react' import { mockAnimationsApi } from 'jsdom-testing-mocks' import { expect, test } from 'vitest' import { JitDbAccessConfiguration } from './JitDbAccessConfiguration' import { mockAccess } from './JitDbAccessConfiguration.test-fixtures' import { createMockAuthContext } from '@/tests/lib/auth-helpers' import { customRender } from '@/tests/lib/custom-render' import { createMockProfileContext } from '@/tests/lib/profile-helpers' mockAnimationsApi() test('keeps member token access usable without checking platform apps when self-hosted', async () => { mockAccess() customRender(, { profileContext: createMockProfileContext(), authContext: createMockAuthContext(), }) const toggle = await screen.findByRole('switch') expect(await screen.findByText('member-0@example.com')).toBeInTheDocument() expect(toggle).toHaveAttribute('aria-busy', 'false') expect(toggle).toBeEnabled() expect(screen.queryByRole('heading', { name: 'Apps' })).not.toBeInTheDocument() expect(screen.queryByText('Loading authorized apps...')).not.toBeInTheDocument() fireEvent.click(toggle) expect(await screen.findByRole('alertdialog')).toHaveTextContent('Disable token access') })