chore: self review changes

This commit is contained in:
Gaurav Tewari
2026-05-07 22:06:40 +05:30
parent 02c78ee53a
commit 68d46a3280
10 changed files with 50 additions and 59 deletions
+28
View File
@@ -0,0 +1,28 @@
import React from 'react';
const IconMock = React.forwardRef<SVGSVGElement, React.SVGProps<SVGSVGElement>>(
(props, ref) => <svg ref={ref} {...props} />,
);
IconMock.displayName = 'IconMock';
// Returns a Proxy that resolves any named export to IconMock by default,
// so `import { AnyIcon } from '@signozhq/icons'` always returns a valid component.
// Pass `overrides` to swap in test-specific stubs (e.g. icons with data-testid).
export function createIconsMock(
overrides: Record<string, unknown> = {},
): Record<string | symbol, unknown> {
return new Proxy(
{ __esModule: true, default: IconMock, ...overrides } as Record<
string | symbol,
unknown
>,
{
get(target, prop: string | symbol): unknown {
if (prop in target) {
return target[prop as string];
}
return IconMock;
},
},
);
}
+2 -24
View File
@@ -1,25 +1,3 @@
import React from 'react';
import { createIconsMock } from './createIconsMock';
const IconMock = React.forwardRef<SVGSVGElement, React.SVGProps<SVGSVGElement>>(
(props, ref) => <svg ref={ref} {...props} />,
);
IconMock.displayName = 'IconMock';
// Re-export IconMock as every possible named export via module.exports proxy
// so that any `import { SomeIcon } from '@signozhq/icons'` resolves to a valid component.
const moduleExports = new Proxy(
{ __esModule: true, default: IconMock },
{
get(
target: Record<string | symbol, unknown>,
prop: string | symbol,
): unknown {
if (prop in target) {
return target[prop];
}
return IconMock;
},
},
);
module.exports = moduleExports;
module.exports = createIconsMock();
+1
View File
@@ -25,6 +25,7 @@ const config: Config.InitialOptions = {
'^constants/env$': '<rootDir>/__mocks__/env.ts',
'^src/constants/env$': '<rootDir>/__mocks__/env.ts',
'^@signozhq/icons$': '<rootDir>/__mocks__/signozhqIconsMock.tsx',
'^test-mocks/(.*)$': '<rootDir>/__mocks__/$1',
'^react-syntax-highlighter/dist/esm/(.*)$':
'<rootDir>/node_modules/react-syntax-highlighter/dist/cjs/$1',
'^@signozhq/(?!ui$)([^/]+)$':
+2 -4
View File
@@ -42,11 +42,9 @@ function GanttChart(props: GanttChartProps): JSX.Element {
title={isExpandAll ? 'Collapse All' : 'Expand All'}
>
{isExpandAll ? (
<SquareMinus
style={{ fontSize: '16px', color: 'var(--accent-primary)' }}
/>
<SquareMinus size={16} style={{ color: 'var(--accent-primary)' }} />
) : (
<SquarePlus style={{ fontSize: '16px', color: 'var(--accent-primary)' }} />
<SquarePlus size={16} style={{ color: 'var(--accent-primary)' }} />
)}
</CollapseButton>
<CardWrapper>
@@ -100,25 +100,15 @@ jest.mock('hooks/dashboard/useGetResolvedText', () => {
});
jest.mock('@signozhq/icons', () => {
const IconMock = (props: React.SVGProps<SVGSVGElement>): JSX.Element => (
<svg {...props} />
);
const overrides: Record<string, unknown> = {
__esModule: true,
default: IconMock,
const { createIconsMock } = jest.requireActual<
typeof import('test-mocks/createIconsMock')
>('test-mocks/createIconsMock');
return createIconsMock({
CircleX: (): JSX.Element => <svg data-testid="lucide-circle-x" />,
TriangleAlert: (): JSX.Element => <svg data-testid="lucide-triangle-alert" />,
SquareArrowOutUpRight: (): JSX.Element => (
<svg data-testid="lucide-square-arrow-out-up-right" />
),
};
return new Proxy(overrides, {
get(target, prop: string | symbol): unknown {
if (prop in target) {
return target[prop as string];
}
return IconMock;
},
});
});
jest.mock('antd', () => ({
@@ -492,7 +492,7 @@ function DashboardsList(): JSX.Element {
placement="bottomRight"
arrow={false}
rootClassName="dashboard-actions"
trigger={['hover', 'click']}
trigger="click"
>
<EllipsisVertical
className="dashboard-action-icon"
@@ -104,7 +104,7 @@ function TopOperationsTable({
const getSearchOption = (): ColumnType<TopOperationList> => ({
filterDropdown,
filterIcon: <Search />,
filterIcon: <Search size="md" />,
onFilter: (value, record): boolean =>
record.name
.toString()
@@ -114,23 +114,13 @@ jest.mock('hooks/queryBuilder/useCreateAlerts', () => ({
}));
jest.mock('@signozhq/icons', () => {
const IconMock = (props: React.SVGProps<SVGSVGElement>): JSX.Element => (
<svg {...props} />
);
const overrides: Record<string, unknown> = {
__esModule: true,
default: IconMock,
const { createIconsMock } = jest.requireActual<
typeof import('test-mocks/createIconsMock')
>('test-mocks/createIconsMock');
return createIconsMock({
SquareArrowOutUpRight: (): JSX.Element => (
<svg data-testid="lucide-square-arrow-out-up-right" />
),
};
return new Proxy(overrides, {
get(target, prop: string | symbol): unknown {
if (prop in target) {
return target[prop as string];
}
return IconMock;
},
});
});
@@ -215,7 +215,10 @@ export default function DataSource(): JSX.Element {
rules={[{ required: true, message: 'Please enter service name' }]}
validateTrigger="onBlur"
>
<Input />
<Input
// oxlint-disable-next-line jsx_a11y/no-autofocus
autoFocus
/>
</Form.Item>
{enableFrameworks && (
+3
View File
@@ -32,6 +32,9 @@
],
"@/*": [
"./src/*"
],
"test-mocks/*": [
"./__mocks__/*"
]
},
"plugins": [