|
|
|
|
@ -5,7 +5,7 @@ import { useParams } from 'react-router-dom-v5-compat'; |
|
|
|
|
import { TestProvider } from 'test/helpers/TestProvider'; |
|
|
|
|
import { getGrafanaContextMock } from 'test/mocks/getGrafanaContextMock'; |
|
|
|
|
|
|
|
|
|
import { PanelProps } from '@grafana/data'; |
|
|
|
|
import { PanelProps, systemDateFormats, SystemDateFormatsState } from '@grafana/data'; |
|
|
|
|
import { getPanelPlugin } from '@grafana/data/test'; |
|
|
|
|
import { selectors } from '@grafana/e2e-selectors'; |
|
|
|
|
import { |
|
|
|
|
@ -229,6 +229,42 @@ describe('DashboardScenePage', () => { |
|
|
|
|
expect(await screen.findByTitle('Panel B')).toBeInTheDocument(); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
describe('absolute time range', () => { |
|
|
|
|
it('should render with absolute time range when use_browser_locale is true', async () => { |
|
|
|
|
locationService.push('/d/my-dash-uid?from=2025-03-11T07:09:37.253Z&to=2025-03-12T07:09:37.253Z'); |
|
|
|
|
systemDateFormats.update({ |
|
|
|
|
fullDate: 'YYYY-MM-DD HH:mm:ss.SSS', |
|
|
|
|
interval: {} as SystemDateFormatsState['interval'], |
|
|
|
|
useBrowserLocale: true, |
|
|
|
|
}); |
|
|
|
|
setup(); |
|
|
|
|
|
|
|
|
|
await waitForDashboardToRenderWithTimeRange({ |
|
|
|
|
from: '03/11/2025, 02:09:37 AM', |
|
|
|
|
to: '03/12/2025, 02:09:37 AM', |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should render correct time range when use_browser_locale is true and time range is other than default system date format', async () => { |
|
|
|
|
locationService.push('/d/my-dash-uid?from=2025-03-11T07:09:37.253Z&to=2025-03-12T07:09:37.253Z'); |
|
|
|
|
// mocking navigator.languages to return 'de'
|
|
|
|
|
// this property configured in the browser settings
|
|
|
|
|
Object.defineProperty(navigator, 'languages', { value: ['de'] }); |
|
|
|
|
systemDateFormats.update({ |
|
|
|
|
// left fullDate empty to show that this should be overridden by the browser locale
|
|
|
|
|
fullDate: '', |
|
|
|
|
interval: {} as SystemDateFormatsState['interval'], |
|
|
|
|
useBrowserLocale: true, |
|
|
|
|
}); |
|
|
|
|
setup(); |
|
|
|
|
|
|
|
|
|
await waitForDashboardToRenderWithTimeRange({ |
|
|
|
|
from: '11.03.2025, 02:09:37', |
|
|
|
|
to: '12.03.2025, 02:09:37', |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
describe('empty state', () => { |
|
|
|
|
it('Shows empty state when dashboard is empty', async () => { |
|
|
|
|
loadDashboardMock.mockResolvedValue({ dashboard: { uid: 'my-dash-uid', panels: [] }, meta: {} }); |
|
|
|
|
@ -373,3 +409,8 @@ async function waitForDashboardToRender() { |
|
|
|
|
expect(await screen.findByText('Last 6 hours')).toBeInTheDocument(); |
|
|
|
|
expect(await screen.findByTitle('Panel A')).toBeInTheDocument(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async function waitForDashboardToRenderWithTimeRange(timeRange: { from: string; to: string }) { |
|
|
|
|
expect(await screen.findByText(`${timeRange.from} to ${timeRange.to}`)).toBeInTheDocument(); |
|
|
|
|
expect(await screen.findByTitle('Panel A')).toBeInTheDocument(); |
|
|
|
|
} |
|
|
|
|
|