From ed286585e92d9813f451a6999623d8fa75b2ded9 Mon Sep 17 00:00:00 2001 From: John Cowen Date: Wed, 4 Jul 2018 13:21:30 +0100 Subject: [PATCH] Add some low hanging intention tests, basically add intentions to others 1. There are various things tests that can just have intentions added into them, like filters and such like, add intentions to these 2. Start thinking about being able to negate steps easily, which will lead on to a cleanup of the steps --- ui-v2/app/templates/dc/intentions/index.hbs | 6 +- .../acceptance/components/acl-filter.feature | 2 +- .../components/intention-filter.feature | 55 +++++++++++++++++++ .../acceptance/components/text-input.feature | 2 +- .../tests/acceptance/page-navigation.feature | 32 ++++++----- .../components/intention-filter-steps.js | 10 ++++ ui-v2/tests/acceptance/submit-blank.feature | 11 ++-- ui-v2/tests/pages.js | 2 + .../pages/components/intention-filter.js | 9 +++ ui-v2/tests/pages/components/page.js | 2 +- ui-v2/tests/pages/dc/intentions/index.js | 16 ++++++ ui-v2/tests/steps.js | 6 +- 12 files changed, 126 insertions(+), 27 deletions(-) create mode 100644 ui-v2/tests/acceptance/components/intention-filter.feature create mode 100644 ui-v2/tests/acceptance/steps/components/intention-filter-steps.js create mode 100644 ui-v2/tests/pages/components/intention-filter.js create mode 100644 ui-v2/tests/pages/dc/intentions/index.js diff --git a/ui-v2/app/templates/dc/intentions/index.hbs b/ui-v2/app/templates/dc/intentions/index.hbs index 60ed96a2fe..946524d05f 100644 --- a/ui-v2/app/templates/dc/intentions/index.hbs +++ b/ui-v2/app/templates/dc/intentions/index.hbs @@ -27,7 +27,7 @@ {{/block-slot}} {{#block-slot 'row'}} - + {{#if (eq item.SourceName '*') }} All Services (*) {{else}} @@ -35,10 +35,10 @@ {{/if}} - + {{item.Action}} - + {{#if (eq item.DestinationName '*') }} All Services (*) {{else}} diff --git a/ui-v2/tests/acceptance/components/acl-filter.feature b/ui-v2/tests/acceptance/components/acl-filter.feature index 15ffad0a2c..6d90a68f78 100644 --- a/ui-v2/tests/acceptance/components/acl-filter.feature +++ b/ui-v2/tests/acceptance/components/acl-filter.feature @@ -1,5 +1,5 @@ @setupApplicationTest -Feature: dc / components /acl filter: Acl Filter +Feature: components / acl filter: Acl Filter In order to find the acl token I'm looking for easier As a user I should be able to filter by type and freetext search tokens by name and token diff --git a/ui-v2/tests/acceptance/components/intention-filter.feature b/ui-v2/tests/acceptance/components/intention-filter.feature new file mode 100644 index 0000000000..c797dee40f --- /dev/null +++ b/ui-v2/tests/acceptance/components/intention-filter.feature @@ -0,0 +1,55 @@ +@setupApplicationTest +Feature: components / intention filter: Intention Filter + In order to find the intention I'm looking for easier + As a user + I should be able to filter by 'policy' (allow/deny) and freetext search tokens by source and destination + Scenario: Filtering [Model] + Given 1 datacenter model with the value "dc-1" + And 2 [Model] models + When I visit the [Page] page for yaml + --- + dc: dc-1 + --- + Then the url should be [Url] + + Then I see 2 [Model] models + And I see allIsSelected on the filter + + When I click allow on the filter + Then I see allowIsSelected on the filter + And I see 1 [Model] model + And I see 1 [Model] model with the action "allow" + + When I click deny on the filter + Then I see denyIsSelected on the filter + And I see 1 [Model] model + And I see 1 [Model] model with the action "deny" + + When I click all on the filter + Then I see 2 [Model] models + Then I see allIsSelected on the filter + Then I fill in with yaml + --- + s: alarm + --- + And I see 1 [Model] model + And I see 1 [Model] model with the source "alarm" + Then I fill in with yaml + --- + s: feed + --- + And I see 1 [Model] model + And I see 1 [Model] model with the destination "feed" + Then I fill in with yaml + --- + s: transmitter + --- + And I see 2 [Model] models + And I see 1 [Model] model with the source "transmitter" + And I see 1 [Model] model with the destination "transmitter" + + Where: + --------------------------------------------- + | Model | Page | Url | + | intention | intentions | /dc-1/intentions | + --------------------------------------------- diff --git a/ui-v2/tests/acceptance/components/text-input.feature b/ui-v2/tests/acceptance/components/text-input.feature index 02bc044138..e8d531b221 100644 --- a/ui-v2/tests/acceptance/components/text-input.feature +++ b/ui-v2/tests/acceptance/components/text-input.feature @@ -1,5 +1,5 @@ @setupApplicationTest -Feature: Text input +Feature: components / text-input: Text input Background: Given 1 datacenter model with the value "dc-1" Scenario: diff --git a/ui-v2/tests/acceptance/page-navigation.feature b/ui-v2/tests/acceptance/page-navigation.feature index 360b910757..73d83beb18 100644 --- a/ui-v2/tests/acceptance/page-navigation.feature +++ b/ui-v2/tests/acceptance/page-navigation.feature @@ -16,13 +16,14 @@ Feature: Page Navigation When I click [Link] on the navigation Then the url should be [Url] Where: - -------------------------------------- - | Link | Url | - | nodes | /dc-1/nodes | - | kvs | /dc-1/kv | - | acls | /dc-1/acls | - | settings | /settings | - -------------------------------------- + ---------------------------------------- + | Link | Url | + | nodes | /dc-1/nodes | + | kvs | /dc-1/kv | + | acls | /dc-1/acls | + | intentions | /dc-1/intentions | + | settings | /settings | + ---------------------------------------- Scenario: Clicking a [Item] in the [Model] listing When I visit the [Model] page for yaml --- @@ -31,13 +32,14 @@ Feature: Page Navigation When I click [Item] on the [Model] Then the url should be [Url] Where: - -------------------------------------------------------- - | Item | Model | Url | - | service | services | /dc-1/services/service-0 | - | node | nodes | /dc-1/nodes/node-0 | - | kv | kvs | /dc-1/kv/necessitatibus-0/edit | - | acl | acls | /dc-1/acls/anonymous | - -------------------------------------------------------- + ------------------------------------------------------------------------------------- + | Item | Model | Url | + | service | services | /dc-1/services/service-0 | + | node | nodes | /dc-1/nodes/node-0 | + | kv | kvs | /dc-1/kv/necessitatibus-0/edit | + | intention | intentions | /dc-1/intentions/ee52203d-989f-4f7a-ab5a-2bef004164ca | + | acl | acls | /dc-1/acls/anonymous | + ------------------------------------------------------------------------------------- @ignore - Scenario: Clicking a kv in the kvs listing, without depending on the salt ^ + Scenario: Clicking items in the listings, without depending on the salt ^ Then ok diff --git a/ui-v2/tests/acceptance/steps/components/intention-filter-steps.js b/ui-v2/tests/acceptance/steps/components/intention-filter-steps.js new file mode 100644 index 0000000000..960cdf533d --- /dev/null +++ b/ui-v2/tests/acceptance/steps/components/intention-filter-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/acceptance/submit-blank.feature b/ui-v2/tests/acceptance/submit-blank.feature index a8024a384d..444c497f3e 100644 --- a/ui-v2/tests/acceptance/submit-blank.feature +++ b/ui-v2/tests/acceptance/submit-blank.feature @@ -13,11 +13,12 @@ Feature: submit blank And I submit Then the url should be /datacenter/[Slug]/create Where: - ------------------ - | Model | Slug | - | kv | kv | - | acl | acls | - ------------------ + -------------------------- + | Model | Slug | + | kv | kv | + | acl | acls | + | intention | intentions | + -------------------------- @ignore Scenario: The button is disabled Then ok diff --git a/ui-v2/tests/pages.js b/ui-v2/tests/pages.js index 599da15a38..99366a40c6 100644 --- a/ui-v2/tests/pages.js +++ b/ui-v2/tests/pages.js @@ -9,6 +9,7 @@ import kvs from 'consul-ui/tests/pages/dc/kv/index'; import kv from 'consul-ui/tests/pages/dc/kv/edit'; import acls from 'consul-ui/tests/pages/dc/acls/index'; import acl from 'consul-ui/tests/pages/dc/acls/edit'; +import intentions from 'consul-ui/tests/pages/dc/intentions/index'; import intention from 'consul-ui/tests/pages/dc/intentions/edit'; export default { @@ -23,5 +24,6 @@ export default { kv, acls, acl, + intentions, intention, }; diff --git a/ui-v2/tests/pages/components/intention-filter.js b/ui-v2/tests/pages/components/intention-filter.js new file mode 100644 index 0000000000..39a835e6d4 --- /dev/null +++ b/ui-v2/tests/pages/components/intention-filter.js @@ -0,0 +1,9 @@ +import { triggerable } from 'ember-cli-page-object'; +import radiogroup from 'consul-ui/tests/lib/page-object/radiogroup'; +export default { + ...radiogroup('action', ['', 'allow', 'deny']), + ...{ + scope: '[data-test-intention-filter]', + search: triggerable('keypress', '[name="s"]'), + }, +}; diff --git a/ui-v2/tests/pages/components/page.js b/ui-v2/tests/pages/components/page.js index 507dcaca96..aa634c7b1b 100644 --- a/ui-v2/tests/pages/components/page.js +++ b/ui-v2/tests/pages/components/page.js @@ -1,6 +1,6 @@ import { clickable } from 'ember-cli-page-object'; export default { - navigation: ['services', 'nodes', 'kvs', 'acls', 'docs', 'settings'].reduce( + navigation: ['services', 'nodes', 'kvs', 'acls', 'intentions', 'docs', 'settings'].reduce( function(prev, item, i, arr) { const key = item; return Object.assign({}, prev, { diff --git a/ui-v2/tests/pages/dc/intentions/index.js b/ui-v2/tests/pages/dc/intentions/index.js new file mode 100644 index 0000000000..b5d2a93722 --- /dev/null +++ b/ui-v2/tests/pages/dc/intentions/index.js @@ -0,0 +1,16 @@ +import { create, visitable, collection, attribute, clickable } from 'ember-cli-page-object'; + +import filter from 'consul-ui/tests/pages/components/intention-filter'; +export default create({ + visit: visitable('/:dc/intentions'), + intentions: collection('[data-test-tabular-row]', { + source: attribute('data-test-intention-source', '[data-test-intention-source]'), + destination: attribute('data-test-intention-destination', '[data-test-intention-destination]'), + action: attribute('data-test-intention-action', '[data-test-intention-action]'), + intention: clickable('a'), + actions: clickable('label'), + delete: clickable('[data-test-delete]'), + confirmDelete: clickable('button.type-delete'), + }), + filter: filter, +}); diff --git a/ui-v2/tests/steps.js b/ui-v2/tests/steps.js index 901843bd12..2a61c74555 100644 --- a/ui-v2/tests/steps.js +++ b/ui-v2/tests/steps.js @@ -5,6 +5,8 @@ import getDictionary from '@hashicorp/ember-cli-api-double/dictionary'; import pages from 'consul-ui/tests/pages'; import api from 'consul-ui/tests/helpers/api'; +const dont = `( don't| shouldn't| can't)?`; + const create = function(number, name, value) { // don't return a promise here as // I don't need it to wait @@ -240,7 +242,9 @@ export default function(assert) { assert.equal(len, num, `Expected ${num} ${model}s, saw ${len}`); }) - .then(['I see $num $model model with the $property "$value"'], function( + // TODO: I${ dont } see + .then([`I see $num $model model[s]? with the $property "$value"`], function( + // negate, num, model, property,