Skip to content

WCMS-21957: Add Message for Datasets Without a Data Dictionary #241

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

Merged
merged 4 commits into from
Aug 20, 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
4 changes: 2 additions & 2 deletions src/components/DatasetDataDictionaryTab/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const DataDictionary = (
const datasetDictionary = data && data.data && data.data.fields && data.data.fields.length ? data.data.fields : null;

return (
<>
<div data-testid="dataset-dictionary-tab">
<h2 className="ds-text-heading--2xl ds-u-margin-y--3">{title}</h2>
{datasetDictionary && (
<>
Expand Down Expand Up @@ -61,7 +61,7 @@ const DataDictionary = (
{datasetSitewideDictionary && (
<SitewideDataDictionaryTable datasetDictionary={datasetSitewideDictionary} pageSize={pageSize} />
)}
</>
</div>
)
}

Expand Down
19 changes: 16 additions & 3 deletions src/templates/Dataset/dataset.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ describe('<Dataset />', () => {
});
await waitFor(() => {
expect(screen.getByRole('heading', { name: 'Product Data for Newly Reported Drugs in the Medicaid Drug Rebate Program 2024-01-08-to-2024-01-14' }));
expect(screen.queryByText('Data Dictionary')).not.toBeInTheDocument();
});

});
Expand All @@ -53,7 +52,21 @@ describe('<Dataset />', () => {
});
await waitFor(() => {
expect(screen.getByRole('heading', { name: '2022 General Payment Data' }));
expect(screen.queryAllByText('Data Dictionary'));
expect(screen.getByTestId('dataset-dictionary-tab')).toBeInTheDocument();
});
})
});
test("Does not render Data Dictionary if dataset does not have describedBy attribute", async () => {
await act(async () => {
jest.useFakeTimers();
await render(<MemoryRouter>
<Dataset
rootUrl={rootUrl}
id={"4eaa5ebe-62f7-402e-a407-963cd380688b"}
/>
</MemoryRouter>);
});
await waitFor(() => {
expect(screen.queryByTestId('dataset-dictionary-tab')).not.toBeInTheDocument();
});
});
});
7 changes: 3 additions & 4 deletions src/templates/Dataset/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ const Dataset = ({
>
<DatasetOverview resource={resource} dataset={dataset} distributions={distributions} metadataMapping={metadataMapping} />
</TabPanel>
{displayDataDictionaryTab && (
<TabPanel
id={'data-dictionary'}
tab={
Expand All @@ -210,15 +209,15 @@ const Dataset = ({
}
className={ borderlessTabs ? 'ds-u-border--0 ds-u-padding-x--0' : '' }
>
<DataDictionary
{displayDataDictionaryTab && <DataDictionary
datasetSitewideDictionary={datasetSitewideDictionary}
datasetDictionaryEndpoint={distribution.data.describedBy}
title={"Data Dictionary"}
additionalParams={additionalParams}
csvDownload={dataDictionaryCSV}
/>
/>}
{!displayDataDictionaryTab && <p>There is no Data Dictionary associated with this dataset.</p>}
</TabPanel>
)}
{ distribution && distribution.data && (
<TabPanel
id={'api'}
Expand Down