Skip to content

Commit

Permalink
Correct total count for schedule list datagrid (goharbor#18148)
Browse files Browse the repository at this point in the history
1.Fixes goharbor#18120

Signed-off-by: AllForNothing <[email protected]>
Signed-off-by: Stephan Hohn <[email protected]>
  • Loading branch information
AllForNothing authored and Stephan Hohn committed Feb 16, 2023
1 parent e55a407 commit 394f9ed
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
{{ pagination.lastItem + 1 }}
{{ 'GROUP.OF' | translate }}
</span>
{{ total }} {{ 'GROUP.ITEMS' | translate }}
<span id="total">{{ total }}</span> {{ 'GROUP.ITEMS' | translate }}
</clr-dg-pagination>
</clr-dg-footer>
</clr-datagrid>
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { of } from 'rxjs';
import { SharedTestingModule } from '../../../../shared/shared.module';
import { JobServiceDashboardSharedDataService } from '../job-service-dashboard-shared-data.service';
import { ScheduleListResponse } from '../job-service-dashboard.interface';
import { delay } from 'rxjs/operators';

describe('ScheduleListComponent', () => {
let component: ScheduleListComponent;
Expand All @@ -18,12 +19,13 @@ describe('ScheduleListComponent', () => {
const fakedJobServiceDashboardSharedDataService = {
_scheduleListResponse: {
scheduleList: mockedSchedules,
total: mockedSchedules.length,
},
getScheduleListResponse(): ScheduleListResponse {
return this._scheduleListResponse;
},
retrieveScheduleListResponse() {
return of({});
return of(this._scheduleListResponse).pipe(delay(0));
},
};

Expand All @@ -41,7 +43,6 @@ describe('ScheduleListComponent', () => {

fixture = TestBed.createComponent(ScheduleListComponent);
component = fixture.componentInstance;
component.loadingSchedules = false;
fixture.detectChanges();
});

Expand All @@ -56,4 +57,13 @@ describe('ScheduleListComponent', () => {
const rows = fixture.nativeElement.querySelectorAll('clr-dg-row');
expect(rows.length).toEqual(2);
});

it('should show the right total count', async () => {
await fixture.whenStable();
fixture.detectChanges();
await fixture.whenStable();
const span: HTMLSpanElement =
fixture.nativeElement.querySelector('#total');
expect(span.innerText).toEqual('2');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export class ScheduleListComponent {
.pipe(finalize(() => (this.loadingSchedules = false)))
.subscribe({
next: res => {
this.total = res.total;
doSorting(res.scheduleList, state);
},
error: err => {
Expand Down

0 comments on commit 394f9ed

Please sign in to comment.