Skip to content

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

split up tests to reduce flakiness

TzeYiing1084cf1c1175
diff --git a/studio/tests/pages/projects/LogPanel.test.js b/studio/tests/pages/projects/LogPanel.test.js
index b707a7303c0..581ec8605df 100644
--- a/studio/tests/pages/projects/LogPanel.test.js
+++ b/studio/tests/pages/projects/LogPanel.test.js
@@ -72,29 +72,34 @@ test('timestamp from filter default value', async () => {
render(<LogPanel defaultFromValue="2022-01-18T10:43:39+0000" />)
userEvent.click(await screen.findByText('Custom'))
await screen.findByDisplayValue('2022-01-18T10:43:39+0000')
+ // TODO: use screen.findByLabelText when https://github.com/supabase/ui/issues/310 is resolved
+ await screen.findByText('From')
+ await screen.findByTitle('Reset')
})
-test('timestamp from filter', async () => {
+
+test('timestamp from filter error handling', async () => {
const mockFn = jest.fn()
render(<LogPanel onSearch={mockFn} />)
- const dropdown = await screen.findByText(/Now/)
-
- // click the dropdown
- userEvent.click(dropdown)
+ userEvent.click(await screen.findByText(/Now/))
- // TODO: use screen.findByLabelText when https://github.com/supabase/ui/issues/310 is resolved
- await screen.findByText('From')
// display iso timestamp
const year = new Date().getFullYear()
const input = await screen.findByDisplayValue(RegExp(year))
-
- // replace the input's value
userEvent.clear(input)
-
- // type some random input to check for error handling
userEvent.type(input, '123456')
await screen.findByText(/[iI]nvalid ISO 8601 timestamp/)
+})
+
+test('timestamp from filter value change', async () => {
+ const mockFn = jest.fn()
+ render(<LogPanel onSearch={mockFn} />)
+ userEvent.click(await screen.findByText(/Now/))
+ // display iso timestamp
+ const year = new Date().getFullYear()
+ const input = await screen.findByDisplayValue(RegExp(year))
+
+ // replace the input's value
userEvent.clear(input)
- await expect(screen.findByText(/[iI]nvalid ISO 8601 timestamp/)).rejects.toThrow()
// get time 20 mins before
const newDate = new Date()
@@ -102,7 +107,6 @@ test('timestamp from filter', async () => {
userEvent.type(input, newDate.toISOString())
// input actions
- await screen.findByTitle('Reset')
const set = await screen.findByRole('button', { name: 'Set' })
userEvent.click(set)