Add tests peers.show

This commit is contained in:
Michael Klein 2022-10-13 15:42:25 +02:00
parent d9b4f5dab4
commit e8f2024e43
11 changed files with 185 additions and 12 deletions

View File

@ -59,7 +59,7 @@
</Action> </Action>
{{/if}} {{/if}}
<Action <Action
data-test-edit-action data-test-view-action
@href={{href-to "dc.peers.show" item.Name}} @href={{href-to "dc.peers.show" item.Name}}
> >
<BlockSlot @name="label"> <BlockSlot @name="label">

View File

@ -1,19 +1,19 @@
export const selectors = { export const selectors = {
$: '.consul-peer-list', $: ".consul-peer-list",
collection: { collection: {
$: '[data-test-list-row]', $: "[data-test-list-row]",
peer: { peer: {
$: 'li', $: "li",
name: { name: {
$: '[data-test-peer]' $: "[data-test-peer]",
} },
}, },
} },
}; };
export default (collection, isPresent, attribute, actions) => () => { export default (collection, isPresent, attribute, actions) => () => {
return collection(`${selectors.$} ${selectors.collection.$}`, { return collection(`${selectors.$} ${selectors.collection.$}`, {
peer: isPresent(selectors.collection.peer.$), peer: isPresent(selectors.collection.peer.$),
name: attribute('data-test-peer', selectors.collection.peer.name.$), name: attribute("data-test-peer", selectors.collection.peer.name.$),
...actions(['regenerate', 'delete']), ...actions(["regenerate", "delete", "view"]),
}); });
}; };

View File

@ -2,7 +2,7 @@
{{#if (gt route.model.items.length 0)}} {{#if (gt route.model.items.length 0)}}
<Consul::Peer::Address::List @items={{route.model.items}} /> <Consul::Peer::Address::List @items={{route.model.items}} />
{{else}} {{else}}
<EmptyState @login={{route.model.app.login.open}}> <EmptyState @login={{route.model.app.login.open}} data-test-addresses-empty>
<BlockSlot @name="header"> <BlockSlot @name="header">
<h2> <h2>
{{t "routes.dc.peers.show.addresses.empty.header"}} {{t "routes.dc.peers.show.addresses.empty.header"}}

View File

@ -76,7 +76,10 @@
</li> </li>
</VerticalCollection> </VerticalCollection>
{{else}} {{else}}
<EmptyState @login={{route.model.app.login.open}}> <EmptyState
@login={{route.model.app.login.open}}
data-test-exported-services-empty
>
<BlockSlot @name="header"> <BlockSlot @name="header">
<h2> <h2>
{{t {{t

View File

@ -82,7 +82,10 @@
/> />
</collection.Collection> </collection.Collection>
<collection.Empty> <collection.Empty>
<EmptyState @login={{route.model.app.login.open}}> <EmptyState
@login={{route.model.app.login.open}}
data-test-imported-services-empty
>
<BlockSlot @name="header"> <BlockSlot @name="header">
<h2> <h2>
{{t {{t

View File

@ -0,0 +1,136 @@
@setupApplcationTest
Feature: dc / peers / show: Peers show
Scenario: Dialer side tabs
And 1 datacenter model with the value "dc-1"
And 1 peer models from yaml
---
Name: a-peer
State: ACTIVE
# dialer side
PeerID: null
---
When I visit the peers page for yaml
---
dc: dc-1
---
And I click actions on the peers
And I click view on the peers
Then the url should be /dc-1/peers/a-peer/imported-services
Then I see importedServicesIsVisible on the tabs
And I see exportedServicesIsVisible on the tabs
And I don't see addressesIsVisible on the tabs
Scenario: Receiver side tabs
And 1 datacenter model with the value "dc-1"
And 1 peer models from yaml
---
Name: a-peer
State: ACTIVE
# receiver side
PeerID: 'some-peer'
---
When I visit the peers page for yaml
---
dc: dc-1
---
And I click actions on the peers
And I click view on the peers
Then the url should be /dc-1/peers/a-peer/imported-services
Then I see importedServicesIsVisible on the tabs
And I see exportedServicesIsVisible on the tabs
And I see addressesIsVisible on the tabs
Scenario: Imported Services Empty
And 1 datacenter model with the value "dc-1"
And 1 peer models from yaml
---
Name: a-peer
State: ACTIVE
---
And 0 service models
When I visit the peer page for yaml
---
dc: dc-1
peer: a-peer
---
Then I see the "[data-test-imported-services-empty]" element
Scenario: Imported Services not empty
And 1 datacenter model with the value "dc-1"
And 1 peer models from yaml
---
Name: a-peer
State: ACTIVE
---
And 1 service models from yaml
---
Name: 'service-for-peer-a'
---
When I visit the peer page for yaml
---
dc: dc-1
peer: a-peer
---
Then I don't see the "[data-test-imported-services-empty]" element
Scenario: Exported Services Empty
And 1 datacenter model with the value "dc-1"
And 1 peer models from yaml
---
Name: a-peer
State: ACTIVE
---
And 0 service models
When I visitExported the peer page for yaml
---
dc: dc-1
peer: a-peer
---
Then I see the "[data-test-exported-services-empty]" element
Scenario: Exported Services not empty
And 1 datacenter model with the value "dc-1"
And 1 peer models from yaml
---
Name: a-peer
State: ACTIVE
---
And 1 service models from yaml
---
Name: 'service-for-peer-a'
---
When I visitExported the peer page for yaml
---
dc: dc-1
peer: a-peer
---
Then I don't see the "[data-test-exported-services-empty]" element
Scenario: Addresses Empty
And 1 datacenter model with the value "dc-1"
And 1 peer models from yaml
---
Name: a-peer
State: ACTIVE
PeerServerAddresses: null
---
When I visitAddresses the peer page for yaml
---
dc: dc-1
peer: a-peer
---
Then I see the "[data-test-addresses-empty]" element
Scenario: Addresses Not Empty
And 1 datacenter model with the value "dc-1"
And 1 peer models from yaml
---
Name: a-peer
State: ACTIVE
---
When I visitAddresses the peer page for yaml
---
dc: dc-1
peer: a-peer
---
Then I don't see the "[data-test-addresses-empty]" element

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

@ -75,6 +75,7 @@ import intention from 'consul-ui/tests/pages/dc/intentions/edit';
import nspaces from 'consul-ui/tests/pages/dc/nspaces/index'; import nspaces from 'consul-ui/tests/pages/dc/nspaces/index';
import nspace from 'consul-ui/tests/pages/dc/nspaces/edit'; import nspace from 'consul-ui/tests/pages/dc/nspaces/edit';
import peers from 'consul-ui/tests/pages/dc/peers/index'; import peers from 'consul-ui/tests/pages/dc/peers/index';
import peersShow from 'consul-ui/tests/pages/dc/peers/show';
// utils // utils
const deletable = createDeletable(clickable); const deletable = createDeletable(clickable);
@ -234,6 +235,7 @@ export default {
nspace(visitable, submitable, deletable, cancelable, policySelector, roleSelector) nspace(visitable, submitable, deletable, cancelable, policySelector, roleSelector)
), ),
peers: create(peers(visitable, creatable, consulPeerList, popoverSelect)), peers: create(peers(visitable, creatable, consulPeerList, popoverSelect)),
peer: create(peersShow(visitable)),
settings: create(settings(visitable, submitable, isPresent)), settings: create(settings(visitable, submitable, isPresent)),
routingConfig: create(routingConfig(visitable, text)), routingConfig: create(routingConfig(visitable, text)),
}; };

View File

@ -1,7 +1,10 @@
import tabgroup from 'consul-ui/components/tab-nav/pageobject';
export default function (visitable, creatable, items, popoverSelect) { export default function (visitable, creatable, items, popoverSelect) {
return creatable({ return creatable({
visit: visitable('/:dc/peers'), visit: visitable('/:dc/peers'),
peers: items(), peers: items(),
sort: popoverSelect('[data-test-sort-control]'), sort: popoverSelect('[data-test-sort-control]'),
tabs: tabgroup('tab', ['imported-services', 'exported-services', 'addresses']),
}); });
} }

View File

@ -0,0 +1,8 @@
export default function (visitable) {
return {
visit: visitable('/:dc/peers/:peer'),
visitExported: visitable('/:dc/peers/:peer/exported-services'),
visitImported: visitable('/:dc/peers/:peer/imported-services'),
visitAddresses: visitable('/:dc/peers/:peer/addresses'),
};
}

View File

@ -29,5 +29,13 @@ export default function (scenario, pages, set, reset) {
// do I absolutely definitely need that all the time? // do I absolutely definitely need that all the time?
return set(pages[name]).visit(data); return set(pages[name]).visit(data);
} }
)
.when(
['I $method the $name page for yaml\n$yaml', 'I $method the $name page for json\n$json'],
function (method, name, data) {
reset();
return set(pages[name])[method](data);
}
); );
} }