From 257c4ca89b063d57b211afd285c1b48f93c37eac Mon Sep 17 00:00:00 2001 From: Pavan Soma Shekar <32700193+pavanshekar@users.noreply.github.com> Date: Tue, 26 Nov 2024 16:16:07 -0500 Subject: [PATCH] Fixes #38015 - Handle empty content counts on Proxy UI (#11232) --- .../scenes/SmartProxy/ExpandableCvDetails.js | 2 +- .../__tests__/SmartProxyContentTest.js | 37 +++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/webpack/scenes/SmartProxy/ExpandableCvDetails.js b/webpack/scenes/SmartProxy/ExpandableCvDetails.js index e3ae3f83562..09580897158 100644 --- a/webpack/scenes/SmartProxy/ExpandableCvDetails.js +++ b/webpack/scenes/SmartProxy/ExpandableCvDetails.js @@ -90,7 +90,7 @@ const ExpandableCvDetails = ({ { + 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)