mirror of
https://github.com/supabase/supabase.git
synced 2026-10-06 01:45:10 +03:00
chore: fix failing tests
This commit is contained in:
1 parent
fdad1187a0
commit
9232ae4dfd
4 files changed
+58
-54
No files matched your search
@@ -45,10 +45,13 @@ const LogSelection: FC<Props> = ({ projectRef, log: partialLog, onClose, queryTy
|
||||
return <FunctionLogsSelectionRender log={fullLog} />
|
||||
|
||||
default:
|
||||
if (fullLog && isDefaultLogPreviewFormat(fullLog)) {
|
||||
if (queryType && fullLog && isDefaultLogPreviewFormat(fullLog)) {
|
||||
return <DefaultPreviewSelectionRenderer log={fullLog} />
|
||||
}
|
||||
|
||||
if (queryType && !fullLog) {
|
||||
return null
|
||||
}
|
||||
if (!partialLog) return null
|
||||
return <DefaultExplorerSelectionRenderer log={partialLog} />
|
||||
}
|
||||
}
|
||||
@@ -128,7 +131,7 @@ const LogSelection: FC<Props> = ({ projectRef, log: partialLog, onClose, queryTy
|
||||
</div>
|
||||
{isLoading && <Connecting />}
|
||||
<div className="bg-scale-300 py-8 flex flex-col space-y-6">
|
||||
{!isLoading && fullLog && <Formatter />}
|
||||
{!isLoading && <Formatter />}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -145,7 +145,6 @@ function useLogsPreview(
|
||||
setFilters((prev) => ({ ...prev, ...newFilters, ...filterOverride }))
|
||||
}
|
||||
}
|
||||
console.log(logData)
|
||||
return [
|
||||
{
|
||||
newCount,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import LogTable from 'components/interfaces/Settings/Logs/LogTable'
|
||||
import { render, waitFor, screen } from '@testing-library/react'
|
||||
import userEvent from '@testing-library/user-event'
|
||||
|
||||
test('can display log data', async () => {
|
||||
render(
|
||||
<LogTable
|
||||
@@ -19,8 +20,8 @@ test('can display log data', async () => {
|
||||
|
||||
const row = await screen.findByText(/some-uuid/)
|
||||
userEvent.click(row)
|
||||
await waitFor(() => screen.getByText(/my_key/))
|
||||
await waitFor(() => screen.getByText(/something_value/))
|
||||
await screen.findByText(/my_key/)
|
||||
await screen.findByText(/something_value/)
|
||||
})
|
||||
|
||||
test('dedupes log lines with exact id', async () => {
|
||||
|
||||
@@ -82,57 +82,58 @@ beforeEach(() => {
|
||||
useRouter.mockReset()
|
||||
useRouter.mockReturnValue(defaultRouterMock())
|
||||
})
|
||||
test('can display log data and metadata', async () => {
|
||||
get.mockResolvedValue({
|
||||
result: [
|
||||
logDataFixture({
|
||||
id: 'some-event-happened-id',
|
||||
metadata: {
|
||||
my_key: 'something_value',
|
||||
},
|
||||
}),
|
||||
],
|
||||
})
|
||||
render(<LogsPreviewer projectRef="123" tableName={LogsTableName.EDGE} />)
|
||||
|
||||
await waitFor(() => {
|
||||
expect(get).toHaveBeenCalledWith(expect.stringContaining('iso_timestamp_start'))
|
||||
expect(get).not.toHaveBeenCalledWith(expect.stringContaining('iso_timestamp_end'))
|
||||
})
|
||||
|
||||
fireEvent.click(await screen.findByText(/some-event-happened-id/))
|
||||
await screen.findByText(/my_key/)
|
||||
await screen.findByText(/something_value/)
|
||||
})
|
||||
|
||||
test('Refresh page', async () => {
|
||||
get.mockImplementation((url) => {
|
||||
if (url.includes('count')) return { result: { count: 0 } }
|
||||
if (url.includes('where+id')) {
|
||||
return {
|
||||
result: [
|
||||
{
|
||||
id: 'some-id',
|
||||
metadata: [{ request: [{ method: 'POST' }] }],
|
||||
},
|
||||
],
|
||||
test.each([
|
||||
{
|
||||
queryType: 'api',
|
||||
tableName: undefined,
|
||||
allLog: logDataFixture({
|
||||
id: 'some-id',
|
||||
request: { path: 'some-path', method: 'POST' },
|
||||
status_code: '400',
|
||||
metadata: undefined,
|
||||
}),
|
||||
singleLog: {
|
||||
id: 'some-id',
|
||||
metadata: [{ request: [{ method: 'POST' }] }],
|
||||
},
|
||||
tableTexts: [/POST/, /some\-path/, /400/],
|
||||
selectionTexts: [/POST/],
|
||||
},
|
||||
// TODO: add more tests for each type of ui
|
||||
])(
|
||||
'selection $queryType $tableName , can display log data and metadata',
|
||||
async ({ queryType, tableName, allLog, singleLog, tableTexts, selectionTexts }) => {
|
||||
get.mockImplementation((url) => {
|
||||
// counts
|
||||
if (url.includes('count')) {
|
||||
return { result: [{ count: 0 }] }
|
||||
}
|
||||
}
|
||||
return {
|
||||
result: [
|
||||
logDataFixture({
|
||||
id: 'some-id',
|
||||
request: { path: 'some-event' },
|
||||
}),
|
||||
],
|
||||
}
|
||||
})
|
||||
render(<LogsPreviewer projectRef="123" queryType="api" tableName={LogsTableName.EDGE} />)
|
||||
// single
|
||||
if (url.includes('where+id')) {
|
||||
return { result: [singleLog] }
|
||||
}
|
||||
// all
|
||||
return { result: [allLog] }
|
||||
})
|
||||
render(<LogsPreviewer projectRef="123" queryType={queryType} tableName={tableName} />)
|
||||
|
||||
const row = await screen.findByText(/some-event/)
|
||||
fireEvent.click(row)
|
||||
await screen.findAllByText(/POST/)
|
||||
})
|
||||
await waitFor(() => {
|
||||
expect(get).toHaveBeenCalledWith(expect.stringContaining('iso_timestamp_start'))
|
||||
expect(get).not.toHaveBeenCalledWith(expect.stringContaining('iso_timestamp_end'))
|
||||
})
|
||||
|
||||
for (const text of tableTexts) {
|
||||
await screen.findByText(text)
|
||||
}
|
||||
const row = await screen.findByText(tableTexts[0])
|
||||
fireEvent.click(row)
|
||||
|
||||
for (const text of selectionTexts) {
|
||||
await screen.findAllByText(text)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
test('Search will trigger a log refresh', async () => {
|
||||
get.mockImplementation((url) => {
|
||||
|
||||
Reference in new issue
Block a user