tiagobento commented on code in PR #2919:
URL:
https://github.com/apache/incubator-kie-tools/pull/2919#discussion_r1972271300
##########
packages/scesim-editor/tests-e2e/scesimEditor/backgroundTable/populate.spec.ts:
##########
@@ -70,6 +70,7 @@ test.describe("Populate decision background table", () => {
});
test.describe("Populate rule background table", () => {
+ test.skip(true, "Rule-Based Test Scenario is not enabled");
Review Comment:
May I ask you to please file an issue at `kie-issues` and link this skipped
test to it via an annotation? @ljmotta Would you be available please to tell
@yesamer what's the best way to do this for Playwright tests? Thank you!
##########
packages/scesim-editor/src/drawer/TestScenarioDrawerDataSelectorPanel.tsx:
##########
@@ -202,6 +202,18 @@ function TestScenarioDataSelectorPanel() {
}
}, []);
+ /* It returns the TestScenarioDataObject that matches the provided ID
serching over all TestScenarioDataObjects and its children */
+ const findTestScenarioDataObjectById = useCallback(
+ (dataObjects: TestScenarioDataObject[], id: string):
TestScenarioDataObject => {
+ let dataObjectToReturn = dataObjects.find((dataObject) =>
id.startsWith(dataObject.id));
+ if (dataObjectToReturn?.id !== id && dataObjectToReturn?.children) {
+ dataObjectToReturn =
findTestScenarioDataObjectById(dataObjectToReturn.children, id);
+ }
+ return dataObjectToReturn!;
+ },
+ []
+ );
Review Comment:
It seems you have other `useCallback`s that can be moved out of the
component too.
##########
packages/scesim-editor/src/drawer/TestScenarioDrawerDataSelectorPanel.tsx:
##########
@@ -288,23 +300,20 @@ function TestScenarioDataSelectorPanel() {
if (isExpressionType) {
fieldID =
selectedColumnMetadata.factMapping.expressionElements!.ExpressionElement![0].step.__$$text;
} else if (isSimpleTypeFact) {
- fieldID =
selectedColumnMetadata.factMapping.expressionElements!.ExpressionElement![0].step.__$$text.concat(".");
+ fieldID = selectedColumnMetadata.factMapping
Review Comment:
```suggestion
fieldId = selectedColumnMetadata.factMapping
```
##########
packages/scesim-editor/src/drawer/TestScenarioDrawerDataSelectorPanel.tsx:
##########
@@ -202,6 +202,18 @@ function TestScenarioDataSelectorPanel() {
}
}, []);
+ /* It returns the TestScenarioDataObject that matches the provided ID
serching over all TestScenarioDataObjects and its children */
+ const findTestScenarioDataObjectById = useCallback(
+ (dataObjects: TestScenarioDataObject[], id: string):
TestScenarioDataObject => {
+ let dataObjectToReturn = dataObjects.find((dataObject) =>
id.startsWith(dataObject.id));
+ if (dataObjectToReturn?.id !== id && dataObjectToReturn?.children) {
+ dataObjectToReturn =
findTestScenarioDataObjectById(dataObjectToReturn.children, id);
+ }
+ return dataObjectToReturn!;
+ },
+ []
+ );
Review Comment:
This function can live in the global scope, outside of the function
component.
##########
packages/scesim-editor/tests-e2e/scesimEditor/testScenarioTable/populate.spec.ts:
##########
@@ -104,6 +104,7 @@ test.describe("Populate decision test scenario table", ()
=> {
});
test.describe("Populate rule test scenario table", () => {
+ test.skip(true, "Rule-Based Test Scenario is not enabled");
Review Comment:
Same.
##########
packages/scesim-editor/src/drawer/TestScenarioDrawerDataSelectorPanel.tsx:
##########
@@ -288,23 +300,20 @@ function TestScenarioDataSelectorPanel() {
if (isExpressionType) {
fieldID =
selectedColumnMetadata.factMapping.expressionElements!.ExpressionElement![0].step.__$$text;
} else if (isSimpleTypeFact) {
- fieldID =
selectedColumnMetadata.factMapping.expressionElements!.ExpressionElement![0].step.__$$text.concat(".");
+ fieldID = selectedColumnMetadata.factMapping
+ .expressionElements!.ExpressionElement![0].step.__$$text.concat(".")
+ .concat("value");
} else {
fieldID = selectedColumnMetadata.factMapping
.expressionElements!.ExpressionElement!.map((expressionElement) =>
expressionElement.step.__$$text)
.join(".");
}
- //TODO 1 This not work with multiple level and expressions fields. see
kie-issues#1514
- const treeViewItemToActivate = filteredDataObjects
- .reduce((acc: TestScenarioDataObject[], item) => {
- return item.children ? acc.concat(item.children) : acc;
- }, [])
- .filter((item) => item.id === fieldID);
+ const treeViewItemToActivate =
findTestScenarioDataObjectById(filteredDataObjects, fieldID)!;
Review Comment:
Not memoized. Please wrap it in a `useMemo` with the matching array of
dependencies.
##########
packages/scesim-editor/src/store/TestScenarioEditorStore.ts:
##########
@@ -50,10 +50,13 @@ export type TestScenarioAlert = {
};
export type TestScenarioDataObject = {
- id: string;
+ id: string; // UI-Scope only
children?: TestScenarioDataObject[];
- customBadgeContent?: string;
- isSimpleTypeFact?: boolean;
+ className?: string;
+ collectionGenericType?: string[];
+ customBadgeContent?: string; // UI-Scoped only
+ expressionElements: string[];
+ hasBadge?: boolean; // UI-Scoped only
Review Comment:
Can you please explain what "UI-Scoped only" means?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]