diff --git a/ui/packages/consul-peerings/app/components/consul/peer/list/index.hbs b/ui/packages/consul-peerings/app/components/consul/peer/list/index.hbs index 1295810fa..d31e1fa15 100644 --- a/ui/packages/consul-peerings/app/components/consul/peer/list/index.hbs +++ b/ui/packages/consul-peerings/app/components/consul/peer/list/index.hbs @@ -46,7 +46,7 @@ as |item index|> {{#if (can "write peer" item=item)}} diff --git a/ui/packages/consul-peerings/app/components/consul/peer/list/test-support.js b/ui/packages/consul-peerings/app/components/consul/peer/list/test-support.js index effb966f9..126e444b9 100644 --- a/ui/packages/consul-peerings/app/components/consul/peer/list/test-support.js +++ b/ui/packages/consul-peerings/app/components/consul/peer/list/test-support.js @@ -10,9 +10,10 @@ export const selectors = { }, } }; -export default (collection, isPresent, attribute) => () => { +export default (collection, isPresent, attribute, actions) => () => { return collection(`${selectors.$} ${selectors.collection.$}`, { peer: isPresent(selectors.collection.peer.$), name: attribute('data-test-peer', selectors.collection.peer.name.$), + ...actions(['regenerate', 'delete']), }); }; diff --git a/ui/packages/consul-peerings/app/templates/dc/peers/index.hbs b/ui/packages/consul-peerings/app/templates/dc/peers/index.hbs index bdde40815..2370fa76c 100644 --- a/ui/packages/consul-peerings/app/templates/dc/peers/index.hbs +++ b/ui/packages/consul-peerings/app/templates/dc/peers/index.hbs @@ -73,6 +73,7 @@ as |sort filters items|}} @aria={{hash label="Add peer connection" }} + class="peer-create-modal" as |modal|> {{did-insert (set this 'create' modal)}} diff --git a/ui/packages/consul-ui/tests/acceptance/dc/peers/create.feature b/ui/packages/consul-ui/tests/acceptance/dc/peers/create.feature new file mode 100644 index 000000000..4cfe29db7 --- /dev/null +++ b/ui/packages/consul-ui/tests/acceptance/dc/peers/create.feature @@ -0,0 +1,43 @@ +@setupApplicationTest +Feature: dc / peers / create: Peer Create Token + Scenario: + Given 1 datacenter model with the value "dc-1" + And the url "/v1/peering/token" responds with from yaml + --- + body: + PeeringToken: an-encoded-token + --- + When I visit the peers page for yaml + --- + dc: dc-1 + --- + Then the url should be /dc-1/peers + And I click create + Then I fill in with yaml + --- + Name: new-peer + --- + When I click ".peer-create-modal .modal-dialog-footer button" + Then a POST request was made to "/v1/peering/token" from yaml + --- + body: + PeerName: new-peer + --- + Then I see the text "an-encoded-token" in ".consul-peer-form-generate code" + When I click ".consul-peer-form-generate button[type=reset]" + And the url "/v1/peering/token" responds with from yaml + --- + body: + PeeringToken: another-encoded-token + --- + Then I fill in with yaml + --- + Name: another-new-peer + --- + When I click ".peer-create-modal .modal-dialog-footer button" + Then a POST request was made to "/v1/peering/token" from yaml + --- + body: + PeerName: another-new-peer + --- + Then I see the text "another-encoded-token" in ".consul-peer-form-generate code" diff --git a/ui/packages/consul-ui/tests/acceptance/dc/peers/delete.feature b/ui/packages/consul-ui/tests/acceptance/dc/peers/delete.feature new file mode 100644 index 000000000..7cd6b4b31 --- /dev/null +++ b/ui/packages/consul-ui/tests/acceptance/dc/peers/delete.feature @@ -0,0 +1,47 @@ +@setupApplicationTest +Feature: dc / peers / delete: Deleting items with confirmations, success and error notifications + Background: + Given 1 datacenter model with the value "datacenter" + Scenario: Deleting a peer model from the listing page + Given 1 peer model from yaml + --- + Name: peer-name + State: ACTIVE + --- + When I visit the peers page for yaml + --- + dc: datacenter + --- + And I click actions on the peers + And I click delete on the peers + And I click confirmDelete on the peers + Then a DELETE request was made to "/v1/peering/peer-name" + And "[data-notification]" has the "notification-delete" class + And "[data-notification]" has the "success" class + Scenario: Deleting a peer from the peer listing page with error + Given 1 peer model from yaml + --- + Name: peer-name + State: ACTIVE + --- + When I visit the peers page for yaml + --- + dc: datacenter + --- + Given the url "/v1/peering/peer-name" responds with a 500 status + And I click actions on the peers + And I click delete on the peers + And I click confirmDelete on the peers + And "[data-notification]" has the "notification-update" class + And "[data-notification]" has the "error" class + Scenario: A Peer currently deleting cannot be deleted + Given 1 peer model from yaml + --- + Name: peer-name + State: DELETING + --- + When I visit the peers page for yaml + --- + dc: datacenter + --- + And I don't see actions on the peers diff --git a/ui/packages/consul-ui/tests/acceptance/dc/peers/establish.feature b/ui/packages/consul-ui/tests/acceptance/dc/peers/establish.feature new file mode 100644 index 000000000..f037d4572 --- /dev/null +++ b/ui/packages/consul-ui/tests/acceptance/dc/peers/establish.feature @@ -0,0 +1,30 @@ +@setupApplicationTest +Feature: dc / peers / establish: Peer Establish Peering + Scenario: + Given 1 datacenter model with the value "dc-1" + And the url "/v1/peering/token" responds with from yaml + --- + body: + PeeringToken: an-encoded-token + --- + When I visit the peers page for yaml + --- + dc: dc-1 + --- + Then the url should be /dc-1/peers + And I click create + When I click "[data-test-tab=tab_establish-peering] button" + Then I fill in with yaml + --- + Name: new-peer + Token: an-encoded-token + --- + When I click ".peer-create-modal .modal-dialog-footer button" + Then a POST request was made to "/v1/peering/establish" from yaml + --- + body: + PeerName: new-peer + PeeringToken: an-encoded-token + --- + And "[data-notification]" has the "notification-update" class + And "[data-notification]" has the "success" class diff --git a/ui/packages/consul-ui/tests/acceptance/dc/peers/regenerate.feature b/ui/packages/consul-ui/tests/acceptance/dc/peers/regenerate.feature new file mode 100644 index 000000000..a925f7887 --- /dev/null +++ b/ui/packages/consul-ui/tests/acceptance/dc/peers/regenerate.feature @@ -0,0 +1,21 @@ +@setupApplicationTest +Feature: dc / peers / regenerate: Regenerate Peer Token + Scenario: + Given 1 datacenter model with the value "datacenter" + And 1 peer model from yaml + --- + Name: peer-name + State: ACTIVE + --- + And the url "/v1/peering/token" responds with from yaml + --- + body: + PeeringToken: an-encoded-token + --- + When I visit the peers page for yaml + --- + dc: datacenter + --- + And I click actions on the peers + And I click regenerate on the peers + Then I see the text "an-encoded-token" in ".consul-peer-form-generate code" diff --git a/ui/packages/consul-ui/tests/acceptance/steps/dc/peers/create-steps.js b/ui/packages/consul-ui/tests/acceptance/steps/dc/peers/create-steps.js new file mode 100644 index 000000000..06173e1e0 --- /dev/null +++ b/ui/packages/consul-ui/tests/acceptance/steps/dc/peers/create-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/packages/consul-ui/tests/acceptance/steps/dc/peers/delete-steps.js b/ui/packages/consul-ui/tests/acceptance/steps/dc/peers/delete-steps.js new file mode 100644 index 000000000..06173e1e0 --- /dev/null +++ b/ui/packages/consul-ui/tests/acceptance/steps/dc/peers/delete-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/packages/consul-ui/tests/acceptance/steps/dc/peers/establish-steps.js b/ui/packages/consul-ui/tests/acceptance/steps/dc/peers/establish-steps.js new file mode 100644 index 000000000..06173e1e0 --- /dev/null +++ b/ui/packages/consul-ui/tests/acceptance/steps/dc/peers/establish-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/packages/consul-ui/tests/acceptance/steps/dc/peers/regenerate-steps.js b/ui/packages/consul-ui/tests/acceptance/steps/dc/peers/regenerate-steps.js new file mode 100644 index 000000000..06173e1e0 --- /dev/null +++ b/ui/packages/consul-ui/tests/acceptance/steps/dc/peers/regenerate-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/packages/consul-ui/tests/pages.js b/ui/packages/consul-ui/tests/pages.js index 6bded9444..c3ceb2af5 100644 --- a/ui/packages/consul-ui/tests/pages.js +++ b/ui/packages/consul-ui/tests/pages.js @@ -111,7 +111,7 @@ const consulNspaceList = consulNspaceListFactory( text, morePopoverMenu ); -const consulPeerList = consulPeerListFactory(collection, isPresent, attribute); +const consulPeerList = consulPeerListFactory(collection, isPresent, attribute, morePopoverMenu); const consulKvList = consulKvListFactory(collection, clickable, attribute, deletable); const consulTokenList = consulTokenListFactory( collection,