diff --git a/lib/ui/src/modules/ui/components/stories_panel/stories_tree/index.test.js b/lib/ui/src/modules/ui/components/stories_panel/stories_tree/index.test.js index 649f8a046557..d5b8ade2e6c4 100644 --- a/lib/ui/src/modules/ui/components/stories_panel/stories_tree/index.test.js +++ b/lib/ui/src/modules/ui/components/stories_panel/stories_tree/index.test.js @@ -2,12 +2,16 @@ import { shallow, mount } from 'enzyme'; import React from 'react'; import Stories from './index'; import { setContext } from '../../../../../compose'; -import { createHierarchies, createHierarchyRoot, prepareStoriesForHierarchy } from '../../../libs/hierarchy'; +import { + createHierarchies, + createHierarchyRoot, + prepareStoriesForHierarchy, +} from '../../../libs/hierarchy'; import { storyFilter } from '../../../libs/filters'; const leftClick = { button: 0 }; -describe('manager.ui.components.left_panel.stories', () => { +describe('manager.ui.components.stories_panel.stories_tree', () => { beforeEach(() => setContext({ clientStore: { diff --git a/lib/ui/src/modules/ui/components/stories_panel/stories_tree/tree_header.test.js b/lib/ui/src/modules/ui/components/stories_panel/stories_tree/tree_header.test.js new file mode 100644 index 000000000000..407c5be7343a --- /dev/null +++ b/lib/ui/src/modules/ui/components/stories_panel/stories_tree/tree_header.test.js @@ -0,0 +1,12 @@ +import React from 'react'; +import { shallow } from 'enzyme'; +import TreeHeader from './tree_header'; + +describe('manager.ui.components.stories_panel.stories_tree.tree_header', () => { + test('should render tree header content', () => { + const content = 'abcd'; + const wrap = shallow({content}); + + expect(wrap.text()).toEqual(content); + }); +}); diff --git a/lib/ui/src/modules/ui/libs/filters.test.js b/lib/ui/src/modules/ui/libs/filters.test.js index 2e24b4eb77c7..104dbba25699 100755 --- a/lib/ui/src/modules/ui/libs/filters.test.js +++ b/lib/ui/src/modules/ui/libs/filters.test.js @@ -8,15 +8,15 @@ describe('manager.ui.libs.filters', () => { }); test('should original stories if there is no filter', () => { - const stories = [{ kind: ['aa'], namespaces: ['aa'], stories: ['bb'] }]; + const stories = [{ kind: ['aa'], namespaces: ['aa'], stories: ['bb'], rootName: '' }]; const res = storyFilter(stories); expect(res).toBe(stories); }); test('should always return the selectedKind', () => { const stories = [ - { kind: 'aa', namespaces: ['aa'], stories: ['bb'] }, - { kind: 'bb', namespaces: ['bb'], stories: ['bb'] }, + { kind: 'aa', namespaces: ['aa'], stories: ['bb'], rootName: '' }, + { kind: 'bb', namespaces: ['bb'], stories: ['bb'], rootName: '' }, ]; const selectedKind = 'bb'; @@ -28,8 +28,8 @@ describe('manager.ui.libs.filters', () => { test('should always return the selectedKind with the single selectedStory', () => { const stories = [ - { kind: 'aa', namespaces: ['aa'], stories: ['bb'] }, - { kind: 'bb', namespaces: ['bb'], stories: ['bb', 'cc', 'dd'] }, + { kind: 'aa', namespaces: ['aa'], stories: ['bb'], rootName: '' }, + { kind: 'bb', namespaces: ['bb'], stories: ['bb', 'cc', 'dd'], rootName: '' }, ]; const selectedKind = 'bb'; @@ -41,9 +41,9 @@ describe('manager.ui.libs.filters', () => { test('should filter kinds correctly', () => { const stories = [ - { kind: 'aa', namespaces: ['aa'], stories: ['bb'] }, - { kind: 'bb', namespaces: ['bb'], stories: ['bb'] }, - { kind: 'ss', namespaces: ['ss'], stories: ['bb'] }, + { kind: 'aa', namespaces: ['aa'], stories: ['bb'], rootName: '' }, + { kind: 'bb', namespaces: ['bb'], stories: ['bb'], rootName: '' }, + { kind: 'ss', namespaces: ['ss'], stories: ['bb'], rootName: '' }, ]; const selectedKind = 'bb'; const selectedStory = 'bb'; @@ -54,9 +54,9 @@ describe('manager.ui.libs.filters', () => { test('should not sort stories by kind', () => { const stories = [ - { kind: 'ss', namespaces: ['ss'], stories: ['bb'] }, - { kind: 'aa', namespaces: ['aa'], stories: ['bb'] }, - { kind: 'bb', namespaces: ['bb'], stories: ['bb'] }, + { kind: 'ss', namespaces: ['ss'], stories: ['bb'], rootName: '' }, + { kind: 'aa', namespaces: ['aa'], stories: ['bb'], rootName: '' }, + { kind: 'bb', namespaces: ['bb'], stories: ['bb'], rootName: '' }, ]; const res = storyFilter(stories); @@ -65,9 +65,9 @@ describe('manager.ui.libs.filters', () => { test('should sort stories by kind', () => { const stories = [ - { kind: 'ss', namespaces: ['ss'], stories: ['bb'] }, - { kind: 'aa', namespaces: ['aa'], stories: ['bb'] }, - { kind: 'bb', namespaces: ['bb'], stories: ['bb'] }, + { kind: 'ss', namespaces: ['ss'], stories: ['bb'], rootName: '' }, + { kind: 'aa', namespaces: ['aa'], stories: ['bb'], rootName: '' }, + { kind: 'bb', namespaces: ['bb'], stories: ['bb'], rootName: '' }, ]; const res = storyFilter(stories, null, null, null, true); @@ -76,9 +76,9 @@ describe('manager.ui.libs.filters', () => { test('should filter on story level', () => { const stories = [ - { kind: 'aa', namespaces: ['aa'], stories: ['bb'] }, - { kind: 'cc', namespaces: ['cc'], stories: ['dd'] }, - { kind: 'ee', namespaces: ['ee'], stories: ['ff'] }, + { kind: 'aa', namespaces: ['aa'], stories: ['bb'], rootName: '' }, + { kind: 'cc', namespaces: ['cc'], stories: ['dd'], rootName: '' }, + { kind: 'ee', namespaces: ['ee'], stories: ['ff'], rootName: '' }, ]; const selectedKind = 'aa'; const selectedStory = 'bb'; @@ -89,21 +89,21 @@ describe('manager.ui.libs.filters', () => { test('should filter out unmatched stories at lowest level', () => { const stories = [ - { kind: 'aa', namespaces: ['aa'], stories: ['bb'] }, - { kind: 'cc', namespaces: ['cc'], stories: ['dd'] }, - { kind: 'ee', namespaces: ['ee'], stories: ['ff', 'gg'] }, + { kind: 'aa', namespaces: ['aa'], stories: ['bb'], rootName: '' }, + { kind: 'cc', namespaces: ['cc'], stories: ['dd'], rootName: '' }, + { kind: 'ee', namespaces: ['ee'], stories: ['ff', 'gg'], rootName: '' }, ]; const selectedKind = 'aa'; const selectedStory = 'bb'; const res = storyFilter(stories, 'ff', selectedKind, selectedStory); - expect(res).toMatchObject([stories[0], { kind: 'ee', stories: ['ff'] }]); + expect(res).toMatchObject([stories[0], { kind: 'ee', stories: ['ff'], rootName: '' }]); }); test('should be case insensitive at tree level', () => { const stories = [ - { kind: 'Aa', namespaces: ['aA'], stories: ['bb'] }, - { kind: 'cc', namespaces: ['cc'], stories: ['dd'] }, + { kind: 'Aa', namespaces: ['aA'], stories: ['bb'], rootName: '' }, + { kind: 'cc', namespaces: ['cc'], stories: ['dd'], rootName: '' }, ]; const selectedKind = 'aA'; const res = storyFilter(stories, 'aa', selectedKind); @@ -113,14 +113,14 @@ describe('manager.ui.libs.filters', () => { test('should be case insensitive at story level', () => { const stories = [ - { kind: 'aa', namespaces: ['aa'], stories: ['bb'] }, - { kind: 'cc', namespaces: ['cc'], stories: ['dd', 'eE'] }, + { kind: 'aa', namespaces: ['aa'], stories: ['bb'], rootName: '' }, + { kind: 'cc', namespaces: ['cc'], stories: ['dd', 'eE'], rootName: '' }, ]; const selectedKind = 'aa'; const selectedStory = 'bb'; const res = storyFilter(stories, 'ee', selectedKind, selectedStory); - expect(res).toMatchObject([stories[0], { kind: 'cc', stories: ['eE'] }]); + expect(res).toMatchObject([stories[0], { kind: 'cc', stories: ['eE'], rootName: '' }]); }); }); });