@finos/legend-application-studio 28.13.2 → 28.13.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/lib/__lib__/LegendStudioApplicationNavigationContext.d.ts +1 -0
  2. package/lib/__lib__/LegendStudioApplicationNavigationContext.d.ts.map +1 -1
  3. package/lib/__lib__/LegendStudioApplicationNavigationContext.js +1 -0
  4. package/lib/__lib__/LegendStudioApplicationNavigationContext.js.map +1 -1
  5. package/lib/application/LegendStudioApplicationConfig.d.ts +5 -9
  6. package/lib/application/LegendStudioApplicationConfig.d.ts.map +1 -1
  7. package/lib/application/LegendStudioApplicationConfig.js +6 -10
  8. package/lib/application/LegendStudioApplicationConfig.js.map +1 -1
  9. package/lib/components/editor/ActivityBar.d.ts.map +1 -1
  10. package/lib/components/editor/ActivityBar.js +2 -2
  11. package/lib/components/editor/ActivityBar.js.map +1 -1
  12. package/lib/components/editor/editor-group/function-activator/FunctionEditor.d.ts +1 -1
  13. package/lib/components/editor/editor-group/function-activator/FunctionEditor.d.ts.map +1 -1
  14. package/lib/components/editor/editor-group/function-activator/FunctionEditor.js +46 -95
  15. package/lib/components/editor/editor-group/function-activator/FunctionEditor.js.map +1 -1
  16. package/lib/components/editor/editor-group/function-activator/SnowflakeAppFunctionActivatorEditor.d.ts.map +1 -1
  17. package/lib/components/editor/editor-group/function-activator/SnowflakeAppFunctionActivatorEditor.js +3 -3
  18. package/lib/components/editor/editor-group/function-activator/SnowflakeAppFunctionActivatorEditor.js.map +1 -1
  19. package/lib/components/editor/editor-group/function-activator/testable/FunctionTestableEditor.d.ts +22 -0
  20. package/lib/components/editor/editor-group/function-activator/testable/FunctionTestableEditor.d.ts.map +1 -0
  21. package/lib/components/editor/editor-group/function-activator/testable/FunctionTestableEditor.js +231 -0
  22. package/lib/components/editor/editor-group/function-activator/testable/FunctionTestableEditor.js.map +1 -0
  23. package/lib/components/editor/side-bar/Explorer.d.ts.map +1 -1
  24. package/lib/components/editor/side-bar/Explorer.js +1 -25
  25. package/lib/components/editor/side-bar/Explorer.js.map +1 -1
  26. package/lib/index.css +1 -1
  27. package/lib/package.json +1 -1
  28. package/lib/stores/editor/editor-state/element-editor-state/{FunctionActivatorPromoteState.d.ts → FunctionActivatorState.d.ts} +9 -9
  29. package/lib/stores/editor/editor-state/element-editor-state/FunctionActivatorState.d.ts.map +1 -0
  30. package/lib/stores/editor/editor-state/element-editor-state/{FunctionActivatorPromoteState.js → FunctionActivatorState.js} +24 -24
  31. package/lib/stores/editor/editor-state/element-editor-state/FunctionActivatorState.js.map +1 -0
  32. package/lib/stores/editor/editor-state/element-editor-state/FunctionEditorState.d.ts +6 -5
  33. package/lib/stores/editor/editor-state/element-editor-state/FunctionEditorState.d.ts.map +1 -1
  34. package/lib/stores/editor/editor-state/element-editor-state/FunctionEditorState.js +6 -5
  35. package/lib/stores/editor/editor-state/element-editor-state/FunctionEditorState.js.map +1 -1
  36. package/lib/stores/editor/editor-state/element-editor-state/{FunctionActivatorBuilderState.d.ts → ToDelete_FunctionActivatorBuilderState.d.ts} +1 -1
  37. package/lib/stores/editor/editor-state/element-editor-state/ToDelete_FunctionActivatorBuilderState.d.ts.map +1 -0
  38. package/lib/stores/editor/editor-state/element-editor-state/{FunctionActivatorBuilderState.js → ToDelete_FunctionActivatorBuilderState.js} +1 -1
  39. package/lib/stores/editor/editor-state/element-editor-state/ToDelete_FunctionActivatorBuilderState.js.map +1 -0
  40. package/lib/stores/editor/editor-state/element-editor-state/function-activator/INTERNAL__UnknownFunctionActivatorEditorState.js +1 -1
  41. package/lib/stores/editor/editor-state/element-editor-state/function-activator/INTERNAL__UnknownFunctionActivatorEditorState.js.map +1 -1
  42. package/lib/stores/editor/editor-state/element-editor-state/function-activator/SnowflakeAppFunctionActivatorEditorState.d.ts +1 -1
  43. package/lib/stores/editor/editor-state/element-editor-state/function-activator/SnowflakeAppFunctionActivatorEditorState.d.ts.map +1 -1
  44. package/lib/stores/editor/editor-state/element-editor-state/function-activator/SnowflakeAppFunctionActivatorEditorState.js +2 -2
  45. package/lib/stores/editor/editor-state/element-editor-state/function-activator/SnowflakeAppFunctionActivatorEditorState.js.map +1 -1
  46. package/lib/stores/editor/editor-state/element-editor-state/function-activator/testable/FunctionTestableState.d.ts +81 -0
  47. package/lib/stores/editor/editor-state/element-editor-state/function-activator/testable/FunctionTestableState.d.ts.map +1 -0
  48. package/lib/stores/editor/editor-state/element-editor-state/function-activator/testable/FunctionTestableState.js +286 -0
  49. package/lib/stores/editor/editor-state/element-editor-state/function-activator/testable/FunctionTestableState.js.map +1 -0
  50. package/lib/stores/editor/editor-state/element-editor-state/mapping/MappingEditorState.d.ts.map +1 -1
  51. package/lib/stores/editor/editor-state/element-editor-state/mapping/MappingEditorState.js +1 -1
  52. package/lib/stores/editor/editor-state/element-editor-state/mapping/MappingEditorState.js.map +1 -1
  53. package/lib/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestableState.d.ts +3 -17
  54. package/lib/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestableState.d.ts.map +1 -1
  55. package/lib/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestableState.js +8 -69
  56. package/lib/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestableState.js.map +1 -1
  57. package/lib/stores/editor/editor-state/element-editor-state/testable/TestableEditorState.d.ts +26 -3
  58. package/lib/stores/editor/editor-state/element-editor-state/testable/TestableEditorState.d.ts.map +1 -1
  59. package/lib/stores/editor/editor-state/element-editor-state/testable/TestableEditorState.js +72 -1
  60. package/lib/stores/editor/editor-state/element-editor-state/testable/TestableEditorState.js.map +1 -1
  61. package/lib/stores/graph-modifier/DomainGraphModifierHelper.d.ts +3 -1
  62. package/lib/stores/graph-modifier/DomainGraphModifierHelper.d.ts.map +1 -1
  63. package/lib/stores/graph-modifier/DomainGraphModifierHelper.js +7 -1
  64. package/lib/stores/graph-modifier/DomainGraphModifierHelper.js.map +1 -1
  65. package/lib/stores/graph-modifier/Testable_GraphModifierHelper.d.ts +3 -2
  66. package/lib/stores/graph-modifier/Testable_GraphModifierHelper.d.ts.map +1 -1
  67. package/lib/stores/graph-modifier/Testable_GraphModifierHelper.js +3 -0
  68. package/lib/stores/graph-modifier/Testable_GraphModifierHelper.js.map +1 -1
  69. package/package.json +4 -4
  70. package/src/__lib__/LegendStudioApplicationNavigationContext.ts +1 -0
  71. package/src/application/LegendStudioApplicationConfig.ts +7 -12
  72. package/src/components/editor/ActivityBar.tsx +3 -2
  73. package/src/components/editor/editor-group/function-activator/FunctionEditor.tsx +59 -276
  74. package/src/components/editor/editor-group/function-activator/SnowflakeAppFunctionActivatorEditor.tsx +3 -10
  75. package/src/components/editor/editor-group/function-activator/testable/FunctionTestableEditor.tsx +748 -0
  76. package/src/components/editor/side-bar/Explorer.tsx +0 -59
  77. package/src/stores/editor/editor-state/element-editor-state/{FunctionActivatorPromoteState.ts → FunctionActivatorState.ts} +23 -23
  78. package/src/stores/editor/editor-state/element-editor-state/FunctionEditorState.ts +7 -6
  79. package/src/stores/editor/editor-state/element-editor-state/function-activator/INTERNAL__UnknownFunctionActivatorEditorState.ts +1 -1
  80. package/src/stores/editor/editor-state/element-editor-state/function-activator/SnowflakeAppFunctionActivatorEditorState.ts +2 -2
  81. package/src/stores/editor/editor-state/element-editor-state/function-activator/testable/FunctionTestableState.ts +414 -0
  82. package/src/stores/editor/editor-state/element-editor-state/mapping/MappingEditorState.ts +1 -4
  83. package/src/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestableState.ts +16 -96
  84. package/src/stores/editor/editor-state/element-editor-state/testable/TestableEditorState.ts +105 -3
  85. package/src/stores/graph-modifier/DomainGraphModifierHelper.ts +23 -2
  86. package/src/stores/graph-modifier/Testable_GraphModifierHelper.ts +9 -1
  87. package/tsconfig.json +4 -2
  88. package/lib/stores/editor/editor-state/element-editor-state/FunctionActivatorBuilderState.d.ts.map +0 -1
  89. package/lib/stores/editor/editor-state/element-editor-state/FunctionActivatorBuilderState.js.map +0 -1
  90. package/lib/stores/editor/editor-state/element-editor-state/FunctionActivatorPromoteState.d.ts.map +0 -1
  91. package/lib/stores/editor/editor-state/element-editor-state/FunctionActivatorPromoteState.js.map +0 -1
  92. /package/src/stores/editor/editor-state/element-editor-state/{FunctionActivatorBuilderState.ts → ToDelete_FunctionActivatorBuilderState.ts} +0 -0
@@ -91,7 +91,6 @@ import { flowResult } from 'mobx';
91
91
  import { useEditorStore } from '../EditorStoreProvider.js';
92
92
  import {
93
93
  type PackageableElement,
94
- type FunctionActivatorConfiguration,
95
94
  ELEMENT_PATH_DELIMITER,
96
95
  ROOT_PACKAGE_NAME,
97
96
  Package,
@@ -144,7 +143,6 @@ import {
144
143
  CodeEditor,
145
144
  } from '@finos/legend-lego/code-editor';
146
145
  import { DatabaseBuilderWizard } from '../editor-group/connection-editor/DatabaseBuilderWizard.js';
147
- import { FunctionEditorState } from '../../../stores/editor/editor-state/element-editor-state/FunctionEditorState.js';
148
146
  import { DatabaseModelBuilder } from '../editor-group/connection-editor/DatabaseModelBuilder.js';
149
147
  import { queryService } from '../editor-group/service-editor/ServiceExecutionQueryEditor.js';
150
148
  import { QueryDatabaseState } from '../../../stores/editor/editor-state/element-editor-state/database/QueryDatabaseState.js';
@@ -755,50 +753,6 @@ const ExplorerContextMenu = observer(
755
753
  ).catch(applicationStore.alertUnhandledError);
756
754
  }
757
755
  };
758
- const activateFunction = (): void => {
759
- if (node?.packageableElement instanceof ConcreteFunctionDefinition) {
760
- editorStore.setQuickInputState({
761
- title: 'Activate function',
762
- placeholder: 'Select an activation...',
763
- options: editorStore.graphState.functionActivatorConfigurations.map(
764
- (config) => ({
765
- value: config,
766
- label: (
767
- <div
768
- className="function-editor__activator__selector__option"
769
- title={config.description}
770
- >
771
- <div className="function-editor__activator__selector__option__name">
772
- {config.name}
773
- </div>
774
- <div className="function-editor__activator__selector__option__description">
775
- {config.description}
776
- </div>
777
- </div>
778
- ),
779
- }),
780
- ),
781
- getSearchValue: (option: {
782
- value: FunctionActivatorConfiguration;
783
- label: React.ReactNode;
784
- }): string => option.value.name,
785
- onSelect: (option: {
786
- value: FunctionActivatorConfiguration;
787
- label: React.ReactNode;
788
- }) => {
789
- editorStore.graphEditorMode.openElement(node.packageableElement);
790
- editorStore.tabManagerState
791
- .getCurrentEditorState(FunctionEditorState)
792
- .activatorBuilderState.setCurrentActivatorConfiguration(
793
- option.value,
794
- );
795
- },
796
- customization: {
797
- rowHeight: 70,
798
- },
799
- });
800
- }
801
- };
802
756
 
803
757
  if (isDependencyProjectRoot()) {
804
758
  return (
@@ -878,19 +832,6 @@ const ExplorerContextMenu = observer(
878
832
  <MenuContentDivider />
879
833
  </>
880
834
  )}
881
- {node.packageableElement instanceof ConcreteFunctionDefinition && (
882
- <>
883
- {editorStore.applicationStore.config.options
884
- .TEMPORARY__enableFunctionActivatorSupport && (
885
- <>
886
- <MenuContentItem onClick={activateFunction}>
887
- Activate...
888
- </MenuContentItem>
889
- <MenuContentDivider />
890
- </>
891
- )}
892
- </>
893
- )}
894
835
  {isRelationalDatabaseConnection(node.packageableElement) && (
895
836
  <>
896
837
  <MenuContentItem onClick={openSQLPlayground}>
@@ -27,54 +27,54 @@ import {
27
27
  SnowflakeAppType,
28
28
  } from '@finos/legend-graph';
29
29
  import { type GeneratorFn } from '@finos/legend-shared';
30
- import { FUNCTION_PROMOTE_TYPE } from '../../../../components/editor/editor-group/function-activator/FunctionEditor.js';
30
+ import { FUNCTION_ACTIVATE_TYPE } from '../../../../components/editor/editor-group/function-activator/FunctionEditor.js';
31
31
 
32
32
  const BASE_ACTIVATOR_NAME = 'NewActivator';
33
33
 
34
- export class FunctionActivatorPromoteState {
34
+ export class FunctionActivatorState {
35
35
  readonly functionEditorState: FunctionEditorState;
36
36
 
37
37
  activatorPath: string;
38
- isPromotingFunction = false;
38
+ isActivatingFunction = false;
39
39
  isFunctionActivatorEditorOpen = false;
40
- promoteType: string | undefined;
40
+ activateType: string | undefined;
41
41
 
42
42
  constructor(functionEditorState: FunctionEditorState) {
43
43
  makeObservable(this, {
44
44
  activatorPath: observable,
45
- isPromotingFunction: observable,
45
+ isActivatingFunction: observable,
46
46
  isFunctionActivatorEditorOpen: observable,
47
- promoteType: observable,
48
- setPromoteType: action,
47
+ activateType: observable,
48
+ setAcitvateType: action,
49
49
  updateActivatorPath: action,
50
- setIsPromotingFunction: action,
50
+ setIsActivatingFunction: action,
51
51
  setIsFunctionActivatorEditorOpen: action,
52
- promote: flow,
52
+ activate: flow,
53
53
  });
54
54
 
55
55
  this.functionEditorState = functionEditorState;
56
- this.promoteType = FUNCTION_PROMOTE_TYPE.SNOWFLAKE_NATIVE_APP;
56
+ this.activateType = FUNCTION_ACTIVATE_TYPE.SNOWFLAKE_NATIVE_APP;
57
57
  this.activatorPath = `${this.functionEditorState.functionElement.package?.path}::${BASE_ACTIVATOR_NAME}`;
58
58
  }
59
59
 
60
- setIsPromotingFunction(val: boolean): void {
61
- this.isPromotingFunction = val;
60
+ setIsActivatingFunction(val: boolean): void {
61
+ this.isActivatingFunction = val;
62
62
  }
63
63
 
64
64
  setIsFunctionActivatorEditorOpen(val: boolean): void {
65
65
  this.isFunctionActivatorEditorOpen = val;
66
66
  }
67
67
 
68
- setPromoteType(val: string | undefined): void {
69
- this.promoteType = val;
68
+ setAcitvateType(val: string | undefined): void {
69
+ this.activateType = val;
70
70
  }
71
71
 
72
- showFunctionPromoteModal(): void {
73
- this.setIsPromotingFunction(true);
72
+ showFunctionActivateModal(): void {
73
+ this.setIsActivatingFunction(true);
74
74
  }
75
75
 
76
- closeFunctionPromoteModal(): void {
77
- this.setIsPromotingFunction(false);
76
+ closeFunctionActivateModal(): void {
77
+ this.setIsActivatingFunction(false);
78
78
  }
79
79
 
80
80
  updateActivatorPath(val: string): void {
@@ -84,9 +84,9 @@ export class FunctionActivatorPromoteState {
84
84
  createFunctionActivator(
85
85
  functionElement: ConcreteFunctionDefinition,
86
86
  ): FunctionActivator | undefined {
87
- const type = this.promoteType;
87
+ const type = this.activateType;
88
88
  switch (type) {
89
- case FUNCTION_PROMOTE_TYPE.SNOWFLAKE_NATIVE_APP: {
89
+ case FUNCTION_ACTIVATE_TYPE.SNOWFLAKE_NATIVE_APP: {
90
90
  const activatorName = this.activatorPath.includes('::')
91
91
  ? extractElementNameFromPath(this.activatorPath)
92
92
  : this.activatorPath;
@@ -106,7 +106,7 @@ export class FunctionActivatorPromoteState {
106
106
  }
107
107
  }
108
108
 
109
- *promote(functionElement: ConcreteFunctionDefinition): GeneratorFn<void> {
109
+ *activate(functionElement: ConcreteFunctionDefinition): GeneratorFn<void> {
110
110
  const functionActivator = this.createFunctionActivator(functionElement);
111
111
  if (!functionActivator) {
112
112
  return;
@@ -121,10 +121,10 @@ export class FunctionActivatorPromoteState {
121
121
  );
122
122
  } catch {
123
123
  this.functionEditorState.editorStore.applicationStore.notificationService.notifyError(
124
- `Can't promote function`,
124
+ `Can't activate function`,
125
125
  );
126
126
  } finally {
127
- this.setPromoteType(FUNCTION_PROMOTE_TYPE.SNOWFLAKE_NATIVE_APP);
127
+ this.setAcitvateType(FUNCTION_ACTIVATE_TYPE.SNOWFLAKE_NATIVE_APP);
128
128
  }
129
129
  }
130
130
  }
@@ -65,13 +65,14 @@ import {
65
65
  buildExecutionParameterValues,
66
66
  getExecutionQueryFromRawLambda,
67
67
  } from '@finos/legend-query-builder';
68
- import { FunctionActivatorBuilderState } from './FunctionActivatorBuilderState.js';
69
- import { FunctionActivatorPromoteState } from './FunctionActivatorPromoteState.js';
68
+ import { FunctionActivatorState } from './FunctionActivatorState.js';
69
+ import { FunctionTestableState } from './function-activator/testable/FunctionTestableState.js';
70
70
 
71
71
  export enum FUNCTION_EDITOR_TAB {
72
72
  DEFINITION = 'DEFINITION',
73
73
  TAGGED_VALUES = 'TAGGED_VALUES',
74
74
  STEREOTYPES = 'STEREOTYPES',
75
+ TEST_SUITES = 'TEST_SUITES',
75
76
  }
76
77
 
77
78
  export class FunctionDefinitionEditorState extends LambdaEditorState {
@@ -244,8 +245,8 @@ export class FunctionParametersState extends LambdaParametersState {
244
245
 
245
246
  export class FunctionEditorState extends ElementEditorState {
246
247
  readonly functionDefinitionEditorState: FunctionDefinitionEditorState;
247
- readonly activatorBuilderState: FunctionActivatorBuilderState; // to be removed
248
- readonly activatorPromoteState: FunctionActivatorPromoteState;
248
+ readonly activatorPromoteState: FunctionActivatorState;
249
+ readonly functionTestableEditorState: FunctionTestableState;
249
250
 
250
251
  selectedTab: FUNCTION_EDITOR_TAB;
251
252
 
@@ -288,13 +289,13 @@ export class FunctionEditorState extends ElementEditorState {
288
289
  element,
289
290
  this.editorStore,
290
291
  );
291
- this.activatorBuilderState = new FunctionActivatorBuilderState(this);
292
- this.activatorPromoteState = new FunctionActivatorPromoteState(this);
292
+ this.activatorPromoteState = new FunctionActivatorState(this);
293
293
  this.executionPlanState = new ExecutionPlanState(
294
294
  this.editorStore.applicationStore,
295
295
  this.editorStore.graphManagerState,
296
296
  );
297
297
  this.parametersState = new FunctionParametersState(this);
298
+ this.functionTestableEditorState = new FunctionTestableState(this);
298
299
  }
299
300
 
300
301
  override get label(): string {
@@ -30,7 +30,7 @@ import {
30
30
  } from '@finos/legend-shared';
31
31
  import { ProtocolValueBuilderState } from '../ProtocolValueBuilderState.js';
32
32
  import { INTERNAL__UnknownFunctionActivator_setContent } from '../../../../graph-modifier/DomainGraphModifierHelper.js';
33
- import { FUNCTION_ACTIVATOR_EXCLUDED_PATHS } from '../FunctionActivatorBuilderState.js';
33
+ import { FUNCTION_ACTIVATOR_EXCLUDED_PATHS } from '../ToDelete_FunctionActivatorBuilderState.js';
34
34
 
35
35
  export class INTERNAL__UnknownFunctionActivatorEdtiorState extends ElementEditorState {
36
36
  readonly activator: INTERNAL__UnknownFunctionActivator;
@@ -50,7 +50,7 @@ export class SnowflakeAppFunctionActivatorEdtiorState extends ElementEditorState
50
50
  updateConnection: action,
51
51
  updateAppType: action,
52
52
  validate: flow,
53
- deploy: flow,
53
+ deployToSandbox: flow,
54
54
  });
55
55
  }
56
56
 
@@ -106,7 +106,7 @@ export class SnowflakeAppFunctionActivatorEdtiorState extends ElementEditorState
106
106
  }
107
107
  }
108
108
 
109
- *deploy(): GeneratorFn<void> {
109
+ *deployToSandbox(): GeneratorFn<void> {
110
110
  this.deployState.inProgress();
111
111
  try {
112
112
  yield this.editorStore.graphManagerState.graphManager.publishFunctionActivatorToSandbox(
@@ -0,0 +1,414 @@
1
+ /**
2
+ * Copyright (c) 2020-present, Goldman Sachs
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { action, flow, makeObservable, observable } from 'mobx';
18
+ import type { EditorStore } from '../../../../EditorStore.js';
19
+ import type { FunctionEditorState } from '../../FunctionEditorState.js';
20
+ import {
21
+ assertErrorThrown,
22
+ isNonNullable,
23
+ uuid,
24
+ type GeneratorFn,
25
+ } from '@finos/legend-shared';
26
+ import {
27
+ FunctionTest,
28
+ type ConcreteFunctionDefinition,
29
+ type EmbeddedData,
30
+ type FunctionStoreTestData,
31
+ type FunctionTestSuite,
32
+ type TestResult,
33
+ type AtomicTest,
34
+ UniqueTestId,
35
+ RunTestsTestableInput,
36
+ } from '@finos/legend-graph';
37
+ import {
38
+ TestablePackageableElementEditorState,
39
+ TestableTestEditorState,
40
+ TestableTestSuiteEditorState,
41
+ } from '../../testable/TestableEditorState.js';
42
+ import { EmbeddedDataEditorState } from '../../data/DataEditorState.js';
43
+ import {
44
+ functionTestable_deleteDataStore,
45
+ functionTestable_setEmbeddedData,
46
+ } from '../../../../../graph-modifier/DomainGraphModifierHelper.js';
47
+ import { isTestPassing } from '../../../../utils/TestableUtils.js';
48
+
49
+ export class FunctionStoreTestDataState {
50
+ readonly editorStore: EditorStore;
51
+ readonly testDataState: FunctionTestDataState;
52
+ storeTestData: FunctionStoreTestData;
53
+ embeddedEditorState: EmbeddedDataEditorState;
54
+ dataElementModal = false;
55
+
56
+ constructor(
57
+ editorStore: EditorStore,
58
+ testDataState: FunctionTestDataState,
59
+ value: FunctionStoreTestData,
60
+ ) {
61
+ makeObservable(this, {
62
+ storeTestData: observable,
63
+ dataElementModal: observable,
64
+ embeddedEditorState: observable,
65
+
66
+ setDataElementModal: action,
67
+ changeEmbeddedData: action,
68
+ });
69
+ this.editorStore = editorStore;
70
+ this.testDataState = testDataState;
71
+ this.storeTestData = value;
72
+ this.embeddedEditorState = new EmbeddedDataEditorState(
73
+ this.testDataState.editorStore,
74
+ this.storeTestData.data,
75
+ {
76
+ hideSource: true,
77
+ },
78
+ );
79
+ }
80
+
81
+ setDataElementModal(val: boolean): void {
82
+ this.dataElementModal = val;
83
+ }
84
+
85
+ changeEmbeddedData(val: EmbeddedData): void {
86
+ functionTestable_setEmbeddedData(
87
+ this.storeTestData,
88
+ val,
89
+ this.editorStore.changeDetectionState.observerContext,
90
+ );
91
+ this.embeddedEditorState = new EmbeddedDataEditorState(
92
+ this.testDataState.editorStore,
93
+ this.storeTestData.data,
94
+ );
95
+ }
96
+ }
97
+
98
+ export class FunctionTestState extends TestableTestEditorState {
99
+ readonly parentState: FunctionTestSuiteState;
100
+ readonly functionTestableState: FunctionTestableState;
101
+ readonly uuid = uuid();
102
+ override test: FunctionTest;
103
+ // TODO: param
104
+
105
+ constructor(
106
+ editorStore: EditorStore,
107
+ parentSuiteState: FunctionTestSuiteState,
108
+ test: FunctionTest,
109
+ ) {
110
+ super(
111
+ parentSuiteState.functionTestableState.function,
112
+ test,
113
+ parentSuiteState.functionTestableState.functionEditorState.isReadOnly,
114
+ editorStore,
115
+ );
116
+ makeObservable(this, {
117
+ selectedAsertionState: observable,
118
+ selectedTab: observable,
119
+ assertionToRename: observable,
120
+ assertionEditorStates: observable,
121
+ testResultState: observable,
122
+ runningTestAction: observable,
123
+ addAssertion: action,
124
+ setAssertionToRename: action,
125
+ handleTestResult: action,
126
+ setSelectedTab: action,
127
+ runTest: flow,
128
+ });
129
+ this.parentState = parentSuiteState;
130
+ this.functionTestableState = parentSuiteState.functionTestableState;
131
+ this.test = test;
132
+ }
133
+ }
134
+
135
+ class FunctionTestDataState {
136
+ readonly editorStore: EditorStore;
137
+ readonly functionTestableState: FunctionTestableState;
138
+ selectedDataState: FunctionStoreTestDataState | undefined;
139
+ dataHolder: FunctionTestSuite;
140
+ showNewModal = false;
141
+
142
+ constructor(
143
+ editorStore: EditorStore,
144
+ functionTestableState: FunctionTestableState,
145
+ holder: FunctionTestSuite,
146
+ ) {
147
+ makeObservable(this, {
148
+ selectedDataState: observable,
149
+ dataHolder: observable,
150
+ showNewModal: observable,
151
+ initDefaultStore: action,
152
+ setShowModal: action,
153
+ deleteStoreTestData: action,
154
+ openStoreTestData: action,
155
+ });
156
+ this.editorStore = editorStore;
157
+ this.functionTestableState = functionTestableState;
158
+ this.dataHolder = holder;
159
+ this.initDefaultStore();
160
+ }
161
+
162
+ initDefaultStore(): void {
163
+ const val = this.dataHolder.testData?.[0];
164
+ if (val) {
165
+ this.openStoreTestData(val);
166
+ } else {
167
+ this.selectedDataState = undefined;
168
+ }
169
+ }
170
+
171
+ setShowModal(val: boolean): void {
172
+ this.showNewModal = val;
173
+ }
174
+
175
+ deleteStoreTestData(val: FunctionStoreTestData): void {
176
+ functionTestable_deleteDataStore(this.dataHolder, val);
177
+ this.initDefaultStore();
178
+ }
179
+
180
+ openStoreTestData(val: FunctionStoreTestData): void {
181
+ this.selectedDataState = new FunctionStoreTestDataState(
182
+ this.editorStore,
183
+ this,
184
+ val,
185
+ );
186
+ }
187
+ }
188
+
189
+ export class FunctionTestSuiteState extends TestableTestSuiteEditorState {
190
+ readonly functionTestableState: FunctionTestableState;
191
+ override suite: FunctionTestSuite;
192
+ override testStates: FunctionTestState[] = [];
193
+ override selectTestState: FunctionTestState | undefined;
194
+ dataState: FunctionTestDataState;
195
+
196
+ showCreateModal = false;
197
+
198
+ constructor(
199
+ editorStore: EditorStore,
200
+ functionTestableState: FunctionTestableState,
201
+ suite: FunctionTestSuite,
202
+ ) {
203
+ super(
204
+ functionTestableState.function,
205
+ suite,
206
+ functionTestableState.functionEditorState.isReadOnly,
207
+ editorStore,
208
+ );
209
+ makeObservable(this, {
210
+ dataState: observable,
211
+ showCreateModal: observable,
212
+ buildTestState: action,
213
+ deleteTest: action,
214
+ buildTestStates: action,
215
+ });
216
+ this.functionTestableState = functionTestableState;
217
+ this.suite = suite;
218
+ this.dataState = new FunctionTestDataState(
219
+ editorStore,
220
+ functionTestableState,
221
+ suite,
222
+ );
223
+ this.testStates = this.buildTestStates();
224
+ this.selectTestState = this.testStates[0];
225
+ }
226
+
227
+ buildTestStates(): FunctionTestState[] {
228
+ return this.suite.tests
229
+ .map((t) => this.buildTestState(t))
230
+ .filter(isNonNullable);
231
+ }
232
+
233
+ buildTestState(val: AtomicTest): FunctionTestState | undefined {
234
+ if (val instanceof FunctionTest) {
235
+ return new FunctionTestState(this.editorStore, this, val);
236
+ }
237
+ return undefined;
238
+ }
239
+ }
240
+
241
+ export class FunctionTestableState extends TestablePackageableElementEditorState {
242
+ readonly functionEditorState: FunctionEditorState;
243
+
244
+ runningSuite: FunctionTestSuite | undefined;
245
+ declare selectedTestSuite: FunctionTestSuiteState | undefined;
246
+
247
+ constructor(functionEditorState: FunctionEditorState) {
248
+ super(functionEditorState, functionEditorState.functionElement);
249
+ makeObservable(this, {
250
+ isRunningTestableSuitesState: observable,
251
+ isRunningFailingSuitesState: observable,
252
+ selectedTestSuite: observable,
253
+ testableResults: observable,
254
+ runningSuite: observable,
255
+ init: action,
256
+ buildTestSuiteState: action,
257
+ deleteTestSuite: action,
258
+ changeSuite: action,
259
+ handleNewResults: action,
260
+ setRenameComponent: action,
261
+ runTestable: flow,
262
+ runSuite: flow,
263
+ runAllFailingSuites: flow,
264
+ });
265
+ this.functionEditorState = functionEditorState;
266
+ this.init();
267
+ }
268
+
269
+ get function(): ConcreteFunctionDefinition {
270
+ return this.functionEditorState.functionElement;
271
+ }
272
+
273
+ get passingSuites(): FunctionTestSuite[] {
274
+ const results = this.testableResults;
275
+ if (results?.length) {
276
+ return this.function.tests.filter((suite) =>
277
+ results
278
+ .filter((res) => res.parentSuite?.id === suite.id)
279
+ .every((e) => isTestPassing(e)),
280
+ );
281
+ }
282
+ return [];
283
+ }
284
+
285
+ get failingSuites(): FunctionTestSuite[] {
286
+ const results = this.testableResults;
287
+ if (results?.length) {
288
+ return this.function.tests.filter((suite) =>
289
+ results
290
+ .filter((res) => res.parentSuite?.id === suite.id)
291
+ .some((e) => !isTestPassing(e)),
292
+ );
293
+ }
294
+ return [];
295
+ }
296
+
297
+ get staticSuites(): FunctionTestSuite[] {
298
+ const results = this.testableResults;
299
+ if (results?.length) {
300
+ return this.function.tests.filter((suite) =>
301
+ results.every((res) => res.parentSuite?.id !== suite.id),
302
+ );
303
+ }
304
+ return this.function.tests;
305
+ }
306
+
307
+ init(): void {
308
+ if (!this.selectedTestSuite) {
309
+ const suite = this.function.tests[0];
310
+ this.selectedTestSuite = suite
311
+ ? this.buildTestSuiteState(suite)
312
+ : undefined;
313
+ }
314
+ }
315
+
316
+ *runSuite(suite: FunctionTestSuite): GeneratorFn<void> {
317
+ try {
318
+ this.runningSuite = suite;
319
+ this.clearTestResultsForSuite(suite);
320
+ this.selectedTestSuite?.testStates.forEach((t) => t.resetResult());
321
+ this.selectedTestSuite?.testStates.forEach((t) =>
322
+ t.runningTestAction.inProgress(),
323
+ );
324
+
325
+ const input = new RunTestsTestableInput(this.function);
326
+ suite.tests.forEach((t) =>
327
+ input.unitTestIds.push(new UniqueTestId(suite, t)),
328
+ );
329
+ const testResults =
330
+ (yield this.editorStore.graphManagerState.graphManager.runTests(
331
+ [input],
332
+ this.editorStore.graphManagerState.graph,
333
+ )) as TestResult[];
334
+
335
+ this.handleNewResults(testResults);
336
+ } catch (error) {
337
+ assertErrorThrown(error);
338
+ this.editorStore.applicationStore.notificationService.notifyError(error);
339
+ this.isRunningTestableSuitesState.fail();
340
+ } finally {
341
+ this.selectedTestSuite?.testStates.forEach((t) =>
342
+ t.runningTestAction.complete(),
343
+ );
344
+ this.runningSuite = undefined;
345
+ }
346
+ }
347
+
348
+ *runAllFailingSuites(): GeneratorFn<void> {
349
+ try {
350
+ this.isRunningFailingSuitesState.inProgress();
351
+ const input = new RunTestsTestableInput(this.testable);
352
+ this.failingSuites.forEach((s) => {
353
+ s.tests.forEach((t) => input.unitTestIds.push(new UniqueTestId(s, t)));
354
+ });
355
+ const testResults =
356
+ (yield this.editorStore.graphManagerState.graphManager.runTests(
357
+ [input],
358
+ this.editorStore.graphManagerState.graph,
359
+ )) as TestResult[];
360
+ this.handleNewResults(testResults);
361
+ this.isRunningFailingSuitesState.complete();
362
+ } catch (error) {
363
+ assertErrorThrown(error);
364
+ this.editorStore.applicationStore.notificationService.notifyError(error);
365
+ this.isRunningFailingSuitesState.fail();
366
+ } finally {
367
+ this.selectedTestSuite?.testStates.forEach((t) =>
368
+ t.runningTestAction.complete(),
369
+ );
370
+ }
371
+ }
372
+
373
+ handleNewResults(results: TestResult[]): void {
374
+ if (this.testableResults?.length) {
375
+ const newSuitesResults = results
376
+ .map((e) => e.parentSuite?.id)
377
+ .filter(isNonNullable);
378
+ const reducedFilters = this.testableResults.filter(
379
+ (res) => !newSuitesResults.includes(res.parentSuite?.id ?? ''),
380
+ );
381
+ this.setTestableResults([...reducedFilters, ...results]);
382
+ } else {
383
+ this.setTestableResults(results);
384
+ }
385
+ this.testableResults?.forEach((result) => {
386
+ const state = this.selectedTestSuite?.testStates.find(
387
+ (t) =>
388
+ t.test.id === result.atomicTest.id &&
389
+ t.parentState.suite.id === result.parentSuite?.id,
390
+ );
391
+ state?.handleTestResult(result);
392
+ });
393
+ }
394
+
395
+ clearTestResultsForSuite(suite: FunctionTestSuite): void {
396
+ this.testableResults = this.testableResults?.filter(
397
+ (t) => !(this.resolveSuiteResults(suite) ?? []).includes(t),
398
+ );
399
+ }
400
+
401
+ resolveSuiteResults(suite: FunctionTestSuite): TestResult[] | undefined {
402
+ return this.testableResults?.filter((t) => t.parentSuite?.id === suite.id);
403
+ }
404
+
405
+ buildTestSuiteState(val: FunctionTestSuite): FunctionTestSuiteState {
406
+ return new FunctionTestSuiteState(this.editorStore, this, val);
407
+ }
408
+
409
+ changeSuite(suite: FunctionTestSuite): void {
410
+ if (this.selectedTestSuite?.suite !== suite) {
411
+ this.selectedTestSuite = this.buildTestSuiteState(suite);
412
+ }
413
+ }
414
+ }
@@ -673,10 +673,7 @@ export class MappingEditorState extends ElementEditorState {
673
673
  this.mapping,
674
674
  editorStore,
675
675
  );
676
- this.mappingTestableState = new MappingTestableState(
677
- this.editorStore,
678
- this,
679
- );
676
+ this.mappingTestableState = new MappingTestableState(this);
680
677
  }
681
678
 
682
679
  get mapping(): Mapping {