Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"build:clickhouse": "NEXT_PUBLIC_IS_LOCAL_MODE=true NEXT_PUBLIC_CLICKHOUSE_BUILD=true next build --webpack && node scripts/prepare-clickhouse-build-export.js",
"run:clickhouse": "test -d out && npx rimraf tmp && mkdir tmp && cp -r out tmp/clickstack && echo 'visit http://localhost:3000/clickstack to start' && npx serve tmp -l 3000 || echo 'run build:clickhouse first'",
"start": "next start",
"lint": "node ../../scripts/ci/oxlint-warnings.mjs --max-warnings 468 && yarn run -T oxfmt --check '**/*.{ts,tsx,css,scss}'",
"lint": "node ../../scripts/ci/oxlint-warnings.mjs --max-warnings 372 && yarn run -T oxfmt --check '**/*.{ts,tsx,css,scss}'",
"lint:fix": "yarn run -T oxlint --fix && yarn run -T oxfmt '**/*.{ts,tsx,css,scss}'",
"lint:styles": "stylelint **/*/*.{css,scss}",
"ci:lint": "yarn lint && yarn tsc --noEmit && yarn lint:styles --quiet",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ describe('Dashboard import - all tile types', () => {
expect(parsed.success).toBe(true);

const displayTypes = new Set(
allTileTypesTemplate.tiles.map(t => (t.config as any).displayType),
allTileTypesTemplate.tiles.map(t => t.config.displayType),
);
// markdown, number, line, stacked_bar, table, pie, heatmap, search
expect(displayTypes.size).toBe(8);
Expand Down
209 changes: 122 additions & 87 deletions packages/app/src/__tests__/DBSearchPage.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { SourceKind } from '@hyperdx/common-utils/dist/types';
import { renderHook } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn';

import {
buildSavedSearchNavigationUrl,
Expand Down Expand Up @@ -212,17 +213,21 @@ describe('useDefaultOrderBy', () => {
sorting_key: testCase.sortingKey,
};

jest.spyOn(sourceModule, 'useSource').mockReturnValue({
data: mockSource,
isLoading: false,
error: null,
} as any);

jest.spyOn(metadataModule, 'useTableMetadata').mockReturnValue({
data: mockTableMetadata,
isLoading: false,
error: null,
} as any);
jest.spyOn(sourceModule, 'useSource').mockReturnValue(
fromPartial({
data: mockSource,
isLoading: false,
error: null,
}),
);

jest.spyOn(metadataModule, 'useTableMetadata').mockReturnValue(
fromPartial({
data: mockTableMetadata,
isLoading: false,
error: null,
}),
);

const { result } = renderHook(() => useDefaultOrderBy('source-id'));

Expand All @@ -232,35 +237,43 @@ describe('useDefaultOrderBy', () => {
});

it('should handle null source ungracefully', () => {
jest.spyOn(sourceModule, 'useSource').mockReturnValue({
data: null,
isLoading: false,
error: null,
} as any);

jest.spyOn(metadataModule, 'useTableMetadata').mockReturnValue({
data: null,
isLoading: false,
error: null,
} as any);
jest.spyOn(sourceModule, 'useSource').mockReturnValue(
fromPartial({
data: undefined,
isLoading: false,
error: null,
}),
);

jest.spyOn(metadataModule, 'useTableMetadata').mockReturnValue(
fromPartial({
data: undefined,
isLoading: false,
error: null,
}),
);

const { result } = renderHook(() => useDefaultOrderBy(null));

expect(result.current).toBe(undefined);
});

it('should handle undefined sourceID ungracefully', () => {
jest.spyOn(sourceModule, 'useSource').mockReturnValue({
data: null,
isLoading: false,
error: null,
} as any);

jest.spyOn(metadataModule, 'useTableMetadata').mockReturnValue({
data: null,
isLoading: false,
error: null,
} as any);
jest.spyOn(sourceModule, 'useSource').mockReturnValue(
fromPartial({
data: undefined,
isLoading: false,
error: null,
}),
);

jest.spyOn(metadataModule, 'useTableMetadata').mockReturnValue(
fromPartial({
data: undefined,
isLoading: false,
error: null,
}),
);

const { result } = renderHook(() => useDefaultOrderBy(undefined));

Expand All @@ -278,17 +291,21 @@ describe('useDefaultOrderBy', () => {
sorting_key: 'toStartOfMinute(Timestamp), Timestamp',
};

jest.spyOn(sourceModule, 'useSource').mockReturnValue({
data: mockSource,
isLoading: false,
error: null,
} as any);
jest.spyOn(sourceModule, 'useSource').mockReturnValue(
fromPartial({
data: mockSource,
isLoading: false,
error: null,
}),
);

jest.spyOn(metadataModule, 'useTableMetadata').mockReturnValue({
data: mockTableMetadata,
isLoading: false,
error: null,
} as any);
jest.spyOn(metadataModule, 'useTableMetadata').mockReturnValue(
fromPartial({
data: mockTableMetadata,
isLoading: false,
error: null,
}),
);

const { result } = renderHook(() => useDefaultOrderBy('source-id'));

Expand All @@ -306,17 +323,21 @@ describe('useDefaultOrderBy', () => {
sorting_key: 'toStartOfHour(Timestamp), Timestamp',
};

jest.spyOn(sourceModule, 'useSource').mockReturnValue({
data: mockSource,
isLoading: false,
error: null,
} as any);
jest.spyOn(sourceModule, 'useSource').mockReturnValue(
fromPartial({
data: mockSource,
isLoading: false,
error: null,
}),
);

jest.spyOn(metadataModule, 'useTableMetadata').mockReturnValue({
data: mockTableMetadata,
isLoading: false,
error: null,
} as any);
jest.spyOn(metadataModule, 'useTableMetadata').mockReturnValue(
fromPartial({
data: mockTableMetadata,
isLoading: false,
error: null,
}),
);

const { result } = renderHook(() => useDefaultOrderBy('source-id'));

Expand All @@ -333,17 +354,21 @@ describe('useDefaultOrderBy', () => {
sorting_key: 'toStartOfHour(Timestamp), Timestamp',
};

jest.spyOn(sourceModule, 'useSource').mockReturnValue({
data: mockSource,
isLoading: false,
error: null,
} as any);
jest.spyOn(sourceModule, 'useSource').mockReturnValue(
fromPartial({
data: mockSource,
isLoading: false,
error: null,
}),
);

jest.spyOn(metadataModule, 'useTableMetadata').mockReturnValue({
data: mockTableMetadata,
isLoading: false,
error: null,
} as any);
jest.spyOn(metadataModule, 'useTableMetadata').mockReturnValue(
fromPartial({
data: mockTableMetadata,
isLoading: false,
error: null,
}),
);

const { result } = renderHook(() => useDefaultOrderBy('source-id'));

Expand All @@ -361,17 +386,21 @@ describe('useDefaultOrderBy', () => {
'toStartOfHour(toDateTime(timestamp_ms / 1000)), toDateTime(timestamp_ms / 1000)',
};

jest.spyOn(sourceModule, 'useSource').mockReturnValue({
data: mockSource,
isLoading: false,
error: null,
} as any);
jest.spyOn(sourceModule, 'useSource').mockReturnValue(
fromPartial({
data: mockSource,
isLoading: false,
error: null,
}),
);

jest.spyOn(metadataModule, 'useTableMetadata').mockReturnValue({
data: mockTableMetadata,
isLoading: false,
error: null,
} as any);
jest.spyOn(metadataModule, 'useTableMetadata').mockReturnValue(
fromPartial({
data: mockTableMetadata,
isLoading: false,
error: null,
}),
);

const { result } = renderHook(() => useDefaultOrderBy('source-id'));

Expand All @@ -391,17 +420,21 @@ describe('useDefaultOrderBy', () => {

const useSourceSpy = jest
.spyOn(sourceModule, 'useSource')
.mockReturnValue({
data: mockSource1,
.mockReturnValue(
fromPartial({
data: mockSource1,
isLoading: false,
error: null,
}),
);

jest.spyOn(metadataModule, 'useTableMetadata').mockReturnValue(
fromPartial({
data: undefined,
isLoading: false,
error: null,
} as any);

jest.spyOn(metadataModule, 'useTableMetadata').mockReturnValue({
data: undefined,
isLoading: false,
error: null,
} as any);
}),
);

const { result, rerender } = renderHook(() =>
useDefaultOrderBy('source-id'),
Expand All @@ -410,11 +443,13 @@ describe('useDefaultOrderBy', () => {
expect(result.current).toBe('timestamp1 DESC');

// Update the mock to return different data
useSourceSpy.mockReturnValue({
data: mockSource2,
isLoading: false,
error: null,
} as any);
useSourceSpy.mockReturnValue(
fromPartial({
data: mockSource2,
isLoading: false,
error: null,
}),
);

rerender();

Expand Down
Loading
Loading