Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

test(logs): regression coverage for datepicker Invalid time value crash (#48027)

Jordi Enric4fa3169e8e58
diff --git a/apps/studio/tests/features/logs/Logs.Datepickers.test.tsx b/apps/studio/tests/features/logs/Logs.Datepickers.test.tsx
index 9d61d27c80f..654a4d52a8c 100644
--- a/apps/studio/tests/features/logs/Logs.Datepickers.test.tsx
+++ b/apps/studio/tests/features/logs/Logs.Datepickers.test.tsx
@@ -296,6 +296,19 @@ test('passing a value prop shows the correct dates in the label', async () => {
)
})
+test('opening with an unparseable date value (legacy epoch-ms its/ite) does not crash', async () => {
+ render(
+ <LogsDatePicker
+ helpers={[]}
+ value={{ from: '1784211420000', to: '1784211540000' }}
+ onSubmit={mockFn}
+ />
+ )
+
+ await userEvent.click(await screen.findByRole('button'))
+ expect(await screen.findByText('Apply')).toBeInTheDocument()
+})
+
test('passing a helper as a value prop shows the helper text in the label', async () => {
const helper = {
text: 'Last 7 days',
diff --git a/apps/studio/tests/features/logs/LogsPreviewer.test.tsx b/apps/studio/tests/features/logs/LogsPreviewer.test.tsx
index 8fc1356ea5c..fb0255f262c 100644
--- a/apps/studio/tests/features/logs/LogsPreviewer.test.tsx
+++ b/apps/studio/tests/features/logs/LogsPreviewer.test.tsx
@@ -140,6 +140,20 @@ test('can click load older', async () => {
expect(handleClick).toHaveBeenCalled()
})
+test('loads its/ite from the URL into the date picker and opens without crashing', async () => {
+ const its = dayjs('2024-01-15T12:00:00.000Z')
+ const ite = dayjs('2024-01-15T12:02:00.000Z')
+
+ customRender(
+ <LogsPreviewer queryType="api" projectRef="default" tableName={LogsTableName.EDGE} />,
+ { nuqs: { searchParams: { its: its.toISOString(), ite: ite.toISOString() } } }
+ )
+
+ const label = `${its.format('DD MMM, HH:mm')} - ${ite.format('DD MMM, HH:mm')}`
+ await userEvent.click(await screen.findByText(label))
+ expect(await screen.findByText('Apply')).toBeInTheDocument()
+})
+
describe('calculateBarClickTimeRange', () => {
const clickedTime = '2024-01-15T12:30:00.000Z'