From fce4311f55a45fbd305cfd256a0929e0d5d9bd41 Mon Sep 17 00:00:00 2001 From: John Cowen Date: Mon, 20 Jul 2020 18:04:43 +0100 Subject: [PATCH] ui: KV Form and List Components (#8307) * Add components for KV form, KV list and Session form * Pass through a @label attribute for a human label + don't require error * Ignore transition aborted errors for if you are re-transitioning * Make old confirmation dialog more ember-like and tagless * Make sure data-source and data-sink supports KV and sessions * Use new components and delete all the things * Fix up tests * Make list component tagless * Add component pageobject and fixup tests from that * Add eslint warning back in --- .../components/confirmation-dialog/index.hbs | 8 +- .../components/confirmation-dialog/index.js | 38 +++--- ui-v2/app/components/consul-kv-form/index.hbs | 59 +++++++++ .../consul-kv-form/index.js} | 40 +++--- ui-v2/app/components/consul-kv-list/index.hbs | 58 +++++++++ ui-v2/app/components/consul-kv-list/index.js | 6 + .../components/consul-kv-list/pageobject.js | 8 ++ .../components/consul-session-form/index.hbs | 54 ++++++++ .../components/consul-session-form/index.js | 3 + ui-v2/app/components/data-form/index.hbs | 4 +- ui-v2/app/components/data-form/index.js | 4 + ui-v2/app/components/data-writer/index.hbs | 6 +- ui-v2/app/components/notification/index.js | 12 +- ui-v2/app/controllers/dc/kv/create.js | 2 - ui-v2/app/controllers/dc/kv/folder.js | 2 - ui-v2/app/controllers/dc/kv/root-create.js | 2 - ui-v2/app/mixins/kv/with-actions.js | 35 ------ ui-v2/app/routes/dc/kv/create.js | 35 +----- ui-v2/app/routes/dc/kv/edit.js | 31 +++-- ui-v2/app/routes/dc/kv/index.js | 3 +- .../app/services/data-sink/protocols/http.js | 1 + .../services/data-source/protocols/http.js | 1 + ui-v2/app/templates/dc/kv/-form.hbs | 46 ------- ui-v2/app/templates/dc/kv/-notifications.hbs | 31 ----- ui-v2/app/templates/dc/kv/edit.hbs | 82 ++++--------- ui-v2/app/templates/dc/kv/index.hbs | 116 ++++++------------ .../acceptance/components/kv-filter.feature | 2 +- ui-v2/tests/acceptance/dc/kvs/delete.feature | 42 +++++++ .../dc/kvs/sessions/invalidate.feature | 4 +- ui-v2/tests/acceptance/deleting.feature | 2 - .../acceptance/steps/dc/kvs/delete-steps.js | 10 ++ .../integration/components/consul-kind.js | 26 ---- ui-v2/tests/pages.js | 4 +- ui-v2/tests/pages/dc/kv/index.js | 11 +- .../unit/controllers/dc/kv/create-test.js | 12 -- .../tests/unit/controllers/dc/kv/edit-test.js | 12 -- .../unit/controllers/dc/kv/folder-test.js | 12 -- .../controllers/dc/kv/root-create-test.js | 12 -- .../tests/unit/mixins/kv/with-actions-test.js | 49 -------- 39 files changed, 386 insertions(+), 499 deletions(-) create mode 100644 ui-v2/app/components/consul-kv-form/index.hbs rename ui-v2/app/{controllers/dc/kv/edit.js => components/consul-kv-form/index.js} (51%) create mode 100644 ui-v2/app/components/consul-kv-list/index.hbs create mode 100644 ui-v2/app/components/consul-kv-list/index.js create mode 100644 ui-v2/app/components/consul-kv-list/pageobject.js create mode 100644 ui-v2/app/components/consul-session-form/index.hbs create mode 100644 ui-v2/app/components/consul-session-form/index.js delete mode 100644 ui-v2/app/controllers/dc/kv/create.js delete mode 100644 ui-v2/app/controllers/dc/kv/folder.js delete mode 100644 ui-v2/app/controllers/dc/kv/root-create.js delete mode 100644 ui-v2/app/mixins/kv/with-actions.js delete mode 100644 ui-v2/app/templates/dc/kv/-form.hbs delete mode 100644 ui-v2/app/templates/dc/kv/-notifications.hbs create mode 100644 ui-v2/tests/acceptance/dc/kvs/delete.feature create mode 100644 ui-v2/tests/acceptance/steps/dc/kvs/delete-steps.js delete mode 100644 ui-v2/tests/integration/components/consul-kind.js delete mode 100644 ui-v2/tests/unit/controllers/dc/kv/create-test.js delete mode 100644 ui-v2/tests/unit/controllers/dc/kv/edit-test.js delete mode 100644 ui-v2/tests/unit/controllers/dc/kv/folder-test.js delete mode 100644 ui-v2/tests/unit/controllers/dc/kv/root-create-test.js delete mode 100644 ui-v2/tests/unit/mixins/kv/with-actions-test.js diff --git a/ui-v2/app/components/confirmation-dialog/index.hbs b/ui-v2/app/components/confirmation-dialog/index.hbs index 1ffade5cf3..c1fd3180cd 100644 --- a/ui-v2/app/components/confirmation-dialog/index.hbs +++ b/ui-v2/app/components/confirmation-dialog/index.hbs @@ -1,11 +1,13 @@ +
{{yield}} - + {{#if (or permanent (not confirming))}} {{yield}} {{/if}} - + {{#if confirming }} {{yield}} {{/if}} - \ No newline at end of file + +
\ No newline at end of file diff --git a/ui-v2/app/components/confirmation-dialog/index.js b/ui-v2/app/components/confirmation-dialog/index.js index b53dcd68ed..d44c7471d9 100644 --- a/ui-v2/app/components/confirmation-dialog/index.js +++ b/ui-v2/app/components/confirmation-dialog/index.js @@ -1,31 +1,27 @@ /*eslint ember/closure-actions: "warn"*/ import Component from '@ember/component'; -import SlotsMixin from 'block-slots'; +import Slotted from 'block-slots'; import { set } from '@ember/object'; -const cancel = function() { - set(this, 'confirming', false); -}; -const execute = function() { - this.sendAction(...['actionName', ...this['arguments']]); -}; -const confirm = function() { - const [action, ...args] = arguments; - set(this, 'actionName', action); - set(this, 'arguments', args); - set(this, 'confirming', true); -}; -export default Component.extend(SlotsMixin, { - classNameBindings: ['confirming'], - classNames: ['with-confirmation'], +export default Component.extend(Slotted, { + tagName: '', message: 'Are you sure?', confirming: false, permanent: false, - init: function() { - this._super(...arguments); - this.cancel = cancel.bind(this); - this.execute = execute.bind(this); - this.confirm = confirm.bind(this); + actions: { + cancel: function() { + set(this, 'confirming', false); + }, + execute: function() { + set(this, 'confirming', false); + this.sendAction(...['actionName', ...this['arguments']]); + }, + confirm: function() { + const [action, ...args] = arguments; + set(this, 'actionName', action); + set(this, 'arguments', args); + set(this, 'confirming', true); + }, }, }); diff --git a/ui-v2/app/components/consul-kv-form/index.hbs b/ui-v2/app/components/consul-kv-form/index.hbs new file mode 100644 index 0000000000..f5fff53910 --- /dev/null +++ b/ui-v2/app/components/consul-kv-form/index.hbs @@ -0,0 +1,59 @@ + + +
+
+{{#if api.isCreate}} + +{{/if}} +{{#if (or (eq (left-trim api.data.Key parent.Key) '') (not-eq (last api.data.Key) '/'))}} +
+
+ +
+ +
+{{/if}} +
+ {{#if api.isCreate}} + + + {{else}} + + + + + + + + + + + {{/if}} +
+
+
diff --git a/ui-v2/app/controllers/dc/kv/edit.js b/ui-v2/app/components/consul-kv-form/index.js similarity index 51% rename from ui-v2/app/controllers/dc/kv/edit.js rename to ui-v2/app/components/consul-kv-form/index.js index e115c85b0b..6297aaac2c 100644 --- a/ui-v2/app/controllers/dc/kv/edit.js +++ b/ui-v2/app/components/consul-kv-form/index.js @@ -1,45 +1,33 @@ -import Controller from '@ember/controller'; +import Component from '@ember/component'; import { get, set } from '@ember/object'; import { inject as service } from '@ember/service'; -export default Controller.extend({ - dom: service('dom'), - builder: service('form'), +export default Component.extend({ + tagName: '', encoder: service('btoa'), json: true, - init: function() { - this._super(...arguments); - this.form = this.builder.form('kv'); + ondelete: function() { + this.onsubmit(...arguments); }, - setProperties: function(model) { - // essentially this replaces the data with changesets - this._super( - Object.keys(model).reduce((prev, key, i) => { - switch (key) { - case 'item': - prev[key] = this.form.setData(prev[key]).getData(); - break; - } - return prev; - }, model) - ); + oncancel: function() { + this.onsubmit(...arguments); }, + onsubmit: function() {}, actions: { - change: function(e, value, item) { - const event = this.dom.normalizeEvent(e, value); - const form = this.form; + change: function(e, form) { + const item = form.getData(); try { - form.handleEvent(event); + form.handleEvent(e); } catch (err) { - const target = event.target; + const target = e.target; let parent; switch (target.name) { case 'value': - set(this.item, 'Value', this.encoder.execute(target.value)); + set(item, 'Value', this.encoder.execute(target.value)); break; case 'additional': parent = get(this, 'parent.Key'); - set(this.item, 'Key', `${parent !== '/' ? parent : ''}${target.value}`); + set(item, 'Key', `${parent !== '/' ? parent : ''}${target.value}`); break; case 'json': // TODO: Potentially save whether json has been clicked to the model, diff --git a/ui-v2/app/components/consul-kv-list/index.hbs b/ui-v2/app/components/consul-kv-list/index.hbs new file mode 100644 index 0000000000..efef90339f --- /dev/null +++ b/ui-v2/app/components/consul-kv-list/index.hbs @@ -0,0 +1,58 @@ + + +{{#if (gt items.length 0)}} + + + Name + + + + {{right-trim (left-trim item.Key parent.Key) '/'}} + + + + + + More + + +
  • + {{if item.isFolder 'View' 'Edit'}} +
  • +
  • + +
    +
    +
    +
    + Confirm Delete +
    +

    + Are you sure you want to delete this key? +

    +
    +
      +
    • + +
    • +
    • + +
    • +
    +
    +
    +
  • +
    +
    +
    +
    +{{else}} + {{yield}} +{{/if}} +
    +
    \ No newline at end of file diff --git a/ui-v2/app/components/consul-kv-list/index.js b/ui-v2/app/components/consul-kv-list/index.js new file mode 100644 index 0000000000..8e9833de26 --- /dev/null +++ b/ui-v2/app/components/consul-kv-list/index.js @@ -0,0 +1,6 @@ +import Component from '@ember/component'; + +export default Component.extend({ + tagName: '', + ondelete: function() {}, +}); diff --git a/ui-v2/app/components/consul-kv-list/pageobject.js b/ui-v2/app/components/consul-kv-list/pageobject.js new file mode 100644 index 0000000000..be5230e366 --- /dev/null +++ b/ui-v2/app/components/consul-kv-list/pageobject.js @@ -0,0 +1,8 @@ +export default (collection, clickable, attribute, deletable) => () => { + return collection('.consul-kv-list [data-test-tabular-row]', { + name: attribute('data-test-kv', '[data-test-kv]'), + kv: clickable('a'), + actions: clickable('label'), + ...deletable(), + }); +}; diff --git a/ui-v2/app/components/consul-session-form/index.hbs b/ui-v2/app/components/consul-session-form/index.hbs new file mode 100644 index 0000000000..bc4cd7027c --- /dev/null +++ b/ui-v2/app/components/consul-session-form/index.hbs @@ -0,0 +1,54 @@ + + +
    +

    + Lock Session +

    +
    +
    Name
    +
    {{api.data.Name}}
    +
    Agent
    +
    + {{api.data.Node}} +
    +
    ID
    +
    {{api.data.ID}}
    +
    Behavior
    +
    {{api.data.Behavior}}
    +{{#if form.data.Delay }} +
    Delay
    +
    {{api.data.LockDelay}}
    +{{/if}} +{{#if form.data.TTL }} +
    TTL
    +
    {{api.data.TTL}}
    +{{/if}} +{{#if (gt api.data.Checks.length 0)}} +
    Health Checks
    +
    + {{ join ', ' api.data.Checks}} +
    +{{/if}} +
    + + + + + +

    + {{message}} +

    + + +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/ui-v2/app/components/consul-session-form/index.js b/ui-v2/app/components/consul-session-form/index.js new file mode 100644 index 0000000000..5570647734 --- /dev/null +++ b/ui-v2/app/components/consul-session-form/index.js @@ -0,0 +1,3 @@ +import Component from '@ember/component'; + +export default Component.extend({}); diff --git a/ui-v2/app/components/data-form/index.hbs b/ui-v2/app/components/data-form/index.hbs index a07770bb7b..39d8d426b8 100644 --- a/ui-v2/app/components/data-form/index.hbs +++ b/ui-v2/app/components/data-form/index.hbs @@ -4,6 +4,7 @@ @@ -19,12 +20,13 @@ ) as |api|}} {{yield api}} - + {{#if hasError}} {{yield api}} + {{/if}} diff --git a/ui-v2/app/components/data-form/index.js b/ui-v2/app/components/data-form/index.js index 9da4b0adbb..547341e9ef 100644 --- a/ui-v2/app/components/data-form/index.js +++ b/ui-v2/app/components/data-form/index.js @@ -27,6 +27,10 @@ export default Component.extend(Slotted, { // this lets us load view only data that doesn't have a form } }, + willRender: function() { + this._super(...arguments); + set(this, 'hasError', this._isRegistered('error')); + }, willDestroyElement: function() { this._super(...arguments); if (get(this, 'data.isNew')) { diff --git a/ui-v2/app/components/data-writer/index.hbs b/ui-v2/app/components/data-writer/index.hbs index 2668aa21ee..2120f5e4a2 100644 --- a/ui-v2/app/components/data-writer/index.hbs +++ b/ui-v2/app/components/data-writer/index.hbs @@ -38,7 +38,7 @@ {{/yield-slot}} @@ -51,7 +51,7 @@ {{else}} {{/yield-slot}} @@ -64,7 +64,7 @@
    -
    -{{#if create }} - -{{/if}} -{{#if (or (eq (left-trim item.Key parent.Key) '') (not-eq (last item.Key) '/')) }} -
    -
    - -
    - -
    -{{/if}} -
    - {{!TODO This has a
    around it in acls, remove or add for consistency }} -{{#if create }} - {{! we only need to check for an empty keyname here as ember munges autofocus, once we have autofocus back revisit this}} - -{{ else }} - - - - - - - - - - -{{/if}} - - diff --git a/ui-v2/app/templates/dc/kv/-notifications.hbs b/ui-v2/app/templates/dc/kv/-notifications.hbs deleted file mode 100644 index 74777e138e..0000000000 --- a/ui-v2/app/templates/dc/kv/-notifications.hbs +++ /dev/null @@ -1,31 +0,0 @@ -{{#if (eq type 'create')}} - {{#if (eq status 'success') }} - Your key has been added. - {{else}} - There was an error adding your key. - {{/if}} -{{else if (eq type 'update') }} - {{#if (eq status 'success') }} - Your key has been saved. - {{else}} - There was an error saving your key. - {{/if}} -{{ else if (eq type 'delete')}} - {{#if (eq status 'success') }} - Your key was deleted. - {{else}} - There was an error deleting your key. - {{/if}} -{{ else if (eq type 'deletesession')}} - {{#if (eq status 'success') }} - Your session was invalidated. - {{else}} - There was an error invalidating your session. - {{/if}} -{{/if}} -{{#let error.errors.firstObject as |error|}} - {{#if error.detail }} -
    {{concat '(' (if error.status (concat error.status ': ')) error.detail ')'}} - {{/if}} -{{/let}} - diff --git a/ui-v2/app/templates/dc/kv/edit.hbs b/ui-v2/app/templates/dc/kv/edit.hbs index 7752d5e5b5..fcb15f31a9 100644 --- a/ui-v2/app/templates/dc/kv/edit.hbs +++ b/ui-v2/app/templates/dc/kv/edit.hbs @@ -1,12 +1,9 @@ -{{#if create }} - {{title 'New Key/Value'}} -{{else}} +{{#if item.Key }} {{title 'Edit Key/Value'}} +{{else}} + {{title 'New Key/Value'}} {{/if}} - - - {{partial 'dc/kv/notifications'}} - +
    1. Key / Values
    2. @@ -27,56 +24,25 @@ - {{#if session}} -

      - Warning. This KV has a lock session. You can edit KV's with lock sessions, but we recommend doing so with care, or not doing so at all. It may negatively impact the active node it's associated with. See below for more details on the Lock Session and see our documentation for more information. -

      - {{/if}} - {{partial 'dc/kv/form'}} - {{#if session}} -
      -

      - Lock Session -

      -
      -
      Name
      -
      {{session.Name}}
      -
      Agent
      -
      - {{session.Node}} -
      -
      ID
      -
      {{session.ID}}
      -
      Behavior
      -
      {{session.Behavior}}
      -{{#if session.Delay }} -
      Delay
      -
      {{session.LockDelay}}
      -{{/if}} -{{#if session.TTL }} -
      TTL
      -
      {{session.TTL}}
      -{{/if}} -{{#if (gt session.Checks.length 0)}} -
      Health Checks
      -
      - {{ join ', ' session.Checks}} -
      -{{/if}} -
      - - - - - -

      - {{message}} -

      - - -
      -
      -
      - {{/if}} + {{#if session}} +

      + Warning. This KV has a lock session. You can edit KV's with lock sessions, but we recommend doing so with care, or not doing so at all. It may negatively impact the active node it's associated with. See below for more details on the Lock Session and see our documentation for more information. +

      + {{/if}} + + {{#if session}} + + {{/if}}
      \ No newline at end of file diff --git a/ui-v2/app/templates/dc/kv/index.hbs b/ui-v2/app/templates/dc/kv/index.hbs index 89154bc721..26f01f3b74 100644 --- a/ui-v2/app/templates/dc/kv/index.hbs +++ b/ui-v2/app/templates/dc/kv/index.hbs @@ -1,8 +1,5 @@ {{title 'Key/Value'}} - - - {{partial 'dc/kv/notifications'}} - +
        {{#if (not-eq parent.Key '/') }} @@ -41,82 +38,41 @@ - - - - Name - - - - {{right-trim (left-trim item.Key parent.Key) '/'}} - - - - - - More - - -
      1. - {{if item.isFolder 'View' 'Edit'}} -
      2. -
      3. - -
        -
        -
        -
        - Confirm Delete -
        -

        - Are you sure you want to delete this key? -

        -
        -
          -
        • - -
        • -
        • - -
        • -
        -
        -
        -
      4. -
        -
        -
        -
        -
        - - - -

        - {{#if (gt items.length 0)}} - No K/V pairs found - {{else}} - Welcome to Key/Value - {{/if}} -

        -
        - -

        - {{#if (gt items.length 0)}} - No K/V pairs where found matching that search, or you may not have access to view the K/V pairs you are searching for. - {{else}} - You don't have any K/V pairs, or you may not have access to view K/V pairs yet. - {{/if}} -

        -
        - - - - -
        + + + + +

        + {{#if (gt items.length 0)}} + No K/V pairs found + {{else}} + Welcome to Key/Value + {{/if}} +

        +
        + +

        + {{#if (gt items.length 0)}} + No K/V pairs where found matching that search, or you may not have access to view the K/V pairs you are searching for. + {{else}} + You don't have any K/V pairs, or you may not have access to view K/V pairs yet. + {{/if}} +

        +
        + + + + +
        +
        diff --git a/ui-v2/tests/acceptance/components/kv-filter.feature b/ui-v2/tests/acceptance/components/kv-filter.feature index f2cedbddbd..950abf6567 100644 --- a/ui-v2/tests/acceptance/components/kv-filter.feature +++ b/ui-v2/tests/acceptance/components/kv-filter.feature @@ -1,6 +1,6 @@ @setupApplicationTest Feature: components / kv-filter - Scenario: Filtering using the freetext filter + Scenario: Filtering using the freetext filter with [Text] Given 1 datacenter model with the value "dc-1" And 2 [Model] models from yaml --- diff --git a/ui-v2/tests/acceptance/dc/kvs/delete.feature b/ui-v2/tests/acceptance/dc/kvs/delete.feature new file mode 100644 index 0000000000..d22bfad39e --- /dev/null +++ b/ui-v2/tests/acceptance/dc/kvs/delete.feature @@ -0,0 +1,42 @@ +@setupApplicationTest +Feature: dc / kvs / deleting: Deleting items with confirmations, success and error notifications + Background: + Given 1 datacenter model with the value "datacenter" + Scenario: Deleting a kv model from the kv listing page + Given 1 kv model from yaml + --- + ["key-name"] + --- + When I visit the kvs page for yaml + --- + dc: datacenter + --- + And I click actions on the kvs + And I click delete on the kvs + And I click confirmDelete on the kvs + Then a DELETE request was made to "/v1/kv/key-name?dc=datacenter&ns=@!namespace" + And "[data-notification]" has the "notification-delete" class + And "[data-notification]" has the "success" class + Scenario: Deleting an kv from the kv detail page + When I visit the kv page for yaml + --- + dc: datacenter + kv: key-name + --- + And I click delete + And I click confirmDelete + Then a DELETE request was made to "/v1/kv/key-name?dc=datacenter&ns=@!namespace" + And "[data-notification]" has the "notification-delete" class + And "[data-notification]" has the "success" class + Scenario: Deleting an kv from the kv detail page and getting an error + When I visit the kv page for yaml + --- + dc: datacenter + kv: key-name + --- + Given the url "/v1/kv/key-name?dc=datacenter&ns=@!namespace" responds with a 500 status + And I click delete + And I click confirmDelete + And "[data-notification]" has the "notification-update" class + And "[data-notification]" has the "error" class + diff --git a/ui-v2/tests/acceptance/dc/kvs/sessions/invalidate.feature b/ui-v2/tests/acceptance/dc/kvs/sessions/invalidate.feature index 6e5621d96c..778df42163 100644 --- a/ui-v2/tests/acceptance/dc/kvs/sessions/invalidate.feature +++ b/ui-v2/tests/acceptance/dc/kvs/sessions/invalidate.feature @@ -21,12 +21,12 @@ Feature: dc / kvs / sessions / invalidate: Invalidate Lock Sessions And I click confirmDelete on the session Then a PUT request was made to "/v1/session/destroy/ee52203d-989f-4f7a-ab5a-2bef004164ca?dc=datacenter&ns=@!namespace" Then the url should be /datacenter/kv/key/edit - And "[data-notification]" has the "notification-deletesession" class + And "[data-notification]" has the "notification-delete" class And "[data-notification]" has the "success" class Scenario: Invalidating a lock session and receiving an error Given the url "/v1/session/destroy/ee52203d-989f-4f7a-ab5a-2bef004164ca?dc=datacenter&ns=@!namespace" responds with a 500 status And I click delete on the session And I click confirmDelete on the session Then the url should be /datacenter/kv/key/edit - And "[data-notification]" has the "notification-deletesession" class + And "[data-notification]" has the "notification-update" class And "[data-notification]" has the "error" class diff --git a/ui-v2/tests/acceptance/deleting.feature b/ui-v2/tests/acceptance/deleting.feature index 3989567afc..053069cc36 100644 --- a/ui-v2/tests/acceptance/deleting.feature +++ b/ui-v2/tests/acceptance/deleting.feature @@ -23,7 +23,6 @@ Feature: deleting: Deleting items with confirmations, success and error notifica Where: -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | Edit | Listing | Method | URL | Data | - | kv | kvs | DELETE | /v1/kv/key-name?dc=datacenter&ns=@!namespace | ["key-name"] | | token | tokens | DELETE | /v1/acl/token/001fda31-194e-4ff1-a5ec-589abf2cafd0?dc=datacenter&ns=@!namespace | {"AccessorID": "001fda31-194e-4ff1-a5ec-589abf2cafd0"} | # | acl | acls | PUT | /v1/acl/destroy/something?dc=datacenter | {"Name": "something", "ID": "something"} | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -51,7 +50,6 @@ Feature: deleting: Deleting items with confirmations, success and error notifica Where: ----------------------------------------------------------------------------------------------------------------------------------------------------------- | Model | Method | URL | Slug | - | kv | DELETE | /v1/kv/key-name?dc=datacenter&ns=@!namespace | kv: key-name | | token | DELETE | /v1/acl/token/001fda31-194e-4ff1-a5ec-589abf2cafd0?dc=datacenter&ns=@!namespace | token: 001fda31-194e-4ff1-a5ec-589abf2cafd0 | # | acl | PUT | /v1/acl/destroy/something?dc=datacenter | acl: something | ----------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/ui-v2/tests/acceptance/steps/dc/kvs/delete-steps.js b/ui-v2/tests/acceptance/steps/dc/kvs/delete-steps.js new file mode 100644 index 0000000000..ba1093295f --- /dev/null +++ b/ui-v2/tests/acceptance/steps/dc/kvs/delete-steps.js @@ -0,0 +1,10 @@ +import steps from '../../steps'; + +// step definitions that are shared between features should be moved to the +// tests/acceptance/steps/steps.js file + +export default function(assert) { + return steps(assert).then('I should find a file', function() { + assert.ok(true, this.step); + }); +} diff --git a/ui-v2/tests/integration/components/consul-kind.js b/ui-v2/tests/integration/components/consul-kind.js deleted file mode 100644 index d7f6e22c1e..0000000000 --- a/ui-v2/tests/integration/components/consul-kind.js +++ /dev/null @@ -1,26 +0,0 @@ -import { module, skip } from 'qunit'; -import { setupRenderingTest } from 'ember-qunit'; -import { render } from '@ember/test-helpers'; -import { hbs } from 'ember-cli-htmlbars'; - -module('Integration | Component | consul-kind', function(hooks) { - setupRenderingTest(hooks); - - skip('it renders', async function(assert) { - // Set any properties with this.set('myProperty', 'value'); - // Handle any actions with this.set('myAction', function(val) { ... }); - - await render(hbs``); - - assert.equal(this.element.textContent.trim(), ''); - - // Template block usage: - await render(hbs` - - template block text - - `); - - assert.equal(this.element.textContent.trim(), 'template block text'); - }); -}); diff --git a/ui-v2/tests/pages.js b/ui-v2/tests/pages.js index bb974e9cb4..4dd6268249 100644 --- a/ui-v2/tests/pages.js +++ b/ui-v2/tests/pages.js @@ -41,6 +41,7 @@ import consulTokenListFactory from 'consul-ui/components/consul-token-list/pageo import consulRoleListFactory from 'consul-ui/components/consul-role-list/pageobject'; import consulPolicyListFactory from 'consul-ui/components/consul-policy-list/pageobject'; import consulIntentionListFactory from 'consul-ui/components/consul-intention-list/pageobject'; +import consulKvListFactory from 'consul-ui/components/consul-kv-list/pageobject'; // pages import index from 'consul-ui/tests/pages/index'; @@ -96,6 +97,7 @@ const morePopoverMenu = morePopoverMenuFactory(clickable); const popoverSelect = popoverSelectFactory(clickable, collection); const consulIntentionList = consulIntentionListFactory(collection, clickable, attribute, deletable); +const consulKvList = consulKvListFactory(collection, clickable, attribute, deletable); const consulTokenList = consulTokenListFactory( collection, clickable, @@ -149,7 +151,7 @@ export default { instance: create(instance(visitable, attribute, collection, text, tabgroup)), nodes: create(nodes(visitable, clickable, attribute, collection, catalogFilter)), node: create(node(visitable, deletable, clickable, attribute, collection, tabgroup, text)), - kvs: create(kvs(visitable, deletable, creatable, clickable, attribute, collection)), + kvs: create(kvs(visitable, creatable, consulKvList)), kv: create(kv(visitable, attribute, submitable, deletable, cancelable, clickable)), acls: create(acls(visitable, deletable, creatable, clickable, attribute, collection, aclFilter)), acl: create(acl(visitable, submitable, deletable, cancelable, clickable)), diff --git a/ui-v2/tests/pages/dc/kv/index.js b/ui-v2/tests/pages/dc/kv/index.js index 8a58569402..cd868c8b7f 100644 --- a/ui-v2/tests/pages/dc/kv/index.js +++ b/ui-v2/tests/pages/dc/kv/index.js @@ -1,13 +1,6 @@ -export default function(visitable, deletable, creatable, clickable, attribute, collection) { +export default function(visitable, creatable, kvs) { return creatable({ visit: visitable(['/:dc/kv/:kv', '/:dc/kv'], str => str), - kvs: collection( - '[data-test-tabular-row]', - deletable({ - name: attribute('data-test-kv', '[data-test-kv]'), - kv: clickable('a'), - actions: clickable('label'), - }) - ), + kvs: kvs(), }); } diff --git a/ui-v2/tests/unit/controllers/dc/kv/create-test.js b/ui-v2/tests/unit/controllers/dc/kv/create-test.js deleted file mode 100644 index a2e69957f4..0000000000 --- a/ui-v2/tests/unit/controllers/dc/kv/create-test.js +++ /dev/null @@ -1,12 +0,0 @@ -import { module, test } from 'qunit'; -import { setupTest } from 'ember-qunit'; - -module('Unit | Controller | dc/kv/create', function(hooks) { - setupTest(hooks); - - // Replace this with your real tests. - test('it exists', function(assert) { - let controller = this.owner.lookup('controller:dc/kv/create'); - assert.ok(controller); - }); -}); diff --git a/ui-v2/tests/unit/controllers/dc/kv/edit-test.js b/ui-v2/tests/unit/controllers/dc/kv/edit-test.js deleted file mode 100644 index c20d4f9a5e..0000000000 --- a/ui-v2/tests/unit/controllers/dc/kv/edit-test.js +++ /dev/null @@ -1,12 +0,0 @@ -import { module, test } from 'qunit'; -import { setupTest } from 'ember-qunit'; - -module('Unit | Controller | dc/kv/edit', function(hooks) { - setupTest(hooks); - - // Replace this with your real tests. - test('it exists', function(assert) { - let controller = this.owner.lookup('controller:dc/kv/edit'); - assert.ok(controller); - }); -}); diff --git a/ui-v2/tests/unit/controllers/dc/kv/folder-test.js b/ui-v2/tests/unit/controllers/dc/kv/folder-test.js deleted file mode 100644 index 0bd7f0d69b..0000000000 --- a/ui-v2/tests/unit/controllers/dc/kv/folder-test.js +++ /dev/null @@ -1,12 +0,0 @@ -import { module, test } from 'qunit'; -import { setupTest } from 'ember-qunit'; - -module('Unit | Controller | dc/kv/folder', function(hooks) { - setupTest(hooks); - - // Replace this with your real tests. - test('it exists', function(assert) { - let controller = this.owner.lookup('controller:dc/kv/folder'); - assert.ok(controller); - }); -}); diff --git a/ui-v2/tests/unit/controllers/dc/kv/root-create-test.js b/ui-v2/tests/unit/controllers/dc/kv/root-create-test.js deleted file mode 100644 index f341c55a83..0000000000 --- a/ui-v2/tests/unit/controllers/dc/kv/root-create-test.js +++ /dev/null @@ -1,12 +0,0 @@ -import { module, test } from 'qunit'; -import { setupTest } from 'ember-qunit'; - -module('Unit | Controller | dc/kv/root-create', function(hooks) { - setupTest(hooks); - - // Replace this with your real tests. - test('it exists', function(assert) { - let controller = this.owner.lookup('controller:dc/kv/root-create'); - assert.ok(controller); - }); -}); diff --git a/ui-v2/tests/unit/mixins/kv/with-actions-test.js b/ui-v2/tests/unit/mixins/kv/with-actions-test.js deleted file mode 100644 index aee6bb6f8c..0000000000 --- a/ui-v2/tests/unit/mixins/kv/with-actions-test.js +++ /dev/null @@ -1,49 +0,0 @@ -import { module, skip } from 'qunit'; -import { setupTest } from 'ember-qunit'; -import test from 'ember-sinon-qunit/test-support/test'; -import Route from '@ember/routing/route'; -import Mixin from 'consul-ui/mixins/kv/with-actions'; - -module('Unit | Mixin | kv/with actions', function(hooks) { - setupTest(hooks); - - hooks.beforeEach(function() { - this.subject = function() { - const MixedIn = Route.extend(Mixin); - this.owner.register('test-container:kv/with-actions-object', MixedIn); - return this.owner.lookup('test-container:kv/with-actions-object'); - }; - }); - - // Replace this with your real tests. - test('it works', function(assert) { - const subject = this.subject(); - assert.ok(subject); - }); - test('afterUpdate calls transitionTo index when the key is a single slash', function(assert) { - const subject = this.subject(); - const expected = 'dc.kv.index'; - const transitionTo = this.stub(subject, 'transitionTo').returnsArg(0); - const actual = subject.afterUpdate({}, { Key: '/' }); - assert.equal(actual, expected); - assert.ok(transitionTo.calledOnce); - }); - test('afterUpdate calls transitionTo folder when the key is not a single slash', function(assert) { - const subject = this.subject(); - const expected = 'dc.kv.folder'; - const transitionTo = this.stub(subject, 'transitionTo').returnsArg(0); - ['', '/key', 'key/name'].forEach(item => { - const actual = subject.afterUpdate({}, { Key: item }); - assert.equal(actual, expected); - }); - assert.ok(transitionTo.calledThrice); - }); - test('afterDelete calls refresh folder when the routeName is `folder`', function(assert) { - const subject = this.subject(); - subject.routeName = 'dc.kv.folder'; - const refresh = this.stub(subject, 'refresh'); - subject.afterDelete({}, {}); - assert.ok(refresh.calledOnce); - }); - skip('action invalidateSession test'); -});