Skip to content
Permalink
Browse files

mgr/dashboard: frontend: move ellipsis to before progress in task exe…

…cution description

Signed-off-by: Ricardo Dias <rdias@suse.com>
  • Loading branch information...
rjfd committed Jul 17, 2019
1 parent 8728bf4 commit 0d735159b4e5df3dd87af5e1484978a1f531d5bb
@@ -10,6 +10,7 @@ import { BehaviorSubject, of } from 'rxjs';

import {
configureTestBed,
expectItemTasks,
i18nProviders,
PermissionHelper
} from '../../../../testing/unit-test-helper';
@@ -136,10 +137,6 @@ describe('IscsiTargetListComponent', () => {
summaryService.addRunningTask(task);
};

const expectTargetTasks = (target: any, executing: string) => {
expect(target.cdExecuting).toEqual(executing);
};

beforeEach(() => {
targets = [];
addTarget('iqn.a');
@@ -160,16 +157,16 @@ describe('IscsiTargetListComponent', () => {
it('should add a new target from a task', () => {
addTask('iscsi/target/create', 'iqn.d');
expect(component.targets.length).toBe(4);
expectTargetTasks(component.targets[0], undefined);
expectTargetTasks(component.targets[1], undefined);
expectTargetTasks(component.targets[2], undefined);
expectTargetTasks(component.targets[3], 'Creating');
expectItemTasks(component.targets[0], undefined);
expectItemTasks(component.targets[1], undefined);
expectItemTasks(component.targets[2], undefined);
expectItemTasks(component.targets[3], 'Creating');
});

it('should show when an existing target is being modified', () => {
addTask('iscsi/target/delete', 'iqn.b');
expect(component.targets.length).toBe(3);
expectTargetTasks(component.targets[1], 'Deleting');
expectItemTasks(component.targets[1], 'Deleting');
});
});

@@ -13,6 +13,7 @@ import { BehaviorSubject, of } from 'rxjs';

import {
configureTestBed,
expectItemTasks,
i18nProviders,
PermissionHelper
} from '../../../../testing/unit-test-helper';
@@ -137,10 +138,6 @@ describe('RbdListComponent', () => {
summaryService.addRunningTask(task);
};

const expectImageTasks = (image: RbdModel, executing: string) => {
expect(image.cdExecuting).toEqual(executing);
};

beforeEach(() => {
images = [];
addImage('a');
@@ -162,38 +159,38 @@ describe('RbdListComponent', () => {
it('should add a new image from a task', () => {
addTask('rbd/create', 'd');
expect(component.images.length).toBe(4);
expectImageTasks(component.images[0], undefined);
expectImageTasks(component.images[1], undefined);
expectImageTasks(component.images[2], undefined);
expectImageTasks(component.images[3], 'Creating');
expectItemTasks(component.images[0], undefined);
expectItemTasks(component.images[1], undefined);
expectItemTasks(component.images[2], undefined);
expectItemTasks(component.images[3], 'Creating');
});

it('should show when a image is being cloned', () => {
addTask('rbd/clone', 'd');
expect(component.images.length).toBe(4);
expectImageTasks(component.images[0], undefined);
expectImageTasks(component.images[1], undefined);
expectImageTasks(component.images[2], undefined);
expectImageTasks(component.images[3], 'Cloning');
expectItemTasks(component.images[0], undefined);
expectItemTasks(component.images[1], undefined);
expectItemTasks(component.images[2], undefined);
expectItemTasks(component.images[3], 'Cloning');
});

it('should show when a image is being copied', () => {
addTask('rbd/copy', 'd');
expect(component.images.length).toBe(4);
expectImageTasks(component.images[0], undefined);
expectImageTasks(component.images[1], undefined);
expectImageTasks(component.images[2], undefined);
expectImageTasks(component.images[3], 'Copying');
expectItemTasks(component.images[0], undefined);
expectItemTasks(component.images[1], undefined);
expectItemTasks(component.images[2], undefined);
expectItemTasks(component.images[3], 'Copying');
});

it('should show when an existing image is being modified', () => {
addTask('rbd/edit', 'a');
addTask('rbd/delete', 'b');
addTask('rbd/flatten', 'c');
expect(component.images.length).toBe(3);
expectImageTasks(component.images[0], 'Updating');
expectImageTasks(component.images[1], 'Deleting');
expectImageTasks(component.images[2], 'Flattening');
expectItemTasks(component.images[0], 'Updating');
expectItemTasks(component.images[1], 'Deleting');
expectItemTasks(component.images[2], 'Flattening');
});
});

@@ -10,6 +10,7 @@ import { Subject, throwError as observableThrowError } from 'rxjs';

import {
configureTestBed,
expectItemTasks,
i18nProviders,
PermissionHelper
} from '../../../../testing/unit-test-helper';
@@ -137,10 +138,6 @@ describe('RbdSnapshotListComponent', () => {
summaryService.addRunningTask(task);
};

const expectImageTasks = (snapshot: RbdSnapshotModel, executing: string) => {
expect(snapshot.cdExecuting).toEqual(executing);
};

const refresh = (data) => {
summaryService['summaryDataSource'].next(data);
};
@@ -167,20 +164,20 @@ describe('RbdSnapshotListComponent', () => {
it('should add a new image from a task', () => {
addTask('rbd/snap/create', 'd');
expect(component.snapshots.length).toBe(4);
expectImageTasks(component.snapshots[0], undefined);
expectImageTasks(component.snapshots[1], undefined);
expectImageTasks(component.snapshots[2], undefined);
expectImageTasks(component.snapshots[3], 'Creating');
expectItemTasks(component.snapshots[0], undefined);
expectItemTasks(component.snapshots[1], undefined);
expectItemTasks(component.snapshots[2], undefined);
expectItemTasks(component.snapshots[3], 'Creating');
});

it('should show when an existing image is being modified', () => {
addTask('rbd/snap/edit', 'a');
addTask('rbd/snap/delete', 'b');
addTask('rbd/snap/rollback', 'c');
expect(component.snapshots.length).toBe(3);
expectImageTasks(component.snapshots[0], 'Updating');
expectImageTasks(component.snapshots[1], 'Deleting');
expectImageTasks(component.snapshots[2], 'Rolling back');
expectItemTasks(component.snapshots[0], 'Updating');
expectItemTasks(component.snapshots[1], 'Deleting');
expectItemTasks(component.snapshots[2], 'Rolling back');
});
});

@@ -6,7 +6,11 @@ import { ToastModule } from 'ng2-toastr';
import { of } from 'rxjs';

import { By } from '@angular/platform-browser';
import { configureTestBed, i18nProviders } from '../../../../testing/unit-test-helper';
import {
configureTestBed,
expectItemTasks,
i18nProviders
} from '../../../../testing/unit-test-helper';
import { RbdService } from '../../../shared/api/rbd.service';
import { CdTableSelection } from '../../../shared/models/cd-table-selection';
import { ExecutingTask } from '../../../shared/models/executing-task';
@@ -74,10 +78,6 @@ describe('RbdTrashListComponent', () => {
summaryService.addRunningTask(task);
};

const expectImageTasks = (image: any, executing: string) => {
expect(image.cdExecuting).toEqual(executing);
};

beforeEach(() => {
images = [];
addImage('1');
@@ -99,8 +99,8 @@ describe('RbdTrashListComponent', () => {
addTask('rbd/trash/remove', '1');
addTask('rbd/trash/restore', '2');
expect(component.images.length).toBe(2);
expectImageTasks(component.images[0], 'Deleting');
expectImageTasks(component.images[1], 'Restoring');
expectItemTasks(component.images[0], 'Deleting');
expectItemTasks(component.images[1], 'Restoring');
});
});

@@ -9,6 +9,7 @@ import { BehaviorSubject, of } from 'rxjs';

import {
configureTestBed,
expectItemTasks,
i18nProviders,
PermissionHelper
} from '../../../../testing/unit-test-helper';
@@ -127,10 +128,6 @@ describe('NfsListComponent', () => {
summaryService.addRunningTask(task);
};

const expectExportTasks = (expo: any, executing: string) => {
expect(expo.cdExecuting).toEqual(executing);
};

beforeEach(() => {
exports = [];
addExport('a');
@@ -154,18 +151,18 @@ describe('NfsListComponent', () => {
addTask('nfs/create', 'd');
tick();
expect(component.exports.length).toBe(4);
expectExportTasks(component.exports[0], undefined);
expectExportTasks(component.exports[1], undefined);
expectExportTasks(component.exports[2], undefined);
expectExportTasks(component.exports[3], 'Creating');
expectItemTasks(component.exports[0], undefined);
expectItemTasks(component.exports[1], undefined);
expectItemTasks(component.exports[2], undefined);
expectItemTasks(component.exports[3], 'Creating');
}));

it('should show when an existing export is being modified', () => {
addTask('nfs/edit', 'a');
addTask('nfs/delete', 'b');
expect(component.exports.length).toBe(3);
expectExportTasks(component.exports[0], 'Updating');
expectExportTasks(component.exports[1], 'Deleting');
expectItemTasks(component.exports[0], 'Updating');
expectItemTasks(component.exports[1], 'Deleting');
});
});

@@ -8,7 +8,11 @@ import { BsModalService } from 'ngx-bootstrap/modal';
import { TabsModule } from 'ngx-bootstrap/tabs';
import { of } from 'rxjs';

import { configureTestBed, i18nProviders } from '../../../../testing/unit-test-helper';
import {
configureTestBed,
expectItemTasks,
i18nProviders
} from '../../../../testing/unit-test-helper';
import { ConfigurationService } from '../../../shared/api/configuration.service';
import { PoolService } from '../../../shared/api/pool.service';
import { CriticalConfirmationModalComponent } from '../../../shared/components/critical-confirmation-modal/critical-confirmation-modal.component';
@@ -195,13 +199,13 @@ describe('PoolListComponent', () => {
it('gets a pool from a task during creation', () => {
addTask('pool/create', 'd');
expect(component.pools.length).toBe(4);
expect(component.pools[3].cdExecuting).toBe('Creating');
expectItemTasks(component.pools[3], 'Creating');
});

it('gets all pools with one executing pools', () => {
addTask('pool/create', 'a');
expect(component.pools.length).toBe(3);
expect(component.pools[0].cdExecuting).toBe('Creating');
expectItemTasks(component.pools[0], 'Creating');
expect(component.pools[1].cdExecuting).toBeFalsy();
expect(component.pools[2].cdExecuting).toBeFalsy();
});
@@ -214,9 +218,9 @@ describe('PoolListComponent', () => {
addTask('pool/delete', 'b');
addTask('pool/delete', 'c');
expect(component.pools.length).toBe(3);
expect(component.pools[0].cdExecuting).toBe('Creating, Updating, Deleting');
expect(component.pools[1].cdExecuting).toBe('Updating, Deleting');
expect(component.pools[2].cdExecuting).toBe('Deleting');
expectItemTasks(component.pools[0], 'Creating..., Updating..., Deleting');
expectItemTasks(component.pools[1], 'Updating..., Deleting');
expectItemTasks(component.pools[2], 'Deleting');
});

it('gets all pools with multiple executing tasks (not only pool tasks)', () => {
@@ -227,8 +231,8 @@ describe('PoolListComponent', () => {
addTask('rbd/delete', 'b');
addTask('rbd/delete', 'c');
expect(component.pools.length).toBe(3);
expect(component.pools[0].cdExecuting).toBe('Deleting');
expect(component.pools[1].cdExecuting).toBe('Updating');
expectItemTasks(component.pools[0], 'Deleting');
expectItemTasks(component.pools[1], 'Updating');
expect(component.pools[2].cdExecuting).toBeFalsy();
});
});
@@ -364,12 +368,12 @@ describe('PoolListComponent', () => {
pg_num_target: 16,
pg_placement_num: 32,
pg_placement_num_target: 16,
cdExecuting: 'Updating 50%'
cdExecuting: 'Updating... 50%'
})
];
expect(component.transformPoolsData(pools)).toEqual(
getPoolData({
cdExecuting: 'Updating 50%',
cdExecuting: 'Updating... 50%',
pg_num: 32,
pg_num_target: 16,
pg_placement_num: 32,
@@ -175,7 +175,7 @@
*ngIf="row.cdExecuting"></i>
{{ value }}
<span *ngIf="row.cdExecuting"
class="text-muted italic">({{ row.cdExecuting }}... )</span>
class="text-muted italic">({{ row.cdExecuting }})</span>
</ng-template>

<ng-template #classAddingTpl
@@ -4,7 +4,11 @@ import { RouterTestingModule } from '@angular/router/testing';

import { of } from 'rxjs';

import { configureTestBed, i18nProviders } from '../../../testing/unit-test-helper';
import {
configureTestBed,
expectItemTasks,
i18nProviders
} from '../../../testing/unit-test-helper';
import { ExecutingTask } from '../models/executing-task';
import { SummaryService } from './summary.service';
import { TaskListService } from './task-list.service';
@@ -71,10 +75,6 @@ describe('TaskListService', () => {
summaryService.addRunningTask(task);
};

const expectItemTasks = (item: any, executing: string) => {
expect(item.cdExecuting).toBe(executing);
};

it('gets all items without any executing items', () => {
expect(list.length).toBe(3);
expect(list.every((item) => !item.cdExecuting)).toBeTruthy();
@@ -90,7 +90,7 @@ describe('TaskListService', () => {
addTask('test/edit', 'd', 97);
addTask('test/edit', 'e', 0);
expect(list.length).toBe(5);
expectItemTasks(list[3], 'Updating 97%');
expectItemTasks(list[3], 'Updating', 97);
expectItemTasks(list[4], 'Updating');
});

@@ -110,8 +110,8 @@ describe('TaskListService', () => {
addTask('test/delete', 'b');
addTask('test/delete', 'c');
expect(list.length).toBe(3);
expectItemTasks(list[0], 'Creating, Updating, Deleting');
expectItemTasks(list[1], 'Updating, Deleting');
expectItemTasks(list[0], 'Creating..., Updating..., Deleting');
expectItemTasks(list[1], 'Updating..., Deleting');
expectItemTasks(list[2], 'Deleting');
});

@@ -93,7 +93,7 @@ export class TaskListService implements OnDestroy {
return tasks
.map((task) => {
const progress = task.progress ? ` ${task.progress}%` : '';
return this.taskMessageService.getRunningText(task) + progress;
return this.taskMessageService.getRunningText(task) + '...' + progress;
})
.join(', ');
}
@@ -275,3 +275,13 @@ const i18nProviders = [
];

export { i18nProviders };

export function expectItemTasks(item: any, executing: string, percentage?: number) {
if (executing) {
executing = executing + '...';
if (percentage) {
executing = `${executing} ${percentage}%`;
}
}
expect(item.cdExecuting).toBe(executing);
}

0 comments on commit 0d73515

Please sign in to comment.
You can’t perform that action at this time.