Skip to content

Commit 5ccd722

Browse files
committed
test: api tests for TaskManager noSpinnerNotification and flashSpinnerForAttention
1 parent 4805ac4 commit 5ccd722

2 files changed

Lines changed: 38 additions & 2 deletions

File tree

docs/generatedApiDocs/features/TaskManager-API.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ tasks in list and renders. IF the active tasks has already been notified, it wo
1313

1414
### Parameters
1515

16-
* `newTaskAdded`
16+
* `showNormalSpinnerIfNone`
1717

1818
## TaskObject
1919

@@ -41,6 +41,7 @@ Type: [Object][1]
4141
* `hidePauseIcon` **function (): void** Hides the pause icon.
4242
* `showRestartIcon` **function ([string][2]): void** Shows the restart (retry) icon with an optional tooltip message.
4343
* `hideRestartIcon` **function (): void** Hides the restart (retry) icon.
44+
* `flashSpinnerForAttention` **function (): void** briefly flashes the task spinner icon for attention.
4445

4546
## addNewTask
4647

@@ -53,14 +54,16 @@ directly from the UI in the status bar.
5354
* `taskTitle` **[string][2]** The title of the task. This is a mandatory parameter and is displayed in the UI.
5455
* `message` **[string][2]** A message or status associated with the task. Displayed as additional information in the UI.
5556
* `iconHTML` **[string][2]?** Optional HTML string for the task's icon. Used to visually represent the task in the UI. (optional, default `null`)
56-
* `options` **[Object][1]?** Optional settings and callbacks for the task. (optional, default `{onPauseClick:null,onPlayClick:null,onStopClick:null,onRetryClick:null,onSelect:null,progressPercent:null}`)
57+
* `options` **[Object][1]?** Optional settings and callbacks for the task. (optional, default `{onPauseClick:null,onPlayClick:null,onStopClick:null,onRetryClick:null,onSelect:null,progressPercent:null,noSpinnerNotification:false}`)
5758

5859
* `options.onPauseClick` **[Function][5]?** Callback function triggered when the pause button is clicked.
5960
* `options.onPlayClick` **[Function][5]?** Callback function triggered when the play button is clicked.
6061
* `options.onStopClick` **[Function][5]?** Callback function triggered when the stop button is clicked.
6162
* `options.onRetryClick` **[Function][5]?** Callback function triggered when the retry button is clicked.
6263
* `options.onSelect` **[Function][5]?** Callback function triggered when the task is selected from the dropdown.
6364
* `options.progressPercent` **[number][3]?** Initial progress percentage of the task.
65+
* `options.noSpinnerNotification` **[boolean][4]?** If set to true, will not show the task spinners for this task.
66+
This can be used for silent background tasks where user attention is not needed.
6467

6568
### Examples
6669

test/spec/TaskManager-integ-test.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,5 +441,38 @@ define(function (require, exports, module) {
441441
expect(testWindow.$("#status-tasks .spinner").hasClass("spinner-success")).toBeFalse();
442442
task.close();
443443
});
444+
445+
it(`Should task be able to not show task spinner on create`, async function(){
446+
const task = TaskManager.addNewTask("title", "message", null, {
447+
noSpinnerNotification: true
448+
});
449+
expect(testWindow.$("#status-tasks .spinner").is(":visible")).toBeFalse();
450+
task.setFailed();
451+
expect(testWindow.$("#status-tasks .spinner").hasClass("spinner-failure")).toBeFalse();
452+
expect(testWindow.$("#status-tasks .spinner").is(":visible")).toBeFalse();
453+
task.setSucceded();
454+
expect(testWindow.$("#status-tasks .spinner").hasClass("spinner-success")).toBeFalse();
455+
expect(testWindow.$("#status-tasks .spinner").is(":visible")).toBeFalse();
456+
task.setProgressPercent(10);
457+
expect(testWindow.$("#status-tasks .spinner").hasClass("spinner-failure")).toBeFalse();
458+
expect(testWindow.$("#status-tasks .spinner").is(":visible")).toBeFalse();
459+
task.close();
460+
});
461+
462+
it(`Should task be able to flash task spinner even if no spinner specified`, async function(){
463+
const task = TaskManager.addNewTask("title", "message", null, {
464+
noSpinnerNotification: true
465+
});
466+
expect(testWindow.$("#status-tasks .spinner").is(":visible")).toBeFalse();
467+
task.flashSpinnerForAttention();
468+
expect(testWindow.$("#status-tasks .spinner").is(":visible")).toBeTrue();
469+
task.setSucceded();
470+
// even though the task succeeded, since task has `noSpinnerNotification` specified, the success-spinner
471+
// will not be shown. Instead, the normal blue spinner displayed by `flashSpinnerForAttention`
472+
// is still visible till the spinner hide timer is hit.
473+
expect(testWindow.$("#status-tasks .spinner").is(":visible")).toBeTrue();
474+
expect(testWindow.$("#status-tasks .spinner").hasClass("spinner-success")).toBeFalse();
475+
task.close();
476+
});
444477
});
445478
});

0 commit comments

Comments
 (0)