From c5b2e17f04fa4fbd869a781cb52ee95b1dd527bd Mon Sep 17 00:00:00 2001 From: John Cowen Date: Mon, 9 Jul 2018 15:51:01 +0100 Subject: [PATCH] Add tests that break when you request a folder without a trailing slash --- .../acceptance/dc/kvs/trailing-slash.feature | 19 +++++++++++++++++++ .../steps/dc/kvs/trailing-slash-steps.js | 10 ++++++++++ ui-v2/tests/pages/dc/kv/index.js | 2 +- ui-v2/tests/steps.js | 9 +++++++++ 4 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 ui-v2/tests/acceptance/dc/kvs/trailing-slash.feature create mode 100644 ui-v2/tests/acceptance/steps/dc/kvs/trailing-slash-steps.js diff --git a/ui-v2/tests/acceptance/dc/kvs/trailing-slash.feature b/ui-v2/tests/acceptance/dc/kvs/trailing-slash.feature new file mode 100644 index 000000000..9a999f2d8 --- /dev/null +++ b/ui-v2/tests/acceptance/dc/kvs/trailing-slash.feature @@ -0,0 +1,19 @@ +@setupApplicationTest +Feature: dc / kvs / trailing slash + Scenario: I have 10 folders + Given 1 datacenter model with the value "datacenter" + And 10 kv models from yaml + When I visit the kvs page for yaml + --- + dc: datacenter + kv: foo/bar + --- + Then the url should be /datacenter/kv/foo/bar + And the last GET request was made to "/v1/kv/foo/bar/?keys&dc=datacenter&separator=%2F" + When I visit the kvs page for yaml + --- + dc: datacenter + kv: foo/bar/ + --- + Then the url should be /datacenter/kv/foo/bar/ + And the last GET request was made to "/v1/kv/foo/bar/?keys&dc=datacenter&separator=%2F" diff --git a/ui-v2/tests/acceptance/steps/dc/kvs/trailing-slash-steps.js b/ui-v2/tests/acceptance/steps/dc/kvs/trailing-slash-steps.js new file mode 100644 index 000000000..a7eff3228 --- /dev/null +++ b/ui-v2/tests/acceptance/steps/dc/kvs/trailing-slash-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/kv/index.js b/ui-v2/tests/pages/dc/kv/index.js index 27c3dda55..8a5856940 100644 --- a/ui-v2/tests/pages/dc/kv/index.js +++ b/ui-v2/tests/pages/dc/kv/index.js @@ -1,6 +1,6 @@ export default function(visitable, deletable, creatable, clickable, attribute, collection) { return creatable({ - visit: visitable('/:dc/kv'), + visit: visitable(['/:dc/kv/:kv', '/:dc/kv'], str => str), kvs: collection( '[data-test-tabular-row]', deletable({ diff --git a/ui-v2/tests/steps.js b/ui-v2/tests/steps.js index f38e09d59..2390232e4 100644 --- a/ui-v2/tests/steps.js +++ b/ui-v2/tests/steps.js @@ -241,6 +241,15 @@ export default function(assert) { ); assert.equal(request.url, url, `Expected the request url to be ${url}, was ${request.url}`); }) + .then('the last $method request was made to "$url"', function(method, url) { + const request = api.server.history + .slice(0) + .reverse() + .find(function(item) { + return item.method === method; + }); + assert.equal(request.url, url, `Expected the request url to be ${url}, was ${request.url}`); + }) .then('the url should be $url', function(url) { // TODO: nice! $url should be wrapped in "" if (url === "''") {