From 493ebb0713f9549baae83bad5f9d3c1fba7373c4 Mon Sep 17 00:00:00 2001 From: John Cowen Date: Mon, 14 Dec 2020 15:28:35 +0000 Subject: [PATCH] ui: Move linting to the `node:test` script (#9385) * Reconfigure linting to be a node-test * Fixup linting across the project --- ui/packages/consul-ui/.eslintignore | 1 + ui/packages/consul-ui/.storybook/main.js | 1 + ui/packages/consul-ui/.template-lintrc.js | 1 + ui/packages/consul-ui/GNUmakefile | 4 +- .../app/components/child-selector/index.js | 2 +- .../consul/discovery-chain/index.js | 1 - .../components/consul/intention/list/index.js | 1 - .../components/consul/nspace/list/index.js | 1 - .../consul/tomography/graph/index.js | 2 +- .../app/components/data-collection/index.js | 4 +- .../app/components/form-component/index.js | 9 +-- .../app/components/list-collection/index.js | 1 - .../topology-metrics/popover/index.hbs | 2 + .../consul-ui/app/filter/predicates/policy.js | 2 + ui/packages/consul-ui/app/models/proxy.js | 2 +- .../consul-ui/app/models/service-instance.js | 4 +- ui/packages/consul-ui/app/models/service.js | 2 +- .../consul-ui/app/routes/dc/services/show.js | 3 +- ui/packages/consul-ui/app/serializers/node.js | 5 +- .../services/repository/service-instance.js | 2 +- .../blueprints/adapter-test/index.js | 4 +- .../consul-ui/blueprints/adapter/index.js | 2 - .../consul-ui/blueprints/model-test/index.js | 3 +- .../consul-ui/blueprints/model/index.js | 2 - .../blueprints/repository-test/index.js | 3 +- .../blueprints/serializer-test/index.js | 3 +- .../consul-ui/blueprints/serializer/index.js | 2 - .../lib/colocated-components/index.js | 1 + ui/packages/consul-ui/lib/startup/index.js | 1 + .../node-tests/config/environment.js | 2 + .../consul-ui/node-tests/config/utils.js | 2 + ui/packages/consul-ui/package.json | 5 +- ui/packages/consul-ui/server/index.js | 1 + .../integration/serializers/node-test.js | 11 ---- .../consul-ui/tests/steps/assertions/form.js | 24 +++---- .../consul-ui/tests/steps/assertions/page.js | 12 ++-- .../tests/steps/interactions/click.js | 10 +-- .../tests/steps/interactions/form.js | 64 +++++++++---------- 38 files changed, 86 insertions(+), 116 deletions(-) diff --git a/ui/packages/consul-ui/.eslintignore b/ui/packages/consul-ui/.eslintignore index df274f720..349abf174 100644 --- a/ui/packages/consul-ui/.eslintignore +++ b/ui/packages/consul-ui/.eslintignore @@ -1,6 +1,7 @@ app/utils/dom/event-target/event-target-shim/event.js # unconventional js /blueprints/*/files/ +/blueprints/*/*-files/ /vendor/ # compiled output diff --git a/ui/packages/consul-ui/.storybook/main.js b/ui/packages/consul-ui/.storybook/main.js index 3b8aad670..2b2c11427 100644 --- a/ui/packages/consul-ui/.storybook/main.js +++ b/ui/packages/consul-ui/.storybook/main.js @@ -1,3 +1,4 @@ +/* eslint-env node */ module.exports = { "stories": [ "../app/**/*.stories.mdx" diff --git a/ui/packages/consul-ui/.template-lintrc.js b/ui/packages/consul-ui/.template-lintrc.js index df2f4f9e0..e1b3f082f 100644 --- a/ui/packages/consul-ui/.template-lintrc.js +++ b/ui/packages/consul-ui/.template-lintrc.js @@ -4,6 +4,7 @@ module.exports = { extends: 'octane', rules: { 'no-partial': false, + 'table-groups': false, 'no-invalid-interactive': false, 'simple-unless': false, diff --git a/ui/packages/consul-ui/GNUmakefile b/ui/packages/consul-ui/GNUmakefile index 27f24e9f3..d667f562c 100644 --- a/ui/packages/consul-ui/GNUmakefile +++ b/ui/packages/consul-ui/GNUmakefile @@ -69,10 +69,10 @@ test-parallel: deps yarn run test:parallel lint: deps - yarn run lint:hbs && yarn run lint:js + yarn run lint format: deps - yarn run format:js + yarn run format steps: yarn run steps:list diff --git a/ui/packages/consul-ui/app/components/child-selector/index.js b/ui/packages/consul-ui/app/components/child-selector/index.js index 9760e1f58..e40a4d0a0 100644 --- a/ui/packages/consul-ui/app/components/child-selector/index.js +++ b/ui/packages/consul-ui/app/components/child-selector/index.js @@ -1,6 +1,6 @@ import Component from '@ember/component'; import { get, set, computed } from '@ember/object'; -import { alias, sort } from '@ember/object/computed'; +import { alias } from '@ember/object/computed'; import { inject as service } from '@ember/service'; import { task } from 'ember-concurrency'; diff --git a/ui/packages/consul-ui/app/components/consul/discovery-chain/index.js b/ui/packages/consul-ui/app/components/consul/discovery-chain/index.js index a4947c683..31842c7de 100644 --- a/ui/packages/consul-ui/app/components/consul/discovery-chain/index.js +++ b/ui/packages/consul-ui/app/components/consul/discovery-chain/index.js @@ -1,7 +1,6 @@ import Component from '@ember/component'; import { inject as service } from '@ember/service'; import { set, get, computed } from '@ember/object'; -import { schedule } from '@ember/runloop'; import { createRoute, getSplitters, getRoutes, getResolvers } from './utils'; diff --git a/ui/packages/consul-ui/app/components/consul/intention/list/index.js b/ui/packages/consul-ui/app/components/consul/intention/list/index.js index e07c637a2..4d9917b77 100644 --- a/ui/packages/consul-ui/app/components/consul/intention/list/index.js +++ b/ui/packages/consul-ui/app/components/consul/intention/list/index.js @@ -2,7 +2,6 @@ import Component from '@glimmer/component'; import { inject as service } from '@ember/service'; import { action } from '@ember/object'; import { tracked } from '@glimmer/tracking'; -import { sort } from '@ember/object/computed'; export default class ConsulIntentionList extends Component { @service('repository/intention') repo; diff --git a/ui/packages/consul-ui/app/components/consul/nspace/list/index.js b/ui/packages/consul-ui/app/components/consul/nspace/list/index.js index 5b894ebb4..e00c5b8a0 100644 --- a/ui/packages/consul-ui/app/components/consul/nspace/list/index.js +++ b/ui/packages/consul-ui/app/components/consul/nspace/list/index.js @@ -1,5 +1,4 @@ import Component from '@glimmer/component'; -import { action } from '@ember/object'; export default class ConsulNspaceList extends Component { isLinkable(item) { diff --git a/ui/packages/consul-ui/app/components/consul/tomography/graph/index.js b/ui/packages/consul-ui/app/components/consul/tomography/graph/index.js index f5403b15b..01a7249f3 100644 --- a/ui/packages/consul-ui/app/components/consul/tomography/graph/index.js +++ b/ui/packages/consul-ui/app/components/consul/tomography/graph/index.js @@ -23,7 +23,7 @@ export default class TomographyGraph extends Component { } get distances() { - const distances = this.args.distances || []; + let distances = this.args.distances || []; const max = distances.reduce((prev, d) => Math.max(prev, d.distance), this.max); const len = distances.length; if (len > 360) { diff --git a/ui/packages/consul-ui/app/components/data-collection/index.js b/ui/packages/consul-ui/app/components/data-collection/index.js index 77f3aa4b8..23d6bb3eb 100644 --- a/ui/packages/consul-ui/app/components/data-collection/index.js +++ b/ui/packages/consul-ui/app/components/data-collection/index.js @@ -27,7 +27,7 @@ export default class DataCollectionComponent extends Component { return this.items; } - @computed('args.items', 'args.items.content') + @computed('args{items,.items.content}') get content() { // TODO: Temporary little hack to ensure we detect DataSource proxy // objects but not any other special Ember Proxy object like ember-data @@ -53,7 +53,7 @@ export default class DataCollectionComponent extends Component { @computed('type', 'filtered', 'args.filters.searchproperties', 'searchTerm') get searched() { - if (typeof this.searchTerm === '') { + if (this.searchTerm === '') { return this.filtered; } const predicate = this.searchService.predicate(this.type); diff --git a/ui/packages/consul-ui/app/components/form-component/index.js b/ui/packages/consul-ui/app/components/form-component/index.js index ef1c0dc17..d1b23fee3 100644 --- a/ui/packages/consul-ui/app/components/form-component/index.js +++ b/ui/packages/consul-ui/app/components/form-component/index.js @@ -37,13 +37,8 @@ export default Component.extend(Slotted, { } else { name = prop; } - const form = this.form; - try { - form.handleEvent(event, name); - this.onchange({ target: this }); - } catch (err) { - throw err; - } + this.form.handleEvent(event, name); + this.onchange({ target: this }); }, }, }); diff --git a/ui/packages/consul-ui/app/components/list-collection/index.js b/ui/packages/consul-ui/app/components/list-collection/index.js index 6762e42c6..9724e9a73 100644 --- a/ui/packages/consul-ui/app/components/list-collection/index.js +++ b/ui/packages/consul-ui/app/components/list-collection/index.js @@ -7,7 +7,6 @@ import Slotted from 'block-slots'; const formatItemStyle = PercentageColumns.prototype.formatItemStyle; export default Component.extend(Slotted, { - tagName: '', dom: service('dom'), tagName: '', height: 500, diff --git a/ui/packages/consul-ui/app/components/topology-metrics/popover/index.hbs b/ui/packages/consul-ui/app/components/topology-metrics/popover/index.hbs index f89a28b59..55bd5e150 100644 --- a/ui/packages/consul-ui/app/components/topology-metrics/popover/index.hbs +++ b/ui/packages/consul-ui/app/components/topology-metrics/popover/index.hbs @@ -32,6 +32,7 @@ @@ -67,6 +68,7 @@ diff --git a/ui/packages/consul-ui/app/filter/predicates/policy.js b/ui/packages/consul-ui/app/filter/predicates/policy.js index 9f6142b9b..d3a6ca4ee 100644 --- a/ui/packages/consul-ui/app/filter/predicates/policy.js +++ b/ui/packages/consul-ui/app/filter/predicates/policy.js @@ -1,3 +1,5 @@ +import setHelpers from 'mnemonist/set'; + export default { kinds: { 'global-management': (item, value) => item.isGlobalManagement, diff --git a/ui/packages/consul-ui/app/models/proxy.js b/ui/packages/consul-ui/app/models/proxy.js index 7508f17c8..65daae44b 100644 --- a/ui/packages/consul-ui/app/models/proxy.js +++ b/ui/packages/consul-ui/app/models/proxy.js @@ -1,4 +1,4 @@ -import Model, { attr } from '@ember-data/model'; +import { attr } from '@ember-data/model'; import ServiceInstanceModel from './service-instance'; export const PRIMARY_KEY = 'uid'; diff --git a/ui/packages/consul-ui/app/models/service-instance.js b/ui/packages/consul-ui/app/models/service-instance.js index 09a386a02..0be3a7047 100644 --- a/ui/packages/consul-ui/app/models/service-instance.js +++ b/ui/packages/consul-ui/app/models/service-instance.js @@ -41,7 +41,7 @@ export default class ServiceInstance extends Model { @alias('Service.Service') Name; // If the ID is blank fallback to the Service.Service (the Name) - @or('Service.ID', 'Service.Service') ID; + @or('Service.{ID,Service}') ID; @or('Service.Address', 'Node.Service') Address; @alias('Service.Tags') Tags; @@ -54,7 +54,7 @@ export default class ServiceInstance extends Model { // MeshChecks are a concatenation of Checks for the Instance and Checks for // the ProxyInstance. Checks is an ember-data-model-fragment, so we can't just // concat it, we have to loop through all the items in order to merge - @computed('Checks', 'ProxyInstance.Checks', 'ProxyInstance.ServiceProxy.Expose.Checks') + @computed('Checks', 'ProxyInstance{Checks,ServiceProxy.Expose.Checks}') get MeshChecks() { return (get(this, 'Checks') || []) .map(item => { diff --git a/ui/packages/consul-ui/app/models/service.js b/ui/packages/consul-ui/app/models/service.js index f55691015..0353caf69 100644 --- a/ui/packages/consul-ui/app/models/service.js +++ b/ui/packages/consul-ui/app/models/service.js @@ -1,5 +1,5 @@ import Model, { attr } from '@ember-data/model'; -import { computed, get } from '@ember/object'; +import { computed } from '@ember/object'; import { tracked } from '@glimmer/tracking'; export const PRIMARY_KEY = 'uid'; diff --git a/ui/packages/consul-ui/app/routes/dc/services/show.js b/ui/packages/consul-ui/app/routes/dc/services/show.js index 18bc16267..b5b37cc2e 100644 --- a/ui/packages/consul-ui/app/routes/dc/services/show.js +++ b/ui/packages/consul-ui/app/routes/dc/services/show.js @@ -1,7 +1,7 @@ import { inject as service } from '@ember/service'; import Route from 'consul-ui/routing/route'; import { get } from '@ember/object'; -import { action, setProperties } from '@ember/object'; +import { action } from '@ember/object'; export default class ShowRoute extends Route { @service('data-source/service') data; @@ -10,7 +10,6 @@ export default class ShowRoute extends Route { @action async createIntention(source, destination) { - const intention = service.Intention; const model = this.repo.create({ Datacenter: source.Datacenter, SourceName: source.Name, diff --git a/ui/packages/consul-ui/app/serializers/node.js b/ui/packages/consul-ui/app/serializers/node.js index e65a45cda..6e8f32a0e 100644 --- a/ui/packages/consul-ui/app/serializers/node.js +++ b/ui/packages/consul-ui/app/serializers/node.js @@ -23,9 +23,10 @@ export default class NodeSerializer extends Serializer.extend(EmbeddedRecordsMix }; transformHasManyResponse(store, relationship, item, parent = null) { + let checks = {}; + let serializer; switch (relationship.key) { case 'Services': - const checks = {}; (item.Checks || []) .filter(item => { return item.ServiceID !== ''; @@ -36,7 +37,7 @@ export default class NodeSerializer extends Serializer.extend(EmbeddedRecordsMix } checks[item.ServiceID].push(item); }); - const serializer = this.store.serializerFor(relationship.type); + serializer = this.store.serializerFor(relationship.type); item.Services = item.Services.map(service => serializer.transformHasManyResponseFromNode(item, service, checks) ); diff --git a/ui/packages/consul-ui/app/services/repository/service-instance.js b/ui/packages/consul-ui/app/services/repository/service-instance.js index 3515903cc..ba2ac8c89 100644 --- a/ui/packages/consul-ui/app/services/repository/service-instance.js +++ b/ui/packages/consul-ui/app/services/repository/service-instance.js @@ -1,6 +1,6 @@ import RepositoryService from 'consul-ui/services/repository'; import { inject as service } from '@ember/service'; -import { set, get } from '@ember/object'; +import { set } from '@ember/object'; const modelName = 'service-instance'; export default class ServiceInstanceService extends RepositoryService { diff --git a/ui/packages/consul-ui/blueprints/adapter-test/index.js b/ui/packages/consul-ui/blueprints/adapter-test/index.js index db9261ce1..fcdb84f3c 100644 --- a/ui/packages/consul-ui/blueprints/adapter-test/index.js +++ b/ui/packages/consul-ui/blueprints/adapter-test/index.js @@ -1,6 +1,4 @@ -const path = require('path'); - -const testInfo = require('ember-cli-test-info'); +/*eslint node/no-extraneous-require: "off"*/ const useTestFrameworkDetector = require('@ember-data/private-build-infra/src/utilities/test-framework-detector'); module.exports = useTestFrameworkDetector({ diff --git a/ui/packages/consul-ui/blueprints/adapter/index.js b/ui/packages/consul-ui/blueprints/adapter/index.js index e718c544f..d4fe91847 100644 --- a/ui/packages/consul-ui/blueprints/adapter/index.js +++ b/ui/packages/consul-ui/blueprints/adapter/index.js @@ -1,7 +1,5 @@ -/*eslint node/no-extraneous-require: "off"*/ 'use strict'; -const path = require('path'); module.exports = { description: 'Generates a Consul HTTP ember-data adapter', diff --git a/ui/packages/consul-ui/blueprints/model-test/index.js b/ui/packages/consul-ui/blueprints/model-test/index.js index df90b56ee..2a45c318c 100644 --- a/ui/packages/consul-ui/blueprints/model-test/index.js +++ b/ui/packages/consul-ui/blueprints/model-test/index.js @@ -1,5 +1,4 @@ -const path = require('path'); - +/*eslint node/no-extraneous-require: "off"*/ const useTestFrameworkDetector = require('@ember-data/private-build-infra/src/utilities/test-framework-detector'); module.exports = useTestFrameworkDetector({ diff --git a/ui/packages/consul-ui/blueprints/model/index.js b/ui/packages/consul-ui/blueprints/model/index.js index f57d80179..4d0c6e185 100644 --- a/ui/packages/consul-ui/blueprints/model/index.js +++ b/ui/packages/consul-ui/blueprints/model/index.js @@ -1,7 +1,5 @@ -/*eslint node/no-extraneous-require: "off"*/ 'use strict'; -const path = require('path'); module.exports = { description: 'Generates a Consul HTTP ember-data model', diff --git a/ui/packages/consul-ui/blueprints/repository-test/index.js b/ui/packages/consul-ui/blueprints/repository-test/index.js index 608090ed1..a35d3b9ab 100644 --- a/ui/packages/consul-ui/blueprints/repository-test/index.js +++ b/ui/packages/consul-ui/blueprints/repository-test/index.js @@ -1,5 +1,4 @@ -const path = require('path'); - +/*eslint node/no-extraneous-require: "off"*/ const useTestFrameworkDetector = require('@ember-data/private-build-infra/src/utilities/test-framework-detector'); module.exports = useTestFrameworkDetector({ diff --git a/ui/packages/consul-ui/blueprints/serializer-test/index.js b/ui/packages/consul-ui/blueprints/serializer-test/index.js index 99f321a20..052ce5357 100644 --- a/ui/packages/consul-ui/blueprints/serializer-test/index.js +++ b/ui/packages/consul-ui/blueprints/serializer-test/index.js @@ -1,5 +1,4 @@ -const path = require('path'); - +/*eslint node/no-extraneous-require: "off"*/ const useTestFrameworkDetector = require('@ember-data/private-build-infra/src/utilities/test-framework-detector'); module.exports = useTestFrameworkDetector({ diff --git a/ui/packages/consul-ui/blueprints/serializer/index.js b/ui/packages/consul-ui/blueprints/serializer/index.js index b2c51f152..c9df3ae22 100644 --- a/ui/packages/consul-ui/blueprints/serializer/index.js +++ b/ui/packages/consul-ui/blueprints/serializer/index.js @@ -1,7 +1,5 @@ -/*eslint node/no-extraneous-require: "off"*/ 'use strict'; -const path = require('path'); module.exports = { description: 'Generates a Consul HTTP ember-data serializer', diff --git a/ui/packages/consul-ui/lib/colocated-components/index.js b/ui/packages/consul-ui/lib/colocated-components/index.js index 487be45eb..33428463f 100644 --- a/ui/packages/consul-ui/lib/colocated-components/index.js +++ b/ui/packages/consul-ui/lib/colocated-components/index.js @@ -1,3 +1,4 @@ +/*eslint node/no-extraneous-require: "off"*/ 'use strict'; const Funnel = require('broccoli-funnel'); diff --git a/ui/packages/consul-ui/lib/startup/index.js b/ui/packages/consul-ui/lib/startup/index.js index fefb117ae..c9601e4bd 100644 --- a/ui/packages/consul-ui/lib/startup/index.js +++ b/ui/packages/consul-ui/lib/startup/index.js @@ -1,4 +1,5 @@ /* eslint-env node */ +/*eslint node/no-extraneous-require: "off"*/ 'use strict'; // const $ = process.env; diff --git a/ui/packages/consul-ui/node-tests/config/environment.js b/ui/packages/consul-ui/node-tests/config/environment.js index 6b5b5fca2..d29066476 100644 --- a/ui/packages/consul-ui/node-tests/config/environment.js +++ b/ui/packages/consul-ui/node-tests/config/environment.js @@ -1,3 +1,5 @@ +/* eslint-env node */ + const test = require('tape'); const getEnvironment = require('../../config/environment.js'); diff --git a/ui/packages/consul-ui/node-tests/config/utils.js b/ui/packages/consul-ui/node-tests/config/utils.js index d9bf3a8a7..bdb51f54d 100644 --- a/ui/packages/consul-ui/node-tests/config/utils.js +++ b/ui/packages/consul-ui/node-tests/config/utils.js @@ -1,3 +1,5 @@ +/* eslint-env node */ + const test = require('tape'); const utils = require('../../config/utils.js'); diff --git a/ui/packages/consul-ui/package.json b/ui/packages/consul-ui/package.json index b3b448412..ad8925a94 100644 --- a/ui/packages/consul-ui/package.json +++ b/ui/packages/consul-ui/package.json @@ -13,7 +13,7 @@ "build:staging": "ember build --environment staging", "build:ci": "ember build --environment test", "doc:toc": "doctoc README.md", - "lint": "npm-run-all --aggregate-output --continue-on-error --parallel lint:*", + "lint": "FORCE_COLOR=1 npm-run-all --aggregate-output --continue-on-error --parallel lint:*", "lint:hbs": "ember-template-lint .", "lint:js": "eslint .", "_lint:dev:js": "eslint -c .dev.eslintrc.js --fix ./*.js ./.*.js app config lib server tests", @@ -25,13 +25,14 @@ "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}", + "test:lint": "yarn run lint", "test:oss": "CONSUL_NSPACES_ENABLED=0 ember test --test-port=${EMBER_TEST_PORT:-7357}", "test:ci": "ember test --test-port=${EMBER_TEST_PORT:-7357} --path dist --silent --reporter xunit", "test:oss:ci": "CONSUL_NSPACES_ENABLED=0 ember test --test-port=${EMBER_TEST_PORT:-7357} --path dist --silent --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:oss:view": "CONSUL_NSPACES_ENABLED=0 ember test --server --test-port=${EMBER_TEST_PORT:-7357}", - "test:node": "tape ./node-tests/**/*.js", + "test:node": "yarn run test:lint && tape ./node-tests/**/*.js", "test:coverage": "COVERAGE=true ember test --environment test --filter=Unit --test-port=${EMBER_TEST_PORT:-7357}", "test:coverage:ci": "COVERAGE=true ember test --environment test --filter=Unit --path dist --test-port=${EMBER_TEST_PORT:-7357}", "test:coverage:view": "COVERAGE=true ember test --server --environment test --filter=Unit --test-port=${EMBER_TEST_PORT:-7357}", diff --git a/ui/packages/consul-ui/server/index.js b/ui/packages/consul-ui/server/index.js index d2a344eb2..56f8bcebc 100644 --- a/ui/packages/consul-ui/server/index.js +++ b/ui/packages/consul-ui/server/index.js @@ -1,3 +1,4 @@ +/*eslint node/no-extraneous-require: "off"*/ 'use strict'; const fs = require('fs'); const promisify = require('util').promisify; diff --git a/ui/packages/consul-ui/tests/integration/serializers/node-test.js b/ui/packages/consul-ui/tests/integration/serializers/node-test.js index c44d3ce47..4b40854cf 100644 --- a/ui/packages/consul-ui/tests/integration/serializers/node-test.js +++ b/ui/packages/consul-ui/tests/integration/serializers/node-test.js @@ -49,17 +49,6 @@ module('Integration | Serializer | node', function(hooks) { url: `/v1/internal/ui/node/${id}?dc=${dc}`, }; return get(request.url).then(function(payload) { - const expected = Object.assign({}, payload, { - Datacenter: dc, - [META]: { - [DC.toLowerCase()]: dc, - [NSPACE.toLowerCase()]: nspace, - }, - // TODO: default isn't required here, once we've - // refactored out our Serializer this can go - Namespace: nspace, - uid: `["${nspace}","${dc}","${id}"]`, - }); const actual = serializer.respondForQueryRecord( function(cb) { const headers = {}; diff --git a/ui/packages/consul-ui/tests/steps/assertions/form.js b/ui/packages/consul-ui/tests/steps/assertions/form.js index 9c4ddec69..377b1ca02 100644 --- a/ui/packages/consul-ui/tests/steps/assertions/form.js +++ b/ui/packages/consul-ui/tests/steps/assertions/form.js @@ -1,21 +1,17 @@ export default function(scenario, assert, find, currentPage) { scenario.then('I see the $property form with yaml\n$yaml', function(property, data) { + let obj; try { - let obj; - try { - obj = find(property); - } catch (e) { - obj = currentPage(); - } - return Object.keys(data).reduce(function(prev, item, i, arr) { - const name = `${obj.prefix || property}[${item}]`; - const $el = document.querySelector(`[name="${name}"]`); - const actual = $el.value; - const expected = data[item]; - assert.strictEqual(actual, expected, `Expected settings to be ${expected} was ${actual}`); - }, obj); + obj = find(property); } catch (e) { - throw e; + obj = currentPage(); } + return Object.keys(data).reduce(function(prev, item, i, arr) { + const name = `${obj.prefix || property}[${item}]`; + const $el = document.querySelector(`[name="${name}"]`); + const actual = $el.value; + const expected = data[item]; + assert.strictEqual(actual, expected, `Expected settings to be ${expected} was ${actual}`); + }, obj); }); } diff --git a/ui/packages/consul-ui/tests/steps/assertions/page.js b/ui/packages/consul-ui/tests/steps/assertions/page.js index 24cb0f651..939289bc2 100644 --- a/ui/packages/consul-ui/tests/steps/assertions/page.js +++ b/ui/packages/consul-ui/tests/steps/assertions/page.js @@ -189,14 +189,12 @@ export default function(scenario, assert, find, currentPage, $) { ], function(property, component, containsLike, value) { let target; - try { - if (typeof component === 'string') { - property = `${component}.${property}`; - } - target = find(property); - } catch (e) { - throw e; + + if (typeof component === 'string') { + property = `${component}.${property}`; } + target = find(property); + if (containsLike === 'like') { assert.equal( target, diff --git a/ui/packages/consul-ui/tests/steps/interactions/click.js b/ui/packages/consul-ui/tests/steps/interactions/click.js index d1ef934f4..773a9763f 100644 --- a/ui/packages/consul-ui/tests/steps/interactions/click.js +++ b/ui/packages/consul-ui/tests/steps/interactions/click.js @@ -11,14 +11,10 @@ export default function(scenario, find, click) { 'I click $property on the $component component', ], function(property, component, next) { - try { - if (typeof component === 'string') { - property = `${component}.${property}`; - } - return find(property)(); - } catch (e) { - throw e; + if (typeof component === 'string') { + property = `${component}.${property}`; } + return find(property)(); } ); } diff --git a/ui/packages/consul-ui/tests/steps/interactions/form.js b/ui/packages/consul-ui/tests/steps/interactions/form.js index 8b9708d35..59edeb37e 100644 --- a/ui/packages/consul-ui/tests/steps/interactions/form.js +++ b/ui/packages/consul-ui/tests/steps/interactions/form.js @@ -37,41 +37,37 @@ export default function(scenario, find, fillIn, triggerKeyEvent, currentPage) { `I${dont} fill in the $property on the $component component with yaml\n$yaml`, ], function(negative, property, component, data, next) { - try { - switch (true) { - case typeof component === 'string': - property = `${component}.${property}`; - // fallthrough - case typeof data === 'undefined': - data = component; - // // fallthrough - // case typeof property !== 'string': - // data = property; - } - let obj; - try { - obj = find(property); - } catch (e) { - obj = currentPage(); - } - return Object.keys(data).reduce(function(prev, item, i, arr) { - const name = `${obj.prefix || property}[${item}]`; - if (negative) { - try { - fillInElement(prev, name, data[item]); - throw new TypeError(`${item} is editable`); - } catch (e) { - if (e instanceof TypeError) { - throw e; - } - } - } else { - return fillInElement(prev, name, data[item]); - } - }, obj); - } catch (e) { - throw e; + switch (true) { + case typeof component === 'string': + property = `${component}.${property}`; + // fallthrough + case typeof data === 'undefined': + data = component; + // // fallthrough + // case typeof property !== 'string': + // data = property; } + let obj; + try { + obj = find(property); + } catch (e) { + obj = currentPage(); + } + return Object.keys(data).reduce(function(prev, item, i, arr) { + const name = `${obj.prefix || property}[${item}]`; + if (negative) { + try { + fillInElement(prev, name, data[item]); + throw new TypeError(`${item} is editable`); + } catch (e) { + if (e instanceof TypeError) { + throw e; + } + } + } else { + return fillInElement(prev, name, data[item]); + } + }, obj); } ) .then(['I type "$text" into "$selector"'], function(text, selector) {