From 849d14014b916cf8f552787dc745cbcef04b27a7 Mon Sep 17 00:00:00 2001 From: shadowusr Date: Fri, 27 Sep 2024 17:49:49 +0300 Subject: [PATCH] chore(new-ui): fix missing suites when suite both has nested browsers and suites --- .../components/SuitesTreeView/selectors.ts | 29 +++++++++---------- lib/static/new-ui/types/store.ts | 3 +- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/static/new-ui/features/suites/components/SuitesTreeView/selectors.ts b/lib/static/new-ui/features/suites/components/SuitesTreeView/selectors.ts index e115ec2b..323e06ea 100644 --- a/lib/static/new-ui/features/suites/components/SuitesTreeView/selectors.ts +++ b/lib/static/new-ui/features/suites/components/SuitesTreeView/selectors.ts @@ -3,7 +3,8 @@ import {get, last} from 'lodash'; import { isImageEntityFail, isResultEntityError, - isSuiteEntityLeaf, + hasBrowsers, + hasSuites, BrowserEntity, SuiteEntity } from '@/static/new-ui/types/store'; @@ -90,21 +91,19 @@ export const getTreeViewItems = createSelector( return null; } - if (isSuiteEntityLeaf(suiteData)) { - return { - data, - children: suiteData.browserIds - .map((browserId) => formatBrowser(browsers[browserId], data)) - .filter(Boolean) as TreeViewItem[] - }; - } else { - return { - data, - children: suiteData.suiteIds - .map((suiteId) => formatSuite(suites[suiteId], data)) - .filter(Boolean) as TreeViewItem[] - }; + const children: TreeViewItem[] = []; + if (hasBrowsers(suiteData)) { + children.push(...suiteData.browserIds + .map((browserId) => formatBrowser(browsers[browserId], data)) + .filter(Boolean) as TreeViewItem[]); } + if (hasSuites(suiteData)) { + children.push(...suiteData.suiteIds + .map((suiteId) => formatSuite(suites[suiteId], data)) + .filter(Boolean) as TreeViewItem[]); + } + + return {data, children}; }; const tree = rootSuiteIds diff --git a/lib/static/new-ui/types/store.ts b/lib/static/new-ui/types/store.ts index 98262358..e4619a1d 100644 --- a/lib/static/new-ui/types/store.ts +++ b/lib/static/new-ui/types/store.ts @@ -21,7 +21,8 @@ export interface SuiteEntityLeaf { export type SuiteEntity = SuiteEntityNode | SuiteEntityLeaf; -export const isSuiteEntityLeaf = (suite: SuiteEntity): suite is SuiteEntityLeaf => Boolean((suite as SuiteEntityLeaf).browserIds); +export const hasBrowsers = (suite: SuiteEntity): suite is SuiteEntityLeaf => Boolean((suite as SuiteEntityLeaf).browserIds); +export const hasSuites = (suite: SuiteEntity): suite is SuiteEntityNode => Boolean((suite as SuiteEntityNode).suiteIds); export interface BrowserEntity { id: string;