From 3325872daf0466f8ddb76dc00bdf15eeb1ee7359 Mon Sep 17 00:00:00 2001 From: John Cowen Date: Thu, 21 Jun 2018 12:44:32 +0100 Subject: [PATCH] Add a beforeModel hook at dc/index to auto transition to services --- ui-v2/app/routes/dc/index.js | 7 +++++++ ui-v2/tests/acceptance/dc/forwarding.feature | 12 ++++++++++++ ui-v2/tests/acceptance/steps/dc/forwarding-steps.js | 10 ++++++++++ ui-v2/tests/pages/dc.js | 2 +- ui-v2/tests/unit/routes/dc/index-test.js | 11 +++++++++++ 5 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 ui-v2/app/routes/dc/index.js create mode 100644 ui-v2/tests/acceptance/dc/forwarding.feature create mode 100644 ui-v2/tests/acceptance/steps/dc/forwarding-steps.js create mode 100644 ui-v2/tests/unit/routes/dc/index-test.js diff --git a/ui-v2/app/routes/dc/index.js b/ui-v2/app/routes/dc/index.js new file mode 100644 index 000000000..8ff228e5c --- /dev/null +++ b/ui-v2/app/routes/dc/index.js @@ -0,0 +1,7 @@ +import Route from '@ember/routing/route'; + +export default Route.extend({ + beforeModel: function() { + this.transitionTo('dc.services'); + }, +}); diff --git a/ui-v2/tests/acceptance/dc/forwarding.feature b/ui-v2/tests/acceptance/dc/forwarding.feature new file mode 100644 index 000000000..5ba35d01d --- /dev/null +++ b/ui-v2/tests/acceptance/dc/forwarding.feature @@ -0,0 +1,12 @@ +@setupApplicationTest +Feature: dc forwarding + In order to arrive at a useful page when only specifying a dc in the url + As a user + I should be redirected to the services page for the dc + Scenario: Arriving at the datacenter index page with no other url info + Given 1 datacenter model with the value "datacenter" + When I visit the dcs page for yaml + --- + dc: datacenter + --- + Then the url should be /datacenter/services diff --git a/ui-v2/tests/acceptance/steps/dc/forwarding-steps.js b/ui-v2/tests/acceptance/steps/dc/forwarding-steps.js new file mode 100644 index 000000000..960cdf533 --- /dev/null +++ b/ui-v2/tests/acceptance/steps/dc/forwarding-steps.js @@ -0,0 +1,10 @@ +import steps from '../steps'; + +// step definitions that are shared between features should be moved to the +// tests/acceptance/steps/steps.js file + +export default function(assert) { + return steps(assert).then('I should find a file', function() { + assert.ok(true, this.step); + }); +} diff --git a/ui-v2/tests/pages/dc.js b/ui-v2/tests/pages/dc.js index f181c0b4c..ad4eeb9a3 100644 --- a/ui-v2/tests/pages/dc.js +++ b/ui-v2/tests/pages/dc.js @@ -1,7 +1,7 @@ import { create, visitable, attribute, collection, clickable } from 'ember-cli-page-object'; export default create({ - visit: visitable('/:dc/services/'), + visit: visitable('/:dc/'), dcs: collection('[data-test-datacenter-picker]'), showDatacenters: clickable('[data-test-datacenter-selected]'), selectedDc: attribute('data-test-datacenter-selected', '[data-test-datacenter-selected]'), diff --git a/ui-v2/tests/unit/routes/dc/index-test.js b/ui-v2/tests/unit/routes/dc/index-test.js new file mode 100644 index 000000000..05fe014c5 --- /dev/null +++ b/ui-v2/tests/unit/routes/dc/index-test.js @@ -0,0 +1,11 @@ +import { moduleFor, test } from 'ember-qunit'; + +moduleFor('route:dc/index', 'Unit | Route | dc/index', { + // Specify the other units that are required for this test. + // needs: ['controller:foo'] +}); + +test('it exists', function(assert) { + let route = this.subject(); + assert.ok(route); +});