@finos/legend-application-studio 26.1.8 → 26.1.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 (108) hide show
  1. package/lib/components/editor/editor-group/connection-editor/RelationalDatabaseConnectionEditor.d.ts.map +1 -1
  2. package/lib/components/editor/editor-group/connection-editor/RelationalDatabaseConnectionEditor.js +2 -2
  3. package/lib/components/editor/editor-group/connection-editor/RelationalDatabaseConnectionEditor.js.map +1 -1
  4. package/lib/components/editor/editor-group/data-editor/EmbeddedDataEditor.d.ts +15 -2
  5. package/lib/components/editor/editor-group/data-editor/EmbeddedDataEditor.d.ts.map +1 -1
  6. package/lib/components/editor/editor-group/data-editor/EmbeddedDataEditor.js +46 -5
  7. package/lib/components/editor/editor-group/data-editor/EmbeddedDataEditor.js.map +1 -1
  8. package/lib/components/editor/editor-group/data-editor/RelationalCSVDataEditor.d.ts.map +1 -1
  9. package/lib/components/editor/editor-group/data-editor/RelationalCSVDataEditor.js +18 -3
  10. package/lib/components/editor/editor-group/data-editor/RelationalCSVDataEditor.js.map +1 -1
  11. package/lib/components/editor/editor-group/external-format-editor/DSL_ExternalFormat_NewSchemaSetDriver.d.ts.map +1 -1
  12. package/lib/components/editor/editor-group/external-format-editor/DSL_ExternalFormat_NewSchemaSetDriver.js +2 -2
  13. package/lib/components/editor/editor-group/external-format-editor/DSL_ExternalFormat_NewSchemaSetDriver.js.map +1 -1
  14. package/lib/components/editor/editor-group/mapping-editor/MappingEditor.d.ts.map +1 -1
  15. package/lib/components/editor/editor-group/mapping-editor/MappingEditor.js +0 -3
  16. package/lib/components/editor/editor-group/mapping-editor/MappingEditor.js.map +1 -1
  17. package/lib/components/editor/editor-group/mapping-editor/MappingTestableEditor.d.ts.map +1 -1
  18. package/lib/components/editor/editor-group/mapping-editor/MappingTestableEditor.js +36 -72
  19. package/lib/components/editor/editor-group/mapping-editor/MappingTestableEditor.js.map +1 -1
  20. package/lib/components/editor/editor-group/service-editor/testable/ServiceTestDataEditor.d.ts +5 -0
  21. package/lib/components/editor/editor-group/service-editor/testable/ServiceTestDataEditor.d.ts.map +1 -1
  22. package/lib/components/editor/editor-group/service-editor/testable/ServiceTestDataEditor.js +53 -8
  23. package/lib/components/editor/editor-group/service-editor/testable/ServiceTestDataEditor.js.map +1 -1
  24. package/lib/components/editor/editor-group/service-editor/testable/ServiceTestableEditor.d.ts.map +1 -1
  25. package/lib/components/editor/editor-group/service-editor/testable/ServiceTestableEditor.js +3 -1
  26. package/lib/components/editor/editor-group/service-editor/testable/ServiceTestableEditor.js.map +1 -1
  27. package/lib/components/editor/editor-group/service-editor/testable/ServiceTestsEditor.d.ts.map +1 -1
  28. package/lib/components/editor/editor-group/service-editor/testable/ServiceTestsEditor.js +7 -3
  29. package/lib/components/editor/editor-group/service-editor/testable/ServiceTestsEditor.js.map +1 -1
  30. package/lib/components/editor/editor-group/testable/TestableSharedComponents.js +1 -1
  31. package/lib/components/editor/editor-group/testable/TestableSharedComponents.js.map +1 -1
  32. package/lib/index.css +2 -2
  33. package/lib/index.css.map +1 -1
  34. package/lib/package.json +3 -3
  35. package/lib/stores/editor/editor-state/element-editor-state/data/EmbeddedDataState.d.ts +22 -1
  36. package/lib/stores/editor/editor-state/element-editor-state/data/EmbeddedDataState.d.ts.map +1 -1
  37. package/lib/stores/editor/editor-state/element-editor-state/data/EmbeddedDataState.js +56 -5
  38. package/lib/stores/editor/editor-state/element-editor-state/data/EmbeddedDataState.js.map +1 -1
  39. package/lib/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestableState.d.ts +12 -12
  40. package/lib/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestableState.d.ts.map +1 -1
  41. package/lib/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestableState.js +113 -61
  42. package/lib/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestableState.js.map +1 -1
  43. package/lib/stores/editor/editor-state/element-editor-state/service/ServiceEditorState.d.ts +4 -2
  44. package/lib/stores/editor/editor-state/element-editor-state/service/ServiceEditorState.d.ts.map +1 -1
  45. package/lib/stores/editor/editor-state/element-editor-state/service/ServiceEditorState.js +23 -9
  46. package/lib/stores/editor/editor-state/element-editor-state/service/ServiceEditorState.js.map +1 -1
  47. package/lib/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestDataState.d.ts +5 -2
  48. package/lib/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestDataState.d.ts.map +1 -1
  49. package/lib/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestDataState.js +23 -16
  50. package/lib/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestDataState.js.map +1 -1
  51. package/lib/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestEditorState.d.ts +3 -2
  52. package/lib/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestEditorState.d.ts.map +1 -1
  53. package/lib/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestEditorState.js +11 -7
  54. package/lib/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestEditorState.js.map +1 -1
  55. package/lib/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestableState.d.ts +3 -2
  56. package/lib/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestableState.d.ts.map +1 -1
  57. package/lib/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestableState.js +29 -8
  58. package/lib/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestableState.js.map +1 -1
  59. package/lib/stores/editor/editor-state/element-editor-state/testable/TestAssertionState.d.ts +2 -2
  60. package/lib/stores/editor/editor-state/element-editor-state/testable/TestAssertionState.d.ts.map +1 -1
  61. package/lib/stores/editor/editor-state/element-editor-state/testable/TestAssertionState.js +8 -6
  62. package/lib/stores/editor/editor-state/element-editor-state/testable/TestAssertionState.js.map +1 -1
  63. package/lib/stores/editor/editor-state/element-editor-state/testable/TestableEditorState.d.ts +14 -2
  64. package/lib/stores/editor/editor-state/element-editor-state/testable/TestableEditorState.d.ts.map +1 -1
  65. package/lib/stores/editor/editor-state/element-editor-state/testable/TestableEditorState.js +75 -5
  66. package/lib/stores/editor/editor-state/element-editor-state/testable/TestableEditorState.js.map +1 -1
  67. package/lib/stores/editor/utils/MockDataUtils.d.ts +4 -1
  68. package/lib/stores/editor/utils/MockDataUtils.d.ts.map +1 -1
  69. package/lib/stores/editor/utils/MockDataUtils.js +70 -2
  70. package/lib/stores/editor/utils/MockDataUtils.js.map +1 -1
  71. package/lib/stores/editor/utils/TestableUtils.d.ts +1 -2
  72. package/lib/stores/editor/utils/TestableUtils.d.ts.map +1 -1
  73. package/lib/stores/editor/utils/TestableUtils.js +4 -13
  74. package/lib/stores/editor/utils/TestableUtils.js.map +1 -1
  75. package/lib/stores/graph-modifier/DSL_Data_GraphModifierHelper.d.ts +6 -2
  76. package/lib/stores/graph-modifier/DSL_Data_GraphModifierHelper.d.ts.map +1 -1
  77. package/lib/stores/graph-modifier/DSL_Data_GraphModifierHelper.js +23 -4
  78. package/lib/stores/graph-modifier/DSL_Data_GraphModifierHelper.js.map +1 -1
  79. package/lib/stores/graph-modifier/DSL_Mapping_GraphModifierHelper.js +1 -1
  80. package/lib/stores/graph-modifier/DSL_Mapping_GraphModifierHelper.js.map +1 -1
  81. package/lib/stores/graph-modifier/STO_Relational_GraphModifierHelper.d.ts +1 -0
  82. package/lib/stores/graph-modifier/STO_Relational_GraphModifierHelper.d.ts.map +1 -1
  83. package/lib/stores/graph-modifier/STO_Relational_GraphModifierHelper.js +3 -0
  84. package/lib/stores/graph-modifier/STO_Relational_GraphModifierHelper.js.map +1 -1
  85. package/package.json +13 -13
  86. package/src/components/editor/editor-group/connection-editor/RelationalDatabaseConnectionEditor.tsx +13 -0
  87. package/src/components/editor/editor-group/data-editor/EmbeddedDataEditor.tsx +129 -3
  88. package/src/components/editor/editor-group/data-editor/RelationalCSVDataEditor.tsx +65 -0
  89. package/src/components/editor/editor-group/external-format-editor/DSL_ExternalFormat_NewSchemaSetDriver.tsx +6 -3
  90. package/src/components/editor/editor-group/mapping-editor/MappingEditor.tsx +0 -6
  91. package/src/components/editor/editor-group/mapping-editor/MappingTestableEditor.tsx +159 -366
  92. package/src/components/editor/editor-group/service-editor/testable/ServiceTestDataEditor.tsx +187 -61
  93. package/src/components/editor/editor-group/service-editor/testable/ServiceTestableEditor.tsx +26 -18
  94. package/src/components/editor/editor-group/service-editor/testable/ServiceTestsEditor.tsx +85 -83
  95. package/src/components/editor/editor-group/testable/TestableSharedComponents.tsx +2 -2
  96. package/src/stores/editor/editor-state/element-editor-state/data/EmbeddedDataState.ts +75 -4
  97. package/src/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestableState.ts +157 -69
  98. package/src/stores/editor/editor-state/element-editor-state/service/ServiceEditorState.ts +45 -10
  99. package/src/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestDataState.ts +37 -15
  100. package/src/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestEditorState.ts +15 -8
  101. package/src/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestableState.ts +57 -6
  102. package/src/stores/editor/editor-state/element-editor-state/testable/TestAssertionState.ts +10 -6
  103. package/src/stores/editor/editor-state/element-editor-state/testable/TestableEditorState.ts +92 -3
  104. package/src/stores/editor/utils/MockDataUtils.ts +109 -1
  105. package/src/stores/editor/utils/TestableUtils.ts +4 -19
  106. package/src/stores/graph-modifier/DSL_Data_GraphModifierHelper.ts +45 -6
  107. package/src/stores/graph-modifier/DSL_Mapping_GraphModifierHelper.ts +1 -1
  108. package/src/stores/graph-modifier/STO_Relational_GraphModifierHelper.ts +6 -0
@@ -15,19 +15,21 @@
15
15
  */
16
16
  import {
17
17
  type EmbeddedData,
18
- type Class,
18
+ type ModelData,
19
19
  type DataElement,
20
20
  DataElementReference,
21
21
  ExternalFormatData,
22
22
  ModelStoreData,
23
23
  RelationalCSVData,
24
24
  RelationalCSVDataTable,
25
+ ModelEmbeddedData,
25
26
  } from '@finos/legend-graph';
26
27
  import {
27
28
  ContentType,
28
29
  guaranteeNonEmptyString,
29
30
  tryToFormatLosslessJSONString,
30
31
  UnsupportedOperationError,
32
+ uuid,
31
33
  } from '@finos/legend-shared';
32
34
  import { action, makeObservable, observable } from 'mobx';
33
35
  import type { DSL_Data_LegendStudioApplicationPlugin_Extension } from '../../../../extensions/DSL_Data_LegendStudioApplicationPlugin_Extension.js';
@@ -36,7 +38,6 @@ import {
36
38
  dataElementReference_setDataElement,
37
39
  externalFormatData_setContentType,
38
40
  externalFormatData_setData,
39
- modelStoreData_setInstance,
40
41
  relationalData_addTable,
41
42
  relationalData_deleteData,
42
43
  relationalData_setTableName,
@@ -44,6 +45,7 @@ import {
44
45
  relationalData_setTableValues,
45
46
  } from '../../../../graph-modifier/DSL_Data_GraphModifierHelper.js';
46
47
  import { EmbeddedDataType } from '../../ExternalFormatState.js';
48
+ import { TEMPORARY__createRelationalDataFromCSV } from '../../../utils/TestableUtils.js';
47
49
 
48
50
  export const createEmbeddedData = (
49
51
  type: string,
@@ -65,7 +67,6 @@ export const createEmbeddedData = (
65
67
  return relational;
66
68
  } else if (type === EmbeddedDataType.MODEL_STORE_DATA) {
67
69
  const modelStoreData = new ModelStoreData();
68
- modelStoreData_setInstance(modelStoreData, new Map<Class, object>());
69
70
  return modelStoreData;
70
71
  } else {
71
72
  const extraEmbeddedDataCreator = editorStore.pluginManager
@@ -103,17 +104,23 @@ export abstract class EmbeddedDataState {
103
104
 
104
105
  export class ExternalFormatDataState extends EmbeddedDataState {
105
106
  override embeddedData: ExternalFormatData;
107
+ canEditContentType = true;
106
108
 
107
109
  constructor(editorStore: EditorStore, embeddedData: ExternalFormatData) {
108
110
  super(editorStore, embeddedData);
109
111
  makeObservable(this, {
110
112
  format: action,
113
+ canEditContentType: observable,
111
114
  });
112
115
  this.embeddedData = embeddedData;
113
116
  }
114
117
 
115
118
  label(): string {
116
- return 'ExternalFormat Data';
119
+ return 'External Format Data';
120
+ }
121
+
122
+ setCanEditoContentType(val: boolean): void {
123
+ this.canEditContentType = val;
117
124
  }
118
125
 
119
126
  get supportsFormatting(): boolean {
@@ -128,17 +135,60 @@ export class ExternalFormatDataState extends EmbeddedDataState {
128
135
  }
129
136
  }
130
137
 
138
+ export abstract class ModelDataState {
139
+ readonly uuid = uuid();
140
+ readonly modelStoreDataState: ModelStoreDataState;
141
+ modelData: ModelData;
142
+
143
+ constructor(modelData: ModelData, modelStoreDataState: ModelStoreDataState) {
144
+ this.modelStoreDataState = modelStoreDataState;
145
+ this.modelData = modelData;
146
+ }
147
+ }
148
+
149
+ export class ModelEmbeddedDataState extends ModelDataState {
150
+ override modelData: ModelEmbeddedData;
151
+ embeddedDataState: EmbeddedDataState;
152
+
153
+ constructor(
154
+ modelData: ModelEmbeddedData,
155
+ modelStoreDataState: ModelStoreDataState,
156
+ ) {
157
+ super(modelData, modelStoreDataState);
158
+ this.modelData = modelData;
159
+ this.embeddedDataState = buildEmbeddedDataEditorState(
160
+ this.modelData.data,
161
+ this.modelStoreDataState.editorStore,
162
+ );
163
+ }
164
+ }
165
+
166
+ export class UnsupportedModelDataState extends ModelDataState {}
167
+
131
168
  export class ModelStoreDataState extends EmbeddedDataState {
132
169
  override embeddedData: ModelStoreData;
170
+ modelDataStates: ModelDataState[] = [];
133
171
 
134
172
  constructor(editorStore: EditorStore, embeddedData: ModelStoreData) {
135
173
  super(editorStore, embeddedData);
136
174
  this.embeddedData = embeddedData;
175
+ this.modelDataStates = this.buildStates();
137
176
  }
138
177
 
139
178
  label(): string {
140
179
  return 'ModelStore Data';
141
180
  }
181
+
182
+ buildStates(): ModelDataState[] {
183
+ return (
184
+ this.embeddedData.modelData?.map((modelData) => {
185
+ if (modelData instanceof ModelEmbeddedData) {
186
+ return new ModelEmbeddedDataState(modelData, this);
187
+ }
188
+ return new UnsupportedModelDataState(modelData, this);
189
+ }) ?? []
190
+ );
191
+ }
142
192
  }
143
193
 
144
194
  export class RelationalCSVDataTableState {
@@ -224,6 +274,7 @@ export class RelationalCSVDataState extends EmbeddedDataState {
224
274
  showTableIdentifierModal = false;
225
275
  tableIdentifierState: IdentifierTableState;
226
276
  selectedTable: RelationalCSVDataTableState | undefined;
277
+ showImportCSVModal = false;
227
278
 
228
279
  constructor(editorStore: EditorStore, embeddedData: RelationalCSVData) {
229
280
  super(editorStore, embeddedData);
@@ -232,27 +283,47 @@ export class RelationalCSVDataState extends EmbeddedDataState {
232
283
  showTableIdentifierModal: observable,
233
284
  deleteTable: observable,
234
285
  tableIdentifierState: observable,
286
+ showImportCSVModal: observable,
235
287
  resetSelectedTable: action,
236
288
  changeSelectedTable: action,
237
289
  closeModal: action,
238
290
  openIdentifierModal: action,
291
+ setShowImportCsvModal: action,
292
+ closeCSVModal: action,
293
+ importCSV: action,
239
294
  });
240
295
  this.embeddedData = embeddedData;
241
296
  this.tableIdentifierState = new IdentifierTableState(this);
242
297
  this.resetSelectedTable();
243
298
  }
244
299
 
300
+ setShowImportCsvModal(val: boolean): void {
301
+ this.showImportCSVModal = val;
302
+ }
303
+
245
304
  openIdentifierModal(renameTable?: RelationalCSVDataTable | undefined): void {
246
305
  this.showTableIdentifierModal = true;
247
306
  this.tableIdentifierState.setTable(renameTable);
248
307
  }
249
308
 
309
+ closeCSVModal(): void {
310
+ this.showImportCSVModal = false;
311
+ }
312
+
250
313
  closeModal(): void {
251
314
  this.tableIdentifierState.setSchemaName('');
252
315
  this.tableIdentifierState.setTableName('');
253
316
  this.showTableIdentifierModal = false;
254
317
  }
255
318
 
319
+ importCSV(val: string): void {
320
+ const generated = TEMPORARY__createRelationalDataFromCSV(val);
321
+ generated.tables.forEach((t) =>
322
+ relationalData_addTable(this.embeddedData, t),
323
+ );
324
+ this.resetSelectedTable();
325
+ }
326
+
256
327
  resetSelectedTable(): void {
257
328
  const table = this.embeddedData.tables[0];
258
329
  if (table) {
@@ -57,7 +57,12 @@ import {
57
57
  getAllClassDerivedProperties,
58
58
  RelationalInstanceSetImplementation,
59
59
  EmbeddedRelationalInstanceSetImplementation,
60
- Database,
60
+ TableAlias,
61
+ Table,
62
+ RelationalCSVDataTable,
63
+ ModelStoreData,
64
+ ModelEmbeddedData,
65
+ getMappingCompatibleClasses,
61
66
  } from '@finos/legend-graph';
62
67
  import { action, flow, flowResult, makeObservable, observable } from 'mobx';
63
68
  import {
@@ -70,15 +75,14 @@ import {
70
75
  UnsupportedOperationError,
71
76
  LogEvent,
72
77
  uuid,
78
+ filterByType,
73
79
  } from '@finos/legend-shared';
74
80
  import {
75
81
  LambdaEditorState,
76
82
  buildGetAllFunction,
77
83
  buildSerialzieFunctionWithGraphFetch,
78
84
  } from '@finos/legend-query-builder';
79
- import type { EditorStore } from '../../../../EditorStore.js';
80
85
  import {
81
- resolveMappingSourceToStore,
82
86
  type MappingEditorState,
83
87
  getMappingElementSource,
84
88
  } from '../MappingEditorState.js';
@@ -98,6 +102,7 @@ import {
98
102
  import {
99
103
  TESTABLE_TEST_TAB,
100
104
  TestableTestEditorState,
105
+ TestableTestSuiteEditorState,
101
106
  } from '../../testable/TestableEditorState.js';
102
107
  import { EmbeddedDataEditorState } from '../../data/DataEditorState.js';
103
108
  import {
@@ -106,6 +111,8 @@ import {
106
111
  testable_setId,
107
112
  } from '../../../../../graph-modifier/Testable_GraphModifierHelper.js';
108
113
  import { EmbeddedDataType } from '../../../ExternalFormatState.js';
114
+ import type { EditorStore } from '../../../../EditorStore.js';
115
+ import { createMockDataForTable } from '../../../../utils/MockDataUtils.js';
109
116
 
110
117
  export enum MAPPING_TEST_SUITE_TYPE {
111
118
  DATA = 'DATA',
@@ -136,9 +143,28 @@ const createGraphFetchLambda = (
136
143
  return buildRawLambdaFromLambdaFunction(lambdaFunction, graphManagerState);
137
144
  };
138
145
 
146
+ const createBareModelStoreData = (
147
+ _class: Class,
148
+ editorStore: EditorStore,
149
+ ): StoreTestData => {
150
+ const embeddedData = createEmbeddedDataFromClass(_class, editorStore);
151
+ const testData = new StoreTestData();
152
+ const modelStoreData = new ModelStoreData();
153
+ const modelData = new ModelEmbeddedData();
154
+ modelData.data = embeddedData;
155
+ modelData.model = PackageableElementExplicitReference.create(_class);
156
+ modelStoreData.modelData = [modelData];
157
+ testData.data = modelStoreData;
158
+ testData.store = PackageableElementExplicitReference.create(
159
+ ModelStore.INSTANCE,
160
+ );
161
+ return testData;
162
+ };
163
+
139
164
  const createBareMappingDataTest = (
140
165
  id: string,
141
166
  storeTestData: StoreTestData | undefined,
167
+ suite?: MappingTestSuite | undefined,
142
168
  ): MappingDataTest => {
143
169
  const dataTest = new MappingDataTest();
144
170
  dataTest.id = id;
@@ -146,19 +172,28 @@ const createBareMappingDataTest = (
146
172
  dataTest.assertions = [
147
173
  createDefaultEqualToJSONTestAssertion(DEFAULT_TEST_ASSERTION_ID),
148
174
  ];
175
+ if (suite) {
176
+ dataTest.__parent = suite;
177
+ suite.tests.push(dataTest);
178
+ }
149
179
  return dataTest;
150
180
  };
151
181
 
152
182
  const createBareMappingQueryTest = (
153
183
  id: string,
154
184
  query: RawLambda,
185
+ suite?: MappingTestSuite | undefined,
155
186
  ): MappingQueryTest => {
156
187
  const dataTest = new MappingQueryTest();
157
188
  dataTest.id = id;
158
- dataTest.query = query;
189
+ dataTest.func = query;
159
190
  dataTest.assertions = [
160
191
  createDefaultEqualToJSONTestAssertion(DEFAULT_TEST_ASSERTION_ID),
161
192
  ];
193
+ if (suite) {
194
+ dataTest.__parent = suite;
195
+ suite.tests.push(dataTest);
196
+ }
162
197
  return dataTest;
163
198
  };
164
199
 
@@ -400,9 +435,9 @@ export class MappingQueryTestState extends MappingTestState {
400
435
  const queryState = new MappingTestableQueryState(
401
436
  this.editorStore,
402
437
  this.test,
403
- this.test.query,
438
+ this.test.func,
404
439
  );
405
- flowResult(queryState.updateLamba(this.test.query)).catch(
440
+ flowResult(queryState.updateLamba(this.test.func)).catch(
406
441
  this.editorStore.applicationStore.alertUnhandledError,
407
442
  );
408
443
  return queryState;
@@ -443,20 +478,15 @@ export class MappingDataTestState extends MappingTestState {
443
478
  }
444
479
 
445
480
  override defaultTab(): TESTABLE_TEST_TAB {
446
- // return this.test.storeTestData.length
447
- // ? TESTABLE_TEST_TAB.ASSERTIONS
448
- // : TESTABLE_TEST_TAB.SETUP;
449
481
  return TESTABLE_TEST_TAB.SETUP;
450
482
  }
451
483
  }
452
484
 
453
- export abstract class MappingTestSuiteState {
454
- readonly editorStore: EditorStore;
485
+ export abstract class MappingTestSuiteState extends TestableTestSuiteEditorState {
455
486
  readonly mappingTestableState: MappingTestableState;
456
- readonly uuid = uuid();
457
- suite: MappingTestSuite;
458
- testsStates: MappingTestState[] = [];
459
- selectTestState: MappingTestState | undefined;
487
+ override suite: MappingTestSuite;
488
+ override testStates: MappingTestState[] = [];
489
+ override selectTestState: MappingTestState | undefined;
460
490
  showCreateModal = false;
461
491
 
462
492
  constructor(
@@ -464,11 +494,16 @@ export abstract class MappingTestSuiteState {
464
494
  mappingTestableState: MappingTestableState,
465
495
  suite: MappingTestSuite,
466
496
  ) {
467
- this.editorStore = editorStore;
497
+ super(
498
+ mappingTestableState.mapping,
499
+ suite,
500
+ mappingTestableState.mappingEditorState.isReadOnly,
501
+ editorStore,
502
+ );
468
503
  this.mappingTestableState = mappingTestableState;
469
504
  this.suite = suite;
470
- this.testsStates = this.buildTestStates();
471
- this.selectTestState = this.testsStates[0];
505
+ this.testStates = this.buildTestStates();
506
+ this.selectTestState = this.testStates[0];
472
507
  }
473
508
 
474
509
  buildTestStates(): MappingTestState[] {
@@ -477,6 +512,8 @@ export abstract class MappingTestSuiteState {
477
512
  .filter(isNonNullable);
478
513
  }
479
514
 
515
+ abstract getDefaultClass(): Class | undefined;
516
+
480
517
  abstract buildTestState(val: MappingTest): MappingTestState | undefined;
481
518
 
482
519
  addNewTest(id: string, _class: Class | undefined): void {
@@ -489,7 +526,7 @@ export abstract class MappingTestSuiteState {
489
526
  );
490
527
  const testState = this.buildTestState(test);
491
528
  if (testState) {
492
- this.testsStates.push(testState);
529
+ this.testStates.push(testState);
493
530
  }
494
531
  this.selectTestState = testState;
495
532
  }
@@ -500,17 +537,9 @@ export abstract class MappingTestSuiteState {
500
537
  this.showCreateModal = val;
501
538
  }
502
539
 
503
- runTests(): void {
504
- // TODO
505
- }
506
-
507
- runFailingTests(): void {
508
- // console
509
- }
510
-
511
540
  changeTest(val: MappingTest): void {
512
541
  if (this.selectTestState?.test !== val) {
513
- this.selectTestState = this.testsStates.find(
542
+ this.selectTestState = this.testStates.find(
514
543
  (testState) => testState.test === val,
515
544
  );
516
545
  }
@@ -520,19 +549,19 @@ export abstract class MappingTestSuiteState {
520
549
  testSuite_deleteTest(this.suite, val);
521
550
  this.removeTestState(val);
522
551
  if (this.selectTestState?.test === val) {
523
- this.selectTestState = this.testsStates[0];
552
+ this.selectTestState = this.testStates[0];
524
553
  }
525
554
  }
526
555
 
527
556
  removeTestState(val: MappingTest): void {
528
- this.testsStates = this.testsStates.filter((e) => e.test !== val);
557
+ this.testStates = this.testStates.filter((e) => e.test !== val);
529
558
  }
530
559
  }
531
560
 
532
561
  export class MappingDataTestSuiteState extends MappingTestSuiteState {
533
562
  override suite: MappingDataTestSuite;
534
563
  dataState: MappingTestableDataState;
535
- declare testsStates: MappingQueryTestState[];
564
+ declare testStates: MappingQueryTestState[];
536
565
  declare selectTestState: MappingQueryTestState | undefined;
537
566
 
538
567
  constructor(
@@ -542,7 +571,7 @@ export class MappingDataTestSuiteState extends MappingTestSuiteState {
542
571
  ) {
543
572
  super(editorStore, mappingTestableState, suite);
544
573
  makeObservable(this, {
545
- testsStates: observable,
574
+ testStates: observable,
546
575
  selectTestState: observable,
547
576
  showCreateModal: observable,
548
577
  buildTestStates: action,
@@ -551,6 +580,8 @@ export class MappingDataTestSuiteState extends MappingTestSuiteState {
551
580
  removeTestState: action,
552
581
  addNewTest: action,
553
582
  setShowModal: action,
583
+ runFailingTests: flow,
584
+ runSuite: flow,
554
585
  });
555
586
  this.suite = suite;
556
587
  this.dataState = new MappingTestableDataState(
@@ -574,13 +605,21 @@ export class MappingDataTestSuiteState extends MappingTestSuiteState {
574
605
  const query = _class
575
606
  ? this.mappingTestableState.createSuiteState.createDefaultQuery(_class)
576
607
  : stub_RawLambda();
577
- return createBareMappingQueryTest(id, query);
608
+ return createBareMappingQueryTest(id, query, this.suite);
609
+ }
610
+
611
+ getDefaultClass(): Class | undefined {
612
+ return getMappingCompatibleClasses(
613
+ this.dataState.mappingTestableState.mapping,
614
+ this.dataState.mappingTestableState.editorStore.graphManagerState
615
+ .usableClasses,
616
+ )[0];
578
617
  }
579
618
  }
580
619
 
581
620
  export class MappingQueryTestSuiteState extends MappingTestSuiteState {
582
621
  override suite: MappingQueryTestSuite;
583
- declare testsStates: MappingDataTestState[];
622
+ declare testStates: MappingDataTestState[];
584
623
  declare selectTestState: MappingDataTestState | undefined;
585
624
  queryState: MappingTestableQueryState;
586
625
 
@@ -592,7 +631,7 @@ export class MappingQueryTestSuiteState extends MappingTestSuiteState {
592
631
  super(editorStore, mappingTestableState, suite);
593
632
  makeObservable(this, {
594
633
  queryState: observable,
595
- testsStates: observable,
634
+ testStates: observable,
596
635
  selectTestState: observable,
597
636
  showCreateModal: observable,
598
637
  deleteTest: action,
@@ -601,6 +640,8 @@ export class MappingQueryTestSuiteState extends MappingTestSuiteState {
601
640
  addNewTest: action,
602
641
  changeTest: action,
603
642
  setShowModal: action,
643
+ runFailingTests: flow,
644
+ runSuite: flow,
604
645
  });
605
646
  this.suite = suite;
606
647
  this.queryState = this.buildQueryState();
@@ -618,25 +659,41 @@ export class MappingQueryTestSuiteState extends MappingTestSuiteState {
618
659
  }
619
660
 
620
661
  override createNewTest(id: string, _class: Class | undefined): MappingTest {
621
- return createBareMappingDataTest(id, undefined);
662
+ const data = _class
663
+ ? createBareModelStoreData(_class, this.mappingTestableState.editorStore)
664
+ : undefined;
665
+ return createBareMappingDataTest(id, data, this.suite);
622
666
  }
667
+
623
668
  buildQueryState(): MappingTestableQueryState {
624
669
  const queryState = new MappingTestableQueryState(
625
670
  this.editorStore,
626
671
  this.suite,
627
- this.suite.query,
672
+ this.suite.func,
628
673
  );
629
- flowResult(queryState.updateLamba(this.suite.query)).catch(
674
+ flowResult(queryState.updateLamba(this.suite.func)).catch(
630
675
  this.editorStore.applicationStore.alertUnhandledError,
631
676
  );
632
677
  return queryState;
633
678
  }
679
+
680
+ getDefaultClass(): Class | undefined {
681
+ const dataTest = this.suite.tests.filter(filterByType(MappingDataTest))[0];
682
+ if (dataTest) {
683
+ const storeTestData = dataTest.storeTestData[0]?.data;
684
+ if (storeTestData instanceof ModelStoreData) {
685
+ return storeTestData.modelData?.[0]?.model.value;
686
+ }
687
+ }
688
+ return undefined;
689
+ }
634
690
  }
635
691
 
636
692
  export class CreateSuiteState {
637
693
  readonly editorStore: EditorStore;
638
694
  readonly mappingTestableState: MappingTestableState;
639
695
  showModal = false;
696
+ isCreatingSuiteState = ActionState.create();
640
697
 
641
698
  constructor(
642
699
  editorStore: EditorStore,
@@ -649,6 +706,7 @@ export class CreateSuiteState {
649
706
  showModal: observable,
650
707
  setShowModal: action,
651
708
  createAndAddTestSuite: flow,
709
+ isCreatingSuiteState: observable,
652
710
  });
653
711
  }
654
712
 
@@ -660,40 +718,55 @@ export class CreateSuiteState {
660
718
  _class: Class,
661
719
  type: MAPPING_TEST_SUITE_TYPE,
662
720
  name: string,
721
+ testName: string,
663
722
  ): GeneratorFn<void> {
664
723
  // type
665
724
  try {
725
+ this.isCreatingSuiteState.inProgress();
666
726
  const mappingTestableState = this.mappingTestableState;
667
727
  if (!mappingTestableState.mappingModelCoverageAnalysisResult) {
728
+ this.isCreatingSuiteState.setMessage(
729
+ 'Analyzing mapping to generate test query...',
730
+ );
668
731
  yield flowResult(mappingTestableState.analyzeMappingModelCoverage());
669
732
  }
733
+ this.isCreatingSuiteState.setMessage('Creating test query...');
670
734
  const rootSetImpl = getRootSetImplementation(
671
735
  this.mappingTestableState.mapping,
672
736
  _class,
673
737
  );
674
738
  const query = this.createDefaultQuery(_class);
675
739
  const storeTestData = rootSetImpl
676
- ? this.attemptToGenerateTestData(rootSetImpl)
740
+ ? this.attemptToGenerateTestData(rootSetImpl, this.editorStore)
677
741
  : undefined;
678
742
  let testSuite: MappingTestSuite;
679
- const test1 = `test_1`;
680
- const assertionId = 'assertion_1';
681
743
  if (type === MAPPING_TEST_SUITE_TYPE.DATA) {
682
744
  const dataSuite = new MappingDataTestSuite();
683
745
  dataSuite.storeTestData = storeTestData ? [storeTestData] : [];
684
- const test = new MappingQueryTest();
685
- dataSuite.tests = [
686
- createBareMappingQueryTest(`${_class.name}_test_1`, query),
687
- ];
688
- // add assertion
689
- test.assertions = [createDefaultEqualToJSONTestAssertion(assertionId)];
746
+ const test = createBareMappingQueryTest(testName, query, dataSuite);
747
+ test.__parent = dataSuite;
748
+ dataSuite.tests = [test];
749
+ const _assertion = createDefaultEqualToJSONTestAssertion(
750
+ `${testName}_assertion1`,
751
+ );
752
+ test.assertions = [_assertion];
753
+ _assertion.parentTest = test;
690
754
  testSuite = dataSuite;
691
755
  } else {
692
756
  const querySuite = new MappingQueryTestSuite();
693
- querySuite.query = query;
694
- testSuite = querySuite;
757
+ querySuite.func = query;
695
758
  // add test
696
- querySuite.tests = [createBareMappingDataTest(test1, storeTestData)];
759
+ const _test = createBareMappingDataTest(
760
+ testName,
761
+ storeTestData,
762
+ querySuite,
763
+ );
764
+ const _assertion = createDefaultEqualToJSONTestAssertion(
765
+ `${testName}_assertion1`,
766
+ );
767
+ _test.assertions = [_assertion];
768
+ _assertion.parentTest = _test;
769
+ testSuite = querySuite;
697
770
  }
698
771
  testSuite.id = name;
699
772
  mapping_addTestSuite(
@@ -702,13 +775,24 @@ export class CreateSuiteState {
702
775
  this.editorStore.changeDetectionState.observerContext,
703
776
  );
704
777
  this.mappingTestableState.changeSuite(testSuite);
778
+ const selectTestState =
779
+ this.mappingTestableState.selectedTestSuite?.selectTestState;
780
+ const selectedAsertionState = selectTestState?.selectedAsertionState;
781
+ if (selectTestState && selectedAsertionState) {
782
+ this.isCreatingSuiteState.setMessage(
783
+ 'Attempting to generate expected result...',
784
+ );
785
+ yield flowResult(selectedAsertionState.generateExpected());
786
+ }
787
+ this.setShowModal(false);
705
788
  } catch (error) {
706
789
  assertErrorThrown(error);
707
790
  this.editorStore.applicationStore.notificationService.notifyError(
708
791
  `Unable to create to test suite: ${error.message}`,
709
792
  );
710
793
  } finally {
711
- this.setShowModal(false);
794
+ this.isCreatingSuiteState.complete();
795
+ this.isCreatingSuiteState.setMessage(undefined);
712
796
  }
713
797
  }
714
798
 
@@ -776,37 +860,41 @@ export class CreateSuiteState {
776
860
  // change to use api call for relational
777
861
  attemptToGenerateTestData(
778
862
  setImpl: SetImplementation,
863
+ editorStore: EditorStore,
779
864
  ): StoreTestData | undefined {
780
865
  if (
781
866
  setImpl instanceof RelationalInstanceSetImplementation ||
782
867
  setImpl instanceof EmbeddedRelationalInstanceSetImplementation ||
783
868
  setImpl instanceof EmbeddedRelationalInstanceSetImplementation
784
869
  ) {
785
- const _store = resolveMappingSourceToStore(
786
- getMappingElementSource(
787
- setImpl,
788
- this.editorStore.pluginManager.getApplicationPlugins(),
789
- ),
870
+ const _table = getMappingElementSource(
871
+ setImpl,
872
+ editorStore.pluginManager.getApplicationPlugins(),
790
873
  );
791
- if (_store instanceof Database) {
792
- const _storeData = new StoreTestData();
793
- _storeData.store = PackageableElementExplicitReference.create(_store);
794
- _storeData.data = new RelationalCSVData();
795
- return _storeData;
874
+ if (_table instanceof TableAlias) {
875
+ const relation = _table.relation.value;
876
+ const owner = relation.schema._OWNER;
877
+ const val = new RelationalCSVData();
878
+ if (relation instanceof Table) {
879
+ const mockTable = new RelationalCSVDataTable();
880
+ const values = createMockDataForTable(relation);
881
+ mockTable.table = relation.name;
882
+ mockTable.schema = relation.schema.name;
883
+ mockTable.values = values;
884
+ val.tables.push(mockTable);
885
+ }
886
+ const testData = new StoreTestData();
887
+ testData.data = val;
888
+ testData.store = PackageableElementExplicitReference.create(owner);
889
+ return testData;
796
890
  }
797
891
  } else if (setImpl instanceof PureInstanceSetImplementation) {
798
892
  const srcClass = setImpl.srcClass;
799
893
  if (srcClass) {
800
- const embeddedData = createEmbeddedDataFromClass(
894
+ return createBareModelStoreData(
801
895
  srcClass.value,
802
- this.editorStore,
896
+ this.mappingTestableState.editorStore,
803
897
  );
804
- const testData = new StoreTestData();
805
- testData.data = embeddedData;
806
- testData.store = PackageableElementExplicitReference.create(
807
- ModelStore.INSTANCE,
808
- );
809
- return testData;
810
898
  }
811
899
  }
812
900
  return undefined;