Skip to content

armgit / dashy

Public Imported from GitHub
0

πŸš€ A self-hostable personal dashboard built for you. Includes status-checking, widgets, themes, icon packs, a UI editor and tons more!

πŸ§ͺ Tests for workspace search fixes

Alicia Sykes0c7c4a4fb3e7
diff --git a/tests/components/workspace.test.js b/tests/components/workspace.test.js
index ba865de7..7036a2f8 100644
--- a/tests/components/workspace.test.js
+++ b/tests/components/workspace.test.js
@@ -145,6 +145,26 @@ describe('Workspace SideBar', () => {
expect(titlesIn(wrapper, '.sub-side-bar')).toEqual(['Two']);
});
+ it('shows only the matching sub-items of a group, unless the group itself matches', async () => {
+ const group = {
+ title: 'Downloads',
+ description: 'Media managers',
+ subItems: [
+ { title: 'Sonarr', url: 'https://sonarr.lab/' },
+ { title: 'Radarr', url: 'https://radarr.lab/' },
+ ],
+ };
+ const wrapper = mountSideBar({ sections: [{ name: 'Media', items: [group] }] });
+ await wrapper.find('.side-bar-toggle').trigger('click');
+ const searchFor = (term) => wrapper.find('.side-bar-search').setValue(term);
+ await searchFor('sonarr');
+ expect(titlesIn(wrapper, '.sub-side-bar')).toEqual(['Sonarr']);
+ await searchFor('downloads radarr');
+ expect(titlesIn(wrapper, '.sub-side-bar')).toEqual(['Radarr']);
+ await searchFor('managers');
+ expect(titlesIn(wrapper, '.sub-side-bar')).toEqual(['Sonarr', 'Radarr']);
+ });
+
it('shows widgets when their section is opened, but not when closed', async () => {
const wrapper = mountSideBar();
const header = wrapper.find('.side-bar-item-container [aria-label="Widgets"]');
diff --git a/tests/unit/search.test.js b/tests/unit/search.test.js
index 6a8f3e54..d6b66e47 100644
--- a/tests/unit/search.test.js
+++ b/tests/unit/search.test.js
@@ -100,6 +100,11 @@ describe('Search - searchTiles', () => {
expect(searchTiles([t], 'admin')).toHaveLength(1);
});
+ it('does not match on the URL scheme', () => {
+ const t = tile({ subItems: [{ title: 'Sub', url: 'http://sub.lab' }] });
+ expect(searchTiles([t], 'http')).toEqual([]);
+ });
+
it('tolerates tiles with missing optional fields', () => {
const t = { title: 'Plex' };
expect(searchTiles([t], 'plex')).toHaveLength(1);