]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: Cleanup of summary refresh test 25504/head
authorStephan Müller <smueller@suse.com>
Wed, 12 Dec 2018 11:07:14 +0000 (12:07 +0100)
committerStephan Müller <smueller@suse.com>
Wed, 12 Dec 2018 11:07:14 +0000 (12:07 +0100)
Now the test is testing what it says.

Additionally resolved typescript compiler issues in the file and
removed not needed doc types in the corresponding service.

Fixes: https://tracker.ceph.com/issues/37619
Signed-off-by: Stephan Müller <smueller@suse.com>
src/pybind/mgr/dashboard/frontend/src/app/shared/services/summary.service.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/shared/services/summary.service.ts

index 75bfdb0ed87347dc8d4b6157619af50ebba0dca3..86ea4e108976d0b5eac9a9092c3054ded6222b62 100644 (file)
@@ -47,21 +47,25 @@ describe('SummaryService', () => {
   });
 
   it('should call refresh', fakeAsync(() => {
-    authStorageService.set('foobar');
-    let result = false;
-    summaryService.refresh();
-    summaryService.subscribe(() => {
-      result = true;
+    authStorageService.set('foobar', undefined, undefined);
+    const calledWith = [];
+    summaryService.subscribe((data) => {
+      calledWith.push(data);
     });
-    tick(5000);
+    expect(calledWith).toEqual([summary]);
+    summaryService.refresh();
+    expect(calledWith).toEqual([summary, summary]);
+    tick(10000);
+    expect(calledWith.length).toEqual(4);
+    // In order to not trigger setTimeout again,
+    // which would raise 'Error: 1 timer(s) still in the queue.'
     spyOn(summaryService, 'refresh').and.callFake(() => true);
     tick(5000);
-    expect(result).toEqual(true);
   }));
 
   describe('Should test methods after first refresh', () => {
     beforeEach(() => {
-      authStorageService.set('foobar');
+      authStorageService.set('foobar', undefined, undefined);
       summaryService.refresh();
     });
 
index d90c16f74c742bcdf0e7275cfb7cbb14f75933b7..a4397f85cba184499f84e42ec8379f42d1b60038 100644 (file)
@@ -40,34 +40,23 @@ export class SummaryService {
 
   /**
    * Returns the current value of summaryData
-   *
-   * @returns {object}
-   * @memberof SummaryService
    */
-  getCurrentSummary() {
+  getCurrentSummary(): { [key: string]: any; executing_tasks: object[] } {
     return this.summaryDataSource.getValue();
   }
 
   /**
    * Subscribes to the summaryData,
    * which is updated once every 5 seconds or when a new task is created.
-   *
-   * @param {(summary: any) => void} call
-   * @param {(error: any) => void} error
-   * @returns {Subscription}
-   * @memberof SummaryService
    */
-  subscribe(call: (summary: any) => void, error?: (error: any) => void): Subscription {
-    return this.summaryData$.subscribe(call, error);
+  subscribe(next: (summary: any) => void, error?: (error: any) => void): Subscription {
+    return this.summaryData$.subscribe(next, error);
   }
 
   /**
    * Inserts a newly created task to the local list of executing tasks.
    * After that, it will automatically push that new information
    * to all subscribers.
-   *
-   * @param {ExecutingTask} task
-   * @memberof SummaryService
    */
   addRunningTask(task: ExecutingTask) {
     const current = this.summaryDataSource.getValue();