@finos/legend-application-studio 28.14.7 → 28.14.9

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 (30) hide show
  1. package/lib/components/editor/editor-group/function-activator/testable/FunctionTestableEditor.d.ts.map +1 -1
  2. package/lib/components/editor/editor-group/function-activator/testable/FunctionTestableEditor.js +15 -8
  3. package/lib/components/editor/editor-group/function-activator/testable/FunctionTestableEditor.js.map +1 -1
  4. package/lib/components/editor/editor-group/testable/TestableSharedComponents.d.ts.map +1 -1
  5. package/lib/components/editor/editor-group/testable/TestableSharedComponents.js +23 -1
  6. package/lib/components/editor/editor-group/testable/TestableSharedComponents.js.map +1 -1
  7. package/lib/index.css +2 -2
  8. package/lib/index.css.map +1 -1
  9. package/lib/package.json +1 -1
  10. package/lib/stores/editor/editor-state/element-editor-state/function-activator/testable/FunctionTestableState.d.ts +4 -2
  11. package/lib/stores/editor/editor-state/element-editor-state/function-activator/testable/FunctionTestableState.d.ts.map +1 -1
  12. package/lib/stores/editor/editor-state/element-editor-state/function-activator/testable/FunctionTestableState.js +30 -12
  13. package/lib/stores/editor/editor-state/element-editor-state/function-activator/testable/FunctionTestableState.js.map +1 -1
  14. package/lib/stores/editor/editor-state/element-editor-state/testable/TestAssertionState.d.ts +11 -1
  15. package/lib/stores/editor/editor-state/element-editor-state/testable/TestAssertionState.d.ts.map +1 -1
  16. package/lib/stores/editor/editor-state/element-editor-state/testable/TestAssertionState.js +40 -2
  17. package/lib/stores/editor/editor-state/element-editor-state/testable/TestAssertionState.js.map +1 -1
  18. package/lib/stores/graph-modifier/Testable_GraphModifierHelper.d.ts +2 -1
  19. package/lib/stores/graph-modifier/Testable_GraphModifierHelper.d.ts.map +1 -1
  20. package/lib/stores/graph-modifier/Testable_GraphModifierHelper.js +3 -0
  21. package/lib/stores/graph-modifier/Testable_GraphModifierHelper.js.map +1 -1
  22. package/lib/stores/workspace-setup/WorkspaceSetupStore.js +5 -5
  23. package/lib/stores/workspace-setup/WorkspaceSetupStore.js.map +1 -1
  24. package/package.json +4 -4
  25. package/src/components/editor/editor-group/function-activator/testable/FunctionTestableEditor.tsx +82 -65
  26. package/src/components/editor/editor-group/testable/TestableSharedComponents.tsx +57 -0
  27. package/src/stores/editor/editor-state/element-editor-state/function-activator/testable/FunctionTestableState.ts +50 -12
  28. package/src/stores/editor/editor-state/element-editor-state/testable/TestAssertionState.ts +65 -0
  29. package/src/stores/graph-modifier/Testable_GraphModifierHelper.ts +7 -0
  30. package/src/stores/workspace-setup/WorkspaceSetupStore.ts +6 -6
@@ -39,6 +39,7 @@ import {
39
39
  type EngineRuntime,
40
40
  type ObserverContext,
41
41
  type ValueSpecification,
42
+ type TestAssertion,
42
43
  FunctionParameterValue,
43
44
  VariableExpression,
44
45
  FunctionTest,
@@ -57,6 +58,7 @@ import {
57
58
  PackageableElementExplicitReference,
58
59
  observe_ValueSpecification,
59
60
  buildLambdaVariableExpressions,
61
+ EqualTo,
60
62
  } from '@finos/legend-graph';
61
63
  import {
62
64
  TestablePackageableElementEditorState,
@@ -80,7 +82,10 @@ import {
80
82
  } from '../../../../utils/TestableUtils.js';
81
83
  import { LEGEND_STUDIO_APP_EVENT } from '../../../../../../__lib__/LegendStudioEvent.js';
82
84
  import { testSuite_addTest } from '../../../../../graph-modifier/Testable_GraphModifierHelper.js';
83
- import { generateVariableExpressionMockValue } from '@finos/legend-query-builder';
85
+ import {
86
+ buildDefaultInstanceValue,
87
+ generateVariableExpressionMockValue,
88
+ } from '@finos/legend-query-builder';
84
89
 
85
90
  const addToFunctionMap = (
86
91
  val: SimpleFunctionExpression,
@@ -567,20 +572,41 @@ class FunctionTestDataState {
567
572
  export const createFunctionTest = (
568
573
  id: string,
569
574
  observerContext: ObserverContext,
575
+ containsRuntime: boolean,
576
+ functionDefinition: ConcreteFunctionDefinition,
577
+ editorStore: EditorStore,
570
578
  suite?: FunctionTestSuite | undefined,
571
579
  ): FunctionTest => {
572
580
  const funcionTest = new FunctionTest();
573
581
  funcionTest.id = id;
574
- funcionTest.assertions = [
575
- createDefaultEqualToJSONTestAssertion(DEFAULT_TEST_ASSERTION_ID),
576
- ];
582
+ funcionTest.assertions = [];
583
+ let _assertion: TestAssertion;
584
+ if (containsRuntime) {
585
+ _assertion = createDefaultEqualToJSONTestAssertion(
586
+ DEFAULT_TEST_ASSERTION_ID,
587
+ );
588
+ } else {
589
+ const equalTo = new EqualTo();
590
+ equalTo.id = DEFAULT_TEST_ASSERTION_ID;
591
+ const type = functionDefinition.returnType.value;
592
+ const valSpec = buildDefaultInstanceValue(
593
+ editorStore.graphManagerState.graph,
594
+ type,
595
+ editorStore.changeDetectionState.observerContext,
596
+ );
597
+ const expected =
598
+ editorStore.graphManagerState.graphManager.serializeValueSpecification(
599
+ valSpec,
600
+ );
601
+ equalTo.expected = expected;
602
+ _assertion = equalTo;
603
+ }
604
+ funcionTest.assertions = [_assertion];
605
+ _assertion.parentTest = funcionTest;
577
606
  if (suite) {
578
607
  funcionTest.__parent = suite;
579
608
  testSuite_addTest(suite, funcionTest, observerContext);
580
609
  }
581
- const assertion = createDefaultEqualToJSONTestAssertion(`expectedAssertion`);
582
- funcionTest.assertions = [assertion];
583
- assertion.parentTest = funcionTest;
584
610
  return funcionTest;
585
611
  };
586
612
  export class FunctionTestSuiteState extends TestableTestSuiteEditorState {
@@ -608,6 +634,8 @@ export class FunctionTestSuiteState extends TestableTestSuiteEditorState {
608
634
  showCreateModal: observable,
609
635
  selectTestState: observable,
610
636
  changeTest: observable,
637
+ runSuite: flow,
638
+ runFailingTests: flow,
611
639
  buildTestState: action,
612
640
  deleteTest: action,
613
641
  buildTestStates: action,
@@ -646,9 +674,11 @@ export class FunctionTestSuiteState extends TestableTestSuiteEditorState {
646
674
  const test = createFunctionTest(
647
675
  id,
648
676
  this.editorStore.changeDetectionState.observerContext,
677
+ this.functionTestableState.containsRuntime,
678
+ this.functionTestableState.function,
679
+ this.editorStore,
649
680
  this.suite,
650
681
  );
651
-
652
682
  testSuite_addTest(
653
683
  this.suite,
654
684
  test,
@@ -700,6 +730,14 @@ export class FunctionTestableState extends TestablePackageableElementEditorState
700
730
  return this.functionEditorState.functionElement;
701
731
  }
702
732
 
733
+ get associatedRuntimes(): EngineRuntime[] | undefined {
734
+ return resolveRuntimesFromQuery(this.function, this.editorStore);
735
+ }
736
+
737
+ get containsRuntime(): boolean {
738
+ return Boolean(this.associatedRuntimes?.length);
739
+ }
740
+
703
741
  override init(): void {
704
742
  if (!this.selectedTestSuite) {
705
743
  const suite = this.function.tests[0];
@@ -716,10 +754,7 @@ export class FunctionTestableState extends TestablePackageableElementEditorState
716
754
  createSuite(suiteName: string, testName: string): void {
717
755
  const functionSuite = new FunctionTestSuite();
718
756
  functionSuite.id = suiteName;
719
- const engineRuntimes = resolveRuntimesFromQuery(
720
- this.function,
721
- this.editorStore,
722
- );
757
+ const engineRuntimes = this.associatedRuntimes;
723
758
  if (engineRuntimes?.length) {
724
759
  try {
725
760
  assertTrue(
@@ -771,6 +806,9 @@ export class FunctionTestableState extends TestablePackageableElementEditorState
771
806
  createFunctionTest(
772
807
  testName,
773
808
  this.editorStore.changeDetectionState.observerContext,
809
+ this.containsRuntime,
810
+ this.function,
811
+ this.editorStore,
774
812
  functionSuite,
775
813
  );
776
814
  // set test suite
@@ -17,6 +17,7 @@
17
17
  import {
18
18
  type TestAssertion,
19
19
  type AssertionStatus,
20
+ type ValueSpecification,
20
21
  AssertFail,
21
22
  type TestResult,
22
23
  TestExecuted,
@@ -27,6 +28,8 @@ import {
27
28
  MultiExecutionServiceTestResult,
28
29
  AssertPass,
29
30
  TestExecutionStatus,
31
+ EqualTo,
32
+ observe_ValueSpecification,
30
33
  } from '@finos/legend-graph';
31
34
  import {
32
35
  type GeneratorFn,
@@ -39,6 +42,8 @@ import {
39
42
  IllegalStateError,
40
43
  guaranteeNonNullable,
41
44
  guaranteeType,
45
+ returnUndefOnError,
46
+ type PlainObject,
42
47
  } from '@finos/legend-shared';
43
48
  import { action, flow, flowResult, makeObservable, observable } from 'mobx';
44
49
  import type { EditorStore } from '../../../EditorStore.js';
@@ -49,6 +54,7 @@ import {
49
54
  } from '../../../sidebar-state/testable/GlobalTestRunnerState.js';
50
55
  import type { TestableTestEditorState } from './TestableEditorState.js';
51
56
  import { isTestPassing } from '../../../utils/TestableUtils.js';
57
+ import { equalTo_setExpected } from '../../../../graph-modifier/Testable_GraphModifierHelper.js';
52
58
 
53
59
  export enum TEST_ASSERTION_TAB {
54
60
  EXPECTED = 'EXPECTED',
@@ -268,6 +274,55 @@ export class EqualToJsonAssertionState extends TestAssertionState {
268
274
  }
269
275
  }
270
276
 
277
+ export class EqualToAssertionState extends TestAssertionState {
278
+ declare assertion: EqualTo;
279
+ valueSpec: ValueSpecification;
280
+
281
+ constructor(
282
+ editorStore: EditorStore,
283
+ assertionState: TestAssertionEditorState,
284
+ valueSpec: ValueSpecification,
285
+ ) {
286
+ super(editorStore, assertionState);
287
+ makeObservable(this, {
288
+ valueSpec: observable,
289
+ assertion: observable,
290
+ updateValueSpec: action,
291
+ });
292
+ this.valueSpec = observe_ValueSpecification(
293
+ valueSpec,
294
+ this.editorStore.changeDetectionState.observerContext,
295
+ );
296
+ }
297
+
298
+ updateValueSpec(val: ValueSpecification): void {
299
+ this.valueSpec = observe_ValueSpecification(
300
+ val,
301
+ this.editorStore.changeDetectionState.observerContext,
302
+ );
303
+ const object =
304
+ this.editorStore.graphManagerState.graphManager.serializeValueSpecification(
305
+ val,
306
+ );
307
+ equalTo_setExpected(this.assertion, object);
308
+ }
309
+
310
+ override generateExpected(status: AssertFail): boolean {
311
+ throw new Error('Method not implemented.');
312
+ }
313
+ override generateBare(): TestAssertion {
314
+ const equal = new EqualTo();
315
+ equal.expected = {};
316
+ return equal;
317
+ }
318
+ override label(): string {
319
+ return 'Equal To';
320
+ }
321
+ override get supportsGeneratingAssertion(): boolean {
322
+ return false;
323
+ }
324
+ }
325
+
271
326
  export class UnsupportedAssertionState extends TestAssertionState {
272
327
  override get supportsGeneratingAssertion(): boolean {
273
328
  return false;
@@ -387,6 +442,16 @@ export class TestAssertionEditorState {
387
442
  buildAssertionState(assertion: TestAssertion): TestAssertionState {
388
443
  if (assertion instanceof EqualToJson) {
389
444
  return new EqualToJsonAssertionState(this.editorStore, this);
445
+ } else if (assertion instanceof EqualTo) {
446
+ const val = returnUndefOnError(() =>
447
+ this.editorStore.graphManagerState.graphManager.buildValueSpecification(
448
+ assertion.expected as PlainObject<ValueSpecification>,
449
+ this.editorStore.graphManagerState.graph,
450
+ ),
451
+ );
452
+ if (val) {
453
+ return new EqualToAssertionState(this.editorStore, this, val);
454
+ }
390
455
  }
391
456
  return new UnsupportedAssertionState(this.editorStore, this);
392
457
  }
@@ -15,6 +15,7 @@
15
15
  */
16
16
 
17
17
  import {
18
+ type EqualTo,
18
19
  type EqualToJson,
19
20
  type ExternalFormatData,
20
21
  type AtomicTest,
@@ -36,6 +37,12 @@ export const equalToJSON_setExpected = action(
36
37
  },
37
38
  );
38
39
 
40
+ export const equalTo_setExpected = action(
41
+ (equalToJSON: EqualTo, val: object): void => {
42
+ equalToJSON.expected = val;
43
+ },
44
+ );
45
+
39
46
  export const testAssertion_setId = action(
40
47
  (test: TestAssertion, val: string): void => {
41
48
  test.id = val;
@@ -221,30 +221,30 @@ export class WorkspaceSetupStore {
221
221
  const sandbox = guaranteeType(
222
222
  this.sandboxProject,
223
223
  Project,
224
- 'Error Retrieving sandbox project',
224
+ 'Error retrieving sandbox project',
225
225
  );
226
- const pilotWorkspace = Workspace.serialization.fromJson(
226
+ const initialWorkspace = Workspace.serialization.fromJson(
227
227
  (yield this.sdlcServerClient.createWorkspace(
228
228
  sandbox.projectId,
229
229
  undefined,
230
- 'pilotWorkspace',
230
+ 'myWorkspace',
231
231
  WorkspaceType.GROUP,
232
232
  )) as PlainObject<Workspace>,
233
233
  );
234
234
  yield flowResult(
235
235
  this.changeProject(sandbox, {
236
- workspaceId: pilotWorkspace.workspaceId,
236
+ workspaceId: initialWorkspace.workspaceId,
237
237
  workspaceType: WorkspaceType.GROUP,
238
238
  }),
239
239
  );
240
240
  this.applicationStore.alertService.setBlockingAlert(undefined);
241
241
  this.applicationStore.notificationService.notifySuccess(
242
- `Sandbox Project with pilot workspace created`,
242
+ `Sandbox project with workspace created`,
243
243
  );
244
244
  } catch (error) {
245
245
  assertErrorThrown(error);
246
246
  this.applicationStore.logService.error(
247
- LogEvent.create(LEGEND_STUDIO_APP_EVENT.DEPOT_MANAGER_FAILURE),
247
+ LogEvent.create(LEGEND_STUDIO_APP_EVENT.ENGINE_MANAGER_FAILURE),
248
248
  error,
249
249
  );
250
250
  this.applicationStore.notificationService.notifyError(error);