]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: fix stale nvmeof spec tests from a semantic merge conflict 69894/head
authorKefu Chai <k.chai@proxmox.com>
Thu, 2 Jul 2026 03:04:45 +0000 (11:04 +0800)
committerKefu Chai <k.chai@proxmox.com>
Thu, 2 Jul 2026 03:28:11 +0000 (11:28 +0800)
mgr-dashboard-frontend-unittests has been failing on main since 2026-07-01,
unrelated to whatever PR triggers it. Bisected to cfe12305fb1, the merge
commit for PR #68180.

6182e67ea4 ("mgr/dashboard: NVMe Onboarding Setup Cards") moved gateway
group selection out of NvmeofSubsystemsComponent and
NvmeofNamespacesListComponent into a new NvmeofGatewayGroupFilterComponent,
dropping gwGroups, updateGroupSelectionState, handleGatewayGroupsError,
onGroupClear, and getSubsystems from both. Clean on its own.

PR #68180 forked from main in April, before that refactor existed, and
added three new tests against the old API. Also clean on its own, and never
rebased. Both PRs only touch lines the other doesn't, so when #68180 merged
34 minutes after 6182e67ea4, git's 3-way merge combined them without a
conflict. The merge is the only place the bug exists: new tests calling
methods the sibling parent had already deleted. TypeError at runtime,
TS2339/TS2551 from tsc, every run since. CI never caught it: GitHub was
showing #68180's make check as green from a run a full day older than
6182e67ea4.

nvmeof-namespaces-list.component.spec.ts: the dedup test is real, current
logic, it just called the old listNamespaces() instead of fetchData().
Fixed the call. The other two duplicate NvmeofGatewayGroupFilterComponent's
own spec; removed.

nvmeof-subsystems.component.spec.ts: same story, all three duplicate the
filter component's spec; removed.

Both removed error tests also checked preventDefault() on the error object,
which had no coverage elsewhere. Added that to
NvmeofGatewayGroupFilterComponent's spec, and hit a second bug while writing
it: the file's throwError(() => err) is the RxJS 7 factory overload, this
project is on RxJS 6.6.3, so it was emitting the arrow function itself as
the error. The existing error test never noticed since it only checks side
effects, not the error's identity. Used throwError(err) instead.

Verified: jest passes on all three spec files (was 6 failing), tsc -p
tsconfig.spec.json --noEmit is clean (was 17 errors), full block/nvmeof
sweep is 29/29 suites, 216/216 tests.

Fixes: cfe12305fb1
Signed-off-by: Kefu Chai <k.chai@proxmox.com>
src/pybind/mgr/dashboard/frontend/src/app/ceph/block/nvmeof-gateway-group-filter/nvmeof-gateway-group-filter.component.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/block/nvmeof-namespaces-list/nvmeof-namespaces-list.component.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/block/nvmeof-subsystems/nvmeof-subsystems.component.spec.ts

index aef321896f57638539f2cc4a71707a1cdc8a7c4a..2324b2ce161206ea4d1e803de7f89f0380773c1f 100644 (file)
@@ -103,6 +103,13 @@ describe('NvmeofGatewayGroupFilterComponent', () => {
     expect(component.placeholder).toBe('Unable to fetch Gateway groups');
   });
 
+  it('should call preventDefault on the error when the API call fails', () => {
+    const err = { preventDefault: jest.fn() };
+    (nvmeofService.listGatewayGroups as jest.Mock).mockReturnValue(throwError(err));
+    fixture.detectChanges();
+    expect(err.preventDefault).toHaveBeenCalled();
+  });
+
   it('should render a cds-combo-box', () => {
     fixture.detectChanges();
     const combo = fixture.nativeElement.querySelector('cds-combo-box');
index f7f6b4261b1168036038b42d1431d37c32d3ad54..945c99ea0406b7ad68bf653e22877b8c6f3461c0 100644 (file)
@@ -148,28 +148,6 @@ describe('NvmeofNamespacesListComponent', () => {
       done();
     });
 
-    component.listNamespaces();
-  });
-
-  it('should default to first group and keep default placeholder when groups exist', () => {
-    component.group = null;
-    component.gwGroups = [{ content: 'g1', selected: false }] as any;
-
-    component.updateGroupSelectionState();
-
-    expect(component.group).toBe('g1');
-    expect(component.gwGroupsEmpty).toBe(false);
-    expect(component.gwGroupPlaceholder).toBe('Enter group name');
-  });
-
-  it('should set error placeholder and call preventDefault on group fetch failure', () => {
-    const preventDefault = jasmine.createSpy('preventDefault');
-
-    component.handleGatewayGroupsError({ preventDefault });
-
-    expect(component.gwGroups).toEqual([]);
-    expect(component.gwGroupsEmpty).toBe(true);
-    expect(component.gwGroupPlaceholder).toBe('Unable to fetch Gateway groups');
-    expect(preventDefault).toHaveBeenCalled();
+    component.fetchData();
   });
 });
index 0acf8711376c31c8dd524533711cc56ef7ddc290..f848d67c66ea32fa5b2083f150542a4dbe21ca52 100644 (file)
@@ -160,39 +160,4 @@ describe('NvmeofSubsystemsComponent', () => {
   it('should set first group as default initially', () => {
     expect(component.group).toBe('default');
   });
-
-  it('should mark only current group as selected', () => {
-    component.group = 'foo';
-    component.gwGroups = [{ content: 'default' }, { content: 'foo' }] as any;
-
-    component.updateGroupSelectionState();
-
-    expect(component.gwGroups).toEqual([
-      { content: 'default', selected: false },
-      { content: 'foo', selected: true }
-    ]);
-  });
-
-  it('should clear selected group and refresh subsystem list', () => {
-    component.group = 'default';
-    const getSubsystemsSpy = spyOn(component, 'getSubsystems');
-
-    component.onGroupClear();
-
-    expect(component.group).toBeNull();
-    expect(getSubsystemsSpy).toHaveBeenCalled();
-  });
-
-  it('should set error placeholder and prevent default on groups load error', () => {
-    const preventDefault = jasmine.createSpy('preventDefault');
-    component.context = { error: jasmine.createSpy('error') } as any;
-
-    component.handleGatewayGroupsError({ preventDefault });
-
-    expect(component.gwGroups).toEqual([]);
-    expect(component.gwGroupsEmpty).toBe(true);
-    expect(component.gwGroupPlaceholder).toBe('Unable to fetch Gateway groups');
-    expect(preventDefault).toHaveBeenCalled();
-    expect(component.context.error).toHaveBeenCalled();
-  });
 });