Skip to content

Commit

Permalink
Fixes #38015 - Handle empty content counts on Proxy UI (Katello#11232)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavanshekar authored Nov 26, 2024
1 parent 7ad24da commit 257c4ca
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion webpack/scenes/SmartProxy/ExpandableCvDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const ExpandableCvDetails = ({
<Tr key="child_row" ouiaId={`ContentViewTableRowChild-${id}`} isExpanded={isExpanded}>
<Td colSpan={12}>
<ExpandedSmartProxyRepositories
contentCounts={contentCounts?.content_view_versions[versionId]?.repositories}
contentCounts={contentCounts?.content_view_versions?.[versionId]?.repositories}
repositories={repositories}
syncedToCapsule={upToDate}
envId={envId}
Expand Down
37 changes: 37 additions & 0 deletions webpack/scenes/SmartProxy/__tests__/SmartProxyContentTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,43 @@ test('Can display Smart proxy content table and expand env and cv details', asyn
assertNockRequest(detailsScope, done);
});

test('Handles empty content_counts and displays N/A for Packages and Additional content', async (done) => {
const emptyContentCountsData = {
...smartProxyContent,
content_counts: {},
};

const detailsScope = nockInstance
.get(smartProxyContentPath)
.query(true)
.reply(200, emptyContentCountsData);

const { getByText, getAllByText, getByLabelText } = renderWithRedux(contentTable);

await patientlyWaitFor(() => expect(getByText('Environment')).toBeInTheDocument());

const tdEnvExpand = getByLabelText('expand-env-1');
const envExpansion = within(tdEnvExpand).getByLabelText('Details');
envExpansion.click();

await patientlyWaitFor(() => expect(getAllByText('Content view')[0]).toBeInTheDocument());
expect(getAllByText('Last published')[0]).toBeInTheDocument();
expect(getAllByText('Repository')[0]).toBeInTheDocument();
expect(getAllByText('Synced')[0]).toBeInTheDocument();

const tdCvExpand = getByLabelText('expand-cv-1');
const cvExpansion = within(tdCvExpand).getByLabelText('Details');
expect(cvExpansion).toHaveAttribute('aria-expanded', 'false');
cvExpansion.click();

await patientlyWaitFor(() => expect(cvExpansion).toHaveAttribute('aria-expanded', 'true'));

expect(getAllByText('N/A')[0]).toBeInTheDocument();
expect(getAllByText('N/A')[1]).toBeInTheDocument();

assertNockRequest(detailsScope, done);
});

test('Can call content count refresh for environment', async (done) => {
const detailsScope = nockInstance
.get(smartProxyContentPath)
Expand Down

0 comments on commit 257c4ca

Please sign in to comment.