|
| 1 | +/** |
| 2 | + * ObjectUI |
| 3 | + * Copyright (c) 2024-present ObjectStack Inc. |
| 4 | + * |
| 5 | + * ADR-0052 ActivityPointer: a timeline row carrying a `sourceObject`/`sourceId` |
| 6 | + * pointer (e.g. an email derived from a `sys_email` row) renders a "view source" |
| 7 | + * link so the user can drill from the one-line summary to the full record. |
| 8 | + */ |
| 9 | +import { describe, it, expect } from 'vitest'; |
| 10 | +import { render, screen } from '@testing-library/react'; |
| 11 | +import { RecordActivityTimeline } from '../RecordActivityTimeline'; |
| 12 | +import type { FeedItem } from '@object-ui/types'; |
| 13 | + |
| 14 | +describe('RecordActivityTimeline — source drill link (ADR-0052 ActivityPointer)', () => { |
| 15 | + it('renders a "view source" link to the source entity when sourceObject/sourceId are present', () => { |
| 16 | + const items: FeedItem[] = [ |
| 17 | + { |
| 18 | + id: 'act-1', |
| 19 | + type: 'comment', |
| 20 | + actor: 'System', |
| 21 | + body: 'Email: Q3 proposal', |
| 22 | + createdAt: new Date().toISOString(), |
| 23 | + sourceObject: 'sys_email', |
| 24 | + sourceId: 'email-123', |
| 25 | + }, |
| 26 | + ]; |
| 27 | + render(<RecordActivityTimeline items={items} />); |
| 28 | + const link = screen.getByTestId('activity-source-link') as HTMLAnchorElement; |
| 29 | + expect(link).toBeTruthy(); |
| 30 | + expect(link.getAttribute('href')).toBe('/objects/sys_email/email-123'); |
| 31 | + }); |
| 32 | + |
| 33 | + it('renders no source link when the activity has no source pointer', () => { |
| 34 | + const items: FeedItem[] = [ |
| 35 | + { |
| 36 | + id: 'act-2', |
| 37 | + type: 'comment', |
| 38 | + actor: 'System', |
| 39 | + body: 'Status: To Do → Done', |
| 40 | + createdAt: new Date().toISOString(), |
| 41 | + }, |
| 42 | + ]; |
| 43 | + render(<RecordActivityTimeline items={items} />); |
| 44 | + expect(screen.queryByTestId('activity-source-link')).toBeNull(); |
| 45 | + }); |
| 46 | +}); |
0 commit comments