]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/dashboard: adapt jest unit tests to angular 14
authorNizamudeen A <nia@redhat.com>
Fri, 9 Jun 2023 14:06:41 +0000 (19:36 +0530)
committerNizamudeen A <nia@redhat.com>
Fri, 25 Aug 2023 07:27:13 +0000 (12:57 +0530)
Important change would be the introduction of `TypedFormControl` which
is now more stricter in typing the FormControl and FormGroups as well.
Right now the dashboard has many number of untypedforms which by default
is migrated to an `UntypedFormControl` class when I ran the angular
upgrade script

Fixes: https://tracker.ceph.com/issues/61641
Signed-off-by: Nizamudeen A <nia@redhat.com>
src/pybind/mgr/dashboard/frontend/package-lock.json
src/pybind/mgr/dashboard/frontend/package.json
src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-form/iscsi-target-form.component.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/shared/api/host.service.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/shared/api/rbd.service.spec.ts
src/pybind/mgr/dashboard/frontend/src/testing/unit-test-helper.ts

index 5fe68f3dc9faa4109c02ec1bf07c0acaf30133da..206d5a06b074fc376e323d68b2a1b7196acb0bdd 100644 (file)
@@ -56,7 +56,6 @@
         "@angular/compiler-cli": "14.3.0",
         "@angular/language-service": "14.3.0",
         "@applitools/eyes-cypress": "3.22.5",
-        "@apteco/ngth": "1.5.0",
         "@compodoc/compodoc": "1.1.18",
         "@cypress/browserify-preprocessor": "3.0.2",
         "@types/brace-expansion": "1.1.0",
         "node": ">=8.9.0"
       }
     },
-    "node_modules/@apteco/ngth": {
-      "version": "1.5.0",
-      "resolved": "https://registry.npmjs.org/@apteco/ngth/-/ngth-1.5.0.tgz",
-      "integrity": "sha512-LBpdybaZbc5PFj8ifNIf6dXGeoQ8tlPhfbN2skcM12ojAe8qH2ymHx9f/ZggVs+KyBuVQLVuJ++jzukG13wryw==",
-      "dev": true,
-      "dependencies": {
-        "tslib": "^2.3.0"
-      },
-      "peerDependencies": {
-        "@angular/common": "14.0.7",
-        "@angular/core": "14.0.7"
-      }
-    },
     "node_modules/@assemblyscript/loader": {
       "version": "0.10.1",
       "resolved": "https://registry.npmjs.org/@assemblyscript/loader/-/loader-0.10.1.tgz",
         "throat": "5.0.0"
       }
     },
-    "@apteco/ngth": {
-      "version": "1.5.0",
-      "resolved": "https://registry.npmjs.org/@apteco/ngth/-/ngth-1.5.0.tgz",
-      "integrity": "sha512-LBpdybaZbc5PFj8ifNIf6dXGeoQ8tlPhfbN2skcM12ojAe8qH2ymHx9f/ZggVs+KyBuVQLVuJ++jzukG13wryw==",
-      "dev": true,
-      "requires": {
-        "tslib": "^2.3.0"
-      }
-    },
     "@assemblyscript/loader": {
       "version": "0.10.1",
       "resolved": "https://registry.npmjs.org/@assemblyscript/loader/-/loader-0.10.1.tgz",
index 51b14dd60e158a70d0923d80bf6d6b922e11cf68..efd9f3cfedc2318a091f693319c10bafdbc4b0d4 100644 (file)
@@ -90,7 +90,6 @@
     "@angular/compiler-cli": "14.3.0",
     "@angular/language-service": "14.3.0",
     "@applitools/eyes-cypress": "3.22.5",
-    "@apteco/ngth": "1.5.0",
     "@compodoc/compodoc": "1.1.18",
     "@cypress/browserify-preprocessor": "3.0.2",
     "@types/brace-expansion": "1.1.0",
index e993468c80d891368bd938e29637e1ae099d1b63..59aac44272851998114ac0b6009b701bc166b289 100644 (file)
@@ -167,7 +167,7 @@ describe('IscsiTargetFormComponent', () => {
     httpTesting.expectOne('ui-api/iscsi/settings').flush(SETTINGS);
     httpTesting.expectOne('ui-api/iscsi/portals').flush(PORTALS);
     httpTesting.expectOne('ui-api/iscsi/version').flush(VERSION);
-    httpTesting.expectOne('api/block/image?offset=0&limit=-1&search=&sort=+name').flush(RBD_LIST);
+    httpTesting.expectOne('api/block/image?offset=0&limit=-1&search=&sort=%2Bname').flush(RBD_LIST);
     httpTesting.expectOne('api/iscsi/target').flush(LIST_TARGET);
     httpTesting.verify();
   });
index 52ce44e30ae53ec5dcbd4d5cfb0ea61f24a1c6bf..49b48cd6cfcfc614acafe96edd95b50ef6d0a081 100644 (file)
@@ -31,7 +31,7 @@ describe('HostService', () => {
     let result: any[] = [{}, {}];
     const hostContext = new CdTableFetchDataContext(() => undefined);
     service.list(hostContext.toParams(), 'true').subscribe((resp) => (result = resp));
-    const req = httpTesting.expectOne('api/host?offset=0&limit=10&search=&sort=+name&facts=true');
+    const req = httpTesting.expectOne('api/host?offset=0&limit=10&search=&sort=%2Bname&facts=true');
     expect(req.request.method).toBe('GET');
     req.flush([{ foo: 1 }, { bar: 2 }]);
     tick();
index 5bafc9e63d37119da657b6a40fc67b05b182d8c6..25b8733d079eac80d4f6c1656741cf14578e16ae 100644 (file)
@@ -59,7 +59,9 @@ describe('RbdService', () => {
     /* tslint:disable:no-empty */
     const context = new CdTableFetchDataContext(() => {});
     service.list(context.toParams()).subscribe();
-    const req = httpTesting.expectOne('api/block/image?offset=0&limit=10&search=&sort=+name');
+    const req = httpTesting.expectOne((req) => {
+      return 'api/block/image?offset=0&limit=-1&search=&sort=+name' && req.method === 'GET';
+    });
     expect(req.request.method).toBe('GET');
   });
 
index 12bef83cc58a6cf1419f09b94cf1c100fa3868a5..ca74ee21ecaef16ea13223eb038cb3900230a5b6 100644 (file)
@@ -6,7 +6,6 @@ import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/t
 
 import { NgbModal, NgbNav, NgbNavItem, NgbNavLink } from '@ng-bootstrap/ng-bootstrap';
 import _ from 'lodash';
-import { configureSuite } from '@apteco/ngth';
 import { of } from 'rxjs';
 
 import { InventoryDevice } from '~/app/ceph/cluster/inventory/inventory-devices/inventory-device.model';
@@ -31,15 +30,18 @@ import {
 } from '~/app/shared/models/prometheus-alerts';
 
 export function configureTestBed(configuration: any, entryComponents?: any) {
-  configureSuite(() => {
+  beforeEach(async () => {
     if (entryComponents) {
       // Declare entryComponents without having to add them to a module
       // This is needed since Jest doesn't yet support not declaring entryComponents
-      TestBed.configureTestingModule(configuration).overrideModule(BrowserDynamicTestingModule, {
-        set: { entryComponents: entryComponents }
-      });
+      await TestBed.configureTestingModule(configuration).overrideModule(
+        BrowserDynamicTestingModule,
+        {
+          set: { entryComponents: entryComponents }
+        }
+      );
     } else {
-      TestBed.configureTestingModule(configuration);
+      await TestBed.configureTestingModule(configuration);
     }
   });
 }