@gravitee/ui-policy-studio-angular 7.12.0 → 7.13.0

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 (75) hide show
  1. package/esm2020/lib/components/flow-details/gio-ps-flow-details.component.mjs +4 -3
  2. package/esm2020/lib/components/flow-details-phase/gio-ps-flow-details-phase.component.mjs +19 -19
  3. package/esm2020/lib/components/flow-details-phase-step/gio-ps-flow-details-phase-step.component.mjs +77 -0
  4. package/esm2020/lib/components/policies-catalog-dialog/gio-ps-policies-catalog-dialog.component.mjs +11 -5
  5. package/esm2020/lib/components/step-edit-dialog/gio-ps-step-edit-dialog.component.mjs +46 -0
  6. package/esm2020/lib/components/step-form/gio-ps-step-form.component.mjs +78 -0
  7. package/esm2020/lib/gio-policy-studio.component.mjs +44 -14
  8. package/esm2020/lib/gio-policy-studio.module.mjs +13 -11
  9. package/esm2020/lib/gio-policy-studio.service.mjs +66 -0
  10. package/esm2020/lib/models/PolicySchemaFetcher.mjs +2 -0
  11. package/esm2020/lib/models/index.mjs +2 -1
  12. package/esm2020/testing/lib/components/flow-details-phase/gio-ps-flow-details-phase.harness.mjs +53 -7
  13. package/esm2020/testing/lib/components/flow-details-phase-step/gio-ps-flow-details-phase-step.harness.mjs +42 -0
  14. package/esm2020/testing/lib/components/policies-catalog-dialog/gio-ps-policies-catalog-dialog.harness.mjs +55 -0
  15. package/esm2020/testing/lib/components/step-edit-dialog/gio-ps-step-edit-dialog.harness.mjs +30 -0
  16. package/esm2020/testing/lib/components/step-form/gio-ps-step-form.harness.mjs +37 -0
  17. package/esm2020/testing/lib/gio-policy-studio.harness.mjs +8 -8
  18. package/esm2020/testing/lib/models/PolicySchemaFetcher.mjs +2 -0
  19. package/esm2020/testing/lib/models/flow/Step.fixture.mjs +10 -9
  20. package/esm2020/testing/lib/models/index.mjs +2 -1
  21. package/fesm2015/gravitee-ui-policy-studio-angular-testing.mjs +171 -27
  22. package/fesm2015/gravitee-ui-policy-studio-angular-testing.mjs.map +1 -1
  23. package/fesm2015/gravitee-ui-policy-studio-angular.mjs +214 -555
  24. package/fesm2015/gravitee-ui-policy-studio-angular.mjs.map +1 -1
  25. package/fesm2020/gravitee-ui-policy-studio-angular-testing.mjs +185 -25
  26. package/fesm2020/gravitee-ui-policy-studio-angular-testing.mjs.map +1 -1
  27. package/fesm2020/gravitee-ui-policy-studio-angular.mjs +220 -611
  28. package/fesm2020/gravitee-ui-policy-studio-angular.mjs.map +1 -1
  29. package/lib/components/flow-details-phase/gio-ps-flow-details-phase.component.d.ts +4 -2
  30. package/lib/components/flow-details-phase-step/gio-ps-flow-details-phase-step.component.d.ts +18 -0
  31. package/lib/components/policies-catalog-dialog/gio-ps-policies-catalog-dialog.component.d.ts +4 -2
  32. package/lib/components/step-edit-dialog/gio-ps-step-edit-dialog.component.d.ts +18 -0
  33. package/lib/components/step-form/gio-ps-step-form.component.d.ts +23 -0
  34. package/lib/gio-policy-studio.component.d.ts +30 -2
  35. package/lib/gio-policy-studio.module.d.ts +4 -4
  36. package/lib/gio-policy-studio.service.d.ts +26 -0
  37. package/lib/models/PolicySchemaFetcher.d.ts +4 -0
  38. package/lib/models/index.d.ts +1 -0
  39. package/package.json +1 -1
  40. package/testing/lib/components/flow-details-phase/gio-ps-flow-details-phase.harness.d.ts +29 -4
  41. package/testing/lib/components/{flow-details-phase-policy/gio-ps-flow-details-phase-policy.harness.d.ts → flow-details-phase-step/gio-ps-flow-details-phase-step.harness.d.ts} +4 -3
  42. package/testing/lib/components/policies-catalog-dialog/gio-ps-policies-catalog-dialog.harness.d.ts +12 -0
  43. package/testing/lib/components/step-edit-dialog/gio-ps-step-edit-dialog.harness.d.ts +8 -0
  44. package/testing/lib/components/step-form/gio-ps-step-form.harness.d.ts +11 -0
  45. package/testing/lib/gio-policy-studio.harness.d.ts +4 -7
  46. package/testing/lib/models/PolicySchemaFetcher.d.ts +4 -0
  47. package/testing/lib/models/flow/Step.fixture.d.ts +2 -2
  48. package/testing/lib/models/index.d.ts +1 -0
  49. package/esm2020/lib/components/flow-details-phase-policy/gio-ps-flow-details-phase-policy.component.mjs +0 -58
  50. package/esm2020/lib/components/policy-form/gio-ps-policy-form.component.mjs +0 -30
  51. package/esm2020/lib/components/policy-form-dialog/gio-ps-policy-form-dialog.component.mjs +0 -43
  52. package/esm2020/lib/models/ConnectorsInfo.fixture.mjs +0 -152
  53. package/esm2020/lib/models/flow/Flow.fixture.mjs +0 -66
  54. package/esm2020/lib/models/flow/FlowExecution.fixture.mjs +0 -43
  55. package/esm2020/lib/models/flow/Step.fixture.mjs +0 -70
  56. package/esm2020/lib/models/flow/index-testing.mjs +0 -19
  57. package/esm2020/lib/models/index-testing.mjs +0 -20
  58. package/esm2020/lib/models/plan/Plan.fixture.mjs +0 -31
  59. package/esm2020/lib/models/plan/index-testing.mjs +0 -17
  60. package/esm2020/lib/models/policy/Policy.fixture.mjs +0 -133
  61. package/esm2020/lib/models/policy/index-testing.mjs +0 -17
  62. package/esm2020/testing/lib/components/flow-details-phase-policy/gio-ps-flow-details-phase-policy.harness.mjs +0 -38
  63. package/lib/components/flow-details-phase-policy/gio-ps-flow-details-phase-policy.component.d.ts +0 -13
  64. package/lib/components/policy-form/gio-ps-policy-form.component.d.ts +0 -8
  65. package/lib/components/policy-form-dialog/gio-ps-policy-form-dialog.component.d.ts +0 -17
  66. package/lib/models/ConnectorsInfo.fixture.d.ts +0 -10
  67. package/lib/models/flow/Flow.fixture.d.ts +0 -3
  68. package/lib/models/flow/FlowExecution.fixture.d.ts +0 -3
  69. package/lib/models/flow/Step.fixture.d.ts +0 -4
  70. package/lib/models/flow/index-testing.d.ts +0 -3
  71. package/lib/models/index-testing.d.ts +0 -4
  72. package/lib/models/plan/Plan.fixture.d.ts +0 -2
  73. package/lib/models/plan/index-testing.d.ts +0 -1
  74. package/lib/models/policy/Policy.fixture.d.ts +0 -4
  75. package/lib/models/policy/index-testing.d.ts +0 -1
@@ -131,12 +131,12 @@ function fakeDefaultFlowExecution(modifier) {
131
131
  * See the License for the specific language governing permissions and
132
132
  * limitations under the License.
133
133
  */
134
- function fakeMockPolicyStep(modifier) {
134
+ function fakeTestPolicyStep(modifier) {
135
135
  const base = {
136
- name: 'Mock Policy',
137
- description: 'Mock Policy description',
136
+ name: fakeTestPolicy().name,
137
+ description: 'Test Policy description',
138
138
  enabled: true,
139
- policy: 'mock',
139
+ policy: 'test-policy',
140
140
  };
141
141
  if (isFunction(modifier)) {
142
142
  return modifier(base);
@@ -168,12 +168,12 @@ function fakeRateLimitStep(modifier) {
168
168
  ...modifier,
169
169
  };
170
170
  }
171
- function fakeXmlToJsonStep(modifier) {
171
+ function fakeJsonToXmlStep(modifier) {
172
172
  const base = {
173
- name: 'XML to JSON',
174
- description: 'XML to JSON',
173
+ name: 'JSON to XML',
174
+ description: 'JSON to XML',
175
175
  enabled: true,
176
- policy: 'xml-json',
176
+ policy: 'json-xml',
177
177
  configuration: {},
178
178
  };
179
179
  if (isFunction(modifier)) {
@@ -987,7 +987,7 @@ GioPolicyStudioFlowExecutionFormDialogHarness.hostSelector = 'gio-ps-flow-execut
987
987
  * See the License for the specific language governing permissions and
988
988
  * limitations under the License.
989
989
  */
990
- class GioPolicyStudioDetailsPhasePolicyHarness extends ComponentHarness {
990
+ class GioPolicyStudioDetailsPhaseStepHarness extends ComponentHarness {
991
991
  /**
992
992
  * Get Harness with the given filter.
993
993
  *
@@ -995,17 +995,134 @@ class GioPolicyStudioDetailsPhasePolicyHarness extends ComponentHarness {
995
995
  * @return a `HarnessPredicate` configured with the given options.
996
996
  */
997
997
  static with(options = {}) {
998
- return new HarnessPredicate(GioPolicyStudioDetailsPhasePolicyHarness, options);
998
+ return new HarnessPredicate(GioPolicyStudioDetailsPhaseStepHarness, options);
999
999
  }
1000
1000
  async getName() {
1001
- return (await (await this.locatorFor(SpanHarness.with({ selector: '.info__primary__name' }))()).getText()) ?? '';
1001
+ return (await (await this.locatorFor(SpanHarness.with({ selector: '.info__head__name' }))()).getText()) ?? '';
1002
+ }
1003
+ async getDescription() {
1004
+ return (await (await this.locatorForOptional(DivHarness.with({ selector: '.info__description' }))())?.getText()) ?? undefined;
1002
1005
  }
1003
1006
  async clickOnEdit() {
1004
1007
  const matMenu = await this.locatorFor(MatMenuHarness)();
1005
1008
  await matMenu.clickItem({ text: 'Edit' });
1006
1009
  }
1007
1010
  }
1008
- GioPolicyStudioDetailsPhasePolicyHarness.hostSelector = 'gio-ps-flow-details-phase-policy';
1011
+ GioPolicyStudioDetailsPhaseStepHarness.hostSelector = 'gio-ps-flow-details-phase-step';
1012
+
1013
+ /*
1014
+ * Copyright (C) 2022 The Gravitee team (http://gravitee.io)
1015
+ *
1016
+ * Licensed under the Apache License, Version 2.0 (the "License");
1017
+ * you may not use this file except in compliance with the License.
1018
+ * You may obtain a copy of the License at
1019
+ *
1020
+ * http://www.apache.org/licenses/LICENSE-2.0
1021
+ *
1022
+ * Unless required by applicable law or agreed to in writing, software
1023
+ * distributed under the License is distributed on an "AS IS" BASIS,
1024
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1025
+ * See the License for the specific language governing permissions and
1026
+ * limitations under the License.
1027
+ */
1028
+ class GioPolicyStudioStepFormHarness extends ComponentHarness {
1029
+ constructor() {
1030
+ super(...arguments);
1031
+ this.getDescriptionInput = this.locatorFor(MatInputHarness.with({ selector: '[formControlName="description"]' }));
1032
+ }
1033
+ async setStepForm(stepForm) {
1034
+ if (stepForm.description) {
1035
+ const descriptionInput = await this.getDescriptionInput();
1036
+ await descriptionInput.setValue(stepForm.description);
1037
+ }
1038
+ }
1039
+ async getStepFormValue() {
1040
+ const descriptionInput = await this.getDescriptionInput();
1041
+ return {
1042
+ description: await descriptionInput.getValue(),
1043
+ };
1044
+ }
1045
+ }
1046
+ GioPolicyStudioStepFormHarness.hostSelector = 'gio-ps-step-form';
1047
+
1048
+ /*
1049
+ * Copyright (C) 2022 The Gravitee team (http://gravitee.io)
1050
+ *
1051
+ * Licensed under the Apache License, Version 2.0 (the "License");
1052
+ * you may not use this file except in compliance with the License.
1053
+ * You may obtain a copy of the License at
1054
+ *
1055
+ * http://www.apache.org/licenses/LICENSE-2.0
1056
+ *
1057
+ * Unless required by applicable law or agreed to in writing, software
1058
+ * distributed under the License is distributed on an "AS IS" BASIS,
1059
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1060
+ * See the License for the specific language governing permissions and
1061
+ * limitations under the License.
1062
+ */
1063
+ class GioPolicyStudioStepEditDialogHarness extends ComponentHarness {
1064
+ async getPolicyName() {
1065
+ return (await this.locatorFor('.title__name')()).text();
1066
+ }
1067
+ async getStepForm() {
1068
+ return await this.locatorFor(GioPolicyStudioStepFormHarness)();
1069
+ }
1070
+ async save() {
1071
+ return (await this.locatorFor('.actions__saveBtn')()).click();
1072
+ }
1073
+ }
1074
+ GioPolicyStudioStepEditDialogHarness.hostSelector = 'gio-ps-step-edit-dialog';
1075
+
1076
+ /*
1077
+ * Copyright (C) 2022 The Gravitee team (http://gravitee.io)
1078
+ *
1079
+ * Licensed under the Apache License, Version 2.0 (the "License");
1080
+ * you may not use this file except in compliance with the License.
1081
+ * You may obtain a copy of the License at
1082
+ *
1083
+ * http://www.apache.org/licenses/LICENSE-2.0
1084
+ *
1085
+ * Unless required by applicable law or agreed to in writing, software
1086
+ * distributed under the License is distributed on an "AS IS" BASIS,
1087
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1088
+ * See the License for the specific language governing permissions and
1089
+ * limitations under the License.
1090
+ */
1091
+ class GioPolicyStudioPoliciesCatalogDialogHarness extends ComponentHarness {
1092
+ constructor() {
1093
+ super(...arguments);
1094
+ this.policiesLocator = this.locatorForAll(DivHarness.with({ selector: '.policiesCatalog__policy' }));
1095
+ }
1096
+ async getPhase() {
1097
+ const phase = await this.locatorFor('.title__phase')();
1098
+ return phase.text();
1099
+ }
1100
+ async getPoliciesName() {
1101
+ const policies = await this.locatorForAll('.policiesCatalog__policy__head__name')();
1102
+ return parallel(() => policies.map(policy => policy.text()));
1103
+ }
1104
+ async selectPolicy(policyName) {
1105
+ const policies = await this.policiesLocator();
1106
+ const policy = policies.find(async (p) => (await p.getText({ childSelector: '.policiesCatalog__policy__head__name' })) === policyName);
1107
+ if (!policy) {
1108
+ throw new Error(`Policy ${policyName} not found`);
1109
+ }
1110
+ const selectBtn = await policy.childLocatorFor(MatButtonHarness.with({ selector: '.policiesCatalog__policy__selectBtn' }))();
1111
+ await selectBtn.click();
1112
+ }
1113
+ async getSelectedPolicyName() {
1114
+ const policy = await this.locatorFor('.policyForm__info__head__name')();
1115
+ return policy.text();
1116
+ }
1117
+ async clickAddPolicyButton() {
1118
+ const addBtn = await this.locatorFor(MatButtonHarness.with({ selector: '.actions__addBtn' }))();
1119
+ await addBtn.click();
1120
+ }
1121
+ async getStepForm() {
1122
+ return await this.locatorFor(GioPolicyStudioStepFormHarness)();
1123
+ }
1124
+ }
1125
+ GioPolicyStudioPoliciesCatalogDialogHarness.hostSelector = 'gio-ps-policies-catalog-dialog';
1009
1126
 
1010
1127
  /*
1011
1128
  * Copyright (C) 2022 The Gravitee team (http://gravitee.io)
@@ -1043,25 +1160,68 @@ class GioPolicyStudioDetailsPhaseHarness extends ComponentHarness {
1043
1160
  return new HarnessPredicate(GioPolicyStudioDetailsPhaseHarness, options).addOption('type', options.type, async (harness, type) => HarnessPredicate.stringMatches(harness.getHeaderName(), TYPE_TO_TEXT[type]));
1044
1161
  }
1045
1162
  async getSteps() {
1163
+ if (await this.locatorForOptional('.disabledContent')()) {
1164
+ return 'DISABLED';
1165
+ }
1046
1166
  const stepsDiv = await this.locatorForAll(DivHarness.with({ selector: '.content__step' }))();
1047
1167
  if (isEmpty(stepsDiv)) {
1048
1168
  // No step - the phase is disabled
1049
- return null;
1169
+ return [];
1050
1170
  }
1051
1171
  return await parallel(() => stepsDiv.map(async (stepDiv) => {
1052
- const idConnector = !!(await stepDiv.getText({ childSelector: '.content__step__connectorBadge' }));
1172
+ const idConnector = !!(await stepDiv.getText({ childSelector: '.content__step__connector__badge' }));
1053
1173
  if (idConnector) {
1054
1174
  return {
1055
- text: (await stepDiv.getText()) ?? '',
1175
+ name: (await stepDiv.getText()) ?? '',
1056
1176
  type: 'connector',
1057
1177
  };
1058
1178
  }
1179
+ const step = await stepDiv.childLocatorFor(GioPolicyStudioDetailsPhaseStepHarness)();
1180
+ const description = await step.getDescription();
1059
1181
  return {
1060
- text: await (await stepDiv.childLocatorFor(GioPolicyStudioDetailsPhasePolicyHarness)()).getName(),
1061
- type: idConnector ? 'connector' : 'policy',
1182
+ type: 'step',
1183
+ name: await step.getName(),
1184
+ ...(description ? { description } : {}),
1062
1185
  };
1063
1186
  }));
1064
1187
  }
1188
+ async getStep(index) {
1189
+ const steps = await this.locatorForAll(GioPolicyStudioDetailsPhaseStepHarness)();
1190
+ if (!steps[index]) {
1191
+ throw new Error(`Step ${index} not found`);
1192
+ }
1193
+ return steps[index];
1194
+ }
1195
+ async clickAddStep(index) {
1196
+ const addStepBtn = await this.locatorForAll(DivHarness.with({ selector: '.content__step' }))().then(divs => divs[index]);
1197
+ await addStepBtn
1198
+ .childLocatorFor(MatButtonHarness.with({ selector: '.content__step__addBtn' }))()
1199
+ .then(btn => btn.click());
1200
+ }
1201
+ /**
1202
+ * Add a step to a phase
1203
+ * @param index Index where to add the step. (Add button index)
1204
+ * @param stepConfig Step to add
1205
+ */
1206
+ async addStep(index, stepConfig) {
1207
+ await this.clickAddStep(index);
1208
+ const catalogDialog = await this.documentRootLocatorFactory().locatorFor(GioPolicyStudioPoliciesCatalogDialogHarness)();
1209
+ await catalogDialog.selectPolicy(stepConfig.policyName);
1210
+ await (await catalogDialog.getStepForm()).setStepForm(stepConfig);
1211
+ await catalogDialog.clickAddPolicyButton();
1212
+ }
1213
+ /**
1214
+ * Edit a step configuration
1215
+ * @param index Index of the policy step to edit
1216
+ * @param stepConfig Step configuration
1217
+ */
1218
+ async editStep(index, stepConfig) {
1219
+ const step = await this.getStep(index);
1220
+ await step.clickOnEdit();
1221
+ const stepEditDialog = await this.documentRootLocatorFactory().locatorFor(GioPolicyStudioStepEditDialogHarness)();
1222
+ await (await stepEditDialog.getStepForm()).setStepForm(stepConfig);
1223
+ await stepEditDialog.save();
1224
+ }
1065
1225
  }
1066
1226
  GioPolicyStudioDetailsPhaseHarness.hostSelector = 'gio-ps-flow-details-phase';
1067
1227
 
@@ -1138,16 +1298,16 @@ class GioPolicyStudioHarness extends ComponentHarness {
1138
1298
  return await (await this.detailsHarness()).getFlowInfos();
1139
1299
  }
1140
1300
  /**
1141
- * Get selected flow steps phase
1142
- * @param tabLabel Select tabs before try to find phase. Useful to find Event phases for Message API
1301
+ * Get selected flow phase harness
1302
+ * @param phaseType Phase type to get
1143
1303
  */
1144
- async getSelectedFlowSteps(phaseType, tabLabel) {
1145
- if (tabLabel) {
1304
+ async getSelectedFlowPhase(phaseType) {
1305
+ if (phaseType === 'PUBLISH' || phaseType === 'SUBSCRIBE') {
1146
1306
  const matTabsHarness = await this.locatorFor(MatTabGroupHarness.with({ selector: '.content__tabs' }))();
1147
- await matTabsHarness.selectTab({ label: tabLabel });
1307
+ await matTabsHarness.selectTab({ label: 'Event messages' });
1148
1308
  }
1149
- const steps = await (await this.phaseHarness(phaseType)).getSteps();
1150
- return steps ? steps : 'DISABLED';
1309
+ const steps = await await this.phaseHarness(phaseType);
1310
+ return steps ? steps : undefined;
1151
1311
  }
1152
1312
  /**
1153
1313
  * Click on the "Save" button
@@ -1222,5 +1382,5 @@ GioPolicyStudioHarness.hostSelector = 'gio-policy-studio';
1222
1382
  * Generated bundle index. Do not edit.
1223
1383
  */
1224
1384
 
1225
- export { GioPolicyStudioHarness, POLICIES_V4_UNREGISTERED_ICON, fakeAllPolicies, fakeBestMatchFlowExecution, fakeChannelFlow, fakeDefaultFlowExecution, fakeHTTPGetMessageEntrypoint, fakeHTTPPostMessageEntrypoint, fakeHTTPProxyEndpoint, fakeHTTPProxyEntrypoint, fakeHttpFlow, fakeKafkaMessageEndpoint, fakeMockMessageEndpoint, fakeMockPolicyStep, fakePlan, fakeRateLimitStep, fakeSSEMessageEntrypoint, fakeTestPolicy, fakeWebhookMessageEntrypoint, fakeWebsocketMessageEntrypoint, fakeXmlToJsonStep };
1385
+ export { GioPolicyStudioHarness, POLICIES_V4_UNREGISTERED_ICON, fakeAllPolicies, fakeBestMatchFlowExecution, fakeChannelFlow, fakeDefaultFlowExecution, fakeHTTPGetMessageEntrypoint, fakeHTTPPostMessageEntrypoint, fakeHTTPProxyEndpoint, fakeHTTPProxyEntrypoint, fakeHttpFlow, fakeJsonToXmlStep, fakeKafkaMessageEndpoint, fakeMockMessageEndpoint, fakePlan, fakeRateLimitStep, fakeSSEMessageEntrypoint, fakeTestPolicy, fakeTestPolicyStep, fakeWebhookMessageEntrypoint, fakeWebsocketMessageEntrypoint };
1226
1386
  //# sourceMappingURL=gravitee-ui-policy-studio-angular-testing.mjs.map