Skip to content

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

Merge branch 'master' into feat/studio-logs-page-query-params

TzeYiing3f87d1d52b9b
diff --cc studio/tests/pages/projects/logs.test.js
index 089b432f055,5d963b3df15..7f2e343ccdb
--- a/studio/tests/pages/projects/logs.test.js
+++ b/studio/tests/pages/projects/logs.test.js
@@@ -163,25 -201,43 +201,67 @@@ test('where clause will trigger a log r
await waitFor(() => screen.getByText(/happened/))
})
+
++
+test('search= query param will populate the search bar', async () => {
+ useRouter.mockReturnValue({
+ query: { ref: '123', type: 'api', search: 'someSearch' },
+ })
+ render(<LogPage />)
+ // should populate input with the search query param
+ screen.getByDisplayValue('someSearch')
+})
+
+test('query= query param will populate the query input', async () => {
+ useRouter.mockReturnValue({
+ query: { ref: '123', type: 'api', query: 'some query', search: 'someSearch' },
+ })
+ render(<LogPage />)
+ // should populate input with the search query param
+ screen.getByText(/some query/)
+ let editor = container.querySelector('.monaco-editor')
+ expect(editor).toBeTruthy()
+ screen.getByText(/some query/)
+ // query takes precedence of search queryparam
+ expect(() => screen.getByDisplayValue(/someSearch/)).toThrow()
+})
++
+ test('load older btn will fetch older logs', async () => {
+ get.mockImplementation((url) => {
+ if (url.includes('count')) {
+ return {}
+ }
+ return {
+ data: [
+ {
+ id: 'some-uuid',
+ timestamp: 1621323232312,
+ event_message: 'first event',
+ metadata: {},
+ },
+ ],
+ }
+ })
+ render(<LogPage />)
+ // should display first log but not second
+ await waitFor(() => screen.getByText('first event'))
+ expect(() => screen.getByText('second event')).toThrow()
+
+ get.mockResolvedValueOnce({
+ data: [
+ {
+ id: 'some-uuid2',
+ timestamp: 1621323232310,
+ event_message: 'second event',
+ metadata: {},
+ },
+ ],
+ })
+ // should display first and second log
+ userEvent.click(screen.getByText('Load older'))
+ await waitFor(() => screen.getByText('first event'))
+ await waitFor(() => {
+ expect(get).toHaveBeenCalledWith(expect.stringContaining('timestamp_end=1'))
+ })
+ await waitFor(() => screen.getByText('second event'))
+ })