@gravitee/ui-policy-studio-angular 7.9.0 → 7.9.1-policy-studio-step-5-2d586ea

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 (46) hide show
  1. package/esm2020/lib/components/filter-pipe/gio-flter-connectors-by-mode.pipe.mjs +40 -0
  2. package/esm2020/lib/components/flow-details/gio-ps-flow-details.component.mjs +5 -4
  3. package/esm2020/lib/components/flow-details-info-bar/gio-ps-flow-details-info-bar.component.mjs +3 -3
  4. package/esm2020/lib/components/flow-details-phase/gio-ps-flow-details-phase.component.mjs +40 -8
  5. package/esm2020/lib/components/flow-details-phase-policy/gio-ps-flow-details-phase-policy.component.mjs +15 -5
  6. package/esm2020/lib/components/flow-execution-form-dialog/gio-ps-flow-execution-form-dialog.component.mjs +1 -1
  7. package/esm2020/lib/components/flow-form-dialog/flow-message-form-dialog/gio-ps-flow-message-form-dialog.component.mjs +3 -3
  8. package/esm2020/lib/components/flows-menu/gio-ps-flows-menu.component.mjs +1 -1
  9. package/esm2020/lib/gio-policy-studio.component.mjs +6 -8
  10. package/esm2020/lib/gio-policy-studio.module.mjs +9 -2
  11. package/esm2020/lib/models/ConnectorsInfo.mjs +1 -1
  12. package/esm2020/testing/lib/components/flow-details-phase/gio-ps-flow-details-phase.harness.mjs +62 -0
  13. package/esm2020/testing/lib/components/flow-details-phase-policy/gio-ps-flow-details-phase-policy.harness.mjs +33 -0
  14. package/esm2020/testing/lib/gio-policy-studio.harness.mjs +35 -1
  15. package/esm2020/testing/lib/models/ConnectorsInfo.fixture.mjs +152 -0
  16. package/esm2020/testing/lib/models/ConnectorsInfo.mjs +1 -1
  17. package/esm2020/testing/lib/models/flow/Step.fixture.mjs +70 -0
  18. package/esm2020/testing/lib/models/flow/index-testing.mjs +2 -1
  19. package/esm2020/testing/lib/models/index-testing.mjs +2 -1
  20. package/fesm2015/gravitee-ui-policy-studio-angular-testing.mjs +287 -3
  21. package/fesm2015/gravitee-ui-policy-studio-angular-testing.mjs.map +1 -1
  22. package/fesm2015/gravitee-ui-policy-studio-angular.mjs +134 -57
  23. package/fesm2015/gravitee-ui-policy-studio-angular.mjs.map +1 -1
  24. package/fesm2020/gravitee-ui-policy-studio-angular-testing.mjs +345 -3
  25. package/fesm2020/gravitee-ui-policy-studio-angular-testing.mjs.map +1 -1
  26. package/fesm2020/gravitee-ui-policy-studio-angular.mjs +131 -55
  27. package/fesm2020/gravitee-ui-policy-studio-angular.mjs.map +1 -1
  28. package/lib/components/filter-pipe/gio-flter-connectors-by-mode.pipe.d.ts +8 -0
  29. package/lib/components/flow-details/gio-ps-flow-details.component.d.ts +3 -3
  30. package/lib/components/flow-details-info-bar/gio-ps-flow-details-info-bar.component.d.ts +2 -2
  31. package/lib/components/flow-details-phase/gio-ps-flow-details-phase.component.d.ts +20 -5
  32. package/lib/components/flow-details-phase-policy/gio-ps-flow-details-phase-policy.component.d.ts +4 -1
  33. package/lib/components/flow-form-dialog/flow-message-form-dialog/gio-ps-flow-message-form-dialog.component.d.ts +3 -2
  34. package/lib/components/flows-menu/gio-ps-flows-menu.component.d.ts +2 -2
  35. package/lib/gio-policy-studio.component.d.ts +3 -4
  36. package/lib/gio-policy-studio.module.d.ts +14 -12
  37. package/lib/models/ConnectorsInfo.d.ts +4 -1
  38. package/package.json +1 -1
  39. package/testing/lib/components/flow-details-phase/gio-ps-flow-details-phase.harness.d.ts +20 -0
  40. package/testing/lib/components/flow-details-phase-policy/gio-ps-flow-details-phase-policy.harness.d.ts +13 -0
  41. package/testing/lib/gio-policy-studio.harness.d.ts +29 -0
  42. package/testing/lib/models/ConnectorsInfo.d.ts +4 -1
  43. package/testing/lib/models/ConnectorsInfo.fixture.d.ts +10 -0
  44. package/testing/lib/models/flow/Step.fixture.d.ts +4 -0
  45. package/testing/lib/models/flow/index-testing.d.ts +1 -0
  46. package/testing/lib/models/index-testing.d.ts +1 -0
@@ -1,7 +1,8 @@
1
- import { isFunction } from 'lodash';
1
+ import { isFunction, isEmpty } from 'lodash';
2
2
  import { __awaiter, __asyncValues } from 'tslib';
3
- import { ComponentHarness, parallel } from '@angular/cdk/testing';
3
+ import { ComponentHarness, parallel, HarnessPredicate } from '@angular/cdk/testing';
4
4
  import { MatButtonHarness } from '@angular/material/button/testing';
5
+ import { MatTabGroupHarness } from '@angular/material/tabs/testing';
5
6
  import { DivHarness, SpanHarness } from '@gravitee/ui-particles-angular/testing';
6
7
  import { MatInputHarness } from '@angular/material/input/testing';
7
8
  import { MatSelectHarness } from '@angular/material/select/testing';
@@ -103,6 +104,66 @@ function fakeDefaultFlowExecution(modifier) {
103
104
  return Object.assign(Object.assign({}, base), modifier);
104
105
  }
105
106
 
107
+ /*
108
+ * Copyright (C) 2023 The Gravitee team (http://gravitee.io)
109
+ *
110
+ * Licensed under the Apache License, Version 2.0 (the "License");
111
+ * you may not use this file except in compliance with the License.
112
+ * You may obtain a copy of the License at
113
+ *
114
+ * http://www.apache.org/licenses/LICENSE-2.0
115
+ *
116
+ * Unless required by applicable law or agreed to in writing, software
117
+ * distributed under the License is distributed on an "AS IS" BASIS,
118
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
119
+ * See the License for the specific language governing permissions and
120
+ * limitations under the License.
121
+ */
122
+ function fakeMockPolicyStep(modifier) {
123
+ const base = {
124
+ name: 'Mock Policy',
125
+ description: 'Mock Policy description',
126
+ enabled: true,
127
+ policy: 'mock',
128
+ };
129
+ if (isFunction(modifier)) {
130
+ return modifier(base);
131
+ }
132
+ return Object.assign(Object.assign({}, base), modifier);
133
+ }
134
+ function fakeRateLimitStep(modifier) {
135
+ const base = {
136
+ name: 'Rate Limit',
137
+ description: 'Step description',
138
+ enabled: true,
139
+ policy: 'rate-limit',
140
+ configuration: {
141
+ rate: {
142
+ limit: 10,
143
+ periodTime: 1,
144
+ periodTimeUnit: 'MINUTES',
145
+ },
146
+ },
147
+ };
148
+ if (isFunction(modifier)) {
149
+ return modifier(base);
150
+ }
151
+ return Object.assign(Object.assign({}, base), modifier);
152
+ }
153
+ function fakeXmlToJsonStep(modifier) {
154
+ const base = {
155
+ name: 'XML to JSON',
156
+ description: 'XML to JSON',
157
+ enabled: true,
158
+ policy: 'xml-json',
159
+ configuration: {},
160
+ };
161
+ if (isFunction(modifier)) {
162
+ return modifier(base);
163
+ }
164
+ return Object.assign(Object.assign({}, base), modifier);
165
+ }
166
+
106
167
  /*
107
168
  * Copyright (C) 2022 The Gravitee team (http://gravitee.io)
108
169
  *
@@ -162,6 +223,130 @@ function fakePlan(modifier) {
162
223
  * limitations under the License.
163
224
  */
164
225
 
226
+ /*
227
+ * Copyright (C) 2023 The Gravitee team (http://gravitee.io)
228
+ *
229
+ * Licensed under the Apache License, Version 2.0 (the "License");
230
+ * you may not use this file except in compliance with the License.
231
+ * You may obtain a copy of the License at
232
+ *
233
+ * http://www.apache.org/licenses/LICENSE-2.0
234
+ *
235
+ * Unless required by applicable law or agreed to in writing, software
236
+ * distributed under the License is distributed on an "AS IS" BASIS,
237
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
238
+ * See the License for the specific language governing permissions and
239
+ * limitations under the License.
240
+ */
241
+ function fakeSSEMessageEntrypoint(modifier) {
242
+ const base = {
243
+ type: 'sse',
244
+ name: 'Server-Sent Events',
245
+ supportedModes: ['SUBSCRIBE'],
246
+ icon: 'gio:sse',
247
+ };
248
+ if (isFunction(modifier)) {
249
+ return modifier(base);
250
+ }
251
+ return Object.assign(Object.assign({}, base), modifier);
252
+ }
253
+ function fakeWebsocketMessageEntrypoint(modifier) {
254
+ const base = {
255
+ type: 'websocket',
256
+ name: 'Websocket',
257
+ supportedModes: ['PUBLISH', 'SUBSCRIBE'],
258
+ icon: 'gio:websocket',
259
+ };
260
+ if (isFunction(modifier)) {
261
+ return modifier(base);
262
+ }
263
+ return Object.assign(Object.assign({}, base), modifier);
264
+ }
265
+ function fakeHTTPPostMessageEntrypoint(modifier) {
266
+ const base = {
267
+ type: 'http-post',
268
+ name: 'HTTP POST',
269
+ supportedModes: ['PUBLISH'],
270
+ icon: 'gio:language',
271
+ };
272
+ if (isFunction(modifier)) {
273
+ return modifier(base);
274
+ }
275
+ return Object.assign(Object.assign({}, base), modifier);
276
+ }
277
+ function fakeHTTPGetMessageEntrypoint(modifier) {
278
+ const base = {
279
+ type: 'http-get',
280
+ name: 'HTTP Get',
281
+ supportedModes: ['SUBSCRIBE'],
282
+ icon: 'gio:language',
283
+ };
284
+ if (isFunction(modifier)) {
285
+ return modifier(base);
286
+ }
287
+ return Object.assign(Object.assign({}, base), modifier);
288
+ }
289
+ function fakeWebhookMessageEntrypoint(modifier) {
290
+ const base = {
291
+ type: 'webhook',
292
+ name: 'Webhook',
293
+ supportedModes: ['SUBSCRIBE'],
294
+ icon: 'gio:webhook',
295
+ };
296
+ if (isFunction(modifier)) {
297
+ return modifier(base);
298
+ }
299
+ return Object.assign(Object.assign({}, base), modifier);
300
+ }
301
+ function fakeHTTPProxyEntrypoint(modifier) {
302
+ const base = {
303
+ type: 'http-proxy',
304
+ name: 'HTTP Proxy',
305
+ supportedModes: ['REQUEST_RESPONSE'],
306
+ icon: 'gio:language',
307
+ };
308
+ if (isFunction(modifier)) {
309
+ return modifier(base);
310
+ }
311
+ return Object.assign(Object.assign({}, base), modifier);
312
+ }
313
+ function fakeMockMessageEndpoint(modifier) {
314
+ const base = {
315
+ type: 'mock',
316
+ name: 'Mock',
317
+ supportedModes: ['PUBLISH', 'SUBSCRIBE'],
318
+ icon: 'gio:language',
319
+ };
320
+ if (isFunction(modifier)) {
321
+ return modifier(base);
322
+ }
323
+ return Object.assign(Object.assign({}, base), modifier);
324
+ }
325
+ function fakeKafkaMessageEndpoint(modifier) {
326
+ const base = {
327
+ type: 'kafka',
328
+ name: 'Kafka',
329
+ supportedModes: ['PUBLISH', 'SUBSCRIBE'],
330
+ icon: 'gio:kafka',
331
+ };
332
+ if (isFunction(modifier)) {
333
+ return modifier(base);
334
+ }
335
+ return Object.assign(Object.assign({}, base), modifier);
336
+ }
337
+ function fakeHTTPProxyEndpoint(modifier) {
338
+ const base = {
339
+ type: 'http-proxy',
340
+ name: 'HTTP Proxy',
341
+ supportedModes: ['REQUEST_RESPONSE'],
342
+ icon: 'gio:language',
343
+ };
344
+ if (isFunction(modifier)) {
345
+ return modifier(base);
346
+ }
347
+ return Object.assign(Object.assign({}, base), modifier);
348
+ }
349
+
165
350
  /*
166
351
  * Copyright (C) 2022 The Gravitee team (http://gravitee.io)
167
352
  *
@@ -582,11 +767,77 @@ class GioPolicyStudioFlowExecutionFormDialogHarness extends ComponentHarness {
582
767
  }
583
768
  GioPolicyStudioFlowExecutionFormDialogHarness.hostSelector = 'gio-ps-flow-execution-form-dialog';
584
769
 
770
+ class GioPolicyStudioDetailsPhasePolicyHarness extends ComponentHarness {
771
+ /**
772
+ * Get Harness with the given filter.
773
+ *
774
+ * @param options Options for filtering which input instances are considered a match.
775
+ * @return a `HarnessPredicate` configured with the given options.
776
+ */
777
+ static with(options = {}) {
778
+ return new HarnessPredicate(GioPolicyStudioDetailsPhasePolicyHarness, options);
779
+ }
780
+ getName() {
781
+ var _a;
782
+ return __awaiter(this, void 0, void 0, function* () {
783
+ return (_a = (yield (yield this.locatorFor(SpanHarness.with({ selector: '.info__primary__name' }))()).getText())) !== null && _a !== void 0 ? _a : '';
784
+ });
785
+ }
786
+ }
787
+ GioPolicyStudioDetailsPhasePolicyHarness.hostSelector = 'gio-ps-flow-details-phase-policy';
788
+
789
+ const TYPE_TO_TEXT = {
790
+ REQUEST: 'Request phase',
791
+ RESPONSE: 'Response phase',
792
+ PUBLISH: 'Publish phase',
793
+ SUBSCRIBE: 'Subscribe phase',
794
+ };
795
+ class GioPolicyStudioDetailsPhaseHarness extends ComponentHarness {
796
+ constructor() {
797
+ super(...arguments);
798
+ this.getHeaderName = () => this.locatorForOptional(SpanHarness.with({ selector: '.header__name' }))().then((span) => __awaiter(this, void 0, void 0, function* () { var _a; return (_a = span === null || span === void 0 ? void 0 : span.getText()) !== null && _a !== void 0 ? _a : null; }));
799
+ }
800
+ /**
801
+ * Get Harness with the given filter.
802
+ *
803
+ * @param options Options for filtering which input instances are considered a match.
804
+ * @return a `HarnessPredicate` configured with the given options.
805
+ */
806
+ static with(options = {}) {
807
+ return new HarnessPredicate(GioPolicyStudioDetailsPhaseHarness, options).addOption('type', options.type, (harness, type) => __awaiter(this, void 0, void 0, function* () { return HarnessPredicate.stringMatches(harness.getHeaderName(), TYPE_TO_TEXT[type]); }));
808
+ }
809
+ getSteps() {
810
+ return __awaiter(this, void 0, void 0, function* () {
811
+ const stepsDiv = yield this.locatorForAll(DivHarness.with({ selector: '.content__step' }))();
812
+ if (isEmpty(stepsDiv)) {
813
+ // No step - the phase is disabled
814
+ return null;
815
+ }
816
+ return yield parallel(() => stepsDiv.map((stepDiv) => __awaiter(this, void 0, void 0, function* () {
817
+ var _a;
818
+ const idConnector = !!(yield stepDiv.getText({ childSelector: '.content__step__connectorBadge' }));
819
+ if (idConnector) {
820
+ return {
821
+ text: (_a = (yield stepDiv.getText())) !== null && _a !== void 0 ? _a : '',
822
+ type: 'connector',
823
+ };
824
+ }
825
+ return {
826
+ text: yield (yield stepDiv.childLocatorFor(GioPolicyStudioDetailsPhasePolicyHarness)()).getName(),
827
+ type: idConnector ? 'connector' : 'policy',
828
+ };
829
+ })));
830
+ });
831
+ }
832
+ }
833
+ GioPolicyStudioDetailsPhaseHarness.hostSelector = 'gio-ps-flow-details-phase';
834
+
585
835
  class GioPolicyStudioHarness extends ComponentHarness {
586
836
  constructor() {
587
837
  super(...arguments);
588
838
  this.menuHarness = this.locatorFor(GioPolicyStudioFlowsMenuHarness);
589
839
  this.detailsHarness = this.locatorFor(GioPolicyStudioDetailsHarness);
840
+ this.phaseHarness = (phaseType) => this.locatorFor(GioPolicyStudioDetailsPhaseHarness.with({ type: phaseType }))();
590
841
  }
591
842
  /**
592
843
  * Add a flow to a plan or to "Common flows"
@@ -613,27 +864,60 @@ class GioPolicyStudioHarness extends ComponentHarness {
613
864
  yield this.setFlowFormDialog(flow);
614
865
  });
615
866
  }
867
+ /**
868
+ * Delete a flow
869
+ *
870
+ * @param flowName Flow name to delete
871
+ */
616
872
  deleteFlow(flowName) {
617
873
  return __awaiter(this, void 0, void 0, function* () {
618
874
  (yield this.menuHarness()).selectFlow(new RegExp(flowName, 'i'));
619
875
  yield (yield this.detailsHarness()).clickDeleteFlowBtn();
620
876
  });
621
877
  }
878
+ /**
879
+ * Select a flow in the menu
880
+ *
881
+ * @param flowName Flow name to select
882
+ */
622
883
  selectFlowInMenu(flowName) {
623
884
  return __awaiter(this, void 0, void 0, function* () {
624
885
  yield (yield this.menuHarness()).selectFlow(new RegExp(flowName, 'i'));
625
886
  });
626
887
  }
888
+ /**
889
+ * Get the list of flows in the menu
890
+ */
627
891
  getFlowsMenu() {
628
892
  return __awaiter(this, void 0, void 0, function* () {
629
893
  return (yield this.menuHarness()).getAllFlowsGroups();
630
894
  });
631
895
  }
896
+ /**
897
+ * Get selected flow infos
898
+ */
632
899
  getSelectedFlowInfos() {
633
900
  return __awaiter(this, void 0, void 0, function* () {
634
901
  return yield (yield this.detailsHarness()).getFlowInfos();
635
902
  });
636
903
  }
904
+ /**
905
+ * Get selected flow steps phase
906
+ * @param tabLabel Select tabs before try to find phase. Useful to find Event phases for Message API
907
+ */
908
+ getSelectedFlowSteps(phaseType, tabLabel) {
909
+ return __awaiter(this, void 0, void 0, function* () {
910
+ if (tabLabel) {
911
+ const matTabsHarness = yield this.locatorFor(MatTabGroupHarness.with({ selector: '.content__tabs' }))();
912
+ yield matTabsHarness.selectTab({ label: tabLabel });
913
+ }
914
+ const steps = yield (yield this.phaseHarness(phaseType)).getSteps();
915
+ return steps ? steps : 'DISABLED';
916
+ });
917
+ }
918
+ /**
919
+ * Click on the "Save" button
920
+ */
637
921
  save() {
638
922
  return __awaiter(this, void 0, void 0, function* () {
639
923
  yield (yield this.locatorFor(MatButtonHarness.with({ text: /Save/ }))()).click();
@@ -711,5 +995,5 @@ GioPolicyStudioHarness.hostSelector = 'gio-policy-studio';
711
995
  * Generated bundle index. Do not edit.
712
996
  */
713
997
 
714
- export { GioPolicyStudioHarness, fakeBestMatchFlowExecution, fakeChannelFlow, fakeDefaultFlowExecution, fakeHttpFlow, fakePlan };
998
+ export { GioPolicyStudioHarness, fakeBestMatchFlowExecution, fakeChannelFlow, fakeDefaultFlowExecution, fakeHTTPGetMessageEntrypoint, fakeHTTPPostMessageEntrypoint, fakeHTTPProxyEndpoint, fakeHTTPProxyEntrypoint, fakeHttpFlow, fakeKafkaMessageEndpoint, fakeMockMessageEndpoint, fakeMockPolicyStep, fakePlan, fakeRateLimitStep, fakeSSEMessageEntrypoint, fakeWebhookMessageEntrypoint, fakeWebsocketMessageEntrypoint, fakeXmlToJsonStep };
715
999
  //# sourceMappingURL=gravitee-ui-policy-studio-angular-testing.mjs.map