From: Stephan Müller Date: Mon, 4 Feb 2019 14:31:25 +0000 (+0100) Subject: mgr/dashboard: Allow test selection overwrite X-Git-Tag: v15.1.0~2271^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b20e9c8db813c8b9dee76c525936cb0b0697b25a;p=ceph.git mgr/dashboard: Allow test selection overwrite 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 --- diff --git a/src/pybind/mgr/dashboard/frontend/src/testing/unit-test-helper.ts b/src/pybind/mgr/dashboard/frontend/src/testing/unit-test-helper.ts index 18888b48aa88..7f432d5d3c05 100644 --- a/src/pybind/mgr/dashboard/frontend/src/testing/unit-test-helper.ts +++ b/src/pybind/mgr/dashboard/frontend/src/testing/unit-test-helper.ts @@ -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' }