import { describe, expect, it } from 'vitest'; import { render, screen } from '../../../tests/helpers/render'; import DemoLock from './DemoLock'; describe('DemoLock', () => { it('FE-COMP-DEMOLOCK-001: unlocked, the section is the section and nothing more', () => { const { container } = render( ); expect(screen.getByRole('button', { name: 'Create key' })).toBeEnabled(); expect(screen.queryByRole('note')).not.toBeInTheDocument(); expect(container.querySelector('[data-demo-lock]')).toBeNull(); }); it('FE-COMP-DEMOLOCK-002: locked, the section stays visible but out of reach, under the badge and the reason', () => { const { container } = render( ); const note = screen.getByRole('note'); expect(note).toHaveTextContent('Demo mode'); expect(note).toHaveTextContent('API keys cannot be created in the demo.'); expect(screen.queryByRole('button', { name: 'Create key' })).not.toBeInTheDocument(); const veiled = container.querySelector('[data-demo-lock] > [inert]'); expect(veiled).toHaveAttribute('aria-hidden', 'true'); expect(veiled).toContainElement(screen.getByRole('button', { hidden: true, name: 'Create key' })); expect(note.getAttribute('style')).toContain('repeating-linear-gradient'); expect(note.getAttribute('style')).toContain('var(--text-primary)'); }); it('FE-COMP-DEMOLOCK-003: a single row puts the note in its middle, a section at its top', () => { const { rerender } = render( row ); expect(screen.getByRole('note').className).toContain('items-center'); rerender( section ); expect(screen.getByRole('note').className).toContain('items-start'); }); });