@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,6 +1,7 @@
1
- import { isFunction } from 'lodash';
2
- import { ComponentHarness, parallel } from '@angular/cdk/testing';
1
+ import { isFunction, isEmpty } from 'lodash';
2
+ import { ComponentHarness, parallel, HarnessPredicate } from '@angular/cdk/testing';
3
3
  import { MatButtonHarness } from '@angular/material/button/testing';
4
+ import { MatTabGroupHarness } from '@angular/material/tabs/testing';
4
5
  import { DivHarness, SpanHarness } from '@gravitee/ui-particles-angular/testing';
5
6
  import { MatInputHarness } from '@angular/material/input/testing';
6
7
  import { MatSelectHarness } from '@angular/material/select/testing';
@@ -114,6 +115,75 @@ function fakeDefaultFlowExecution(modifier) {
114
115
  };
115
116
  }
116
117
 
118
+ /*
119
+ * Copyright (C) 2023 The Gravitee team (http://gravitee.io)
120
+ *
121
+ * Licensed under the Apache License, Version 2.0 (the "License");
122
+ * you may not use this file except in compliance with the License.
123
+ * You may obtain a copy of the License at
124
+ *
125
+ * http://www.apache.org/licenses/LICENSE-2.0
126
+ *
127
+ * Unless required by applicable law or agreed to in writing, software
128
+ * distributed under the License is distributed on an "AS IS" BASIS,
129
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
130
+ * See the License for the specific language governing permissions and
131
+ * limitations under the License.
132
+ */
133
+ function fakeMockPolicyStep(modifier) {
134
+ const base = {
135
+ name: 'Mock Policy',
136
+ description: 'Mock Policy description',
137
+ enabled: true,
138
+ policy: 'mock',
139
+ };
140
+ if (isFunction(modifier)) {
141
+ return modifier(base);
142
+ }
143
+ return {
144
+ ...base,
145
+ ...modifier,
146
+ };
147
+ }
148
+ function fakeRateLimitStep(modifier) {
149
+ const base = {
150
+ name: 'Rate Limit',
151
+ description: 'Step description',
152
+ enabled: true,
153
+ policy: 'rate-limit',
154
+ configuration: {
155
+ rate: {
156
+ limit: 10,
157
+ periodTime: 1,
158
+ periodTimeUnit: 'MINUTES',
159
+ },
160
+ },
161
+ };
162
+ if (isFunction(modifier)) {
163
+ return modifier(base);
164
+ }
165
+ return {
166
+ ...base,
167
+ ...modifier,
168
+ };
169
+ }
170
+ function fakeXmlToJsonStep(modifier) {
171
+ const base = {
172
+ name: 'XML to JSON',
173
+ description: 'XML to JSON',
174
+ enabled: true,
175
+ policy: 'xml-json',
176
+ configuration: {},
177
+ };
178
+ if (isFunction(modifier)) {
179
+ return modifier(base);
180
+ }
181
+ return {
182
+ ...base,
183
+ ...modifier,
184
+ };
185
+ }
186
+
117
187
  /*
118
188
  * Copyright (C) 2022 The Gravitee team (http://gravitee.io)
119
189
  *
@@ -176,6 +246,157 @@ function fakePlan(modifier) {
176
246
  * limitations under the License.
177
247
  */
178
248
 
249
+ /*
250
+ * Copyright (C) 2023 The Gravitee team (http://gravitee.io)
251
+ *
252
+ * Licensed under the Apache License, Version 2.0 (the "License");
253
+ * you may not use this file except in compliance with the License.
254
+ * You may obtain a copy of the License at
255
+ *
256
+ * http://www.apache.org/licenses/LICENSE-2.0
257
+ *
258
+ * Unless required by applicable law or agreed to in writing, software
259
+ * distributed under the License is distributed on an "AS IS" BASIS,
260
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
261
+ * See the License for the specific language governing permissions and
262
+ * limitations under the License.
263
+ */
264
+ function fakeSSEMessageEntrypoint(modifier) {
265
+ const base = {
266
+ type: 'sse',
267
+ name: 'Server-Sent Events',
268
+ supportedModes: ['SUBSCRIBE'],
269
+ icon: 'gio:sse',
270
+ };
271
+ if (isFunction(modifier)) {
272
+ return modifier(base);
273
+ }
274
+ return {
275
+ ...base,
276
+ ...modifier,
277
+ };
278
+ }
279
+ function fakeWebsocketMessageEntrypoint(modifier) {
280
+ const base = {
281
+ type: 'websocket',
282
+ name: 'Websocket',
283
+ supportedModes: ['PUBLISH', 'SUBSCRIBE'],
284
+ icon: 'gio:websocket',
285
+ };
286
+ if (isFunction(modifier)) {
287
+ return modifier(base);
288
+ }
289
+ return {
290
+ ...base,
291
+ ...modifier,
292
+ };
293
+ }
294
+ function fakeHTTPPostMessageEntrypoint(modifier) {
295
+ const base = {
296
+ type: 'http-post',
297
+ name: 'HTTP POST',
298
+ supportedModes: ['PUBLISH'],
299
+ icon: 'gio:language',
300
+ };
301
+ if (isFunction(modifier)) {
302
+ return modifier(base);
303
+ }
304
+ return {
305
+ ...base,
306
+ ...modifier,
307
+ };
308
+ }
309
+ function fakeHTTPGetMessageEntrypoint(modifier) {
310
+ const base = {
311
+ type: 'http-get',
312
+ name: 'HTTP Get',
313
+ supportedModes: ['SUBSCRIBE'],
314
+ icon: 'gio:language',
315
+ };
316
+ if (isFunction(modifier)) {
317
+ return modifier(base);
318
+ }
319
+ return {
320
+ ...base,
321
+ ...modifier,
322
+ };
323
+ }
324
+ function fakeWebhookMessageEntrypoint(modifier) {
325
+ const base = {
326
+ type: 'webhook',
327
+ name: 'Webhook',
328
+ supportedModes: ['SUBSCRIBE'],
329
+ icon: 'gio:webhook',
330
+ };
331
+ if (isFunction(modifier)) {
332
+ return modifier(base);
333
+ }
334
+ return {
335
+ ...base,
336
+ ...modifier,
337
+ };
338
+ }
339
+ function fakeHTTPProxyEntrypoint(modifier) {
340
+ const base = {
341
+ type: 'http-proxy',
342
+ name: 'HTTP Proxy',
343
+ supportedModes: ['REQUEST_RESPONSE'],
344
+ icon: 'gio:language',
345
+ };
346
+ if (isFunction(modifier)) {
347
+ return modifier(base);
348
+ }
349
+ return {
350
+ ...base,
351
+ ...modifier,
352
+ };
353
+ }
354
+ function fakeMockMessageEndpoint(modifier) {
355
+ const base = {
356
+ type: 'mock',
357
+ name: 'Mock',
358
+ supportedModes: ['PUBLISH', 'SUBSCRIBE'],
359
+ icon: 'gio:language',
360
+ };
361
+ if (isFunction(modifier)) {
362
+ return modifier(base);
363
+ }
364
+ return {
365
+ ...base,
366
+ ...modifier,
367
+ };
368
+ }
369
+ function fakeKafkaMessageEndpoint(modifier) {
370
+ const base = {
371
+ type: 'kafka',
372
+ name: 'Kafka',
373
+ supportedModes: ['PUBLISH', 'SUBSCRIBE'],
374
+ icon: 'gio:kafka',
375
+ };
376
+ if (isFunction(modifier)) {
377
+ return modifier(base);
378
+ }
379
+ return {
380
+ ...base,
381
+ ...modifier,
382
+ };
383
+ }
384
+ function fakeHTTPProxyEndpoint(modifier) {
385
+ const base = {
386
+ type: 'http-proxy',
387
+ name: 'HTTP Proxy',
388
+ supportedModes: ['REQUEST_RESPONSE'],
389
+ icon: 'gio:language',
390
+ };
391
+ if (isFunction(modifier)) {
392
+ return modifier(base);
393
+ }
394
+ return {
395
+ ...base,
396
+ ...modifier,
397
+ };
398
+ }
399
+
179
400
  /*
180
401
  * Copyright (C) 2022 The Gravitee team (http://gravitee.io)
181
402
  *
@@ -602,6 +823,95 @@ class GioPolicyStudioFlowExecutionFormDialogHarness extends ComponentHarness {
602
823
  }
603
824
  GioPolicyStudioFlowExecutionFormDialogHarness.hostSelector = 'gio-ps-flow-execution-form-dialog';
604
825
 
826
+ /*
827
+ * Copyright (C) 2022 The Gravitee team (http://gravitee.io)
828
+ *
829
+ * Licensed under the Apache License, Version 2.0 (the "License");
830
+ * you may not use this file except in compliance with the License.
831
+ * You may obtain a copy of the License at
832
+ *
833
+ * http://www.apache.org/licenses/LICENSE-2.0
834
+ *
835
+ * Unless required by applicable law or agreed to in writing, software
836
+ * distributed under the License is distributed on an "AS IS" BASIS,
837
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
838
+ * See the License for the specific language governing permissions and
839
+ * limitations under the License.
840
+ */
841
+ class GioPolicyStudioDetailsPhasePolicyHarness extends ComponentHarness {
842
+ /**
843
+ * Get Harness with the given filter.
844
+ *
845
+ * @param options Options for filtering which input instances are considered a match.
846
+ * @return a `HarnessPredicate` configured with the given options.
847
+ */
848
+ static with(options = {}) {
849
+ return new HarnessPredicate(GioPolicyStudioDetailsPhasePolicyHarness, options);
850
+ }
851
+ async getName() {
852
+ return (await (await this.locatorFor(SpanHarness.with({ selector: '.info__primary__name' }))()).getText()) ?? '';
853
+ }
854
+ }
855
+ GioPolicyStudioDetailsPhasePolicyHarness.hostSelector = 'gio-ps-flow-details-phase-policy';
856
+
857
+ /*
858
+ * Copyright (C) 2022 The Gravitee team (http://gravitee.io)
859
+ *
860
+ * Licensed under the Apache License, Version 2.0 (the "License");
861
+ * you may not use this file except in compliance with the License.
862
+ * You may obtain a copy of the License at
863
+ *
864
+ * http://www.apache.org/licenses/LICENSE-2.0
865
+ *
866
+ * Unless required by applicable law or agreed to in writing, software
867
+ * distributed under the License is distributed on an "AS IS" BASIS,
868
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
869
+ * See the License for the specific language governing permissions and
870
+ * limitations under the License.
871
+ */
872
+ const TYPE_TO_TEXT = {
873
+ REQUEST: 'Request phase',
874
+ RESPONSE: 'Response phase',
875
+ PUBLISH: 'Publish phase',
876
+ SUBSCRIBE: 'Subscribe phase',
877
+ };
878
+ class GioPolicyStudioDetailsPhaseHarness extends ComponentHarness {
879
+ constructor() {
880
+ super(...arguments);
881
+ this.getHeaderName = () => this.locatorForOptional(SpanHarness.with({ selector: '.header__name' }))().then(async (span) => span?.getText() ?? null);
882
+ }
883
+ /**
884
+ * Get Harness with the given filter.
885
+ *
886
+ * @param options Options for filtering which input instances are considered a match.
887
+ * @return a `HarnessPredicate` configured with the given options.
888
+ */
889
+ static with(options = {}) {
890
+ return new HarnessPredicate(GioPolicyStudioDetailsPhaseHarness, options).addOption('type', options.type, async (harness, type) => HarnessPredicate.stringMatches(harness.getHeaderName(), TYPE_TO_TEXT[type]));
891
+ }
892
+ async getSteps() {
893
+ const stepsDiv = await this.locatorForAll(DivHarness.with({ selector: '.content__step' }))();
894
+ if (isEmpty(stepsDiv)) {
895
+ // No step - the phase is disabled
896
+ return null;
897
+ }
898
+ return await parallel(() => stepsDiv.map(async (stepDiv) => {
899
+ const idConnector = !!(await stepDiv.getText({ childSelector: '.content__step__connectorBadge' }));
900
+ if (idConnector) {
901
+ return {
902
+ text: (await stepDiv.getText()) ?? '',
903
+ type: 'connector',
904
+ };
905
+ }
906
+ return {
907
+ text: await (await stepDiv.childLocatorFor(GioPolicyStudioDetailsPhasePolicyHarness)()).getName(),
908
+ type: idConnector ? 'connector' : 'policy',
909
+ };
910
+ }));
911
+ }
912
+ }
913
+ GioPolicyStudioDetailsPhaseHarness.hostSelector = 'gio-ps-flow-details-phase';
914
+
605
915
  /*
606
916
  * Copyright (C) 2022 The Gravitee team (http://gravitee.io)
607
917
  *
@@ -622,6 +932,7 @@ class GioPolicyStudioHarness extends ComponentHarness {
622
932
  super(...arguments);
623
933
  this.menuHarness = this.locatorFor(GioPolicyStudioFlowsMenuHarness);
624
934
  this.detailsHarness = this.locatorFor(GioPolicyStudioDetailsHarness);
935
+ this.phaseHarness = (phaseType) => this.locatorFor(GioPolicyStudioDetailsPhaseHarness.with({ type: phaseType }))();
625
936
  }
626
937
  /**
627
938
  * Add a flow to a plan or to "Common flows"
@@ -644,19 +955,50 @@ class GioPolicyStudioHarness extends ComponentHarness {
644
955
  await (await this.detailsHarness()).clickEditFlowBtn();
645
956
  await this.setFlowFormDialog(flow);
646
957
  }
958
+ /**
959
+ * Delete a flow
960
+ *
961
+ * @param flowName Flow name to delete
962
+ */
647
963
  async deleteFlow(flowName) {
648
964
  (await this.menuHarness()).selectFlow(new RegExp(flowName, 'i'));
649
965
  await (await this.detailsHarness()).clickDeleteFlowBtn();
650
966
  }
967
+ /**
968
+ * Select a flow in the menu
969
+ *
970
+ * @param flowName Flow name to select
971
+ */
651
972
  async selectFlowInMenu(flowName) {
652
973
  await (await this.menuHarness()).selectFlow(new RegExp(flowName, 'i'));
653
974
  }
975
+ /**
976
+ * Get the list of flows in the menu
977
+ */
654
978
  async getFlowsMenu() {
655
979
  return (await this.menuHarness()).getAllFlowsGroups();
656
980
  }
981
+ /**
982
+ * Get selected flow infos
983
+ */
657
984
  async getSelectedFlowInfos() {
658
985
  return await (await this.detailsHarness()).getFlowInfos();
659
986
  }
987
+ /**
988
+ * Get selected flow steps phase
989
+ * @param tabLabel Select tabs before try to find phase. Useful to find Event phases for Message API
990
+ */
991
+ async getSelectedFlowSteps(phaseType, tabLabel) {
992
+ if (tabLabel) {
993
+ const matTabsHarness = await this.locatorFor(MatTabGroupHarness.with({ selector: '.content__tabs' }))();
994
+ await matTabsHarness.selectTab({ label: tabLabel });
995
+ }
996
+ const steps = await (await this.phaseHarness(phaseType)).getSteps();
997
+ return steps ? steps : 'DISABLED';
998
+ }
999
+ /**
1000
+ * Click on the "Save" button
1001
+ */
660
1002
  async save() {
661
1003
  await (await this.locatorFor(MatButtonHarness.with({ text: /Save/ }))()).click();
662
1004
  }
@@ -727,5 +1069,5 @@ GioPolicyStudioHarness.hostSelector = 'gio-policy-studio';
727
1069
  * Generated bundle index. Do not edit.
728
1070
  */
729
1071
 
730
- export { GioPolicyStudioHarness, fakeBestMatchFlowExecution, fakeChannelFlow, fakeDefaultFlowExecution, fakeHttpFlow, fakePlan };
1072
+ export { GioPolicyStudioHarness, fakeBestMatchFlowExecution, fakeChannelFlow, fakeDefaultFlowExecution, fakeHTTPGetMessageEntrypoint, fakeHTTPPostMessageEntrypoint, fakeHTTPProxyEndpoint, fakeHTTPProxyEntrypoint, fakeHttpFlow, fakeKafkaMessageEndpoint, fakeMockMessageEndpoint, fakeMockPolicyStep, fakePlan, fakeRateLimitStep, fakeSSEMessageEntrypoint, fakeWebhookMessageEntrypoint, fakeWebsocketMessageEntrypoint, fakeXmlToJsonStep };
731
1073
  //# sourceMappingURL=gravitee-ui-policy-studio-angular-testing.mjs.map