Skip to content

Commit

Permalink
open-metadata#10502 Show dbt node fields in the UI (open-metadata#16411)
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaileshParmar11 authored May 24, 2024
1 parent fe2db2d commit 89b1b09
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,54 @@ describe('TestDetailsPageV1 component', () => {
expect(screen.queryByText('label.view-definition')).not.toBeInTheDocument();
});

it('TableDetailsPageV1 should dbt tab for rawSql, when sql is empty', async () => {
(usePermissionProvider as jest.Mock).mockImplementationOnce(() => ({
getEntityPermissionByFqn: jest.fn().mockImplementationOnce(() => ({
ViewBasic: true,
})),
}));

(getTableDetailsByFQN as jest.Mock).mockImplementationOnce(() =>
Promise.resolve({
name: 'test',
id: '123',
tableFqn: 'fqn',
dataModel: { sql: '', rawSql: 'rawSql' },
})
);

await act(async () => {
render(<TableDetailsPageV1 />);
});

expect(await screen.findByText('label.dbt-lowercase')).toBeInTheDocument();
expect(screen.queryByText('label.view-definition')).not.toBeInTheDocument();
});

it('TableDetailsPageV1 should dbt tab for rawSql, when there is no sql available', async () => {
(usePermissionProvider as jest.Mock).mockImplementationOnce(() => ({
getEntityPermissionByFqn: jest.fn().mockImplementationOnce(() => ({
ViewBasic: true,
})),
}));

(getTableDetailsByFQN as jest.Mock).mockImplementationOnce(() =>
Promise.resolve({
name: 'test',
id: '123',
tableFqn: 'fqn',
dataModel: { rawSql: 'rawSql' },
})
);

await act(async () => {
render(<TableDetailsPageV1 />);
});

expect(await screen.findByText('label.dbt-lowercase')).toBeInTheDocument();
expect(screen.queryByText('label.view-definition')).not.toBeInTheDocument();
});

it('TableDetailsPageV1 should render schema definition tab table type is not view', async () => {
(usePermissionProvider as jest.Mock).mockImplementationOnce(() => ({
getEntityPermissionByFqn: jest.fn().mockImplementationOnce(() => ({
Expand All @@ -325,6 +373,7 @@ describe('TestDetailsPageV1 component', () => {
});

expect(screen.getByText('label.schema-definition')).toBeInTheDocument();
expect(screen.queryByText('label.dbt-lowercase')).not.toBeInTheDocument();
});

it('TableDetailsPageV1 should render view definition tab if table type is view', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { Col, Row, Space, Tabs, Typography } from 'antd';
import { AxiosError } from 'axios';
import classNames from 'classnames';
import { compare } from 'fast-json-patch';
import { isEmpty, isEqual, isUndefined } from 'lodash';
import { get, isEmpty, isEqual, isUndefined } from 'lodash';
import { EntityTags } from 'Models';
import React, { useCallback, useEffect, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
Expand Down Expand Up @@ -733,15 +733,14 @@ const TableDetailsPageV1: React.FC = () => {
<TabsLabel id={EntityTabs.DBT} name={t('label.dbt-lowercase')} />
),
isHidden: !(
tableDetails?.dataModel?.sql ?? tableDetails?.dataModel?.rawSql
tableDetails?.dataModel?.sql || tableDetails?.dataModel?.rawSql
),
key: EntityTabs.DBT,
children: (
<QueryViewer
sqlQuery={
tableDetails?.dataModel?.sql ??
tableDetails?.dataModel?.rawSql ??
''
get(tableDetails, 'dataModel.sql', '') ||
get(tableDetails, 'dataModel.rawSql', '')
}
title={
<Space className="p-y-xss">
Expand Down

0 comments on commit 89b1b09

Please sign in to comment.