Skip to content

Commit 7f34ee8

Browse files
committed
filter tests
1 parent 16b5fd6 commit 7f34ee8

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

packages/compass-data-modeling/src/components/saved-diagrams-list.spec.tsx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,5 +122,35 @@ describe('SavedDiagramsList', function () {
122122
userEvent.click(createDiagramButton);
123123
expect(store.getState().generateDiagramWizard.inProgress).to.be.true;
124124
});
125+
126+
it('filters the list of diagrams', async function () {
127+
const searchInput = screen.getByPlaceholderText('Search');
128+
userEvent.type(searchInput, 'One');
129+
await waitFor(() => {
130+
expect(screen.queryByText('One')).to.exist;
131+
});
132+
133+
await waitFor(() => {
134+
expect(screen.queryByText('Two')).to.not.exist;
135+
expect(screen.queryByText('Three')).to.not.exist;
136+
});
137+
});
138+
139+
it('shows empty content when filter for a non-existent diagram', async function () {
140+
const searchInput = screen.getByPlaceholderText('Search');
141+
userEvent.type(searchInput, 'Hello');
142+
await waitFor(() => {
143+
expect(screen.queryByText('No results found.')).to.exist;
144+
expect(
145+
screen.queryByText("We can't find any diagram matching your search.")
146+
).to.exist;
147+
});
148+
149+
await waitFor(() => {
150+
expect(screen.queryByText('One')).to.not.exist;
151+
expect(screen.queryByText('Two')).to.not.exist;
152+
expect(screen.queryByText('Three')).to.not.exist;
153+
});
154+
});
125155
});
126156
});

packages/compass-data-modeling/src/components/saved-diagrams-list.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,12 @@ export const SavedDiagramsList: React.FunctionComponent<{
225225
headerHeight={spacing[800] * 3 + spacing[200]}
226226
classNames={{ row: rowStyles }}
227227
resetActiveItemOnBlur={false}
228+
renderEmptyList={() => (
229+
<EmptyContent
230+
title="No results found."
231+
subTitle="We can't find any diagram matching your search."
232+
/>
233+
)}
228234
></VirtualGrid>
229235
</WorkspaceContainer>
230236
</DiagramListContext.Provider>

0 commit comments

Comments
 (0)