Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ui: CI Experiments #7187

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix up, add some comments and revert to run the entire suite
  • Loading branch information
John Cowen committed Jan 31, 2020
commit 3b1be7b5fea4be3b92f4fe9a10ff8f36d570c2c8
2 changes: 1 addition & 1 deletion ui-v2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"start:staging": "ember serve --port=${EMBER_SERVE_PORT:-4200} --live-reload-port=${EMBER_LIVE_RELOAD_PORT:-7020} --environment staging",
"start:consul": "ember serve --proxy=${CONSUL_HTTP_ADDR:-http://localhost:8500} --port=${EMBER_SERVE_PORT:-4200} --live-reload-port=${EMBER_LIVE_RELOAD_PORT:-7020}",
"start:api": "api-double --dir ./node_modules/@hashicorp/consul-api-double",
"test": "ember test --test-port=${EMBER_TEST_PORT:-7357} --path dist --reporter xunit --filter 'dc / acls / tokens / anonymous-no-delete'",
"test": "ember test --test-port=${EMBER_TEST_PORT:-7357} --path dist --reporter xunit",
"test:parallel": "EMBER_EXAM_PARALLEL=true ember exam --split=4 --parallel",
"test:view": "ember test --server --test-port=${EMBER_TEST_PORT:-7357}",
"test:node": "tape ./node-tests/**/*.js",
Expand Down
38 changes: 28 additions & 10 deletions ui-v2/tests/steps/assertions/page.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,30 @@
/* eslint no-console: "off" */
const notFound = 'Element not found';
const cannotDestructure = "Cannot destructure property 'context'";
const cannotReadContext = "Cannot read property 'context' of undefined";
// checking for existence of pageObjects is pretty difficult
// errors are thrown but we should check to make sure its the error that we
// want and not another real error
// to make things more difficult depending on how you reference the pageObject
// an error with a different message is thrown for example:

// pageObject[thing]() will give you a Element not found error

// whereas:

// const obj = pageObject[thing]; obj() will give you a 'cannot destructure error'
// and in CI it will give you a 'cannot read property' error

// the difference in CI could be a difference due to headless vs headed browser
// or difference in Chrome/browser versions

// ideally we wouldn't be checking on error messages at all, but we want to make sure
// that real errors are picked up by the tests, so if this gets unmanageable at any point
// look at checking for the instance of e being TypeError or similar
const isExpectedError = function(e) {
return [notFound, cannotDestructure, cannotReadContext].some(item => e.message.startsWith(item));
};

export default function(scenario, assert, find, currentPage) {
scenario
.then('I see $property on the $component like yaml\n$yaml', function(
Expand Down Expand Up @@ -65,9 +91,6 @@ export default function(scenario, assert, find, currentPage) {
})
.then(["I don't see $property on the $component"], function(property, component) {
const message = `Expected to not see ${property} on ${component}`;
const notFound = 'Element not found';
const cannotDestructure = 'Cannot destructure property';
const cannotReadContext = "Cannot read property 'context' of undefined";
// Cope with collections
let obj;
if (typeof currentPage()[component].objectAt === 'function') {
Expand All @@ -79,9 +102,7 @@ export default function(scenario, assert, find, currentPage) {
try {
prop = obj[property];
} catch (e) {
if (
[notFound, cannotDestructure, cannotReadContext].some(item => e.message.startsWith(item))
) {
if (isExpectedError(e)) {
assert.ok(true, message);
} else {
throw e;
Expand All @@ -93,10 +114,7 @@ export default function(scenario, assert, find, currentPage) {
prop();
},
function(e) {
console.log(JSON.stringify(e));
return [notFound, cannotDestructure, cannotReadContext].some(item =>
e.message.startsWith(item)
);
return isExpectedError(e);
},
message
);
Expand Down