Skip to content

Commit

Permalink
Test wrangling
Browse files Browse the repository at this point in the history
  • Loading branch information
John Cowen committed Mar 5, 2021
1 parent 760dafd commit fdc0775
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 22 deletions.
12 changes: 3 additions & 9 deletions ui/packages/consul-ui/app/components/modal-dialog/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Component from '@ember/component';
import Slotted from 'block-slots';
import A11yDialog from 'a11y-dialog'
import A11yDialog from 'a11y-dialog';

export default Component.extend(Slotted, {
tagName: '',
Expand All @@ -9,14 +9,8 @@ export default Component.extend(Slotted, {
actions: {
connect: function($el) {
this.dialog = new A11yDialog($el);
this.dialog.on(
'hide',
() => this.onclose()
);
this.dialog.on(
'show',
() => this.onopen()
);
this.dialog.on('hide', () => this.onclose({ target: $el }));
this.dialog.on('show', () => this.onopen({ target: $el }));
},
disconnect: function($el) {
this.dialog.destroy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
{{else}}
<label
class="type-dialog"
data-test-policy-create
{{on "click" (optional this.modal.open)}}
>
<span>Create new policy</span>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export default (clickable, deletable, collection, alias, policyForm) => (
scope = '#policies',
createSelector = '[for="new-policy-toggle"]'
createSelector = '[data-test-policy-create]'
) => {
return {
scope: scope,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ as |modal|>
</BlockSlot>
<BlockSlot @name="create">
<label class="type-dialog"
data-test-role-create
{{on "click" (optional this.modal.open)}}
>
<span>Create new role</span>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export default (clickable, deletable, collection, alias, roleForm) => (scope = '#roles') => {
return {
scope: scope,
create: clickable('[for="new-role-toggle"]'),
create: clickable('[data-test-role-create]'),
form: roleForm(),
roles: alias('selectedOptions'),
selectedOptions: collection(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Feature: dc / intentions / create: Intention Create
And I click ".ember-power-select-option:first-child"
Then I see the text "db" in "[data-test-destination-element] .ember-power-select-selected-item"
# Specifically set deny
And I click "[value=deny]"
And I click ".value-deny"
And I submit
# TODO: When namespace is empty we expect *
# Then a PUT request was made to "/v1/connect/intentions/exact?source=@namespace%2Fweb&destination=@namespace%2Fdb&dc=datacenter" from yaml
Expand Down Expand Up @@ -75,7 +75,7 @@ Feature: dc / intentions / create: Intention Create
And I click ".ember-power-select-option:first-child"
Then I see the text "db" in "[data-test-destination-element] .ember-power-select-selected-item"
# Specifically set deny
And I click "[value=deny]"
And I click ".value-deny"
And I submit
Then a PUT request was made to "/v1/connect/intentions/exact?source=default%2Fweb&destination=default%2Fdb&dc=datacenter" from yaml
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Feature: dc / intentions / permissions / create: Intention Permission Create
Then the url should be /datacenter/intentions/create
And the title should be "New Intention - Consul"
# Specifically set L7
And I click "[value='']"
And I click ".value-"

And I click the permissions.create object
And I click the permissions.form.Action.option.Deny object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ Feature: dc / intentions / permissions / warn: Intention Permission Warn
intention: intention-id
---
Then the url should be /datacenter/intentions/intention-id
And I click "[value='deny']"
And I click ".value-deny"
And I submit
And the warning object is present
And I see the warning object
And I click the warning.cancel object
And the warning object isn't present
And I don't see the warning object
And I submit
And the warning object is present
And I see the warning object
And I click the warning.confirm object
Then a PUT request was made to "/v1/connect/intentions/exact?source=default%2Fweb&destination=default%2Fdb&dc=datacenter" from yaml
3 changes: 2 additions & 1 deletion ui/packages/consul-ui/tests/pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
collection,
text,
isPresent,
isVisible,
} from 'ember-cli-page-object';

import { alias } from 'ember-cli-page-object/macros';
Expand Down Expand Up @@ -204,7 +205,7 @@ export default {
intention(
visitable,
clickable,
isPresent,
isVisible,
submitable,
deletable,
cancelable,
Expand Down
4 changes: 2 additions & 2 deletions ui/packages/consul-ui/tests/pages/dc/intentions/edit.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export default function(
visitable,
clickable,
isPresent,
isVisible,
submitable,
deletable,
cancelable,
Expand All @@ -22,7 +22,7 @@ export default function(
warning: {
scope: '[data-test-action-warning]',
resetScope: true,
present: isPresent(),
see: isVisible(),
confirm: {
scope: '[data-test-action-warning-confirm]',
click: clickable(),
Expand Down
6 changes: 5 additions & 1 deletion ui/packages/consul-ui/tests/steps/assertions/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ const dont = `( don't| shouldn't| can't)?`;
export default function(scenario, assert, find, currentPage, $) {
scenario
.then([`I${dont} $verb the $pageObject object`], function(negative, verb, element, next) {
assert[negative ? 'notOk' : 'ok'](element[verb]());
let res = element[verb];
if (typeof res === 'function') {
res = res.call(element);
}
assert[negative ? 'notOk' : 'ok'](res, this.step);
setTimeout(() => next());
})
.then(
Expand Down

0 comments on commit fdc0775

Please sign in to comment.