Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

1.9 KB
Raw Blame
/**
 * @vitest-environment happy-dom
 */
import { render, screen } from '@testing-library/react';
import { describe, expect, it } from 'vitest';

import VisibilityConfirmContent from './index';

describe('VisibilityConfirmContent', () => {
  it('renders 3 makePrivate items in escalation order with an irreversible suffix on the last', () => {
    render(<VisibilityConfirmContent variant="makePrivate" />);
    // All three item text keys should surface as the last two direct-child spans
    // in each <li>. We assert by looking up the concrete i18n key strings.
    expect(screen.getByText('visibilityConfirm.makePrivate.itemAccess')).toBeTruthy();
    expect(screen.getByText('visibilityConfirm.makePrivate.itemReferences')).toBeTruthy();
    expect(screen.getByText('visibilityConfirm.makePrivate.itemLoaded')).toBeTruthy();
    // The irreversible tag should render exactly once, next to the last item.
    expect(screen.getAllByText('visibilityConfirm.irreversible')).toHaveLength(1);
  });

  it('renders 3 publish items — visible / reversible / irreversible-tail', () => {
    render(<VisibilityConfirmContent variant="publish" />);
    expect(screen.getByText('visibilityConfirm.publish.itemVisible')).toBeTruthy();
    expect(screen.getByText('visibilityConfirm.publish.itemReversible')).toBeTruthy();
    expect(screen.getByText('visibilityConfirm.publish.itemLoaded')).toBeTruthy();
    expect(screen.getAllByText('visibilityConfirm.irreversible')).toHaveLength(1);
  });

  // Publishing no longer asks for member permissions up front —
  // the resource lands on the workspace default and the owner tunes it later
  // from the resource's own "Member Permissions" entry.
  it('does not render a member-permission select when publishing', () => {
    render(<VisibilityConfirmContent variant="publish" />);
    expect(screen.queryByText('permission.generalAccess.label')).toBeNull();
  });
});