component.images = images;
refresh({ executing_tasks: [], finished_tasks: [] });
spyOn(rbdService, 'list').and.callFake(() =>
- of([{ poool_name: 'rbd', status: 1, value: images }])
+ of([{ pool_name: 'rbd', status: 1, value: images }])
);
fixture.detectChanges();
});
component.images = images;
summaryService['summaryDataSource'].next({ executingTasks: [] });
spyOn(rbdService, 'listTrash').and.callFake(() =>
- of([{ poool_name: 'rbd', status: 1, value: images }])
+ of([{ pool_name: 'rbd', status: 1, value: images }])
);
fixture.detectChanges();
});
});
describe('display purge button', () => {
- beforeEach(() => {});
+ let images: any[];
+ const addImage = (id: string) => {
+ images.push({
+ id: id,
+ pool_name: 'pl',
+ deferment_end_time: 'abc'
+ });
+ };
+
+ beforeEach(() => {
+ summaryService['summaryDataSource'].next({ executingTasks: [] });
+ spyOn(rbdService, 'listTrash').and.callFake(() => {
+ of([{ pool_name: 'rbd', status: 1, value: images }]);
+ });
+ fixture.detectChanges();
+ });
+
+ it('should show button disabled when no image is in trash', () => {
+ expect(component.disablePurgeBtn).toBeTruthy();
+ });
+
+ it('should show button enabled when an existing image is in trash', () => {
+ images = [];
+ addImage('1');
+ const payload = [{ pool_name: 'rbd', status: 1, value: images }];
+ component.prepareResponse(payload);
+ expect(component.disablePurgeBtn).toBeFalsy();
+ });
it('should show button with delete permission', () => {
component.permission = {
selection = new CdTableSelection();
tableActions: CdTableAction[];
viewCacheStatusList: any[];
+ disablePurgeBtn = true;
constructor(
private authStorageService: AuthStorageService,
}
viewCacheStatusMap[pool.status].push(pool.pool_name);
images = images.concat(pool.value);
+ this.disablePurgeBtn = !images.length;
});
const viewCacheStatusList: any[] = [];
novalidate>
<div class="modal-body">
<p>
- <ng-container i18n>To purge, select one or All images and click</ng-container>
+ <ng-container i18n>To purge, select one or</ng-container>
+ <kbd i18n>All</kbd>
+ <ng-container i18n>pools and click</ng-container>
<kbd i18n>Purge Trash</kbd>.
</p>