[Cherry-pick]Correct total count for schedule list datagrid (#18149)

Correct total count for schedule list datagrid
  1.Fixes #18120

Signed-off-by: AllForNothing <sshijun@vmware.com>
This commit is contained in:
Shijun Sun 2023-02-08 10:56:10 +08:00 committed by GitHub
parent 24f58f70d6
commit dc931cfd2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 3 deletions

View File

@ -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>

View File

@ -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;
@ -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));
},
};
@ -41,7 +43,6 @@ describe('ScheduleListComponent', () => {
fixture = TestBed.createComponent(ScheduleListComponent);
component = fixture.componentInstance;
component.loadingSchedules = false;
fixture.detectChanges();
});
@ -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');
});
});

View File

@ -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 => {