Skip to content

Commit 5803016

Browse files
authored
feat: add result meta extension point to new ui and enhance plugins SDK (#733)
* feat: add result meta extension point to new ui and enhance plugins SDK * feat: support nested plugin descriptions
1 parent a9807fe commit 5803016

File tree

9 files changed

+40
-5
lines changed

9 files changed

+40
-5
lines changed

lib/config/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ const assertArrayOf = <T>(itemsType: string, name: string, predicateFn: TypePred
8888
};
8989

9090
const assertPluginDescription = (description: unknown): description is PluginDescription => {
91+
if (Array.isArray(description)) {
92+
return description.every(assertPluginDescription);
93+
}
94+
9195
const maybeDescription = description as PluginDescription;
9296

9397
if (!_.isPlainObject(maybeDescription)) {
@@ -255,6 +259,7 @@ const getParser = (): ReturnType<typeof root<ReporterConfig>> => {
255259
defaultValue: configDefaults.plugins,
256260
parseEnv: JSON.parse,
257261
parseCli: JSON.parse,
262+
map: (value: PluginDescription[] | PluginDescription[][]) => value.flat(),
258263
validate: assertArrayOf('plugin descriptions', 'plugins', assertPluginDescription)
259264
}),
260265
staticImageAccepter: section({

lib/static/modules/default-state.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,5 +174,6 @@ export default Object.assign({config: configDefaults}, {
174174
}
175175
},
176176
timestamp: 0,
177-
browserFeatures: {}
177+
browserFeatures: {},
178+
plugins: {}
178179
}) satisfies State;

lib/static/modules/load-plugin.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import immer from 'immer';
1313
import * as reselect from 'reselect';
1414
import axios from 'axios';
1515
import * as GravityUI from '@gravity-ui/uikit';
16+
import * as GravityUIIcons from '@gravity-ui/icons';
1617
import * as pluginsSDKUI from './plugins-sdk-ui';
1718
import * as selectors from './selectors';
1819
import actionNames from './action-names';
@@ -35,6 +36,7 @@ const whitelistedDeps = {
3536
'reselect': reselect,
3637
'axios': axios,
3738
'@gravity-ui/uikit': GravityUI,
39+
'@gravity-ui/icons': GravityUIIcons,
3840
'html-reporter/plugins-sdk/ui': pluginsSDKUI,
3941
'components': {
4042
Details
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export {PanelSection} from '../new-ui/components/PanelSection';
2+
export {CollapsibleSection} from '../new-ui/features/suites/components/CollapsibleSection';
23
export {State} from '../new-ui/types/store';
34
export * as Features from '../../constants/features';
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export enum ExtensionPointName {
2-
SettingsPanel = 'settings-panel'
2+
SettingsPanel = 'settings-panel',
3+
ResultMeta = 'result_meta'
34
}

lib/static/new-ui/features/suites/components/CollapsibleSection/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ interface CollapsibleSectionProps {
1515
title: string;
1616
children?: ReactNode;
1717
className?: string;
18+
defaultExpanded?: boolean;
19+
onUpdate?: (expanded: boolean) => void;
1820
}
1921

2022
interface CollapsibleSectionInternalProps extends CollapsibleSectionProps{
@@ -26,6 +28,7 @@ interface CollapsibleSectionInternalProps extends CollapsibleSectionProps{
2628
export function CollapsibleSectionInternal(props: CollapsibleSectionInternalProps): ReactNode {
2729
const onUpdateHandler = (): void => {
2830
props.actions.setSectionExpandedState({sectionId: props.sectionId, isExpanded: !props.expanded});
31+
props.onUpdate?.(!props.expanded);
2932
};
3033

3134
return <Disclosure expanded={props.expanded} size={'l'} arrowPosition={'end'} key={props.sectionId} className={props.className}>
@@ -52,6 +55,6 @@ export const CollapsibleSection = connect((state: State, props: CollapsibleSecti
5255

5356
return {
5457
sectionId,
55-
expanded: state.ui.suitesPage.expandedSectionsById[sectionId] ?? true
58+
expanded: state.ui.suitesPage.expandedSectionsById[sectionId] ?? props.defaultExpanded ?? true
5659
};
5760
}, (dispatch) => ({actions: bindActionCreators(actions, dispatch)}))(CollapsibleSectionInternal);

lib/static/new-ui/features/suites/components/TestInfo/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import {ErrorHandler} from '@/static/new-ui/features/error-handling/components/E
1212
import {RunTestLoading} from '@/static/new-ui/components/RunTestLoading';
1313

1414
import styles from './index.module.css';
15+
import ExtensionPoint from '../../../../../components/extension-point';
16+
import {ExtensionPointName} from '../../../../constants/plugins';
1517

1618
export function TestInfo(): ReactNode {
1719
const currentResult = useSelector(getCurrentResult);
@@ -23,7 +25,7 @@ export function TestInfo(): ReactNode {
2325

2426
const shouldShowPlayer = isPlayerAvailable && isPlayerVisible;
2527

26-
return <>
28+
return <ExtensionPoint name={ExtensionPointName.ResultMeta} result={currentResult} testName={currentResult?.name}>
2729
<CollapsibleSection id={'actions'} title={'Actions'}>
2830
<div className={styles.stepsContainer}>
2931
{steps.length > 0 ? (
@@ -48,5 +50,5 @@ export function TestInfo(): ReactNode {
4850
<MetaInfo resultId={currentResult.id}/>
4951
</div>}
5052
</CollapsibleSection>
51-
</>;
53+
</ExtensionPoint>;
5254
}

lib/static/new-ui/types/store.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {CheckStatus} from '@/constants/checked-statuses';
1616
import {EntityType} from '@/static/new-ui/features/suites/components/SuitesPage/types';
1717
import {DbDetails} from '@/db-utils/common';
1818
import {Stats, PerBrowserStats} from '@/tests-tree-builder/static';
19+
import type {Database} from '@gemini-testing/sql.js';
1920

2021
export interface GroupEntity {
2122
id: string;
@@ -366,6 +367,8 @@ export interface State {
366367
timestamp: number;
367368
fetchDbDetails: DbDetails[];
368369
stats: {all: Stats | Record<string, never>, perBrowser: PerBrowserStats | undefined} | null;
370+
db?: Database;
371+
plugins: Record<string, unknown>;
369372
}
370373

371374
declare module 'react-redux' {

lib/static/styles.css

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,25 @@
2020
}
2121

2222
:root {
23+
--color-link: #4f46e5;
24+
--color-link-hover: #818cf8;
25+
--color-bg-dark: #101827;
26+
--color-bg-gray: #eee;
27+
2328
--color-pink-100: #fce0ff;
2429
--color-pink-600: #be00ffbf;
30+
31+
--color-neutral-50: oklch(0.985 0 0);
32+
--color-neutral-100: oklch(0.97 0 0);
33+
--color-neutral-200: oklch(0.922 0 0);
34+
--color-neutral-300: oklch(0.87 0 0);
35+
--color-neutral-400: oklch(0.708 0 0);
36+
--color-neutral-500: oklch(0.556 0 0);
37+
--color-neutral-600: oklch(0.439 0 0);
38+
--color-neutral-700: oklch(0.371 0 0);
39+
--color-neutral-800: oklch(0.269 0 0);
40+
--color-neutral-900: oklch(0.205 0 0);
41+
--color-neutral-950: oklch(0.145 0 0);
2542
}
2643

2744
.report {

0 commit comments

Comments
 (0)