Start purifying page objects
This commit is contained in:
parent
75cb5f695e
commit
b7c806a061
|
@ -35,7 +35,7 @@
|
|||
{{# if (and (not create) (not-eq item.ID 'anonymous')) }}
|
||||
{{#confirmation-dialog message='Are you sure you want to delete this ACL token?'}}
|
||||
{{#block-slot 'action' as |confirm|}}
|
||||
<button type="button" class="type-delete" {{action confirm 'delete' item parent}}>Delete</button>
|
||||
<button type="button" data-test-delete class="type-delete" {{action confirm 'delete' item parent}}>Delete</button>
|
||||
{{/block-slot}}
|
||||
{{#block-slot 'dialog' as |execute cancel message|}}
|
||||
<p>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
@setupApplicationTest
|
||||
Feature: dc / acls / delete: ACL Delete
|
||||
Scenario: Delete ACL
|
||||
Scenario: Deleting an ACL from the ACL listing page
|
||||
Given 1 datacenter model with the value "datacenter"
|
||||
And 1 acl model from yaml
|
||||
---
|
||||
|
@ -15,3 +15,18 @@ Feature: dc / acls / delete: ACL Delete
|
|||
And I click delete on the acls
|
||||
And I click confirmDelete on the acls
|
||||
Then a PUT request is made to "/v1/acl/destroy/key?dc=datacenter"
|
||||
Scenario: Deleting an ACL from the ACL detail page
|
||||
Given 1 datacenter model with the value "datacenter"
|
||||
And 1 acl model from yaml
|
||||
---
|
||||
Name: something
|
||||
ID: key
|
||||
---
|
||||
When I visit the acl page for yaml
|
||||
---
|
||||
dc: datacenter
|
||||
acl: something
|
||||
---
|
||||
And I click delete
|
||||
And I click confirmDelete
|
||||
Then a PUT request is made to "/v1/acl/destroy/something?dc=datacenter"
|
||||
|
|
11
ui-v2/tests/lib/page-object/createDeletable.js
Normal file
11
ui-v2/tests/lib/page-object/createDeletable.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
export default function(clickable) {
|
||||
return function(obj) {
|
||||
return {
|
||||
...obj,
|
||||
...{
|
||||
delete: clickable('[data-test-delete]'),
|
||||
confirmDelete: clickable('button.type-delete'),
|
||||
},
|
||||
};
|
||||
};
|
||||
}
|
11
ui-v2/tests/lib/page-object/createSubmitable.js
Normal file
11
ui-v2/tests/lib/page-object/createSubmitable.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
export default function(clickable, is) {
|
||||
return function(obj) {
|
||||
return {
|
||||
...obj,
|
||||
...{
|
||||
submit: clickable('[type=submit]'),
|
||||
submitIsEnabled: is(':not(:disabled)', '[type=submit]'),
|
||||
},
|
||||
};
|
||||
};
|
||||
}
|
|
@ -1,29 +1,44 @@
|
|||
import { create, clickable, is, attribute, collection, text } from 'ember-cli-page-object';
|
||||
import { visitable } from 'consul-ui/tests/lib/page-object/visitable';
|
||||
import createDeletable from 'consul-ui/tests/lib/page-object/createDeletable';
|
||||
import createSubmitable from 'consul-ui/tests/lib/page-object/createSubmitable';
|
||||
|
||||
import page from 'consul-ui/tests/pages/components/page';
|
||||
import radiogroup from 'consul-ui/tests/lib/page-object/radiogroup';
|
||||
|
||||
import index from 'consul-ui/tests/pages/index';
|
||||
import dcs from 'consul-ui/tests/pages/dc';
|
||||
import settings from 'consul-ui/tests/pages/settings';
|
||||
import catalogFilter from 'consul-ui/tests/pages/components/catalog-filter';
|
||||
import services from 'consul-ui/tests/pages/dc/services/index';
|
||||
import service from 'consul-ui/tests/pages/dc/services/show';
|
||||
import nodes from 'consul-ui/tests/pages/dc/nodes/index';
|
||||
import node from 'consul-ui/tests/pages/dc/nodes/show';
|
||||
import kvs from 'consul-ui/tests/pages/dc/kv/index';
|
||||
import kv from 'consul-ui/tests/pages/dc/kv/edit';
|
||||
import aclFilter from 'consul-ui/tests/pages/components/acl-filter';
|
||||
import acls from 'consul-ui/tests/pages/dc/acls/index';
|
||||
import acl from 'consul-ui/tests/pages/dc/acls/edit';
|
||||
import intentionFilter from 'consul-ui/tests/pages/components/intention-filter';
|
||||
import intentions from 'consul-ui/tests/pages/dc/intentions/index';
|
||||
import intention from 'consul-ui/tests/pages/dc/intentions/edit';
|
||||
|
||||
const deletable = createDeletable(clickable);
|
||||
const submitable = createSubmitable(clickable, is);
|
||||
export default {
|
||||
index,
|
||||
dcs,
|
||||
settings,
|
||||
services,
|
||||
service,
|
||||
nodes,
|
||||
node,
|
||||
kvs,
|
||||
kv,
|
||||
acls,
|
||||
acl,
|
||||
intentions,
|
||||
intention,
|
||||
index: create(index(visitable, collection)),
|
||||
dcs: create(dcs(visitable, clickable, attribute, collection)),
|
||||
services: create(services(visitable, clickable, attribute, collection, page, catalogFilter)),
|
||||
service: create(service(visitable, attribute, collection, text, catalogFilter)),
|
||||
nodes: create(nodes(visitable, clickable, attribute, collection, catalogFilter)),
|
||||
node: create(node(visitable, deletable, clickable, attribute, collection, radiogroup)),
|
||||
kvs: create(kvs(visitable, deletable, clickable, attribute, collection)),
|
||||
kv: create(kv(visitable, submitable, deletable)),
|
||||
acls: create(acls(visitable, deletable, clickable, attribute, collection, aclFilter)),
|
||||
acl: create(acl(visitable, submitable, deletable)),
|
||||
intentions: create(
|
||||
intentions(visitable, deletable, clickable, attribute, collection, intentionFilter)
|
||||
),
|
||||
intention: create(intention(visitable, submitable, deletable)),
|
||||
settings: create(settings(visitable, submitable)),
|
||||
};
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
import { create, visitable, attribute, collection, clickable } from 'ember-cli-page-object';
|
||||
|
||||
export default create({
|
||||
export default function(visitable, clickable, attribute, collection) {
|
||||
return {
|
||||
visit: visitable('/:dc/'),
|
||||
dcs: collection('[data-test-datacenter-picker]'),
|
||||
showDatacenters: clickable('[data-test-datacenter-selected]'),
|
||||
selectedDc: attribute('data-test-datacenter-selected', '[data-test-datacenter-selected]'),
|
||||
selectedDatacenter: attribute('data-test-datacenter-selected', '[data-test-datacenter-selected]'),
|
||||
});
|
||||
selectedDatacenter: attribute(
|
||||
'data-test-datacenter-selected',
|
||||
'[data-test-datacenter-selected]'
|
||||
),
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,11 +1,7 @@
|
|||
import { create, clickable, triggerable, is } from 'ember-cli-page-object';
|
||||
import { visitable } from 'consul-ui/tests/lib/page-object/visitable';
|
||||
|
||||
export default create({
|
||||
// custom visitable
|
||||
export default function(visitable, submitable, deletable, triggerable) {
|
||||
return submitable(
|
||||
deletable({
|
||||
visit: visitable(['/:dc/acls/:acl', '/:dc/acls/create']),
|
||||
// fillIn: fillable('input, textarea, [contenteditable]'),
|
||||
name: triggerable('keypress', '[name="name"]'),
|
||||
submit: clickable('[type=submit]'),
|
||||
submitIsEnabled: is(':not(:disabled)', '[type=submit]'),
|
||||
});
|
||||
})
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
import { create, visitable, collection, attribute, clickable } from 'ember-cli-page-object';
|
||||
|
||||
import filter from 'consul-ui/tests/pages/components/acl-filter';
|
||||
export default create({
|
||||
export default function(visitable, deletable, clickable, attribute, collection, filter) {
|
||||
return {
|
||||
visit: visitable('/:dc/acls'),
|
||||
acls: collection('[data-test-tabular-row]', {
|
||||
acls: collection(
|
||||
'[data-test-tabular-row]',
|
||||
deletable({
|
||||
name: attribute('data-test-acl', '[data-test-acl]'),
|
||||
acl: clickable('a'),
|
||||
actions: clickable('label'),
|
||||
delete: clickable('[data-test-delete]'),
|
||||
confirmDelete: clickable('button.type-delete'),
|
||||
}),
|
||||
})
|
||||
),
|
||||
filter: filter,
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
import { create, clickable } from 'ember-cli-page-object';
|
||||
import { visitable } from 'consul-ui/tests/lib/page-object/visitable';
|
||||
|
||||
export default create({
|
||||
// custom visitable
|
||||
export default function(visitable, submitable, deletable) {
|
||||
return submitable(
|
||||
deletable({
|
||||
visit: visitable(['/:dc/intentions/:intention', '/:dc/intentions/create']),
|
||||
submit: clickable('[type=submit]'),
|
||||
});
|
||||
})
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,16 +1,19 @@
|
|||
import { create, visitable, collection, attribute, clickable } from 'ember-cli-page-object';
|
||||
|
||||
import filter from 'consul-ui/tests/pages/components/intention-filter';
|
||||
export default create({
|
||||
export default function(visitable, deletable, clickable, attribute, collection, filter) {
|
||||
return {
|
||||
visit: visitable('/:dc/intentions'),
|
||||
intentions: collection('[data-test-tabular-row]', {
|
||||
intentions: collection(
|
||||
'[data-test-tabular-row]',
|
||||
deletable({
|
||||
source: attribute('data-test-intention-source', '[data-test-intention-source]'),
|
||||
destination: attribute('data-test-intention-destination', '[data-test-intention-destination]'),
|
||||
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,
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,11 +1,7 @@
|
|||
import { create, clickable, is } from 'ember-cli-page-object';
|
||||
import { visitable } from 'consul-ui/tests/lib/page-object/visitable';
|
||||
|
||||
export default create({
|
||||
// custom visitable
|
||||
export default function(visitable, submitable, deletable) {
|
||||
return submitable(
|
||||
deletable({
|
||||
visit: visitable(['/:dc/kv/:kv/edit', '/:dc/kv/create'], str => str),
|
||||
// fillIn: fillable('input, textarea, [contenteditable]'),
|
||||
// name: triggerable('keypress', '[name="additional"]'),
|
||||
submit: clickable('[type=submit]'),
|
||||
submitIsEnabled: is(':not(:disabled)', '[type=submit]'),
|
||||
});
|
||||
})
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
import { create, visitable, collection, attribute, clickable } from 'ember-cli-page-object';
|
||||
|
||||
export default create({
|
||||
export default function(visitable, deletable, clickable, attribute, collection) {
|
||||
return {
|
||||
visit: visitable('/:dc/kv'),
|
||||
kvs: collection('[data-test-tabular-row]', {
|
||||
kvs: collection(
|
||||
'[data-test-tabular-row]',
|
||||
deletable({
|
||||
name: attribute('data-test-kv', '[data-test-kv]'),
|
||||
kv: clickable('a'),
|
||||
actions: clickable('label'),
|
||||
delete: clickable('[data-test-delete]'),
|
||||
confirmDelete: clickable('button.type-delete'),
|
||||
}),
|
||||
});
|
||||
})
|
||||
),
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
import { create, visitable, collection, attribute, clickable } from 'ember-cli-page-object';
|
||||
import filter from 'consul-ui/tests/pages/components/catalog-filter';
|
||||
|
||||
export default create({
|
||||
export default function(visitable, clickable, attribute, collection, filter) {
|
||||
return {
|
||||
visit: visitable('/:dc/nodes'),
|
||||
nodes: collection('[data-test-node]', {
|
||||
name: attribute('data-test-node'),
|
||||
node: clickable('header a'),
|
||||
}),
|
||||
filter: filter,
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
import { create, visitable, collection, attribute, clickable } from 'ember-cli-page-object';
|
||||
|
||||
import radiogroup from 'consul-ui/tests/lib/page-object/radiogroup';
|
||||
export default create({
|
||||
export default function(visitable, deletable, clickable, attribute, collection, radiogroup) {
|
||||
return {
|
||||
visit: visitable('/:dc/nodes/:node'),
|
||||
tabs: radiogroup('tab', ['health-checks', 'services', 'round-trip-time', 'lock-sessions']),
|
||||
healthchecks: collection('[data-test-node-healthcheck]', {
|
||||
|
@ -10,9 +8,11 @@ export default create({
|
|||
services: collection('#services [data-test-tabular-row]', {
|
||||
port: attribute('data-test-service-port', '.port'),
|
||||
}),
|
||||
sessions: collection('#lock-sessions [data-test-tabular-row]', {
|
||||
delete: clickable('[data-test-delete]'),
|
||||
confirmDelete: clickable('button.type-delete'),
|
||||
sessions: collection(
|
||||
'#lock-sessions [data-test-tabular-row]',
|
||||
deletable({
|
||||
TTL: attribute('data-test-session-ttl', '[data-test-session-ttl]'),
|
||||
}),
|
||||
});
|
||||
})
|
||||
),
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
import { create, visitable, collection, attribute, clickable } from 'ember-cli-page-object';
|
||||
|
||||
import page from 'consul-ui/tests/pages/components/page';
|
||||
import filter from 'consul-ui/tests/pages/components/catalog-filter';
|
||||
|
||||
export default create({
|
||||
export default function(visitable, clickable, attribute, collection, page, filter) {
|
||||
return {
|
||||
visit: visitable('/:dc/services'),
|
||||
services: collection('[data-test-service]', {
|
||||
name: attribute('data-test-service'),
|
||||
|
@ -11,6 +7,6 @@ export default create({
|
|||
}),
|
||||
dcs: collection('[data-test-datacenter-picker]'),
|
||||
navigation: page.navigation,
|
||||
|
||||
filter: filter,
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
import { create, visitable, collection, attribute, text } from 'ember-cli-page-object';
|
||||
import filter from 'consul-ui/tests/pages/components/catalog-filter';
|
||||
|
||||
export default create({
|
||||
export default function(visitable, attribute, collection, text, filter) {
|
||||
return {
|
||||
visit: visitable('/:dc/services/:service'),
|
||||
nodes: collection('[data-test-node]', {
|
||||
name: attribute('data-test-node'),
|
||||
|
@ -15,4 +13,5 @@ export default create({
|
|||
address: text('header strong'),
|
||||
}),
|
||||
filter: filter,
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { create, visitable, collection } from 'ember-cli-page-object';
|
||||
|
||||
export default create({
|
||||
export default function(visitable, collection) {
|
||||
return {
|
||||
visit: visitable('/'),
|
||||
dcs: collection('[data-test-datacenter-list]'),
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import { create, visitable, clickable } from 'ember-cli-page-object';
|
||||
|
||||
export default create({
|
||||
export default function(visitable, submitable) {
|
||||
return submitable({
|
||||
visit: visitable('/settings'),
|
||||
submit: clickable('[type=submit]'),
|
||||
});
|
||||
}
|
||||
|
|
|
@ -85,6 +85,15 @@ export default function(assert) {
|
|||
.when('I click "$selector"', function(selector) {
|
||||
return click(selector);
|
||||
})
|
||||
// TODO: Probably nicer to thing of better vocab than having the 'without " rule'
|
||||
.when('I click (?!")$property(?!")', function(property) {
|
||||
try {
|
||||
return currentPage[property]();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
throw new Error(`The '${property}' property on the page object doesn't exist`);
|
||||
}
|
||||
})
|
||||
.when('I click $prop on the $component', function(prop, component) {
|
||||
// Collection
|
||||
var obj;
|
||||
|
|
Loading…
Reference in a new issue