From 8fe561865d980b4df55f98a80f24a9189cd156a7 Mon Sep 17 00:00:00 2001 From: Shijun Sun <30999793+AllForNothing@users.noreply.github.com> Date: Mon, 3 Jul 2023 10:58:14 +0800 Subject: [PATCH] Add unit test for hidden columns (#18873) 1. Fixes #18870 Signed-off-by: AllForNothing --- .../list-replication-rule.component.spec.ts | 8 ++++++++ .../artifact-list-tab.component.spec.ts | 7 +++++++ .../artifact-list-tab.component.ts | 14 +------------- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/portal/src/app/base/left-side-nav/replication/replication/list-replication-rule/list-replication-rule.component.spec.ts b/src/portal/src/app/base/left-side-nav/replication/replication/list-replication-rule/list-replication-rule.component.spec.ts index 43b6edda1..4c2f3fb57 100644 --- a/src/portal/src/app/base/left-side-nav/replication/replication/list-replication-rule/list-replication-rule.component.spec.ts +++ b/src/portal/src/app/base/left-side-nav/replication/replication/list-replication-rule/list-replication-rule.component.spec.ts @@ -159,4 +159,12 @@ describe('ListReplicationRuleComponent (inline template)', () => { fixture.nativeElement.querySelector('.modal-body'); expect(body).toBeFalsy(); }); + + it('the length of hide array should equal to the number of column', async () => { + comp.loading = false; + fixture.detectChanges(); + await fixture.whenStable(); + const cols = fixture.nativeElement.querySelectorAll('clr-dg-column'); + expect(cols.length).toEqual(comp.hiddenArray.length); + }); }); diff --git a/src/portal/src/app/base/project/repository/artifact/artifact-list-page/artifact-list/artifact-list-tab/artifact-list-tab.component.spec.ts b/src/portal/src/app/base/project/repository/artifact/artifact-list-page/artifact-list/artifact-list-tab/artifact-list-tab.component.spec.ts index bd67bf39f..b9fb2f5cd 100644 --- a/src/portal/src/app/base/project/repository/artifact/artifact-list-page/artifact-list/artifact-list-tab/artifact-list-tab.component.spec.ts +++ b/src/portal/src/app/base/project/repository/artifact/artifact-list-page/artifact-list/artifact-list-tab/artifact-list-tab.component.spec.ts @@ -353,6 +353,13 @@ describe('ArtifactListTabComponent (inline template)', () => { fixture.nativeElement.querySelector('.confirmation-title') ).toBeTruthy(); }); + it('the length of hide array should equal to the number of column', async () => { + comp.loading = false; + fixture.detectChanges(); + await fixture.whenStable(); + const cols = fixture.nativeElement.querySelectorAll('.datagrid-column'); + expect(cols.length).toEqual(comp.hiddenArray.length); + }); }); async function stepOpenAction(fixture, comp) { diff --git a/src/portal/src/app/base/project/repository/artifact/artifact-list-page/artifact-list/artifact-list-tab/artifact-list-tab.component.ts b/src/portal/src/app/base/project/repository/artifact/artifact-list-page/artifact-list/artifact-list-tab/artifact-list-tab.component.ts index 72e0459f1..2ffa0291f 100644 --- a/src/portal/src/app/base/project/repository/artifact/artifact-list-page/artifact-list/artifact-list-tab/artifact-list-tab.component.ts +++ b/src/portal/src/app/base/project/repository/artifact/artifact-list-page/artifact-list/artifact-list-tab/artifact-list-tab.component.ts @@ -162,19 +162,7 @@ export class ArtifactListTabComponent implements OnInit, OnDestroy { hiddenArray: boolean[] = getHiddenArrayFromLocalStorage( PageSizeMapKeys.ARTIFACT_LIST_TAB_COMPONENT, - [ - false, - false, - false, - false, - false, - false, - false, - true, - false, - false, - false, - ] + [false, false, false, false, false, false, true, false, false, false] ); deleteAccessorySub: Subscription; copyDigestSub: Subscription;