fix(D3): derive ticker exchange label from profile

This commit is contained in:
Saravana Achu Mac 2026-05-04 17:43:20 -07:00
parent 91bf41f319
commit 1e502b9f90
2 changed files with 15 additions and 4 deletions

View File

@ -85,7 +85,7 @@ describe('TickerHeader', () => {
});
it('opens watchlist and alerts routes from header actions', async () => {
fetchResearchProfileMock.mockResolvedValue({ companyName: 'Apple Inc.' });
fetchResearchProfileMock.mockResolvedValue({ companyName: 'Apple Inc.', exchangeShortName: 'NYSE' });
const user = userEvent.setup();
const firstRender = renderTickerHeader();
@ -112,7 +112,7 @@ describe('TickerHeader', () => {
});
it('shows the latest chart bar timestamp instead of the render time', async () => {
fetchResearchProfileMock.mockResolvedValue({ companyName: 'Apple Inc.' });
fetchResearchProfileMock.mockResolvedValue({ companyName: 'Apple Inc.', exchangeShortName: 'NYSE' });
fetchChartBarsMock.mockResolvedValueOnce([
{ ts: Date.UTC(2024, 0, 3, 19, 30), open: 210, high: 213, low: 209, close: 212, volume: 1000 },
{ ts: Date.UTC(2024, 0, 3, 20, 30), open: 212, high: 214, low: 211, close: 213, volume: 1200 },
@ -122,10 +122,18 @@ describe('TickerHeader', () => {
expect(screen.getByText(/Latest bar pending ET/)).toBeInTheDocument();
await waitFor(() => {
expect(screen.getByText(/Jan 3, 2024, 03:30 PM ET · NASDAQ/)).toBeInTheDocument();
expect(screen.getByText(/Jan 3, 2024, 03:30 PM ET · NYSE/)).toBeInTheDocument();
});
});
it('falls back to a neutral exchange marker when profile exchange is unavailable', async () => {
fetchResearchProfileMock.mockResolvedValue({ companyName: 'Apple Inc.' });
renderTickerHeader();
await waitFor(() => expect(screen.getByText(/Latest bar pending ET · —/)).toBeInTheDocument());
});
it('derives quick stats from chart bars for symbols missing bot indicators', async () => {
fetchResearchProfileMock.mockResolvedValue({ companyName: 'Microsoft Corporation' });
fetchChartBarsMock.mockResolvedValueOnce(

View File

@ -188,6 +188,9 @@ export function TickerHeader({
const positive = change >= 0;
const company = profile?.companyName;
const companyName = typeof company === 'string' && company.trim() ? company.trim() : symbol;
const exchange = typeof profile?.exchangeShortName === 'string' && profile.exchangeShortName.trim()
? profile.exchangeShortName.trim()
: '—';
return (
<div style={{ marginBottom: 16 }}>
@ -239,7 +242,7 @@ export function TickerHeader({
</div>
<div style={{ fontSize: 11, color: '#9CA3AF', marginTop: 3 }}>
{formatAsOfTimestamp(latestBarTimestamp ?? null)} ET · NASDAQ
{formatAsOfTimestamp(latestBarTimestamp ?? null)} ET · {exchange}
</div>
</div>
);