mirror of
https://github.com/stablyai/orca.git
synced 2026-10-30 08:37:49 +00:00
feat(native-chat): show the full date and time when hovering a message timestamp (#32051)
Message timestamps render time-only; the full localized date and time was only exposed via aria-label. Wrap the <time> element in the shared Tooltip so hover and keyboard focus reveal the same full label, without adding a duplicate aria-describedby announcement. Transcript render tests now go through a TooltipProvider harness, matching App's production provider. Co-authored-by: Neil <4138956+nwparker@users.noreply.github.com>
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
// @vitest-environment happy-dom
|
||||
import '@testing-library/jest-dom/vitest'
|
||||
import { cleanup, fireEvent, render, screen } from '@testing-library/react'
|
||||
import { cleanup, fireEvent, screen } from '@testing-library/react'
|
||||
import { render } from './native-chat-tooltip-test-harness'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import type { AgentMessageSource } from '../../../../shared/agent-session/agent-session-message-source'
|
||||
import type { NativeChatMessage } from '../../../../shared/native-chat-types'
|
||||
import { MessageRow } from './NativeChatMessageRow'
|
||||
import { NativeChatQueuedMessageCard } from './NativeChatQueuedMessageCard'
|
||||
import { TooltipProvider } from '@/components/ui/tooltip'
|
||||
|
||||
const openAgentMessageSender = vi.hoisted(() => vi.fn(async () => {}))
|
||||
vi.mock('@/lib/open-agent-message-sender', () => ({ openAgentMessageSender }))
|
||||
@@ -126,24 +126,22 @@ describe("another agent's message in the transcript", () => {
|
||||
describe("another agent's queued card", () => {
|
||||
function renderCard(source: AgentMessageSource, chatWorktreeId: string | null = 'wt-chat') {
|
||||
return render(
|
||||
<TooltipProvider>
|
||||
<NativeChatQueuedMessageCard
|
||||
card={{
|
||||
messageId: 'card',
|
||||
position: 1,
|
||||
text: 'You have 1 orchestration message.',
|
||||
state: 'waiting',
|
||||
hold: 'turn',
|
||||
from: source
|
||||
}}
|
||||
chatWorktreeId={chatWorktreeId}
|
||||
showsSteerShortcut={false}
|
||||
onSteer={vi.fn()}
|
||||
onDelete={vi.fn()}
|
||||
onEdit={vi.fn()}
|
||||
onTurnOffQueueing={vi.fn()}
|
||||
/>
|
||||
</TooltipProvider>
|
||||
<NativeChatQueuedMessageCard
|
||||
card={{
|
||||
messageId: 'card',
|
||||
position: 1,
|
||||
text: 'You have 1 orchestration message.',
|
||||
state: 'waiting',
|
||||
hold: 'turn',
|
||||
from: source
|
||||
}}
|
||||
chatWorktreeId={chatWorktreeId}
|
||||
showsSteerShortcut={false}
|
||||
onSteer={vi.fn()}
|
||||
onDelete={vi.fn()}
|
||||
onEdit={vi.fn()}
|
||||
onTurnOffQueueing={vi.fn()}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
// @vitest-environment happy-dom
|
||||
|
||||
import { act, cleanup, fireEvent, render, screen } from '@testing-library/react'
|
||||
import { act, cleanup, fireEvent, screen } from '@testing-library/react'
|
||||
import { render } from './native-chat-tooltip-test-harness'
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { createGlobalSettingsFixture } from '../../../../shared/global-settings-test-fixture'
|
||||
import { useAppStore } from '../../store'
|
||||
|
||||
+2
-1
@@ -1,4 +1,5 @@
|
||||
import { act, fireEvent, render, screen } from '@testing-library/react'
|
||||
import { act, fireEvent, screen } from '@testing-library/react'
|
||||
import { render } from './native-chat-tooltip-test-harness'
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
import type { NativeChatMessage } from '../../../../shared/native-chat-types'
|
||||
|
||||
+2
-1
@@ -2,7 +2,8 @@
|
||||
|
||||
import '@testing-library/jest-dom/vitest'
|
||||
|
||||
import { cleanup, fireEvent, render, screen, within } from '@testing-library/react'
|
||||
import { cleanup, fireEvent, screen, within } from '@testing-library/react'
|
||||
import { render } from './native-chat-tooltip-test-harness'
|
||||
import { afterAll, afterEach, beforeAll, describe, expect, it, vi } from 'vitest'
|
||||
import type {
|
||||
AgentJournalItemBody,
|
||||
|
||||
+2
-1
@@ -2,7 +2,8 @@
|
||||
|
||||
import '@testing-library/jest-dom/vitest'
|
||||
|
||||
import { act, cleanup, render, screen } from '@testing-library/react'
|
||||
import { act, cleanup, screen } from '@testing-library/react'
|
||||
import { render } from './native-chat-tooltip-test-harness'
|
||||
import { createRef } from 'react'
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import type { NativeChatMessage } from '../../../../shared/native-chat-types'
|
||||
|
||||
+2
-1
@@ -2,7 +2,8 @@
|
||||
|
||||
import '@testing-library/jest-dom/vitest'
|
||||
|
||||
import { act, cleanup, fireEvent, render, screen } from '@testing-library/react'
|
||||
import { act, cleanup, fireEvent, screen } from '@testing-library/react'
|
||||
import { render } from './native-chat-tooltip-test-harness'
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
// Why: these fixtures have neither inline visual owners nor sender navigation.
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
// Queued sends wait after the opening turn’s live status until actual handover, including across Stop.
|
||||
|
||||
import '@testing-library/jest-dom/vitest'
|
||||
import { cleanup, render, screen } from '@testing-library/react'
|
||||
import { cleanup, screen } from '@testing-library/react'
|
||||
import { render } from './native-chat-tooltip-test-harness'
|
||||
import { afterAll, afterEach, beforeAll, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
// Why: these fixtures have neither inline visual owners nor sender navigation.
|
||||
|
||||
+2
-1
@@ -2,7 +2,8 @@
|
||||
|
||||
import '@testing-library/jest-dom/vitest'
|
||||
|
||||
import { cleanup, render, screen } from '@testing-library/react'
|
||||
import { cleanup, screen } from '@testing-library/react'
|
||||
import { render } from './native-chat-tooltip-test-harness'
|
||||
import { afterAll, afterEach, beforeAll, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
// Why: these fixtures have neither inline visual owners nor sender navigation.
|
||||
|
||||
+2
-1
@@ -2,7 +2,8 @@
|
||||
|
||||
import '@testing-library/jest-dom/vitest'
|
||||
|
||||
import { act, cleanup, fireEvent, render, screen } from '@testing-library/react'
|
||||
import { act, cleanup, fireEvent, screen } from '@testing-library/react'
|
||||
import { render } from './native-chat-tooltip-test-harness'
|
||||
import { useCallback, useMemo, useState } from 'react'
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
|
||||
+2
-1
@@ -1,4 +1,5 @@
|
||||
import { act, fireEvent, render, screen } from '@testing-library/react'
|
||||
import { act, fireEvent, screen } from '@testing-library/react'
|
||||
import { render } from './native-chat-tooltip-test-harness'
|
||||
import { createRef } from 'react'
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
import '@testing-library/jest-dom/vitest'
|
||||
|
||||
import { cleanup, fireEvent, render, screen } from '@testing-library/react'
|
||||
import { cleanup, fireEvent, screen } from '@testing-library/react'
|
||||
import { render } from './native-chat-tooltip-test-harness'
|
||||
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
// Why: these fixtures have neither inline visual owners nor sender navigation.
|
||||
|
||||
+2
-1
@@ -2,7 +2,8 @@
|
||||
|
||||
import '@testing-library/jest-dom/vitest'
|
||||
|
||||
import { cleanup, fireEvent, render, screen, within, act } from '@testing-library/react'
|
||||
import { cleanup, fireEvent, screen, within, act } from '@testing-library/react'
|
||||
import { render } from './native-chat-tooltip-test-harness'
|
||||
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
import '@testing-library/jest-dom/vitest'
|
||||
|
||||
import { cleanup, fireEvent, render, screen } from '@testing-library/react'
|
||||
import { cleanup, fireEvent, screen } from '@testing-library/react'
|
||||
import { render } from './native-chat-tooltip-test-harness'
|
||||
|
||||
import { afterAll, afterEach, beforeAll, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
|
||||
+2
-1
@@ -1,5 +1,6 @@
|
||||
// @vitest-environment happy-dom
|
||||
import { cleanup, render, screen } from '@testing-library/react'
|
||||
import { cleanup, screen } from '@testing-library/react'
|
||||
import { render } from './native-chat-tooltip-test-harness'
|
||||
import { afterAll, afterEach, beforeAll, expect, it, vi } from 'vitest'
|
||||
|
||||
// Why: these fixtures have neither inline visual owners nor sender navigation.
|
||||
|
||||
+2
-1
@@ -2,7 +2,8 @@
|
||||
|
||||
import '@testing-library/jest-dom/vitest'
|
||||
|
||||
import { cleanup, fireEvent, render, screen } from '@testing-library/react'
|
||||
import { cleanup, fireEvent, screen } from '@testing-library/react'
|
||||
import { render } from './native-chat-tooltip-test-harness'
|
||||
import { afterAll, afterEach, beforeAll, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
// Why: these fixtures have neither inline visual owners nor sender navigation.
|
||||
|
||||
+2
-1
@@ -2,7 +2,8 @@
|
||||
|
||||
import '@testing-library/jest-dom/vitest'
|
||||
|
||||
import { cleanup, render, screen, fireEvent } from '@testing-library/react'
|
||||
import { cleanup, screen, fireEvent } from '@testing-library/react'
|
||||
import { render } from './native-chat-tooltip-test-harness'
|
||||
|
||||
import { afterAll, afterEach, beforeAll, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
|
||||
+16
-18
@@ -2,7 +2,8 @@
|
||||
|
||||
import '@testing-library/jest-dom/vitest'
|
||||
|
||||
import { cleanup, render, screen } from '@testing-library/react'
|
||||
import { cleanup, screen } from '@testing-library/react'
|
||||
import { render } from './native-chat-tooltip-test-harness'
|
||||
import { afterAll, afterEach, beforeAll, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
// Why: these fixtures have neither inline visual owners nor sender navigation.
|
||||
@@ -24,7 +25,6 @@ afterEach(() => {
|
||||
expect(unusedChatLeaves.inlineVisual).not.toHaveBeenCalled()
|
||||
expect(unusedChatLeaves.openSender).not.toHaveBeenCalled()
|
||||
})
|
||||
import { TooltipProvider } from '@/components/ui/tooltip'
|
||||
import { NativeChatOrcaStopContext } from './native-chat-orca-stop-context'
|
||||
import { agentSessionFailureWords } from '../../../../shared/agent-session-failure-words'
|
||||
import type {
|
||||
@@ -299,22 +299,20 @@ const usageLimitView = {
|
||||
}
|
||||
]
|
||||
render(
|
||||
<TooltipProvider>
|
||||
<NativeChatOrcaStopContext.Provider value={usageLimitView}>
|
||||
<NativeChatMessageList
|
||||
session={{
|
||||
...session,
|
||||
agent,
|
||||
status: 'ready',
|
||||
messages: projectStructuredAgentSessionMessages(items, [], [])
|
||||
}}
|
||||
journalItems={items}
|
||||
settledTurns={selectStructuredAgentSettledTurns(items)}
|
||||
isWorking={false}
|
||||
expandSignal={false}
|
||||
/>
|
||||
</NativeChatOrcaStopContext.Provider>
|
||||
</TooltipProvider>
|
||||
<NativeChatOrcaStopContext.Provider value={usageLimitView}>
|
||||
<NativeChatMessageList
|
||||
session={{
|
||||
...session,
|
||||
agent,
|
||||
status: 'ready',
|
||||
messages: projectStructuredAgentSessionMessages(items, [], [])
|
||||
}}
|
||||
journalItems={items}
|
||||
settledTurns={selectStructuredAgentSettledTurns(items)}
|
||||
isWorking={false}
|
||||
expandSignal={false}
|
||||
/>
|
||||
</NativeChatOrcaStopContext.Provider>
|
||||
)
|
||||
expect(screen.getByRole('button', { name: 'Toggle turn details' })).toHaveAttribute(
|
||||
'aria-expanded',
|
||||
|
||||
+2
-1
@@ -4,7 +4,8 @@
|
||||
|
||||
import '@testing-library/jest-dom/vitest'
|
||||
|
||||
import { cleanup, render } from '@testing-library/react'
|
||||
import { cleanup } from '@testing-library/react'
|
||||
import { render } from './native-chat-tooltip-test-harness'
|
||||
import { afterAll, afterEach, beforeAll, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
// Why: these fixtures have neither inline visual owners nor sender navigation.
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
import '@testing-library/jest-dom/vitest'
|
||||
|
||||
import { act, cleanup, fireEvent, render, screen } from '@testing-library/react'
|
||||
import { act, cleanup, fireEvent, screen } from '@testing-library/react'
|
||||
import { render } from './native-chat-tooltip-test-harness'
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
// Why: these fixtures have neither inline visual owners nor sender navigation.
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// @vitest-environment happy-dom
|
||||
import '@testing-library/jest-dom/vitest'
|
||||
import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react'
|
||||
import { cleanup, fireEvent, screen, waitFor } from '@testing-library/react'
|
||||
import { render } from './native-chat-tooltip-test-harness'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
// Why: these fixtures have neither inline visual owners nor sender navigation.
|
||||
@@ -24,7 +25,6 @@ afterEach(() => {
|
||||
})
|
||||
import type { NativeChatMessage } from '../../../../shared/native-chat-types'
|
||||
import { MessageRow, type NativeChatDeliveryNotice } from './NativeChatMessageRow'
|
||||
import { TooltipProvider } from '@/components/ui/tooltip'
|
||||
import type { NativeChatRewindSurface } from './use-native-chat-rewind'
|
||||
import { readNativeChatQuotableSelection } from './native-chat-quote-selection'
|
||||
|
||||
@@ -45,20 +45,18 @@ function renderMessage(
|
||||
rewind?: NativeChatRewindSurface
|
||||
) {
|
||||
return render(
|
||||
<TooltipProvider>
|
||||
<MessageRow
|
||||
message={{
|
||||
id: 'message',
|
||||
role,
|
||||
timestamp,
|
||||
source: 'transcript',
|
||||
blocks: [{ type: 'text', text: 'Message text' }]
|
||||
}}
|
||||
expandSignal={false}
|
||||
onScrollMessageToTop={vi.fn()}
|
||||
rewind={rewind}
|
||||
/>
|
||||
</TooltipProvider>
|
||||
<MessageRow
|
||||
message={{
|
||||
id: 'message',
|
||||
role,
|
||||
timestamp,
|
||||
source: 'transcript',
|
||||
blocks: [{ type: 'text', text: 'Message text' }]
|
||||
}}
|
||||
expandSignal={false}
|
||||
onScrollMessageToTop={vi.fn()}
|
||||
rewind={rewind}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -120,24 +118,22 @@ describe('MessageRow control visibility', () => {
|
||||
Object.assign(window, { api: { ui: { writeClipboardText } } })
|
||||
|
||||
render(
|
||||
<TooltipProvider>
|
||||
<MessageRow
|
||||
message={{
|
||||
id: 'message',
|
||||
role: 'assistant',
|
||||
timestamp: 0,
|
||||
source: 'transcript',
|
||||
blocks: [
|
||||
{
|
||||
type: 'text',
|
||||
text: 'Here it is.\n\n::orca-visual{file="usage.html" title="Usage"}\n\nDone.'
|
||||
}
|
||||
]
|
||||
}}
|
||||
expandSignal={false}
|
||||
onScrollMessageToTop={vi.fn()}
|
||||
/>
|
||||
</TooltipProvider>
|
||||
<MessageRow
|
||||
message={{
|
||||
id: 'message',
|
||||
role: 'assistant',
|
||||
timestamp: 0,
|
||||
source: 'transcript',
|
||||
blocks: [
|
||||
{
|
||||
type: 'text',
|
||||
text: 'Here it is.\n\n::orca-visual{file="usage.html" title="Usage"}\n\nDone.'
|
||||
}
|
||||
]
|
||||
}}
|
||||
expandSignal={false}
|
||||
onScrollMessageToTop={vi.fn()}
|
||||
/>
|
||||
)
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Copy message' }))
|
||||
|
||||
@@ -184,21 +180,19 @@ describe('MessageRow control visibility', () => {
|
||||
|
||||
it('holds the agent controls back until the turn stops working', () => {
|
||||
const row = (activeTurnIsWorking: boolean) => (
|
||||
<TooltipProvider>
|
||||
<MessageRow
|
||||
message={{
|
||||
id: 'message',
|
||||
role: 'assistant',
|
||||
timestamp: 0,
|
||||
source: 'transcript',
|
||||
blocks: [{ type: 'text', text: 'Message text' }]
|
||||
}}
|
||||
expandSignal={false}
|
||||
activeTurnIsWorking={activeTurnIsWorking}
|
||||
trailingRun
|
||||
onScrollMessageToTop={vi.fn()}
|
||||
/>
|
||||
</TooltipProvider>
|
||||
<MessageRow
|
||||
message={{
|
||||
id: 'message',
|
||||
role: 'assistant',
|
||||
timestamp: 0,
|
||||
source: 'transcript',
|
||||
blocks: [{ type: 'text', text: 'Message text' }]
|
||||
}}
|
||||
expandSignal={false}
|
||||
activeTurnIsWorking={activeTurnIsWorking}
|
||||
trailingRun
|
||||
onScrollMessageToTop={vi.fn()}
|
||||
/>
|
||||
)
|
||||
const { rerender } = render(row(true))
|
||||
expect(screen.getByText('Message text')).toBeInTheDocument()
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// @vitest-environment happy-dom
|
||||
import '@testing-library/jest-dom/vitest'
|
||||
import { cleanup, fireEvent, render, screen } from '@testing-library/react'
|
||||
import { cleanup, fireEvent, screen } from '@testing-library/react'
|
||||
import { render } from './native-chat-tooltip-test-harness'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
// Why: these fixtures have neither inline visual owners nor sender navigation.
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
// @vitest-environment happy-dom
|
||||
import '@testing-library/jest-dom/vitest'
|
||||
import { act, cleanup, render, screen } from '@testing-library/react'
|
||||
import { act, cleanup, screen } from '@testing-library/react'
|
||||
import userEvent from '@testing-library/user-event'
|
||||
import { afterEach, describe, expect, it } from 'vitest'
|
||||
import { i18n } from '@/i18n/i18n'
|
||||
import { NativeChatMessageTimestamp } from './NativeChatMessageTimestamp'
|
||||
import { render } from './native-chat-tooltip-test-harness'
|
||||
|
||||
const fullLabel = (timestamp: number): string =>
|
||||
new Intl.DateTimeFormat('en', { dateStyle: 'full', timeStyle: 'long' }).format(timestamp)
|
||||
|
||||
afterEach(async () => {
|
||||
cleanup()
|
||||
@@ -28,19 +33,27 @@ describe('NativeChatMessageTimestamp', () => {
|
||||
expect(time).toHaveTextContent(
|
||||
new Intl.DateTimeFormat('en', { hour: 'numeric', minute: '2-digit' }).format(timestamp)
|
||||
)
|
||||
expect(time).toHaveAccessibleName(
|
||||
new Intl.DateTimeFormat('en', { dateStyle: 'full', timeStyle: 'long' }).format(timestamp)
|
||||
)
|
||||
expect(time).toHaveAccessibleName(fullLabel(timestamp))
|
||||
expect(time).not.toHaveAttribute('tabindex')
|
||||
}
|
||||
)
|
||||
|
||||
it('provides a focus target only when requested for user metadata', () => {
|
||||
render(<NativeChatMessageTimestamp timestamp={0} focusable />)
|
||||
it('shows the full date and time on hover', async () => {
|
||||
const timestamp = Date.parse('2026-09-06T19:04:05Z')
|
||||
render(<NativeChatMessageTimestamp timestamp={timestamp} />)
|
||||
await userEvent.setup().hover(screen.getByRole('time'))
|
||||
expect(await screen.findByRole('tooltip')).toHaveTextContent(fullLabel(timestamp))
|
||||
})
|
||||
|
||||
it('names a focusable timestamp before focus and shows, not re-announces, the tooltip on focus', async () => {
|
||||
const timestamp = Date.parse('2026-09-06T19:04:05Z')
|
||||
render(<NativeChatMessageTimestamp timestamp={timestamp} focusable />)
|
||||
const time = screen.getByRole('time')
|
||||
time.focus()
|
||||
expect(time).toHaveAccessibleName(fullLabel(timestamp))
|
||||
await userEvent.setup().tab()
|
||||
expect(time).toHaveFocus()
|
||||
expect(time).toHaveAttribute('tabindex', '0')
|
||||
expect(await screen.findByRole('tooltip')).toHaveTextContent(fullLabel(timestamp))
|
||||
expect(time).not.toHaveAttribute('aria-describedby')
|
||||
})
|
||||
|
||||
it('updates settled time when the UI language changes without a parent rerender', async () => {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'
|
||||
import { getIntlLocale } from '@/i18n/i18n'
|
||||
import { cn } from '@/lib/utils'
|
||||
import {
|
||||
@@ -42,18 +43,27 @@ export function NativeChatMessageTimestamp({
|
||||
return null
|
||||
}
|
||||
const formatters = getTimestampFormatters()
|
||||
const fullLabel = formatters.full.format(date)
|
||||
|
||||
return (
|
||||
<time
|
||||
dateTime={date.toISOString()}
|
||||
aria-label={formatters.full.format(date)}
|
||||
tabIndex={focusable ? 0 : undefined}
|
||||
className={cn(
|
||||
'rounded-md text-xs whitespace-nowrap text-chat-foreground-faint tabular-nums focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring',
|
||||
className
|
||||
)}
|
||||
>
|
||||
{formatters.time.format(date)}
|
||||
</time>
|
||||
<Tooltip>
|
||||
{/* The label already carries the full date in every reading mode; the tooltip would repeat it. */}
|
||||
<TooltipTrigger asChild aria-describedby={undefined}>
|
||||
<time
|
||||
dateTime={date.toISOString()}
|
||||
aria-label={fullLabel}
|
||||
tabIndex={focusable ? 0 : undefined}
|
||||
className={cn(
|
||||
'rounded-md text-xs whitespace-nowrap text-chat-foreground-faint tabular-nums focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring',
|
||||
className
|
||||
)}
|
||||
>
|
||||
{formatters.time.format(date)}
|
||||
</time>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent side="top" sideOffset={4}>
|
||||
{fullLabel}
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
)
|
||||
}
|
||||
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
// @vitest-environment happy-dom
|
||||
import '@testing-library/jest-dom/vitest'
|
||||
import { cleanup, render, screen } from '@testing-library/react'
|
||||
import { cleanup, screen } from '@testing-library/react'
|
||||
import { render } from './native-chat-tooltip-test-harness'
|
||||
import { afterEach, describe, expect, it } from 'vitest'
|
||||
import type { AgentJournalQuestionItem } from '../../../../shared/agent-session-journal-types'
|
||||
import { NativeChatResolutionReceipt } from './NativeChatResolutionReceipt'
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// @vitest-environment happy-dom
|
||||
import '@testing-library/jest-dom/vitest'
|
||||
import { act, cleanup, fireEvent, render, screen } from '@testing-library/react'
|
||||
import { act, cleanup, fireEvent, screen } from '@testing-library/react'
|
||||
import { render } from './native-chat-tooltip-test-harness'
|
||||
import { afterEach, describe, expect, it } from 'vitest'
|
||||
import { i18n } from '@/i18n/i18n'
|
||||
import type {
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
// @vitest-environment happy-dom
|
||||
|
||||
import { afterEach, beforeEach, expect, it, vi } from 'vitest'
|
||||
import { cleanup, render, screen, waitFor } from '@testing-library/react'
|
||||
import { cleanup, screen, waitFor } from '@testing-library/react'
|
||||
import { render } from './native-chat-tooltip-test-harness'
|
||||
import type { NativeChatLiveSession } from './use-native-chat-live-session'
|
||||
import { resetLocalImageSrcStateForTests } from '@/components/editor/useLocalImageSrc'
|
||||
import { useAppStore } from '@/store'
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
import { render as renderUnwrapped, type RenderOptions } from '@testing-library/react'
|
||||
import { TooltipProvider } from '@/components/ui/tooltip'
|
||||
|
||||
// Transcript rows carry tooltips (message timestamps), which App's TooltipProvider supplies in production.
|
||||
export function render(ui: React.ReactElement, options?: Omit<RenderOptions, 'wrapper'>) {
|
||||
return renderUnwrapped(ui, { ...options, wrapper: TooltipProvider })
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import '@testing-library/jest-dom/vitest'
|
||||
|
||||
import { cleanup, fireEvent, render, screen } from '@testing-library/react'
|
||||
import { cleanup, fireEvent, screen } from '@testing-library/react'
|
||||
import { afterAll, afterEach, beforeAll, expect, it, vi } from 'vitest'
|
||||
|
||||
// Why: these fixtures have neither inline visual owners nor sender navigation.
|
||||
@@ -27,6 +27,7 @@ afterEach(() => {
|
||||
import { createElement } from 'react'
|
||||
import { NativeChatMessageList } from '../../src/renderer/src/components/native-chat/NativeChatMessageList'
|
||||
import { installNativeChatMessageListTestViewport } from '../../src/renderer/src/components/native-chat/native-chat-message-list-test-viewport'
|
||||
import { render } from '../../src/renderer/src/components/native-chat/native-chat-tooltip-test-harness'
|
||||
|
||||
let restoreViewport = (): void => {}
|
||||
beforeAll(() => {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import React from 'react'
|
||||
import { createRoot } from 'react-dom/client'
|
||||
import { TooltipProvider } from '@/components/ui/tooltip'
|
||||
import { NativeChatMessageList } from '../../../src/renderer/src/components/native-chat/NativeChatMessageList'
|
||||
import type { NativeChatMessage } from '../../../src/shared/native-chat-types'
|
||||
import './fixture.css'
|
||||
@@ -17,24 +18,26 @@ if (!root) {
|
||||
throw new Error('Missing fixture root')
|
||||
}
|
||||
createRoot(root).render(
|
||||
<main className="flex h-screen flex-col bg-background text-foreground">
|
||||
<header className="border-b border-border px-4 py-3 text-sm">OMP · Native chat</header>
|
||||
<div className="flex min-h-0 flex-1 flex-col">
|
||||
<NativeChatMessageList
|
||||
session={{
|
||||
agent: 'omp',
|
||||
sessionId: transcript.sessionId,
|
||||
status: 'ready',
|
||||
messages: transcript.messages,
|
||||
hasMore: false,
|
||||
loadingEarlier: false,
|
||||
olderHistoryGeneration: 0,
|
||||
loadEarlier: () => Promise.resolve('exhausted' as const),
|
||||
readPhase: 'ready'
|
||||
}}
|
||||
isWorking={false}
|
||||
expandSignal={false}
|
||||
/>
|
||||
</div>
|
||||
</main>
|
||||
<TooltipProvider delayDuration={400}>
|
||||
<main className="flex h-screen flex-col bg-background text-foreground">
|
||||
<header className="border-b border-border px-4 py-3 text-sm">OMP · Native chat</header>
|
||||
<div className="flex min-h-0 flex-1 flex-col">
|
||||
<NativeChatMessageList
|
||||
session={{
|
||||
agent: 'omp',
|
||||
sessionId: transcript.sessionId,
|
||||
status: 'ready',
|
||||
messages: transcript.messages,
|
||||
hasMore: false,
|
||||
loadingEarlier: false,
|
||||
olderHistoryGeneration: 0,
|
||||
loadEarlier: () => Promise.resolve('exhausted' as const),
|
||||
readPhase: 'ready'
|
||||
}}
|
||||
isWorking={false}
|
||||
expandSignal={false}
|
||||
/>
|
||||
</div>
|
||||
</main>
|
||||
</TooltipProvider>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user