import { describe, expect, it } from 'vitest'; import { Chip, ChipRow, DiscoverGrid, DiscoverMap, DiscoverProfileCard, } from './discover'; import { SelectRow, TextField } from './forms'; import { ChatInboxCapabilities, EmptyState, FlashInboxCapabilities, FloatingCreateMenu, InboxHubChrome, InboxPersonRow, InboxSearchField, ProfileVisitsCapabilities, SegmentedTabs, } from './inbox'; import { AlbumDetail, AlbumGrid, ChatGroupAddMembers, ChatGroupCreate, ChatGroupInfo, ChatGroupInvite, ChatThread, DiscoverBrowseLocation, NewPostComposer, NewStoryComposer, StoryViewersPanel, PostComments, ProfileOnboarding, ProfileReport, ProfileSelf, ProfileSetup, ProfileView, SettingsHome, SettingsPage, SocialPostFeed, SocialProfile, ThoughtFeed, } from './native-blocks'; import { ProfileCompletionBanner, StoryRail } from './social'; import { Button, Card, Column, InfoBanner, ListItem, NativeAd, Row, Screen, Scroll, SectionHeader, Spacer, Text, ToggleRow, screenProps, } from './ui'; describe('bdc ui components', () => { it('builds layout and leaf blocks', () => { expect(Screen({ id: 'demo', children: [] })).toMatchObject({ type: 'screen' }); expect(Column({ gap: 8, children: [] }).type).toBe('column'); expect(Row({}).type).toBe('row'); expect(Scroll({}).type).toBe('scroll'); expect(Spacer({ height: 12 }).type).toBe('spacer'); expect(Text({ text: 'hi' }).type).toBe('text'); expect(Button({ actionId: 'go', label: 'Go' }).type).toBe('button'); expect(InfoBanner({ message: 'msg' }).type).toBe('info_banner'); expect(NativeAd({ placement: 'home' }).type).toBe('native_ad'); expect(Card({}).type).toBe('card'); expect(SectionHeader({ title: 'T' }).type).toBe('section_header'); expect(ListItem({ title: 'Item' }).type).toBe('list_item'); expect(ToggleRow({ label: 'On' }).type).toBe('toggle_row'); expect(screenProps({ id: 'x' })).toEqual({ id: 'x' }); }); }); describe('bdc discover/forms/social/inbox/native', () => { it('builds discover and form blocks', () => { expect(Chip({ label: 'All' }).type).toBe('chip'); expect(ChipRow({}).type).toBe('chip_row'); expect(DiscoverGrid({ itemsRef: 'items' }).type).toBe('discover_grid'); expect(DiscoverProfileCard({ profileRef: 'p' }).type).toBe('discover_profile_card'); expect(DiscoverMap({}).type).toBe('discover_map'); expect(TextField({ placeholder: 'x' }).type).toBe('text_field'); expect(SelectRow({ label: 'Pick', optionsRef: 'form_options.gender' }).type).toBe('select_row'); expect(StoryRail({ surface: 'discover' }).type).toBe('story_rail'); expect(ProfileCompletionBanner({}).type).toBe('profile_completion_banner'); }); it('builds inbox blocks and normalizes floating menu actions', () => { expect(SegmentedTabs({}).type).toBe('segmented_tabs'); expect(EmptyState({ title: 'Empty' }).type).toBe('empty_state'); expect(InboxPersonRow({ variant: 'chat', rowRef: 'r' }).type).toBe('inbox_person_row'); expect(InboxSearchField({ placeholder: 'q' }).type).toBe('inbox_search_field'); expect(ChatInboxCapabilities({}).type).toBe('chat_inbox_capabilities'); expect(FlashInboxCapabilities({}).type).toBe('flash_inbox_capabilities'); expect(ProfileVisitsCapabilities({}).type).toBe('profile_visits_capabilities'); expect(InboxHubChrome({}).type).toBe('inbox_hub_chrome'); expect(InboxHubChrome({}).props).toMatchObject({ hub_ref: 'hub', active_filter_ref: 'active_filter', }); const menu = FloatingCreateMenu({ id: 'fab', closedLabel: '+', actions: [{ id: 'a1', label: 'Post', actionId: 'create_post', tone: 'primary', icon: 'plus' }], }); expect(menu.type).toBe('floating_create_menu'); expect(menu.props.actions).toEqual([ { id: 'a1', label: 'Post', tone: 'primary', icon: 'plus', action_id: 'create_post' }, ]); expect(FloatingCreateMenu({ actions: [] }).props).not.toHaveProperty('id'); }); it('builds all native hybrid blocks', () => { const natives = [ ChatThread, SocialPostFeed, ThoughtFeed, ProfileView, ProfileSelf, ProfileSetup, ProfileOnboarding, ProfileReport, AlbumGrid, AlbumDetail, NewPostComposer, NewStoryComposer, StoryViewersPanel, PostComments, SocialProfile, SettingsHome, SettingsPage, ChatGroupCreate, ChatGroupInfo, ChatGroupAddMembers, ChatGroupInvite, DiscoverBrowseLocation, ]; for (const Comp of natives) { const el = Comp({ id: 'n1' }); expect(el.children).toEqual([]); expect(typeof el.type).toBe('string'); } }); });