The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
improve failing tests
Alaister Young9828b9ff06b9
diff --git a/studio/hooks/analytics/useLogsPreview.tsx b/studio/hooks/analytics/useLogsPreview.tsxindex 422d15b04a2..b1ad557de41 100644--- a/studio/hooks/analytics/useLogsPreview.tsx+++ b/studio/hooks/analytics/useLogsPreview.tsx@@ -85,7 +85,7 @@ function useLogsPreview({refetchOnWindowFocus: false,getNextPageParam(lastPage) {- if (lastPage.result.length === 0) {+ if ((lastPage?.result?.length ?? 0) === 0) {return undefined}const len = lastPage.result.lengthdiff --git a/studio/tests/components/Home/ProjectUsage.test.js b/studio/tests/components/Home/ProjectUsage.test.jsindex a8e250d3d3c..948f030f447 100644--- a/studio/tests/components/Home/ProjectUsage.test.js+++ b/studio/tests/components/Home/ProjectUsage.test.js@@ -100,7 +100,7 @@ test('dropdown options changes chart query', async () => {await waitFor(() => screen.getByText(/Statistics for past 24 hours/))await waitFor(() => screen.getAllByRole('button', { name: '24 hours' }))await waitFor(() => {- expect(get).toHaveBeenCalledWith(expect.stringContaining('interval=hourly'))+ expect(get).toHaveBeenCalledWith(expect.stringContaining('interval=hourly'), expect.anything())})// find button that has radix idconst [btn] = screen.getAllByRole('button', { name: '24 hours' }).filter((e) => e.id)@@ -111,5 +111,5 @@ test('dropdown options changes chart query', async () => {// simulate changing of dropdownuserEvent.click(screen.getByText(/60 minutes/))await waitFor(() => screen.getByText(/Statistics for past 60 minutes/))- expect(get).toHaveBeenCalledWith(expect.stringContaining('interval=minutely'))+ expect(get).toHaveBeenCalledWith(expect.stringContaining('interval=minutely'), expect.anything())})diff --git a/studio/tests/pages/projects/LogsPreviewer.test.js b/studio/tests/pages/projects/LogsPreviewer.test.jsindex c7f0aafd683..7f18517dafc 100644--- a/studio/tests/pages/projects/LogsPreviewer.test.js+++ b/studio/tests/pages/projects/LogsPreviewer.test.js@@ -139,8 +139,14 @@ test.each([render(<LogsPreviewer projectRef="123" queryType={queryType} tableName={tableName} />)await waitFor(() => {- expect(get).toHaveBeenCalledWith(expect.stringContaining('iso_timestamp_start'))- expect(get).not.toHaveBeenCalledWith(expect.stringContaining('iso_timestamp_end'))+ expect(get).toHaveBeenCalledWith(+ expect.stringContaining('iso_timestamp_start'),+ expect.anything()+ )+ expect(get).not.toHaveBeenCalledWith(+ expect.stringContaining('iso_timestamp_end'),+ expect.anything()+ )})// reset mock so that we can check for selection callget.mockClear()@@ -152,8 +158,14 @@ test.each([fireEvent.click(row)await waitFor(() => {- expect(get).toHaveBeenCalledWith(expect.stringContaining('iso_timestamp_start'))- expect(get).not.toHaveBeenCalledWith(expect.stringContaining('iso_timestamp_end'))+ expect(get).toHaveBeenCalledWith(+ expect.stringContaining('iso_timestamp_start'),+ expect.anything()+ )+ expect(get).not.toHaveBeenCalledWith(+ expect.stringContaining('iso_timestamp_end'),+ expect.anything()+ )})for (const text of selectionTexts) {@@ -177,7 +189,7 @@ test('Search will trigger a log refresh', async () => {await waitFor(() => {- expect(get).toHaveBeenCalledWith(expect.stringContaining('something'))+ expect(get).toHaveBeenCalledWith(expect.stringContaining('something'), expect.anything())// updates router query paramsconst router = useRouter()@@ -226,7 +238,7 @@ test('log event chart', async () => {render(<LogsPreviewer projectRef="123" tableName={LogsTableName.EDGE} />)await waitFor(() => screen.queryByText(/some-uuid123/) === null)- expect(get).toBeCalledWith(expect.stringContaining('trunc'))+ expect(get).toBeCalledWith(expect.stringContaining('trunc'), expect.anything())})test('s= query param will populate the search bar', async () => {@@ -237,7 +249,7 @@ test('s= query param will populate the search bar', async () => {render(<LogsPreviewer projectRef="123" tableName={LogsTableName.EDGE} />)// should populate search input with the search paramawait screen.findByDisplayValue('someSearch')- expect(get).toHaveBeenCalledWith(expect.stringContaining('someSearch'))+ expect(get).toHaveBeenCalledWith(expect.stringContaining('someSearch'), expect.anything())})test('te= query param will populate the timestamp to input', async () => {@@ -253,7 +265,8 @@ test('te= query param will populate the timestamp to input', async () => {await waitFor(() => {expect(get).toHaveBeenCalledWith(- expect.stringContaining(`iso_timestamp_end=${encodeURIComponent(iso)}`)+ expect.stringContaining(`iso_timestamp_end=${encodeURIComponent(iso)}`),+ expect.anything())})userEvent.click(await screen.findByTitle('Custom'))@@ -271,7 +284,8 @@ test('ts= query param will populate the timestamp from input', async () => {await waitFor(() => {expect(get).toHaveBeenCalledWith(- expect.stringContaining(`iso_timestamp_start=${encodeURIComponent(iso)}`)+ expect.stringContaining(`iso_timestamp_start=${encodeURIComponent(iso)}`),+ expect.anything())})userEvent.click(await screen.findByTitle('Custom'))@@ -299,7 +313,7 @@ test('load older btn will fetch older logs', async () => {userEvent.click(await screen.findByText('Load older'))await screen.findByText('first event')await screen.findByText('second event')- expect(get).toHaveBeenCalledWith(expect.stringContaining('timestamp_end='))+ expect(get).toHaveBeenCalledWith(expect.stringContaining('timestamp_end='), expect.anything())})test('bug: load older btn does not error out when previous page is empty', async () => {@@ -375,14 +389,17 @@ test('filters alter generated query', async () => {await waitFor(() => {// counts are adjusted- expect(get).toHaveBeenCalledWith(expect.stringMatching(/count.+\*.+as.count.+where.+500.+599/))-- expect(get).toHaveBeenCalledWith(expect.stringContaining('500'))- expect(get).toHaveBeenCalledWith(expect.stringContaining('599'))- expect(get).toHaveBeenCalledWith(expect.stringContaining('200'))- expect(get).toHaveBeenCalledWith(expect.stringContaining('299'))- expect(get).toHaveBeenCalledWith(expect.stringContaining('where'))- expect(get).toHaveBeenCalledWith(expect.stringContaining('and'))+ expect(get).toHaveBeenCalledWith(+ expect.stringMatching(/count.+\*.+as.count.+where.+500.+599/),+ expect.anything()+ )++ expect(get).toHaveBeenCalledWith(expect.stringContaining('500'), expect.anything())+ expect(get).toHaveBeenCalledWith(expect.stringContaining('599'), expect.anything())+ expect(get).toHaveBeenCalledWith(expect.stringContaining('200'), expect.anything())+ expect(get).toHaveBeenCalledWith(expect.stringContaining('299'), expect.anything())+ expect(get).toHaveBeenCalledWith(expect.stringContaining('where'), expect.anything())+ expect(get).toHaveBeenCalledWith(expect.stringContaining('and'), expect.anything())})// should be able to clear the filters@@ -397,18 +414,22 @@ test('filters alter generated query', async () => {await waitFor(() => {// counts are adjustedexpect(get).not.toHaveBeenCalledWith(- expect.stringMatching(/count.+\*.+as.count.+where.+500.+599/)+ expect.stringMatching(/count.+\*.+as.count.+where.+500.+599/),+ expect.anything())- expect(get).toHaveBeenCalledWith(expect.stringMatching(/count.+\*.+as.count.+where.+400.+499/))-- expect(get).not.toHaveBeenCalledWith(expect.stringContaining('500'))- expect(get).not.toHaveBeenCalledWith(expect.stringContaining('599'))- expect(get).not.toHaveBeenCalledWith(expect.stringContaining('200'))- expect(get).not.toHaveBeenCalledWith(expect.stringContaining('299'))- expect(get).toHaveBeenCalledWith(expect.stringContaining('400'))- expect(get).toHaveBeenCalledWith(expect.stringContaining('499'))- expect(get).toHaveBeenCalledWith(expect.stringContaining('where'))- expect(get).toHaveBeenCalledWith(expect.stringContaining('and'))+ expect(get).toHaveBeenCalledWith(+ expect.stringMatching(/count.+\*.+as.count.+where.+400.+499/),+ expect.anything()+ )++ expect(get).not.toHaveBeenCalledWith(expect.stringContaining('500'), expect.anything())+ expect(get).not.toHaveBeenCalledWith(expect.stringContaining('599'), expect.anything())+ expect(get).not.toHaveBeenCalledWith(expect.stringContaining('200'), expect.anything())+ expect(get).not.toHaveBeenCalledWith(expect.stringContaining('299'), expect.anything())+ expect(get).toHaveBeenCalledWith(expect.stringContaining('400'), expect.anything())+ expect(get).toHaveBeenCalledWith(expect.stringContaining('499'), expect.anything())+ expect(get).toHaveBeenCalledWith(expect.stringContaining('where'), expect.anything())+ expect(get).toHaveBeenCalledWith(expect.stringContaining('and'), expect.anything())})})test('filters accept filterOverride', async () => {@@ -421,8 +442,8 @@ test('filters accept filterOverride', async () => {)await waitFor(() => {- expect(get).toHaveBeenCalledWith(expect.stringContaining('my.nestedkey'))- expect(get).toHaveBeenCalledWith(expect.stringContaining('myvalue'))+ expect(get).toHaveBeenCalledWith(expect.stringContaining('my.nestedkey'), expect.anything())+ expect(get).toHaveBeenCalledWith(expect.stringContaining('myvalue'), expect.anything())})})diff --git a/studio/tests/pages/projects/logs-query.test.js b/studio/tests/pages/projects/logs-query.test.jsindex f364a54e65f..e0868fc11dc 100644--- a/studio/tests/pages/projects/logs-query.test.js+++ b/studio/tests/pages/projects/logs-query.test.js@@ -58,7 +58,7 @@ test('q= query param will populate the query input', async () => {render(<LogsExplorerPage />)// should populate editor with the query paramawait waitFor(() => {- expect(get).toHaveBeenCalledWith(expect.stringContaining('sql=some_query'))+ expect(get).toHaveBeenCalledWith(expect.stringContaining('sql=some_query'), expect.anything())})})@@ -79,9 +79,13 @@ test('ite= and its= query param will populate the datepicker', async () => {// should populate editor with the query paramawait waitFor(() => {expect(get).toHaveBeenCalledWith(- expect.stringContaining(encodeURIComponent(start.toISOString()))+ expect.stringContaining(encodeURIComponent(start.toISOString())),+ expect.anything()+ )+ expect(get).toHaveBeenCalledWith(+ expect.stringContaining(encodeURIComponent(end.toISOString())),+ expect.anything())- expect(get).toHaveBeenCalledWith(expect.stringContaining(encodeURIComponent(end.toISOString())))})})@@ -118,14 +122,23 @@ test('custom sql querying', async () => {userEvent.type(editor, '\nlimit 123{ctrl}{enter}')await waitFor(() => {- expect(get).toHaveBeenCalledWith(expect.stringContaining(encodeURI('\n')))- expect(get).toHaveBeenCalledWith(expect.stringContaining('sql='))- expect(get).toHaveBeenCalledWith(expect.stringContaining('select'))- expect(get).toHaveBeenCalledWith(expect.stringContaining('edge_logs'))- expect(get).toHaveBeenCalledWith(expect.stringContaining('iso_timestamp_start'))- expect(get).not.toHaveBeenCalledWith(expect.stringContaining('iso_timestamp_end')) // should not have an end date- expect(get).not.toHaveBeenCalledWith(expect.stringContaining('where'))- expect(get).not.toHaveBeenCalledWith(expect.stringContaining(encodeURIComponent('limit 123')))+ expect(get).toHaveBeenCalledWith(expect.stringContaining(encodeURI('\n')), expect.anything())+ expect(get).toHaveBeenCalledWith(expect.stringContaining('sql='), expect.anything())+ expect(get).toHaveBeenCalledWith(expect.stringContaining('select'), expect.anything())+ expect(get).toHaveBeenCalledWith(expect.stringContaining('edge_logs'), expect.anything())+ expect(get).toHaveBeenCalledWith(+ expect.stringContaining('iso_timestamp_start'),+ expect.anything()+ )+ expect(get).not.toHaveBeenCalledWith(+ expect.stringContaining('iso_timestamp_end'),+ expect.anything()+ ) // should not have an end date+ expect(get).not.toHaveBeenCalledWith(expect.stringContaining('where'), expect.anything())+ expect(get).not.toHaveBeenCalledWith(+ expect.stringContaining(encodeURIComponent('limit 123')),+ expect.anything()+ )},{ timeout: 1000 })