Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(react): Fix typescript errors in test files #9982

Merged
merged 3 commits into from
Mar 6, 2024
Merged
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
@@ -1,9 +1,10 @@
import { DateInterval, TimeSeriesChart } from '../../../../types.generated';
import { computeLines } from '../TimeSeriesChart';

describe('timeSeriesChart', () => {
describe('computeLines', () => {
it('compute lines works works correctly for weekly case', () => {
const chartData = {
const chartData: TimeSeriesChart = {
title: 'Weekly Active Users',
lines: [
{
Expand All @@ -15,7 +16,7 @@ describe('timeSeriesChart', () => {
start: '1672012800000',
end: '1677369600000',
},
interval: 'WEEK',
interval: DateInterval.Week,
};
const result = computeLines(chartData, true);
expect(result[0]).toEqual({
Expand All @@ -35,7 +36,7 @@ describe('timeSeriesChart', () => {
});

it('compute lines works works correctly for monthly case', () => {
const chartData = {
const chartData:TimeSeriesChart = {
title: 'Weekly Active Users',
lines: [
{
Expand All @@ -51,7 +52,7 @@ describe('timeSeriesChart', () => {
start: '1648771200000',
end: '1680307199999',
},
interval: 'MONTH',
interval: DateInterval.Month,
};
const result = computeLines(chartData, true);
expect(result[0]).toEqual({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import { mocks } from '../../../../../Mocks';
import { SchemaTab } from '../../../shared/tabs/Dataset/Schema/SchemaTab';
import EntityContext from '../../../shared/EntityContext';
import { EntityType, SchemaMetadata } from '../../../../../types.generated';
import { SchemaRow } from'../../../shared/tabs/Dataset/Schema/components/SchemaRow';
import { SchemaRow } from '../../../shared/tabs/Dataset/Schema/components/SchemaRow';

vi.mock('virtualizedtableforantd4', async () => {
return {
...await vi.importActual<object>('virtualizedtableforantd4'),
...(await vi.importActual<object>('virtualizedtableforantd4')),
useVT: () => [{ body: { row: SchemaRow } }, vi.fn()],
};
});
Expand All @@ -38,6 +38,9 @@ describe('Schema', () => {
updateEntity: vi.fn(),
routeToTab: vi.fn(),
refetch: vi.fn(),
loading: true,
lineage: undefined,
dataNotCombinedWithSiblings: null,
}}
>
<SchemaTab />
Expand All @@ -60,13 +63,18 @@ describe('Schema', () => {
urn: 'urn:li:dataset:123',
entityType: EntityType.Dataset,
entityData: {
description: 'This is a description',
properties: {
description: 'This is a description',
},
schemaMetadata: sampleSchema as SchemaMetadata,
},
baseEntity: {},
updateEntity: vi.fn(),
routeToTab: vi.fn(),
refetch: vi.fn(),
loading: true,
lineage: undefined,
dataNotCombinedWithSiblings: null,
}}
>
<SchemaTab />
Expand Down Expand Up @@ -97,13 +105,18 @@ describe('Schema', () => {
urn: 'urn:li:dataset:123',
entityType: EntityType.Dataset,
entityData: {
description: 'This is a description',
properties: {
description: 'This is a description',
},
schemaMetadata: sampleSchemaWithTags as SchemaMetadata,
},
baseEntity: {},
updateEntity: vi.fn(),
routeToTab: vi.fn(),
refetch: vi.fn(),
loading: true,
lineage: undefined,
dataNotCombinedWithSiblings: null,
}}
>
<SchemaTab />
Expand All @@ -124,13 +137,18 @@ describe('Schema', () => {
urn: 'urn:li:dataset:123',
entityType: EntityType.Dataset,
entityData: {
description: 'This is a description',
properties: {
description: 'This is a description',
},
schemaMetadata: sampleSchemaWithTags as SchemaMetadata,
},
baseEntity: {},
updateEntity: vi.fn(),
routeToTab: vi.fn(),
refetch: vi.fn(),
loading: true,
lineage: undefined,
dataNotCombinedWithSiblings: null,
}}
>
<SchemaTab />
Expand All @@ -150,13 +168,18 @@ describe('Schema', () => {
urn: 'urn:li:dataset:123',
entityType: EntityType.Dataset,
entityData: {
description: 'This is a description',
properties: {
description: 'This is a description',
},
schemaMetadata: sampleSchemaWithTags as SchemaMetadata,
},
baseEntity: {},
updateEntity: vi.fn(),
routeToTab: vi.fn(),
refetch: vi.fn(),
loading: true,
lineage: undefined,
dataNotCombinedWithSiblings: null,
}}
>
<SchemaTab />
Expand All @@ -176,13 +199,18 @@ describe('Schema', () => {
urn: 'urn:li:dataset:123',
entityType: EntityType.Dataset,
entityData: {
description: 'This is a description',
properties: {
description: 'This is a description',
},
schemaMetadata: sampleSchemaWithPkFk as SchemaMetadata,
},
baseEntity: {},
updateEntity: vi.fn(),
routeToTab: vi.fn(),
refetch: vi.fn(),
loading: true,
lineage: undefined,
dataNotCombinedWithSiblings: null,
}}
>
<SchemaTab />
Expand All @@ -202,13 +230,18 @@ describe('Schema', () => {
urn: 'urn:li:dataset:123',
entityType: EntityType.Dataset,
entityData: {
description: 'This is a description',
properties: {
description: 'This is a description',
},
schemaMetadata: sampleSchemaWithPkFk as SchemaMetadata,
},
baseEntity: {},
updateEntity: vi.fn(),
routeToTab: vi.fn(),
refetch: vi.fn(),
loading: true,
lineage: undefined,
dataNotCombinedWithSiblings: null,
}}
>
<SchemaTab />
Expand All @@ -234,13 +267,18 @@ describe('Schema', () => {
urn: 'urn:li:dataset:123',
entityType: EntityType.Dataset,
entityData: {
description: 'This is a description',
properties: {
description: 'This is a description',
},
schemaMetadata: sampleSchemaWithKeyValueFields as SchemaMetadata,
},
baseEntity: {},
updateEntity: vi.fn(),
routeToTab: vi.fn(),
refetch: vi.fn(),
loading: true,
lineage: undefined,
dataNotCombinedWithSiblings: null,
}}
>
<SchemaTab />
Expand Down Expand Up @@ -273,13 +311,18 @@ describe('Schema', () => {
urn: 'urn:li:dataset:123',
entityType: EntityType.Dataset,
entityData: {
description: 'This is a description',
properties: {
description: 'This is a description',
},
schemaMetadata: sampleSchemaWithoutFields as SchemaMetadata,
},
baseEntity: {},
updateEntity: vi.fn(),
routeToTab: vi.fn(),
refetch: vi.fn(),
loading: true,
lineage: undefined,
dataNotCombinedWithSiblings: null,
}}
>
<SchemaTab />
Expand Down Expand Up @@ -325,7 +368,9 @@ describe('Schema', () => {
urn: 'urn:li:dataset:123',
entityType: EntityType.Dataset,
entityData: {
description: 'This is a description',
properties: {
description: 'This is a description',
},
schemaMetadata: sampleSchema as SchemaMetadata,
},
baseEntity: {
Expand All @@ -337,6 +382,9 @@ describe('Schema', () => {
updateEntity: vi.fn(),
routeToTab: vi.fn(),
refetch: vi.fn(),
loading: true,
lineage: undefined,
dataNotCombinedWithSiblings: null,
}}
>
<SchemaTab />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import React from 'react';
import { mocks } from '../../../../../Mocks';
import TestPageContainer from '../../../../../utils/test-utils/TestPageContainer';
import { Preview } from '../Preview';
import { PreviewType } from '../../../Entity';

describe('Preview', () => {
it('renders', () => {
Expand All @@ -15,6 +16,7 @@ describe('Preview', () => {
name="name"
description="definition"
owners={null}
previewType={PreviewType.PREVIEW}
/>
</TestPageContainer>
</MockedProvider>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import GlossaryTermHeader from '../GlossaryTermHeader';

const glossaryTermHeaderData = {
definition: 'this is sample definition',
termSource: 'termSource',
sourceUrl: 'sourceUrl',
sourceRef: 'Source ref',
fqdn: 'fqdn',
};
Expand All @@ -19,9 +19,9 @@ describe('Glossary Term Header', () => {
<TestPageContainer>
<GlossaryTermHeader
definition={glossaryTermHeaderData.definition}
termSource={glossaryTermHeaderData.termSource}
sourceUrl={glossaryTermHeaderData.sourceUrl}
sourceRef={glossaryTermHeaderData.sourceRef}
fqdn={glossaryTermHeaderData.fqdn}
ownership={undefined}
/>
</TestPageContainer>
</MockedProvider>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ describe('EntityProfile', () => {
display: {
visible: (_, _1) => true,
enabled: (_, dataset: GetDatasetQuery) =>
(dataset?.dataset?.upstreamLineage?.entities?.length || 0) > 0 ||
(dataset?.dataset?.downstreamLineage?.entities?.length || 0) > 0,
((dataset?.dataset as any)?.upstreamLineage?.entities?.length || 0) > 0 ||
((dataset?.dataset as any)?.downstreamLineage?.entities?.length || 0) > 0,
},
},
{
Expand Down Expand Up @@ -136,8 +136,8 @@ describe('EntityProfile', () => {
display: {
visible: (_, _1) => true,
enabled: (_, dataset: GetDatasetQuery) =>
(dataset?.dataset?.upstreamLineage?.entities?.length || 0) > 0 ||
(dataset?.dataset?.downstreamLineage?.entities?.length || 0) > 0,
((dataset?.dataset as any)?.upstreamLineage?.entities?.length || 0) > 0 ||
((dataset?.dataset as any)?.downstreamLineage?.entities?.length || 0) > 0,
},
},
{
Expand Down Expand Up @@ -220,8 +220,8 @@ describe('EntityProfile', () => {
display: {
visible: (_, _1) => true,
enabled: (_, dataset: GetDatasetQuery) =>
(dataset?.dataset?.upstreamLineage?.entities?.length || 0) > 0 ||
(dataset?.dataset?.downstreamLineage?.entities?.length || 0) > 0,
((dataset?.dataset as any)?.upstreamLineage?.entities?.length || 0) > 0 ||
((dataset?.dataset as any)?.downstreamLineage?.entities?.length || 0) > 0,
},
},
{
Expand Down Expand Up @@ -314,12 +314,6 @@ describe('EntityProfile', () => {
{
name: 'Lineage',
component: LineageTab,
display: {
visible: (_, _1) => true,
enabled: (_, dataset: GetDatasetQuery) =>
(dataset?.dataset?.upstreamLineage?.entities?.length || 0) > 0 ||
(dataset?.dataset?.downstreamLineage?.entities?.length || 0) > 0,
},
},
{
name: 'Queries',
Expand Down Expand Up @@ -401,8 +395,8 @@ describe('EntityProfile', () => {
display: {
visible: (_, _1) => true,
enabled: (_, dataset: GetDatasetQuery) =>
(dataset?.dataset?.upstreamLineage?.entities?.length || 0) > 0 ||
(dataset?.dataset?.downstreamLineage?.entities?.length || 0) > 0,
((dataset?.dataset as any)?.upstreamLineage?.entities?.length || 0) > 0 ||
((dataset?.dataset as any)?.downstreamLineage?.entities?.length || 0) > 0,
},
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ describe('Form', () => {
urn: '',
entityType: EntityType.Dataset,
entityData: mockEntityDataWithFieldPrompts,
baseEntity: {},
routeToTab: vi.fn(),
refetch: vi.fn(),
loading: true,
lineage: undefined,
dataNotCombinedWithSiblings: null,
}}
>
<Form formUrn="urn:li:form:1" />
Expand All @@ -50,6 +56,12 @@ describe('Form', () => {
urn: '',
entityType: EntityType.Dataset,
entityData: mockEntityData,
baseEntity: {},
routeToTab: vi.fn(),
refetch: vi.fn(),
loading: true,
lineage: undefined,
dataNotCombinedWithSiblings: null,
}}
>
<Form formUrn="urn:li:form:3" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ describe('handleAccessRoles', () => {
createTags: true,
manageGlobalViews: true,
manageOwnershipTypes: true,
manageGlobalAnnouncements: true,
manageTokens: true,
__typename: 'PlatformPrivileges',
},
__typename: 'AuthenticatedUser',
Expand Down Expand Up @@ -155,6 +157,8 @@ describe('handleAccessRoles', () => {
createTags: true,
manageGlobalViews: true,
manageOwnershipTypes: true,
manageGlobalAnnouncements: true,
manageTokens: true,
__typename: 'PlatformPrivileges',
},
__typename: 'AuthenticatedUser',
Expand Down Expand Up @@ -246,6 +250,8 @@ describe('handleAccessRoles', () => {
createTags: true,
manageGlobalViews: true,
manageOwnershipTypes: true,
manageGlobalAnnouncements: true,
manageTokens: true,
__typename: 'PlatformPrivileges',
},
__typename: 'AuthenticatedUser',
Expand Down
Loading
Loading