@kumori/aurora-backend-handler 1.0.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.
@@ -0,0 +1,792 @@
1
+ import {
2
+ acceptInvite,
3
+ createTenant,
4
+ rejectInvite,
5
+ } from "../api/tenant-api-service";
6
+ import { loadUser } from "../api/user-api-service";
7
+ import { createAccount } from "../api/account-api-service";
8
+ import { createEnvironment } from "../api/environment-api-service";
9
+ import { changeRevision, deployService, requestRevisionData, updateService } from "../api/service-api-service";
10
+ import {
11
+ deployMarketplaceItem,
12
+ getMarketplaceItems,
13
+ } from "../api/marketplace-api-service";
14
+ import { BackendHandler } from "../backend-handler";
15
+ import { Account, Tenant, UserData, Environment, Service, MarketplaceService } from "@hestekumori/aurora-interfaces";
16
+
17
+ jest.mock("../event-helper", () => {
18
+ return jest.fn().mockImplementation((globalEventHandler) => {
19
+ return globalEventHandler;
20
+ });
21
+ });
22
+
23
+ jest.mock("../api/tenant-api-service", () => ({ createTenant: jest.fn() }));
24
+ jest.mock("../api/user-api-service", () => ({ loadUser: jest.fn() }));
25
+ jest.mock("../api/account-api-service", () => ({ createAccount: jest.fn() }));
26
+ jest.mock("../api/environment-api-service", () => ({
27
+ createEnvironment: jest.fn(),
28
+ }));
29
+ jest.mock("../api/service-api-service", () => ({ deployService: jest.fn() }));
30
+ jest.mock("../api/marketplace-api-service", () => ({
31
+ deployMarketplaceItem: jest.fn(),
32
+ getMarketplaceItems: jest.fn(() =>
33
+ Promise.resolve({ items: ["item1", "item2"] })
34
+ ),
35
+ }));
36
+
37
+ const createDummyGlobalEventHandler = () => ({
38
+ subscribe: jest.fn(),
39
+ publish: jest.fn(),
40
+ unsubscribe: jest.fn(),
41
+ tenant: {
42
+ subscribe: {
43
+ creation: jest.fn(),
44
+ created: jest.fn(),
45
+ creationError: jest.fn(),
46
+ update: jest.fn(),
47
+ updated: jest.fn(),
48
+ updateError: jest.fn(),
49
+ delete: jest.fn(),
50
+ deleted: jest.fn(),
51
+ deletionError: jest.fn(),
52
+ createRegistry: jest.fn(),
53
+ registryCreated: jest.fn(),
54
+ registryCreationError: jest.fn(),
55
+ updateRegistry: jest.fn(),
56
+ registryUpdated: jest.fn(),
57
+ registryUpdateError: jest.fn(),
58
+ deleteRegistry: jest.fn(),
59
+ registryDeleted: jest.fn(),
60
+ registryDeletionError: jest.fn(),
61
+ inviteUser: jest.fn(),
62
+ userInvited: jest.fn(),
63
+ inviteError: jest.fn(),
64
+ removeUser: jest.fn(),
65
+ userRemoved: jest.fn(),
66
+ removeUserError: jest.fn(),
67
+ acceptInvite: jest.fn(),
68
+ inviteAccepted: jest.fn(),
69
+ acceptInviteError: jest.fn(),
70
+ updateInvite: jest.fn(),
71
+ inviteUpdated: jest.fn(),
72
+ inviteUpdateError: jest.fn(),
73
+ rejectInvite: jest.fn(),
74
+ inviteRejected: jest.fn(),
75
+ inviteRejectError: jest.fn(),
76
+ },
77
+ unsubscribe: {
78
+ creation: jest.fn(),
79
+ created: jest.fn(),
80
+ creationError: jest.fn(),
81
+ update: jest.fn(),
82
+ updated: jest.fn(),
83
+ updateError: jest.fn(),
84
+ delete: jest.fn(),
85
+ deleted: jest.fn(),
86
+ deletionError: jest.fn(),
87
+ createRegistry: jest.fn(),
88
+ registryCreated: jest.fn(),
89
+ registryCreationError: jest.fn(),
90
+ updateRegistry: jest.fn(),
91
+ registryUpdated: jest.fn(),
92
+ registryUpdateError: jest.fn(),
93
+ deleteRegistry: jest.fn(),
94
+ registryDeleted: jest.fn(),
95
+ registryDeletionError: jest.fn(),
96
+ inviteUser: jest.fn(),
97
+ userInvited: jest.fn(),
98
+ inviteError: jest.fn(),
99
+ removeUser: jest.fn(),
100
+ userRemoved: jest.fn(),
101
+ removeUserError: jest.fn(),
102
+ acceptInvite: jest.fn(),
103
+ inviteAccepted: jest.fn(),
104
+ acceptInviteError: jest.fn(),
105
+ updateInvite: jest.fn(),
106
+ inviteUpdated: jest.fn(),
107
+ inviteUpdateError: jest.fn(),
108
+ rejectInvite: jest.fn(),
109
+ inviteRejected: jest.fn(),
110
+ inviteRejectError: jest.fn(),
111
+ },
112
+ },
113
+ user: {
114
+ subscribe: {
115
+ creation: jest.fn(),
116
+ created: jest.fn(),
117
+ creationError: jest.fn(),
118
+ update: jest.fn(),
119
+ updated: jest.fn(),
120
+ updateError: jest.fn(),
121
+ load: jest.fn(),
122
+ loaded: jest.fn(),
123
+ loadError: jest.fn(),
124
+ delete: jest.fn(),
125
+ deleted: jest.fn(),
126
+ deletionError: jest.fn(),
127
+ },
128
+ unsubscribe: {
129
+ creation: jest.fn(),
130
+ created: jest.fn(),
131
+ creationError: jest.fn(),
132
+ update: jest.fn(),
133
+ updated: jest.fn(),
134
+ updateError: jest.fn(),
135
+ load: jest.fn(),
136
+ loaded: jest.fn(),
137
+ loadError: jest.fn(),
138
+ delete: jest.fn(),
139
+ deleted: jest.fn(),
140
+ deletionError: jest.fn(),
141
+ },
142
+ },
143
+ account: {
144
+ subscribe: {
145
+ creation: jest.fn(),
146
+ created: jest.fn(),
147
+ creationError: jest.fn(),
148
+ update: jest.fn(),
149
+ updated: jest.fn(),
150
+ updateError: jest.fn(),
151
+ delete: jest.fn(),
152
+ deleted: jest.fn(),
153
+ deletionError: jest.fn(),
154
+ clean: jest.fn(),
155
+ cleaned: jest.fn(),
156
+ cleanError: jest.fn(),
157
+ },
158
+ unsubscribe: {
159
+ creation: jest.fn(),
160
+ created: jest.fn(),
161
+ creationError: jest.fn(),
162
+ update: jest.fn(),
163
+ updated: jest.fn(),
164
+ updateError: jest.fn(),
165
+ delete: jest.fn(),
166
+ deleted: jest.fn(),
167
+ deletionError: jest.fn(),
168
+ clean: jest.fn(),
169
+ cleaned: jest.fn(),
170
+ cleanError: jest.fn(),
171
+ },
172
+ },
173
+ environment: {
174
+ subscribe: {
175
+ creation: jest.fn(),
176
+ created: jest.fn(),
177
+ creationError: jest.fn(),
178
+ update: jest.fn(),
179
+ updated: jest.fn(),
180
+ updateError: jest.fn(),
181
+ delete: jest.fn(),
182
+ deleted: jest.fn(),
183
+ deletionError: jest.fn(),
184
+ clean: jest.fn(),
185
+ cleaned: jest.fn(),
186
+ cleanError: jest.fn(),
187
+ scale: jest.fn(),
188
+ scaled: jest.fn(),
189
+ scaleError: jest.fn()
190
+ },
191
+ unsubscribe: {
192
+ creation: jest.fn(),
193
+ created: jest.fn(),
194
+ creationError: jest.fn(),
195
+ update: jest.fn(),
196
+ updated: jest.fn(),
197
+ updateError: jest.fn(),
198
+ delete: jest.fn(),
199
+ deleted: jest.fn(),
200
+ deletionError: jest.fn(),
201
+ clean: jest.fn(),
202
+ cleaned: jest.fn(),
203
+ cleanError: jest.fn(),
204
+ scale: jest.fn(),
205
+ scaled: jest.fn(),
206
+ scaleError: jest.fn()
207
+ },
208
+ },
209
+ service: {
210
+ subscribe: {
211
+ deploy: jest.fn(),
212
+ deployed: jest.fn(),
213
+ deploymentError: jest.fn(),
214
+ update: jest.fn(),
215
+ updated: jest.fn(),
216
+ updateError: jest.fn(),
217
+ delete: jest.fn(),
218
+ deleted: jest.fn(),
219
+ deletionError: jest.fn(),
220
+ requestLogs: jest.fn(),
221
+ restart: jest.fn(),
222
+ requestRevisionData: jest.fn(),
223
+ updateServiceLinks: jest.fn(),
224
+ changeRevision: jest.fn(),
225
+ revisionChanged : jest.fn(),
226
+ revisionChangeError: jest.fn(),
227
+ },
228
+ unsubscribe: {
229
+ deploy: jest.fn(),
230
+ deployed: jest.fn(),
231
+ deploymentError: jest.fn(),
232
+ update: jest.fn(),
233
+ updated: jest.fn(),
234
+ updateError: jest.fn(),
235
+ delete: jest.fn(),
236
+ deleted: jest.fn(),
237
+ deletionError: jest.fn(),
238
+ requestLogs: jest.fn(),
239
+ requestRevisionData: jest.fn(),
240
+ updateServiceLinks: jest.fn(),
241
+ changeRevision: jest.fn(),
242
+ revisionChanged : jest.fn(),
243
+ revisionChangeError: jest.fn(),
244
+ },
245
+ },
246
+ marketplace: {
247
+ subscribe: {
248
+ deployItem: jest.fn(),
249
+ itemDeployed: jest.fn(),
250
+ deploymentError: jest.fn(),
251
+ updateItem: jest.fn(),
252
+ itemUpdated: jest.fn(),
253
+ updateError: jest.fn(),
254
+ deleteItem: jest.fn(),
255
+ itemDeleted: jest.fn(),
256
+ deletionError: jest.fn(),
257
+ loadItems: jest.fn(),
258
+ },
259
+ unsubscribe: {
260
+ deployItem: jest.fn(),
261
+ itemDeployed: jest.fn(),
262
+ deploymentError: jest.fn(),
263
+ updateItem: jest.fn(),
264
+ itemUpdated: jest.fn(),
265
+ updateError: jest.fn(),
266
+ deleteItem: jest.fn(),
267
+ itemDeleted: jest.fn(),
268
+ deletionError: jest.fn(),
269
+ loadItems: jest.fn(),
270
+ },
271
+ },
272
+ resource: {
273
+ subscribe: {
274
+ creation: jest.fn(),
275
+ created: jest.fn(),
276
+ creationError: jest.fn(),
277
+ update: jest.fn(),
278
+ updated: jest.fn(),
279
+ updateError: jest.fn(),
280
+ delete: jest.fn(),
281
+ deleted: jest.fn(),
282
+ deletionError: jest.fn(),
283
+ },
284
+ unsubscribe: {
285
+ creation: jest.fn(),
286
+ created: jest.fn(),
287
+ creationError: jest.fn(),
288
+ update: jest.fn(),
289
+ updated: jest.fn(),
290
+ updateError: jest.fn(),
291
+ delete: jest.fn(),
292
+ deleted: jest.fn(),
293
+ deletionError: jest.fn(),
294
+ },
295
+ },
296
+ plan: {
297
+ subscribe: {
298
+ upgrade: jest.fn(),
299
+ upgraded: jest.fn(),
300
+ upgradeError: jest.fn(),
301
+ downgrade: jest.fn(),
302
+ downgraded: jest.fn(),
303
+ downgradeError: jest.fn(),
304
+ },
305
+ unsubscribe: {
306
+ upgrade: jest.fn(),
307
+ upgraded: jest.fn(),
308
+ upgradeError: jest.fn(),
309
+ downgrade: jest.fn(),
310
+ downgraded: jest.fn(),
311
+ downgradeError: jest.fn(),
312
+ },
313
+ },
314
+ organization: {
315
+ subscribe: {
316
+ creation: jest.fn(),
317
+ created: jest.fn(),
318
+ creationError: jest.fn(),
319
+ update: jest.fn(),
320
+ updated: jest.fn(),
321
+ updateError: jest.fn(),
322
+ delete: jest.fn(),
323
+ deleted: jest.fn(),
324
+ deletionError: jest.fn(),
325
+ },
326
+ unsubscribe: {
327
+ creation: jest.fn(),
328
+ created: jest.fn(),
329
+ creationError: jest.fn(),
330
+ update: jest.fn(),
331
+ updated: jest.fn(),
332
+ updateError: jest.fn(),
333
+ delete: jest.fn(),
334
+ deleted: jest.fn(),
335
+ deletionError: jest.fn(),
336
+ },
337
+ },
338
+ planProviders: {
339
+ subscribe: {
340
+ loadPlans: jest.fn(),
341
+ plansLoaded: jest.fn(),
342
+ loadError: jest.fn(),
343
+ },
344
+ unsubscribe: {
345
+ loadPlans: jest.fn(),
346
+ plansLoaded: jest.fn(),
347
+ loadError: jest.fn(),
348
+ },
349
+ },
350
+ });
351
+
352
+ describe("BackendHandler - Cobertura extendida", () => {
353
+ let dummyGlobalEventHandler: ReturnType<typeof createDummyGlobalEventHandler>;
354
+
355
+ beforeEach(() => {
356
+ dummyGlobalEventHandler = createDummyGlobalEventHandler();
357
+ jest.clearAllMocks();
358
+ });
359
+
360
+ it("lanza error si globalEventHandler es inválido", () => {
361
+ expect(() => {
362
+ new BackendHandler("home", null, "httl://localhost:9080", "nightly");
363
+ }).toThrow("globalEventHandler inválido");
364
+ });
365
+
366
+ it("se suscribe al evento load de usuario en el constructor", () => {
367
+ new BackendHandler(
368
+ "user-information",
369
+ dummyGlobalEventHandler,
370
+ "httl://localhost:9080",
371
+ "nightly"
372
+ );
373
+ expect(dummyGlobalEventHandler.user.subscribe.load).toHaveBeenCalled();
374
+ });
375
+
376
+ it("se suscribe a eventos de tenant cuando la ruta es 'tenants' o 'create-tenant'", () => {
377
+ new BackendHandler(
378
+ "tenants",
379
+ dummyGlobalEventHandler,
380
+ "httl://localhost:9080",
381
+ "nightly"
382
+ );
383
+ expect(
384
+ dummyGlobalEventHandler.tenant.subscribe.creation
385
+ ).toHaveBeenCalled();
386
+ expect(dummyGlobalEventHandler.tenant.subscribe.created).toHaveBeenCalled();
387
+ expect(
388
+ dummyGlobalEventHandler.tenant.subscribe.deletionError
389
+ ).toHaveBeenCalled();
390
+ expect(
391
+ dummyGlobalEventHandler.planProviders.subscribe.loadPlans
392
+ ).toHaveBeenCalled();
393
+ });
394
+
395
+ it("se suscribe a eventos de usuario cuando la ruta es 'user-information' o 'home'", () => {
396
+ new BackendHandler(
397
+ "home",
398
+ dummyGlobalEventHandler,
399
+ "httl://localhost:9080",
400
+ "nightly"
401
+ );
402
+ expect(dummyGlobalEventHandler.user.subscribe.creation).toHaveBeenCalled();
403
+ expect(dummyGlobalEventHandler.user.subscribe.load).toHaveBeenCalled();
404
+ });
405
+
406
+ it("se suscribe a eventos de account y plan cuando la ruta es 'accounts' o 'create-account'", () => {
407
+ new BackendHandler(
408
+ "accounts",
409
+ dummyGlobalEventHandler,
410
+ "httl://localhost:9080",
411
+ "nightly"
412
+ );
413
+ expect(
414
+ dummyGlobalEventHandler.account.subscribe.creation
415
+ ).toHaveBeenCalled();
416
+ expect(dummyGlobalEventHandler.plan.subscribe.upgrade).toHaveBeenCalled();
417
+ });
418
+
419
+ it("se suscribe a eventos de environment cuando la ruta es 'environments' o 'create-environment'", () => {
420
+ new BackendHandler(
421
+ "environments",
422
+ dummyGlobalEventHandler,
423
+ "httl://localhost:9080",
424
+ "nightly"
425
+ );
426
+ expect(
427
+ dummyGlobalEventHandler.environment.subscribe.creation
428
+ ).toHaveBeenCalled();
429
+ });
430
+
431
+ it("se suscribe a eventos de service cuando la ruta es 'deploy-service'", () => {
432
+ new BackendHandler(
433
+ "deploy-service",
434
+ dummyGlobalEventHandler,
435
+ "httl://localhost:9080",
436
+ "nightly"
437
+ );
438
+ expect(dummyGlobalEventHandler.service.subscribe.deploy).toHaveBeenCalled();
439
+ });
440
+
441
+ it("se suscribe a eventos de marketplace para deployItem y loadItems", () => {
442
+ new BackendHandler(
443
+ "deploy-marketplace",
444
+ dummyGlobalEventHandler,
445
+ "httl://localhost:9080",
446
+ "nightly"
447
+ );
448
+ expect(
449
+ dummyGlobalEventHandler.marketplace.subscribe.deployItem
450
+ ).toHaveBeenCalled();
451
+
452
+ new BackendHandler(
453
+ "marketplace",
454
+ dummyGlobalEventHandler,
455
+ "httl://localhost:9080",
456
+ "nightly"
457
+ );
458
+ expect(
459
+ dummyGlobalEventHandler.marketplace.subscribe.loadItems
460
+ ).toHaveBeenCalled();
461
+ });
462
+
463
+ it("se suscribe a eventos de resource cuando la ruta es 'resources'", () => {
464
+ new BackendHandler(
465
+ "resources",
466
+ dummyGlobalEventHandler,
467
+ "httl://localhost:9080",
468
+ "nightly"
469
+ );
470
+ expect(
471
+ dummyGlobalEventHandler.resource.subscribe.creation
472
+ ).toHaveBeenCalled();
473
+ });
474
+
475
+ // it("ejecuta unsubscribeAll al cambiar de ruta", () => {
476
+ // const handler = new BackendHandler(
477
+ // "tenants",
478
+ // dummyGlobalEventHandler,
479
+ // "httl://localhost:9080",
480
+ // "nightly"
481
+ // );
482
+ // const unsubscribeMock = jest.fn();
483
+ // (handler as any).unsubscribeFunctions.push(unsubscribeMock);
484
+ // handler.changeRoute("user-information");
485
+ // expect(unsubscribeMock).toHaveBeenCalled();
486
+ // expect(dummyGlobalEventHandler.user.subscribe.creation).toHaveBeenCalled();
487
+ // });
488
+
489
+ it("dispara los callbacks de API al invocar los métodos internos", () => {
490
+ const tenantCbSpy = jest
491
+ .spyOn(BackendHandler.prototype as any, "subscribeTenantEvents")
492
+ .mockImplementation(function () {
493
+ createTenant(
494
+ {
495
+ id: "t1",
496
+ name: "Tenant 1",
497
+ organizationsIds: [],
498
+ services: [],
499
+ accounts: [],
500
+ environments: [],
501
+ marketplaceItems: [],
502
+ resources: [],
503
+ role: "",
504
+ status: "",
505
+ users: [],
506
+ registry: [],
507
+ } as Tenant,
508
+ ""
509
+ );
510
+ });
511
+ const testUserData: UserData = {
512
+ id: "",
513
+ name: "",
514
+ surname: "",
515
+ provider: [
516
+ {
517
+ name: "",
518
+ email: "",
519
+ password: "",
520
+ },
521
+ ],
522
+ notificationsEnabled: "",
523
+ organizations: [],
524
+ clusterTokens: [],
525
+ tokens: [],
526
+ tenants: [],
527
+ axebowPlan: "freemium",
528
+ companyName: "",
529
+ rol: "",
530
+ };
531
+ const userCbSpy = jest
532
+ .spyOn(BackendHandler.prototype as any, "subscribeUserEvents")
533
+ .mockImplementation(function () {
534
+ loadUser("", testUserData);
535
+ });
536
+ const accountCbSpy = jest
537
+ .spyOn(BackendHandler.prototype as any, "subscribeAccountEvents")
538
+ .mockImplementation(function () {
539
+ createAccount(
540
+ {
541
+ id: "a1",
542
+ name: "Account 1",
543
+ tenant: "",
544
+ cloudProvider: { name: "" },
545
+ logo: "",
546
+ environments: [],
547
+ services: [],
548
+ domains: [],
549
+ status: "",
550
+ usage: {
551
+ current: {
552
+ cpu: 0,
553
+ memory: 0,
554
+ storage: 0,
555
+ volatileStorage: 0,
556
+ nonReplicatedStorage: 0,
557
+ persistentStorage: 0,
558
+ },
559
+ limit: {
560
+ cpu: { max: 0, min: 0 },
561
+ memory: { max: 0, min: 0 },
562
+ storage: { max: 0, min: 0 },
563
+ volatileStorage: { max: 0, min: 0 },
564
+ nonReplicatedStorage: { max: 0, min: 0 },
565
+ persistentStorage: { max: 0, min: 0 },
566
+ },
567
+ cost: 0,
568
+ },
569
+ } as Account,
570
+ ""
571
+ );
572
+ });
573
+ const envCbSpy = jest
574
+ .spyOn(BackendHandler.prototype as any, "subscribeEnvironmentEvents")
575
+ .mockImplementation(function () {
576
+ createEnvironment(
577
+ {
578
+ id: "e1",
579
+ name: "Env 1",
580
+ account: "",
581
+ tenant: "",
582
+ logo: "",
583
+ services: [],
584
+ domains: [],
585
+ status: {
586
+ code:"",
587
+ message: "",
588
+ timestamp: ""
589
+ },
590
+ usage: {
591
+ current: {
592
+ cpu: 0,
593
+ memory: 0,
594
+ storage: 0,
595
+ volatileStorage: 0,
596
+ nonReplicatedStorage: 0,
597
+ persistentStorage: 0,
598
+ },
599
+ limit: {
600
+ cpu: { max: 0, min: 0 },
601
+ memory: { max: 0, min: 0 },
602
+ storage: { max: 0, min: 0 },
603
+ volatileStorage: { max: 0, min: 0 },
604
+ nonReplicatedStorage: { max: 0, min: 0 },
605
+ persistentStorage: { max: 0, min: 0 },
606
+ },
607
+ cost: 0,
608
+ },
609
+ type: "",
610
+ cluster: { name: "" },
611
+ } as Environment,
612
+ ""
613
+ );
614
+ });
615
+ const serviceCbSpy = jest
616
+ .spyOn(BackendHandler.prototype as any, "subscribeServiceEvents")
617
+ .mockImplementation(function () {
618
+ deployService(
619
+ {
620
+ id: "s1",
621
+ tenant: "",
622
+ account: "",
623
+ environment: "",
624
+ name: "Service 1",
625
+ logo: "",
626
+ description: "",
627
+ revisions: [],
628
+ status: "",
629
+ role: [{ name: "", instances: [] }],
630
+ links: [],
631
+ resources: [],
632
+ parameters: [],
633
+ usage: {
634
+ current: {
635
+ cpu: 0,
636
+ memory: 0,
637
+ storage: 0,
638
+ volatileStorage: 0,
639
+ nonReplicatedStorage: 0,
640
+ persistentStorage: 0,
641
+ },
642
+ limit: {
643
+ cpu: { max: 0, min: 0 },
644
+ memory: { max: 0, min: 0 },
645
+ storage: { max: 0, min: 0 },
646
+ volatileStorage: { max: 0, min: 0 },
647
+ nonReplicatedStorage: { max: 0, min: 0 },
648
+ persistentStorage: { max: 0, min: 0 },
649
+ },
650
+ cost: 0,
651
+ },
652
+ project: "",
653
+ registry: "",
654
+ imageName: "",
655
+ entrypoint: "",
656
+ cmd: "",
657
+ serverChannels: [],
658
+ clientChannels: [],
659
+ duplexChannels: [],
660
+ cloudProvider: "",
661
+ } as Service,
662
+ ""
663
+ );
664
+ });
665
+ const marketplaceDeploySpy = jest
666
+ .spyOn(BackendHandler.prototype as any, "subscribeMarketplaceEvents")
667
+ .mockImplementation(function () {
668
+ deployMarketplaceItem({
669
+ deploymentData: {
670
+ id: "m1",
671
+ tenant: "",
672
+ account: "",
673
+ environment: "",
674
+ name: "Market 1",
675
+ logo: "",
676
+ description: "",
677
+ revisions: [],
678
+ status: "",
679
+ role: [{ name: "", instances: [] }],
680
+ links: [],
681
+ resources: [],
682
+ parameters: [],
683
+ usage: {
684
+ current: {
685
+ cpu: 0,
686
+ memory: 0,
687
+ storage: 0,
688
+ volatileStorage: 0,
689
+ nonReplicatedStorage: 0,
690
+ persistentStorage: 0,
691
+ },
692
+ limit: {
693
+ cpu: { max: 0, min: 0 },
694
+ memory: { max: 0, min: 0 },
695
+ storage: { max: 0, min: 0 },
696
+ volatileStorage: { max: 0, min: 0 },
697
+ nonReplicatedStorage: { max: 0, min: 0 },
698
+ persistentStorage: { max: 0, min: 0 },
699
+ },
700
+ cost: 0,
701
+ },
702
+ project: "",
703
+ registry: "",
704
+ imageName: "",
705
+ entrypoint: "",
706
+ cmd: "",
707
+ serverChannels: [],
708
+ clientChannels: [],
709
+ duplexChannels: [],
710
+ cloudProvider: "",
711
+ },
712
+ step: 0,
713
+ selectedAccount: "",
714
+ step1collapsed: false,
715
+ step2collapsed: false,
716
+ step3collapsed: false,
717
+ step4collapsed: false,
718
+ defaultExecutableCollapsed: false,
719
+ autoScallingCollapsed: false,
720
+ variableCreation: "",
721
+ variableName: "",
722
+ variableValue: "",
723
+ variableList: [{ name: "", value: "", type: "" }],
724
+ openCreationPopup: false,
725
+ domain: "",
726
+ module: "",
727
+ version: "",
728
+ resourceList: [{ name: "", type: "", required: false }],
729
+ parameterList: [{ name: "", type: "", required: false }],
730
+ serviceName: "",
731
+ type: "",
732
+ artifactName: "",
733
+ } as MarketplaceService);
734
+ });
735
+ const marketplaceLoadSpy = jest
736
+ .spyOn(BackendHandler.prototype as any, "subscribeMarketplaceEvents")
737
+ .mockImplementation(function () {
738
+ getMarketplaceItems(["t1", "t2"], "");
739
+ });
740
+
741
+ new BackendHandler(
742
+ "tenants",
743
+ dummyGlobalEventHandler,
744
+ "httl://localhost:9080",
745
+ "nightly"
746
+ );
747
+ new BackendHandler(
748
+ "user-information",
749
+ dummyGlobalEventHandler,
750
+ "httl://localhost:9080",
751
+ "nightly"
752
+ );
753
+ new BackendHandler(
754
+ "accounts",
755
+ dummyGlobalEventHandler,
756
+ "httl://localhost:9080",
757
+ "nightly"
758
+ );
759
+ new BackendHandler(
760
+ "environments",
761
+ dummyGlobalEventHandler,
762
+ "httl://localhost:9080",
763
+ "nightly"
764
+ );
765
+ new BackendHandler(
766
+ "deploy-service",
767
+ dummyGlobalEventHandler,
768
+ "httl://localhost:9080",
769
+ "nightly"
770
+ );
771
+ new BackendHandler(
772
+ "deploy-marketplace",
773
+ dummyGlobalEventHandler,
774
+ "httl://localhost:9080",
775
+ "nightly"
776
+ );
777
+ new BackendHandler(
778
+ "marketplace",
779
+ dummyGlobalEventHandler,
780
+ "httl://localhost:9080",
781
+ "nightly"
782
+ );
783
+
784
+ expect(tenantCbSpy).toHaveBeenCalled();
785
+ expect(userCbSpy).toHaveBeenCalled();
786
+ expect(accountCbSpy).toHaveBeenCalled();
787
+ expect(envCbSpy).toHaveBeenCalled();
788
+ expect(serviceCbSpy).toHaveBeenCalled();
789
+ expect(marketplaceDeploySpy).toHaveBeenCalled();
790
+ expect(marketplaceLoadSpy).toHaveBeenCalled();
791
+ });
792
+ });