mirror of https://github.com/hashicorp/consul
ui: Adds an acceptance test for hiding Blocking Queries (#7162)
* Adds an acceptance test for hiding Blocking Queries * Creates a new scenario - If a user adds CONSUL_UI_DISABLE_REALTIME to localStorage, the Blocking Queries section is hidden. * Updates page assertion to accept functions and booleans as properties * ui: Fix "don't see" step to watch for the different pageObject error ember-cli-page object seems to throw a an error with a different message depending on how you call a function: currentPage()[property]() // message = 'Element not found' const prop = currentPage()[property]; prop() // message = 'Something about destructuring' This changes the step/test/assertion to ensure we check for both types of errors Co-authored-by: John Cowen <johncowen@users.noreply.github.com>pull/7195/head
parent
7f786d809e
commit
b9e023dfe1
|
@ -26,7 +26,7 @@
|
||||||
</label>
|
</label>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
{{#if (not (env 'CONSUL_UI_DISABLE_REALTIME'))}}
|
{{#if (not (env 'CONSUL_UI_DISABLE_REALTIME'))}}
|
||||||
<fieldset>
|
<fieldset data-test-blocking-queries>
|
||||||
<h2>Blocking Queries</h2>
|
<h2>Blocking Queries</h2>
|
||||||
<p>Keep catalog info up-to-date without refreshing the page. Any changes made to services, nodes and intentions would be reflected in real time.</p>
|
<p>Keep catalog info up-to-date without refreshing the page. Any changes made to services, nodes and intentions would be reflected in real time.</p>
|
||||||
<div class="type-toggle">
|
<div class="type-toggle">
|
||||||
|
|
|
@ -2,8 +2,23 @@
|
||||||
@notNamespaceable
|
@notNamespaceable
|
||||||
|
|
||||||
Feature: settings / show: Show Settings Page
|
Feature: settings / show: Show Settings Page
|
||||||
Scenario:
|
Scenario: I see the Blocking queries
|
||||||
Given 1 datacenter model with the value "datacenter"
|
Given 1 datacenter model with the value "datacenter"
|
||||||
When I visit the settings page
|
When I visit the settings page
|
||||||
Then the url should be /setting
|
Then the url should be /setting
|
||||||
And the title should be "Settings - Consul"
|
And the title should be "Settings - Consul"
|
||||||
|
And I see blockingQueries
|
||||||
|
Scenario: Setting CONSUL_UI_DISABLE_REALTIME hides Blocking Queries
|
||||||
|
Given 1 datacenter model with the value "datacenter"
|
||||||
|
And settings from yaml
|
||||||
|
---
|
||||||
|
CONSUL_UI_DISABLE_REALTIME: 1
|
||||||
|
---
|
||||||
|
Then I have settings like yaml
|
||||||
|
---
|
||||||
|
CONSUL_UI_DISABLE_REALTIME: "1"
|
||||||
|
---
|
||||||
|
When I visit the settings page
|
||||||
|
Then the url should be /setting
|
||||||
|
And the title should be "Settings - Consul"
|
||||||
|
And I don't see blockingQueries
|
|
@ -1,4 +1,12 @@
|
||||||
import { create, clickable, is, attribute, collection, text } from 'ember-cli-page-object';
|
import {
|
||||||
|
create,
|
||||||
|
clickable,
|
||||||
|
is,
|
||||||
|
attribute,
|
||||||
|
collection,
|
||||||
|
text,
|
||||||
|
isPresent,
|
||||||
|
} from 'ember-cli-page-object';
|
||||||
import { alias } from 'ember-cli-page-object/macros';
|
import { alias } from 'ember-cli-page-object/macros';
|
||||||
import { visitable } from 'consul-ui/tests/lib/page-object/visitable';
|
import { visitable } from 'consul-ui/tests/lib/page-object/visitable';
|
||||||
import createDeletable from 'consul-ui/tests/lib/page-object/createDeletable';
|
import createDeletable from 'consul-ui/tests/lib/page-object/createDeletable';
|
||||||
|
@ -112,5 +120,5 @@ export default {
|
||||||
nspace: create(
|
nspace: create(
|
||||||
nspace(visitable, submitable, deletable, cancelable, policySelector, roleSelector)
|
nspace(visitable, submitable, deletable, cancelable, policySelector, roleSelector)
|
||||||
),
|
),
|
||||||
settings: create(settings(visitable, submitable)),
|
settings: create(settings(visitable, submitable, isPresent)),
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
export default function(visitable, submitable) {
|
export default function(visitable, submitable, isPresent) {
|
||||||
return submitable({
|
return submitable({
|
||||||
visit: visitable('/setting'),
|
visit: visitable('/setting'),
|
||||||
|
blockingQueries: isPresent('[data-test-blocking-queries]'),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,15 +123,30 @@ export default function(scenario, assert, find, currentPage) {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.then(["I don't see $property"], function(property) {
|
.then(["I don't see $property"], function(property) {
|
||||||
|
const message = `Expected to not see ${property}`;
|
||||||
|
let prop;
|
||||||
|
try {
|
||||||
|
prop = currentPage()[property];
|
||||||
|
} catch (e) {
|
||||||
|
if (isExpectedError(e)) {
|
||||||
|
assert.ok(true, message);
|
||||||
|
} else {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (typeof prop === 'function') {
|
||||||
assert.throws(
|
assert.throws(
|
||||||
function() {
|
function() {
|
||||||
return currentPage()[property]();
|
prop();
|
||||||
},
|
},
|
||||||
function(e) {
|
function(e) {
|
||||||
return e.message.startsWith('Element not found');
|
return isExpectedError(e);
|
||||||
},
|
},
|
||||||
`Expected to not see ${property}`
|
message
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
assert.notOk(prop);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.then(['I see $property'], function(property) {
|
.then(['I see $property'], function(property) {
|
||||||
assert.ok(currentPage()[property], `Expected to see ${property}`);
|
assert.ok(currentPage()[property], `Expected to see ${property}`);
|
||||||
|
|
Loading…
Reference in New Issue