Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
import { describe, it, expect, vi } from 'vitest';
import { render, screen, fireEvent } from '@testing-library/react';
import InlineConfirmRow from './InlineConfirmRow';
describe('InlineConfirmRow', () => {
it('renders the question with default Delete/Cancel labels and error tone', () => {
render(<InlineConfirmRow question="Delete this? This cannot be undone." />);
expect(screen.getByText('Delete this? This cannot be undone.')).toBeTruthy();
const wrapper = screen.getByText('Delete this? This cannot be undone.').closest('div');
expect(wrapper.className).toContain('bg-port-error/10');
expect(wrapper.className).toContain('border-port-error/30');
const confirm = screen.getByRole('button', { name: 'Delete' });
expect(confirm.className).toContain('bg-port-error');
expect(screen.getByRole('button', { name: 'Cancel' })).toBeTruthy();
});
it('fires onConfirm and onCancel for the respective buttons', () => {
const onConfirm = vi.fn();
const onCancel = vi.fn();
render(<InlineConfirmRow question="x" onConfirm={onConfirm} onCancel={onCancel} />);
fireEvent.click(screen.getByRole('button', { name: 'Delete' }));
fireEvent.click(screen.getByRole('button', { name: 'Cancel' }));
expect(onConfirm).toHaveBeenCalledTimes(1);
expect(onCancel).toHaveBeenCalledTimes(1);
});
it('honors custom labels and button titles', () => {
render(
<InlineConfirmRow
question="x"
confirmText="Remove"
cancelText="Keep"
confirmTitle="Confirm delete"
cancelTitle="Cancel delete"
/>,
);
const confirm = screen.getByRole('button', { name: 'Remove' });
expect(confirm.getAttribute('title')).toBe('Confirm delete');
expect(screen.getByRole('button', { name: 'Keep' }).getAttribute('title')).toBe('Cancel delete');
});
it('omits the title attribute when no title prop is supplied', () => {
render(<InlineConfirmRow question="x" />);
expect(screen.getByRole('button', { name: 'Delete' }).getAttribute('title')).toBeNull();
});
it('merges passthrough className after tone classes', () => {
render(<InlineConfirmRow question="x" className="mb-2" />);
const wrapper = screen.getByText('x').closest('div');
expect(wrapper.className).toContain('mb-2');
expect(wrapper.className).toContain('bg-port-error/10');
});
it('falls back to the error tone for an unknown tone value', () => {
render(<InlineConfirmRow question="x" tone="bogus" />);
const wrapper = screen.getByText('x').closest('div');
expect(wrapper.className).toContain('bg-port-error/10');
});
it('renders buttons as type=button so they never submit a surrounding form', () => {
render(<InlineConfirmRow question="x" />);
expect(screen.getByRole('button', { name: 'Delete' }).getAttribute('type')).toBe('button');
expect(screen.getByRole('button', { name: 'Cancel' }).getAttribute('type')).toBe('button');
});
it('stacks the question above equal-width actions on narrow screens', () => {
render(<InlineConfirmRow question="Delete this image?" />);
const wrapper = screen.getByText('Delete this image?').closest('div');
const actions = screen.getByRole('button', { name: 'Delete' }).parentElement;
expect(wrapper.className).toContain('flex-col');
expect(wrapper.className).toContain('sm:flex-row');
expect(actions.className).toContain('grid-cols-2');
expect(screen.getByRole('button', { name: 'Delete' }).className).toContain('min-h-9');
expect(screen.getByRole('button', { name: 'Cancel' }).className).toContain('min-h-9');
});
it('forwards passthrough props (data-*/aria-*) to the root like sibling primitives', () => {
render(<InlineConfirmRow question="x" data-testid="confirm-row" aria-label="Confirm deletion" />);
const wrapper = screen.getByTestId('confirm-row');
expect(wrapper.getAttribute('aria-label')).toBe('Confirm deletion');
});
it('defaults to the box variant (rounded border, text-xs)', () => {
render(<InlineConfirmRow question="x" />);
const wrapper = screen.getByText('x').closest('div');
expect(wrapper.className).toContain('rounded');
expect(wrapper.className).not.toContain('border-b');
expect(screen.getByText('x').className).toContain('text-xs');
});
it('renders a full-width bottom-border strip at text-sm for the separator variant', () => {
render(<InlineConfirmRow question="x" variant="separator" />);
const wrapper = screen.getByText('x').closest('div');
expect(wrapper.className).toContain('border-b');
expect(wrapper.className).not.toContain('rounded');
expect(screen.getByText('x').className).toContain('text-sm');
// Buttons keep the shared (box) styling — filled confirm + ghost cancel with hover.
expect(screen.getByRole('button', { name: 'Delete' }).className).toContain('bg-port-error');
expect(screen.getByRole('button', { name: 'Cancel' }).className).toContain('hover:text-white');
});
it('is not focusable by default', () => {
render(<InlineConfirmRow question="x" />);
const wrapper = screen.getByText('x').closest('div');
expect(wrapper.hasAttribute('tabindex')).toBe(false);
expect(document.activeElement).toBe(document.body);
});
it('focuses the row (never the destructive button) when autoFocus is set', () => {
render(<InlineConfirmRow question="x" autoFocus aria-label="Confirm deletion of Thing" />);
const wrapper = screen.getByText('x').closest('div');
expect(wrapper.getAttribute('tabindex')).toBe('-1');
expect(document.activeElement).toBe(wrapper);
expect(document.activeElement).not.toBe(screen.getByRole('button', { name: 'Delete' }));
});
it('falls back to the box variant for an unknown variant value', () => {
render(<InlineConfirmRow question="x" variant="bogus" />);
const wrapper = screen.getByText('x').closest('div');
expect(wrapper.className).toContain('rounded');
expect(wrapper.className).not.toContain('border-b');
});
});