From b20e9c8db813c8b9dee76c525936cb0b0697b25a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Stephan=20M=C3=BCller?= Date: Mon, 4 Feb 2019 15:31:25 +0100 Subject: [PATCH] mgr/dashboard: Allow test selection overwrite MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- .../frontend/src/testing/unit-test-helper.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) 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 18888b48aa8..7f432d5d3c0 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' } -- 2.39.5