From 1d192beb38021145ce235bd9bd6524002a25d6e0 Mon Sep 17 00:00:00 2001 From: Greg Wong Date: Tue, 9 Sep 2025 08:38:40 -0700 Subject: [PATCH] fix(metadata-view): show error state when exception is thrown in metdataview v2 --- src/elements/content-explorer/Content.tsx | 1 + .../MetadataViewContainer.tsx | 3 +- .../__tests__/Content.test.tsx | 28 ++++++++++++++++++- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/elements/content-explorer/Content.tsx b/src/elements/content-explorer/Content.tsx index d1ed0da368..a4bcb6e83d 100644 --- a/src/elements/content-explorer/Content.tsx +++ b/src/elements/content-explorer/Content.tsx @@ -80,6 +80,7 @@ const Content = ({ {view === VIEW_ERROR || view === VIEW_SELECTED ? null : } {!isMetadataViewV2Feature && isViewEmpty && } + {isMetadataViewV2Feature && view === VIEW_ERROR && } {!isMetadataViewV2Feature && !isViewEmpty && isMetadataBasedView && ( { expect(screen.getByLabelText('File')).toBeInTheDocument(); }); - describe('contentExplorer.metadataViewV2 feature', () => { + describe('MetadataView V2 feature', () => { const features = { contentExplorer: { metadataViewV2: true }, }; @@ -123,5 +123,31 @@ describe('Content Component', () => { expect(screen.getByText('MetadataViewContainer')).toBeInTheDocument(); }); + + describe('EmptyView rendering for VIEW_ERROR with metadataViewV2 feature', () => { + test('renders EmptyView with isLoading=false when metadataViewV2 feature is enabled and view is VIEW_ERROR', () => { + // This test verifies that the EmptyView receives isLoading={false} + // We can verify this by checking that the loading message is not shown + renderComponent({ + features, + view: VIEW_ERROR, + }); + + // Should show error message, not loading message + expect(screen.getByText('A network error has occurred while trying to load.')).toBeInTheDocument(); + expect(screen.queryByText('Please wait while the items load...')).not.toBeInTheDocument(); + }); + + test('does not render EmptyView when metadataViewV2 feature is enabled but view is not VIEW_ERROR', () => { + renderComponent({ + features, + view: VIEW_FOLDER, + }); + + expect( + screen.queryByText('A network error has occurred while trying to load.'), + ).not.toBeInTheDocument(); + }); + }); }); });