Add tests that break when you request a folder without a trailing slash

This commit is contained in:
John Cowen 2018-07-09 15:51:01 +01:00
parent 488c147ade
commit c5b2e17f04
4 changed files with 39 additions and 1 deletions

View file

@ -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"

View file

@ -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);
});
}

View file

@ -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({

View file

@ -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 === "''") {