]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: Allow test selection overwrite
authorStephan Müller <smueller@suse.com>
Mon, 4 Feb 2019 14:31:25 +0000 (15:31 +0100)
committerStephan Müller <smueller@suse.com>
Thu, 4 Jul 2019 14:19:26 +0000 (16:19 +0200)
Currently it's not easily possible to mock a selection during table
action tests, that's why I added a method that is used to create the
selection that is used through out the table action scenario tests.
You can simply overwrite it to get a different base object as selection.

Fixes: https://tracker.ceph.com/issues/36722
Signed-off-by: Stephan Müller <smueller@suse.com>
src/pybind/mgr/dashboard/frontend/src/testing/unit-test-helper.ts

index 18888b48aa887274dc127770fff9beab000d7533..7f432d5d3c05b3c48adedef59c103041830fa89f 100644 (file)
@@ -63,6 +63,11 @@ export class PermissionHelper {
     return this.tableActions;
   }
 
+  // Overwrite if needed
+  createSelection(): object {
+    return {};
+  }
+
   testScenarios({
     fn,
     empty,
@@ -78,17 +83,19 @@ export class PermissionHelper {
   }) {
     this.testScenario(
       // 'multiple selections'
-      [{}, {}],
+      [this.createSelection(), this.createSelection()],
       fn,
       _.isUndefined(multiple) ? empty : multiple
     );
+    const executing = this.createSelection();
+    executing['cdExecuting'] = 'someAction';
     this.testScenario(
       // 'select executing item'
-      [{ cdExecuting: 'someAction' }],
+      [executing],
       fn,
       _.isUndefined(singleExecuting) ? single : singleExecuting
     );
-    this.testScenario([{}], fn, single); // 'select non-executing item'
+    this.testScenario([this.createSelection()], fn, single); // 'select non-executing item'
     this.testScenario([], fn, empty); // 'no selection'
   }