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
Original file line number Diff line number Diff line change
Expand Up @@ -19,47 +19,26 @@ import { FeedEditor } from './FeedEditor';
const onSave = jest.fn();
const onChangeHandler = jest.fn();

const onKeyDownHandler = jest.fn().mockImplementation((e: KeyboardEvent) => {
if (e.key === 'Enter') {
if (e.nativeEvent.isComposing || e.keyCode === 229) {
return;
}
if (!e.shiftKey) {
onSave();
}
}
});

const mockFeedEditorProp = {
onChangeHandler: onChangeHandler,
onSave: onSave,
};

jest.mock('quilljs-markdown', () => {
class MockQuillMarkdown {
constructor() {
// eslint-disable-next-line no-console
console.log('Markdown constructor');
}
}
jest.unmock('./FeedEditor');

const instance = new MockQuillMarkdown();
jest.mock('@windmillcode/quill-emoji', () => ({
TextAreaEmoji: jest.fn(),
}));

return instance;
});
jest.mock('quill', () => ({
Parchment: {},
}));

jest.mock('quill-mention/autoregister', () => ({}));

jest.mock('react-quill-new', () => {
class MockQuill {
constructor() {
// eslint-disable-next-line no-console
console.log('Quill constructor');
}

register(val: string) {
// eslint-disable-next-line no-console
console.log(`Register ${val} module`);
}

register() {}
import(val: string) {
return val;
}
Expand All @@ -68,21 +47,53 @@ jest.mock('react-quill-new', () => {
return {
__esModule: true,
Quill: new MockQuill(),
default: jest.fn().mockImplementation(() => {
return (
<div data-testid="react-quill" onKeyDown={onKeyDownHandler}>
editor
</div>
);
}),
default: jest
.fn()
.mockImplementation(
(props: { onKeyDown?: (e: KeyboardEvent<HTMLDivElement>) => void }) => {
return (
<div data-testid="react-quill" onKeyDown={props.onKeyDown}>
editor
</div>
);
}
),
};
});

jest.mock('../../../utils/QuillLink/QuillLink', () => {
return jest.fn();
});
jest.mock('../../../utils/QuillLink/QuillLink', () => ({
LinkBlot: jest.fn(),
}));

jest.mock('../../../hooks/useApplicationStore', () => ({
useApplicationStore: jest.fn().mockReturnValue({ userProfilePics: {} }),
}));

jest.mock('../../../rest/userAPI', () => ({
getUserByName: jest.fn(),
}));

jest.mock('../../../utils/FeedUtils', () => ({
HTMLToMarkdown: { turndown: jest.fn() },
suggestions: jest.fn(),
userMentionItemWithAvatar: jest.fn(),
}));

jest.mock('../../../utils/QuillUtils', () => ({
insertMention: jest.fn(),
insertRef: jest.fn(),
}));

jest.mock('../../../utils/sanitize.utils', () => ({
getSanitizeContent: jest.fn().mockImplementation((v: string) => v),
}));

jest.mock('../../../utils/SearchClassBase', () => ({
__esModule: true,
default: { getEntityIcon: jest.fn() },
}));

describe.skip('Test FeedEditor Component', () => {
describe('Test FeedEditor Component', () => {
it('Should render FeedEditor Component', async () => {
const { container } = render(<FeedEditor {...mockFeedEditorProp} />, {
wrapper: MemoryRouter,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,9 @@ export const FeedEditor = forwardRef<EditorContentRef, FeedEditorProp>(
toggleMentionList(true);
},
onSelect: (
item: Record<string, any>,
item: Record<string, unknown>,

insertItem: (item: Record<string, any>) => void
insertItem: (item: Record<string, unknown>) => void
) => {
toggleMentionList(true);
insertItem(item);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ jest.mock('../../context/TourProvider/TourProvider');
jest.mock('../../utils/SearchUtils', () => ({
filterOptionsByIndex: jest.fn((options, index) => {
return options.filter(
(option: any) => option._source?.entityType === index
(option: { _source?: { entityType?: string } }) =>
option._source?.entityType === index
);
}),
getGroupLabel: jest.fn((index) => `Group ${index}`),
Expand All @@ -40,7 +41,13 @@ jest.mock('../../utils/SearchClassBase', () => ({
getEntitiesSuggestions: jest.fn(() => []),
}));
jest.mock('../../utils/CommonUtils', () => ({
Transi18next: ({ i18nKey, values }: { i18nKey: string; values: any }) => (
Transi18next: ({
i18nKey,
values,
}: {
i18nKey: string;
values: Record<string, string>;
}) => (
<span data-testid="transi18next">
{i18nKey} {values?.keyword || ''}
</span>
Expand Down Expand Up @@ -74,12 +81,12 @@ describe('Suggestions Component', () => {
mockUseTranslation.mockReturnValue({
t: jest.fn((key: string) => key),
i18n: { language: 'en' },
} as any);
} as ReturnType<typeof useTranslation>);
mockUseTourProvider.mockReturnValue({
isTourOpen: false,
updateTourPage: jest.fn(),
updateTourSearch: jest.fn(),
} as any);
} as ReturnType<typeof useTourProvider>);
});

describe('AI Query Suggestions', () => {
Expand Down Expand Up @@ -147,7 +154,7 @@ describe('Suggestions Component', () => {
isTourOpen: true,
updateTourPage: jest.fn(),
updateTourSearch: jest.fn(),
} as any);
} as ReturnType<typeof useTourProvider>);

render(<Suggestions {...defaultProps} />);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ jest.mock('./AdminProtectedRoute', () => ({
default: jest.fn().mockImplementation(({ children }) => children),
}));

describe.skip('SettingsRouter', () => {
describe('SettingsRouter', () => {
it('should render GlobalSettingPage component for exact settings route', async () => {
render(
<MemoryRouter initialEntries={['/settings']}>
Expand Down Expand Up @@ -326,7 +326,7 @@ describe.skip('SettingsRouter', () => {
).toBeInTheDocument();
});

it.skip('should render CustomPageSettings component for custom page settings route', async () => {
it('should render CustomPageSettings component for custom page settings route', async () => {
render(
<MemoryRouter
initialEntries={[`/settings/preferences/customizeLandingPage`]}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,11 @@ const isEmailVerifyField = 'isEmailVerified';
let requestInterceptor: number | null = null;
let responseInterceptor: number | null = null;

let pendingRequests: any[] = [];
let pendingRequests: {
resolve: (value: unknown) => void;
reject: (reason?: unknown) => void;
config: InternalAxiosRequestConfig | undefined;
}[] = [];

type AuthContextType = {
onLoginHandler: () => void;
Expand Down Expand Up @@ -461,7 +465,7 @@ export const AuthProvider = ({
}

requestInterceptor = axiosClient.interceptors.request.use(async function (
config: InternalAxiosRequestConfig<any>
config: InternalAxiosRequestConfig
) {
// Need to read token from local storage as it might have been updated with refresh
const token: string = await getOidcToken();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,15 @@ jest.mock('../common/DescriptionSection/DescriptionSection', () => {
jest.mock('../common/OverviewSection/OverviewSection', () => {
return jest.fn().mockImplementation(({ entityInfoV1 }) => (
<div data-testid="overview-section">
{(entityInfoV1 || []).map((item: any, index: number) => (
<div
data-testid={`overview-item-${String(item.name).toLowerCase()}`}
key={index}>
{item.name} {item.value}
</div>
))}
{(entityInfoV1 || []).map(
(item: { name: string; value: string }, index: number) => (
<div
data-testid={`overview-item-${String(item.name).toLowerCase()}`}
key={index}>
{item.name} {item.value}
</div>
)
)}
</div>
));
});
Expand All @@ -221,7 +223,7 @@ jest.mock('../common/DataQualitySection/DataQualitySection', () => {
return jest.fn().mockImplementation(({ tests, totalTests }) => (
<div data-testid="data-quality-section">
<div data-testid="total-tests">{totalTests}</div>
{tests.map((test: any, index: number) => (
{tests.map((test: { type: string; count: number }, index: number) => (
<div data-testid={`test-${test.type}`} key={index}>
{test.type}: {test.count}
</div>
Expand Down Expand Up @@ -382,7 +384,7 @@ describe('DataAssetSummaryPanelV1', () => {
const mockOnDescriptionUpdate = jest.fn();

const defaultProps: DataAssetSummaryPanelProps = {
dataAsset: mockDataAsset as any,
dataAsset: mockDataAsset as DataAssetSummaryPanelProps['dataAsset'],
entityType: EntityType.TABLE,
isLoading: false,
onOwnerUpdate: mockOnOwnerUpdate,
Expand Down Expand Up @@ -415,7 +417,11 @@ describe('DataAssetSummaryPanelV1', () => {
);
(listTestCases as jest.Mock).mockResolvedValue({ data: mockTestCaseData });
(getEntityOverview as jest.Mock).mockImplementation(
(_entityType: any, _dataAsset: any, additionalInfo: any) => [
(
_entityType: string,
_dataAsset: DataAssetSummaryPanelProps['dataAsset'],
additionalInfo?: Record<string, number | string>
) => [
{ name: 'Type', value: 'Table', visible: ['explore'] },
{ name: 'Rows', value: 1000, visible: ['explore'] },
{ name: 'Columns', value: 15, visible: ['explore'] },
Expand Down Expand Up @@ -596,7 +602,7 @@ describe('DataAssetSummaryPanelV1', () => {
dataAsset: {
...mockDataAsset,
deleted: true,
} as any,
} as DataAssetSummaryPanelProps['dataAsset'],
};

await act(async () => {
Expand Down Expand Up @@ -904,7 +910,7 @@ describe('DataAssetSummaryPanelV1', () => {
name: 'new-table',
displayName: 'New Table',
fullyQualifiedName: 'new.fqn',
} as any;
} as DataAssetSummaryPanelProps['dataAsset'];

await act(async () => {
rerender(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,18 @@ import { ContractDetailFormTab } from './ContractDetailFormTab';

jest.mock('../../../utils/formUtils', () => ({
generateFormFields: jest.fn((fields) =>
fields.map((field: any) => (
<div data-testid={field.props?.['data-testid']} key={field.name}>
<label>{field.label}</label>
<input data-testid={field.props?.['data-testid']} name={field.name} />
</div>
))
fields.map(
(field: {
name: string;
label: string;
props?: Record<string, string>;
}) => (
<div data-testid={field.props?.['data-testid']} key={field.name}>
<label>{field.label}</label>
<input data-testid={field.props?.['data-testid']} name={field.name} />
</div>
)
)
),
}));

Expand Down
Loading
Loading