mirror of https://github.com/status-im/consul.git
ui: Reinstate listing of available test steps via CLI (#8614)
* Unignore any bin files underneath the UI folder * Add previously ignored node exec script * Rearrange steps file so we can continue to list steps out
This commit is contained in:
parent
5cc1fefa95
commit
d818e892fa
|
@ -1,3 +1,4 @@
|
|||
!bin
|
||||
/public/consul-api-double
|
||||
# See https://help.github.com/ignore-files/ for more about ignoring files.
|
||||
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
require('../lib/list.js')(`${process.cwd()}/tests/steps.js`);
|
|
@ -40,11 +40,12 @@ const library = {
|
|||
return this;
|
||||
},
|
||||
};
|
||||
const root = process.cwd();
|
||||
const exec = function(filename) {
|
||||
const js = read(filename);
|
||||
const code = babel.transform(js.toString(), {
|
||||
filename: filename,
|
||||
presets: [require('babel-preset-env')],
|
||||
presets: ['@babel/preset-env'],
|
||||
}).code;
|
||||
const exports = {};
|
||||
vm.runInNewContext(
|
||||
|
@ -52,7 +53,7 @@ const exec = function(filename) {
|
|||
{
|
||||
exports: exports,
|
||||
require: function(str) {
|
||||
return exec(path.resolve(`${process.cwd()}/tests`, `${str}.js`)).default;
|
||||
return exec(path.resolve(`${root}/tests`, `${str}.js`)).default;
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -63,5 +64,6 @@ const exec = function(filename) {
|
|||
};
|
||||
|
||||
module.exports = function(filename) {
|
||||
exec(filename).default(function() {}, library, {}, {}, {}, function() {});
|
||||
const assert = () => {};
|
||||
exec(filename).default({ assert, library });
|
||||
};
|
||||
|
|
|
@ -1,5 +1,19 @@
|
|||
import steps from 'consul-ui/tests/steps';
|
||||
import pages from 'consul-ui/tests/pages';
|
||||
import Inflector from 'ember-inflector';
|
||||
import utils from '@ember/test-helpers';
|
||||
import $ from '-jquery';
|
||||
|
||||
import api from 'consul-ui/tests/helpers/api';
|
||||
|
||||
export default function({ assert, library }) {
|
||||
return steps(assert, library);
|
||||
return steps({
|
||||
assert,
|
||||
library,
|
||||
pages,
|
||||
utils,
|
||||
api,
|
||||
Inflector,
|
||||
$,
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
import pages from 'consul-ui/tests/pages';
|
||||
import Inflector from 'ember-inflector';
|
||||
import utils from '@ember/test-helpers';
|
||||
|
||||
import api from 'consul-ui/tests/helpers/api';
|
||||
// This files export is executed from 2 places:
|
||||
// 1. consul-ui/tests/acceptance/steps/steps.js - run during testing
|
||||
// 2. consul-ui/lib/commands/lib/list.js - run when listing steps via the CLI
|
||||
|
||||
import models from './steps/doubles/model';
|
||||
import http from './steps/doubles/http';
|
||||
|
@ -18,10 +16,19 @@ import assertForm from './steps/assertions/form';
|
|||
|
||||
// const dont = `( don't| shouldn't| can't)?`;
|
||||
|
||||
const pluralize = function(str) {
|
||||
export default function({
|
||||
assert,
|
||||
library,
|
||||
pages = {},
|
||||
utils = {},
|
||||
api = {},
|
||||
Inflector = {},
|
||||
$ = {},
|
||||
}) {
|
||||
const pluralize = function(str) {
|
||||
return Inflector.inflector.pluralize(str);
|
||||
};
|
||||
const getLastNthRequest = function(getRequests) {
|
||||
};
|
||||
const getLastNthRequest = function(getRequests) {
|
||||
return function(n, method) {
|
||||
let requests = getRequests()
|
||||
.slice(0)
|
||||
|
@ -36,8 +43,8 @@ const getLastNthRequest = function(getRequests) {
|
|||
}
|
||||
return requests[n];
|
||||
};
|
||||
};
|
||||
const mb = function(path) {
|
||||
};
|
||||
const mb = function(path) {
|
||||
return function(obj) {
|
||||
return (
|
||||
path.map(function(prop) {
|
||||
|
@ -50,8 +57,7 @@ const mb = function(path) {
|
|||
}) && obj
|
||||
);
|
||||
};
|
||||
};
|
||||
export default function(assert, library) {
|
||||
};
|
||||
const pauseUntil = function(run, message = 'assertion timed out') {
|
||||
return new Promise(function(r) {
|
||||
let count = 0;
|
||||
|
@ -135,7 +141,7 @@ export default function(assert, library) {
|
|||
debug(library, assert, utils.currentURL);
|
||||
assertHttp(library, assert, lastNthRequest);
|
||||
assertModel(library, assert, find, getCurrentPage, pauseUntil, pluralize);
|
||||
assertPage(library, assert, find, getCurrentPage);
|
||||
assertPage(library, assert, find, getCurrentPage, $);
|
||||
assertDom(library, assert, pauseUntil, utils.find, utils.currentURL, clipboard);
|
||||
assertForm(library, assert, find, getCurrentPage);
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
/* eslint no-console: "off" */
|
||||
import $ from '-jquery';
|
||||
|
||||
const elementNotFound = 'Element not found';
|
||||
// this error comes from our pageObject `find `function
|
||||
|
@ -32,7 +31,7 @@ const isExpectedError = function(e) {
|
|||
);
|
||||
};
|
||||
const dont = `( don't| shouldn't| can't)?`;
|
||||
export default function(scenario, assert, find, currentPage) {
|
||||
export default function(scenario, assert, find, currentPage, $) {
|
||||
scenario
|
||||
.then(['I see $num of the $component object'], function(num, component) {
|
||||
assert.equal(
|
||||
|
|
Loading…
Reference in New Issue