Repository: ambari Updated Branches: refs/heads/branch-2.4 c26dfced7 -> d4c839318
AMBARI-17482. Hive2 view : port changes of following 8 UI bugs in hive2 view (pallavkul) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/d4c83931 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/d4c83931 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/d4c83931 Branch: refs/heads/branch-2.4 Commit: d4c839318448d554aed020455dc213c3346398b8 Parents: c26dfce Author: Pallav Kulshreshtha <[email protected]> Authored: Thu Jun 30 16:27:00 2016 +0530 Committer: Pallav Kulshreshtha <[email protected]> Committed: Thu Jun 30 16:29:17 2016 +0530 ---------------------------------------------------------------------- .../app/components/date-range-widget.js | 13 ++ .../ui/hive-web/app/controllers/databases.js | 21 +++- .../controllers/index/history-query/explain.js | 14 ++- .../ui/hive-web/app/controllers/open-queries.js | 5 +- .../ui/hive-web/app/initializers/i18n.js | 1 + .../ui/hive-web/app/services/settings.js | 44 +++++-- .../resources/ui/hive-web/app/styles/app.scss | 28 ++++- .../app/templates/components/tree-view.hbs | 2 +- .../app/templates/databases-search-results.hbs | 6 +- .../ui/hive-web/app/templates/databases.hbs | 4 +- .../templates/index/history-query/explain.hbs | 14 ++- .../ui/hive-web/tests/helpers/api-mock.js | 13 ++ .../ui/hive-web/tests/helpers/dbclick.js | 26 ++++ .../hive-web/tests/integration/database-test.js | 27 ++++ .../tests/integration/query-editor-test.js | 20 +++ .../tests/integration/saved-queries-test.js | 30 ++++- .../ui/hive-web/tests/integration/udfs-test.js | 18 +++ .../tests/unit/components/udf-tr-view-test.js | 122 +++++++++++++++++++ .../tests/unit/controllers/udfs-test.js | 26 +++- 19 files changed, 403 insertions(+), 31 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/d4c83931/contrib/views/hive-next/src/main/resources/ui/hive-web/app/components/date-range-widget.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive-next/src/main/resources/ui/hive-web/app/components/date-range-widget.js b/contrib/views/hive-next/src/main/resources/ui/hive-web/app/components/date-range-widget.js index 9e38786..a9315ba 100644 --- a/contrib/views/hive-next/src/main/resources/ui/hive-web/app/components/date-range-widget.js +++ b/contrib/views/hive-next/src/main/resources/ui/hive-web/app/components/date-range-widget.js @@ -68,6 +68,7 @@ export default Ember.Component.extend({ this.$(".toDate").datepicker({ defaultDate: new Date(dateRange.get('to')), + minDate: new Date(dateRange.get('from')), onSelect: function (selectedDate) { @@ -80,6 +81,18 @@ export default Ember.Component.extend({ } }); + this.$(".fromDate").on('blur', () => { + if(moment(self.$(".fromDate").val(), 'MM/DD/YYYY', true).format() === 'Invalid date'){ + self.$(".fromDate").val('') + } + }); + + this.$(".toDate").on('blur', () => { + if(moment(self.$(".toDate").val(), 'MM/DD/YYYY', true).format() === 'Invalid date'){ + self.$(".toDate").val('') + } + }); + this.set('rendered', true); } }); http://git-wip-us.apache.org/repos/asf/ambari/blob/d4c83931/contrib/views/hive-next/src/main/resources/ui/hive-web/app/controllers/databases.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive-next/src/main/resources/ui/hive-web/app/controllers/databases.js b/contrib/views/hive-next/src/main/resources/ui/hive-web/app/controllers/databases.js index b76bca3..2c3cd5e 100644 --- a/contrib/views/hive-next/src/main/resources/ui/hive-web/app/controllers/databases.js +++ b/contrib/views/hive-next/src/main/resources/ui/hive-web/app/controllers/databases.js @@ -33,6 +33,8 @@ export default Ember.Controller.extend({ tableSearchResults: Ember.Object.create(), isDatabaseRefreshInProgress: false, + showColumnsResultAlert: false, + textColumnSearchTerm:'', tableControls: [ { @@ -357,6 +359,8 @@ export default Ember.Controller.extend({ searchTerm = searchTerm ? searchTerm.toLowerCase() : ''; + this.set('showColumnsResultAlert', false); + this.set('tablesSearchTerm', searchTerm); resultsTab.set('visible', true); this.set('selectedTab', resultsTab); @@ -381,18 +385,33 @@ export default Ember.Controller.extend({ searchTerm = searchTerm ? searchTerm.toLowerCase() : ''; - this.set('selectedTab', resultsTab); + this.set('columnSearchTerm', searchTerm); + this.set('textColumnSearchTerm', searchTerm); + this.set('selectedTab', resultsTab); this.set('isLoading', true); + this.set('showColumnsResultAlert', false); + + var tableCount = tables.length || 0; + var noColumnMatchTableCount = 0; tables.forEach(function (table) { self.get('databaseService').getColumnsPage(database.get('name'), table, searchTerm, true).then(function (result) { + + if(Ember.isEmpty(result.columns)){ + noColumnMatchTableCount = noColumnMatchTableCount + 1; + } table.set('columns', result.columns); table.set('hasNext', result.hasNext); if (tables.indexOf(table) === tables.get('length') -1) { self.set('isLoading', false); } + + // This will execute only in the last interation + if(noColumnMatchTableCount === tableCount) { + self.set('showColumnsResultAlert', true); + } }, function (err) { self._handleError(err); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/d4c83931/contrib/views/hive-next/src/main/resources/ui/hive-web/app/controllers/index/history-query/explain.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive-next/src/main/resources/ui/hive-web/app/controllers/index/history-query/explain.js b/contrib/views/hive-next/src/main/resources/ui/hive-web/app/controllers/index/history-query/explain.js index 20092e2..bc74e0b 100644 --- a/contrib/views/hive-next/src/main/resources/ui/hive-web/app/controllers/index/history-query/explain.js +++ b/contrib/views/hive-next/src/main/resources/ui/hive-web/app/controllers/index/history-query/explain.js @@ -119,7 +119,6 @@ export default Ember.ObjectController.extend({ } else { formatted.pushObject(currentNode); } - break; } } @@ -128,7 +127,16 @@ export default Ember.ObjectController.extend({ formatted.pushObject(currentNode); } } - + formatted = this.filterExplain(formatted); this.set('formattedExplain', formatted); + }, + filterExplain: function (explain){ + var formattedExplain = explain.filter(function(item){ + if(item.text !== '""'){ + return item; + } + }) + return formattedExplain; } -}); \ No newline at end of file +}); + http://git-wip-us.apache.org/repos/asf/ambari/blob/d4c83931/contrib/views/hive-next/src/main/resources/ui/hive-web/app/controllers/open-queries.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive-next/src/main/resources/ui/hive-web/app/controllers/open-queries.js b/contrib/views/hive-next/src/main/resources/ui/hive-web/app/controllers/open-queries.js index a4048be..e4e1490 100644 --- a/contrib/views/hive-next/src/main/resources/ui/hive-web/app/controllers/open-queries.js +++ b/contrib/views/hive-next/src/main/resources/ui/hive-web/app/controllers/open-queries.js @@ -364,7 +364,10 @@ export default Ember.ArrayController.extend({ }); }, function () { model.rollback(); - query.rollback(); + // Rollback the query if it is a DS model + if(query.get('constructor.typeKey') !== undefined) { + query.rollback(); + } self.closeTab(tab, true); }); } http://git-wip-us.apache.org/repos/asf/ambari/blob/d4c83931/contrib/views/hive-next/src/main/resources/ui/hive-web/app/initializers/i18n.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive-next/src/main/resources/ui/hive-web/app/initializers/i18n.js b/contrib/views/hive-next/src/main/resources/ui/hive-web/app/initializers/i18n.js index d2f6aaf..056db29 100644 --- a/contrib/views/hive-next/src/main/resources/ui/hive-web/app/initializers/i18n.js +++ b/contrib/views/hive-next/src/main/resources/ui/hive-web/app/initializers/i18n.js @@ -212,6 +212,7 @@ TRANSLATIONS = { labels: { noTablesMatch: 'No tables match', + noColumnsMatch: 'No columns match', table: 'Table ', hoursShort: "{{hours}} hrs", minsShort: "{{minutes}} mins", http://git-wip-us.apache.org/repos/asf/ambari/blob/d4c83931/contrib/views/hive-next/src/main/resources/ui/hive-web/app/services/settings.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive-next/src/main/resources/ui/hive-web/app/services/settings.js b/contrib/views/hive-next/src/main/resources/ui/hive-web/app/services/settings.js index b813bbf..df135d3 100644 --- a/contrib/views/hive-next/src/main/resources/ui/hive-web/app/services/settings.js +++ b/contrib/views/hive-next/src/main/resources/ui/hive-web/app/services/settings.js @@ -124,20 +124,40 @@ export default Ember.Service.extend({ var url = adapter.buildURL() + '/savedQueries/defaultSettings'; var settings = this.get('settings'); - settings.forEach(function(setting) { - data[ setting.get('key.name') ] = setting.get('value'); - }); + var settingException = {}; + + try { + settings.forEach(function(setting) { + + settingException['value'] = Ember.isEmpty(setting.get('value')); + + if(settingException['value']) { + settingException['name'] = setting.get('key.name'); + throw settingException + } + data[setting.get('key.name')] = setting.get('value'); + + }); + } catch(e) { + if (e!==settingException) throw e; + } + + + if(settingException['value']){ + self.get('notifyService').error('Please enter the value for '+ settingException['name'] ); + return; + } adapter.ajax(url, 'POST', { - data: {settings: data } - }) - .then(function(response) { - if (response && response.settings) { - self.get('notifyService').success(Ember.I18n.t('alerts.success.settings.saved')); - } else { - self.get('notifyService').error(response); - } - }); + data: {settings: data } + }) + .then(function(response) { + if (response && response.settings) { + self.get('notifyService').success(Ember.I18n.t('alerts.success.settings.saved')); + } else { + self.get('notifyService').error(response); + } + }); }, getSettings: function() { http://git-wip-us.apache.org/repos/asf/ambari/blob/d4c83931/contrib/views/hive-next/src/main/resources/ui/hive-web/app/styles/app.scss ---------------------------------------------------------------------- diff --git a/contrib/views/hive-next/src/main/resources/ui/hive-web/app/styles/app.scss b/contrib/views/hive-next/src/main/resources/ui/hive-web/app/styles/app.scss index 803d9b7..d72ae8c 100644 --- a/contrib/views/hive-next/src/main/resources/ui/hive-web/app/styles/app.scss +++ b/contrib/views/hive-next/src/main/resources/ui/hive-web/app/styles/app.scss @@ -468,6 +468,7 @@ body { .input-group-addon { text-align: justify; width: 50%; + vertical-align: top; } } @@ -475,11 +476,15 @@ body { line-height: 30px; font-size: 18px; cursor: pointer; + position: absolute; } .setting .setting-input-value { width: calc(100% - 30px); display: inline-block; + input { + height: 33px; + } } .setting .global-setting-value { width: calc(100% - 25px); @@ -640,6 +645,11 @@ td.data-upload-form-field { width: 350px; } +.hdfsPath { + width: 80%; + display: inline; +} + #hdfs-param input { width: 80%; display: inline; @@ -675,10 +685,26 @@ td.data-upload-form-field { padding-right: 10px; } +.accordion-body { + word-break: break-all; + overflow-y: scroll; +} + table.no-border, table.no-border tr, table.no-border tr td { border: none; } .red-border { border-color :red; -} \ No newline at end of file +} + +ul.explainlist li{ + background: none; + word-break: break-all; + padding: 0; +} + +pre.explainprint{ + line-height: 0.5; + padding: 12px 15px; +} http://git-wip-us.apache.org/repos/asf/ambari/blob/d4c83931/contrib/views/hive-next/src/main/resources/ui/hive-web/app/templates/components/tree-view.hbs ---------------------------------------------------------------------- diff --git a/contrib/views/hive-next/src/main/resources/ui/hive-web/app/templates/components/tree-view.hbs b/contrib/views/hive-next/src/main/resources/ui/hive-web/app/templates/components/tree-view.hbs index cb83ec3..ef9a566 100644 --- a/contrib/views/hive-next/src/main/resources/ui/hive-web/app/templates/components/tree-view.hbs +++ b/contrib/views/hive-next/src/main/resources/ui/hive-web/app/templates/components/tree-view.hbs @@ -16,7 +16,7 @@ * limitations under the License. }} -<ul class="list-unstyled"> +<ul class="list-unstyled explainlist"> {{#each item in content}} <li> {{item.text}} http://git-wip-us.apache.org/repos/asf/ambari/blob/d4c83931/contrib/views/hive-next/src/main/resources/ui/hive-web/app/templates/databases-search-results.hbs ---------------------------------------------------------------------- diff --git a/contrib/views/hive-next/src/main/resources/ui/hive-web/app/templates/databases-search-results.hbs b/contrib/views/hive-next/src/main/resources/ui/hive-web/app/templates/databases-search-results.hbs index 007d9ca..8ff3895 100644 --- a/contrib/views/hive-next/src/main/resources/ui/hive-web/app/templates/databases-search-results.hbs +++ b/contrib/views/hive-next/src/main/resources/ui/hive-web/app/templates/databases-search-results.hbs @@ -37,10 +37,14 @@ {{/if}} </div> {{/each}} - {{#if tableSearchResults.hasNext}} <strong><a {{action "showMoreResultTables" database}}>{{t "buttons.loadMore"}}</a></strong> {{/if}} + {{#if showColumnsResultAlert}} + <div class="alert alert-warning database-explorer-alert" role="alert"> + {{t "labels.noColumnsMatch"}} <strong>"{{textColumnSearchTerm}}"</strong> + </div> + {{/if}} </div> </div> {{else}} http://git-wip-us.apache.org/repos/asf/ambari/blob/d4c83931/contrib/views/hive-next/src/main/resources/ui/hive-web/app/templates/databases.hbs ---------------------------------------------------------------------- diff --git a/contrib/views/hive-next/src/main/resources/ui/hive-web/app/templates/databases.hbs b/contrib/views/hive-next/src/main/resources/ui/hive-web/app/templates/databases.hbs index 290cdac..3997ea8 100644 --- a/contrib/views/hive-next/src/main/resources/ui/hive-web/app/templates/databases.hbs +++ b/contrib/views/hive-next/src/main/resources/ui/hive-web/app/templates/databases.hbs @@ -29,7 +29,7 @@ <hr /> {{#if selectedDatabase}} - {{extended-input class="form-control input-sm mozBoxSizeFix" + {{extended-input class="form-control input-sm mozBoxSizeFix input-sm search-tables-text" placeholderTranslation="placeholders.search.tables" valueSearched="searchTables" value=tableSearchTerm}} @@ -39,7 +39,7 @@ {{#if tableSearchResults.tables}} - {{extended-input class="form-control input-sm mozBoxSizeFix" + {{extended-input class="form-control input-sm mozBoxSizeFix search-columns-text" placeholderTranslation="placeholders.search.columns" valueSearched="searchColumns" value=columnSearchTerm}} http://git-wip-us.apache.org/repos/asf/ambari/blob/d4c83931/contrib/views/hive-next/src/main/resources/ui/hive-web/app/templates/index/history-query/explain.hbs ---------------------------------------------------------------------- diff --git a/contrib/views/hive-next/src/main/resources/ui/hive-web/app/templates/index/history-query/explain.hbs b/contrib/views/hive-next/src/main/resources/ui/hive-web/app/templates/index/history-query/explain.hbs index 3f8810f..f7948e2 100644 --- a/contrib/views/hive-next/src/main/resources/ui/hive-web/app/templates/index/history-query/explain.hbs +++ b/contrib/views/hive-next/src/main/resources/ui/hive-web/app/templates/index/history-query/explain.hbs @@ -15,9 +15,13 @@ * See the License for the specific language governing permissions and * limitations under the License. }} - +<pre class="explainprint"> {{#each header in formattedExplain}} - {{#expander-widget heading=header.text}} - {{tree-view content=header.contents}} - {{/expander-widget}} -{{/each}} \ No newline at end of file + {{#if header.text}} + <div>{{header.text}}</div> + {{#if header.contents.length }} + {{tree-view content=header.contents}} + {{/if}} + {{/if}} +{{/each}} +</pre> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/d4c83931/contrib/views/hive-next/src/main/resources/ui/hive-web/tests/helpers/api-mock.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive-next/src/main/resources/ui/hive-web/tests/helpers/api-mock.js b/contrib/views/hive-next/src/main/resources/ui/hive-web/tests/helpers/api-mock.js index ed4822d..5bf41e6 100644 --- a/contrib/views/hive-next/src/main/resources/ui/hive-web/tests/helpers/api-mock.js +++ b/contrib/views/hive-next/src/main/resources/ui/hive-web/tests/helpers/api-mock.js @@ -246,6 +246,15 @@ export default function() { return [200, {"Content-Type": "application/json"}, JSON.stringify(files)]; }); + this.delete(baseUrl + '/fileResources/1', function (req) { + return [200, {"Content-Type": "application/json"}, JSON.stringify({})]; + }); + + this.put(baseUrl + '/udfs/1', function (req) { + return [200, {"Content-Type": "application/json"}, JSON.stringify({})]; + }); + + this.get(baseUrl + '/fileResources/1', function (req) { var files = { "fileResources": [ @@ -274,6 +283,10 @@ export default function() { return [200, {"Content-Type": "application/json"}, JSON.stringify(data)]; }); + this.delete(baseUrl + '/savedQueries/1', function (req) { + return [200, {"Content-Type": "application/json"}, JSON.stringify({})]; + }); + this.get(baseUrl + '/api/v1/views/TEZ/versions/1', function (req) { var data = { instances: [ http://git-wip-us.apache.org/repos/asf/ambari/blob/d4c83931/contrib/views/hive-next/src/main/resources/ui/hive-web/tests/helpers/dbclick.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive-next/src/main/resources/ui/hive-web/tests/helpers/dbclick.js b/contrib/views/hive-next/src/main/resources/ui/hive-web/tests/helpers/dbclick.js new file mode 100644 index 0000000..e6dfe83 --- /dev/null +++ b/contrib/views/hive-next/src/main/resources/ui/hive-web/tests/helpers/dbclick.js @@ -0,0 +1,26 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +Ember.Test.registerAsyncHelper('dblclick', + function (app, selector, context) { + var $el = findWithAssert(selector, context); + Ember.run(function () { + $el.dblclick(); + }); + } +); http://git-wip-us.apache.org/repos/asf/ambari/blob/d4c83931/contrib/views/hive-next/src/main/resources/ui/hive-web/tests/integration/database-test.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive-next/src/main/resources/ui/hive-web/tests/integration/database-test.js b/contrib/views/hive-next/src/main/resources/ui/hive-web/tests/integration/database-test.js index 52cda77..1af72c8 100644 --- a/contrib/views/hive-next/src/main/resources/ui/hive-web/tests/integration/database-test.js +++ b/contrib/views/hive-next/src/main/resources/ui/hive-web/tests/integration/database-test.js @@ -101,3 +101,30 @@ test('Searching for a table will display table results and column search field', }); }); }); + + +test('Users can search tables', function (assert) { + assert.expect(4); + + visit('/'); + + andThen(function () { + fillIn(find('.database-explorer .search-tables-text'), 'not_found'); + keyEvent(find('.database-explorer .search-tables-text'), 'keyup', 13); + }); + + andThen(function () { + assert.ok(find('.alert-warning .database-explorer-alert'), 'Alert is show when a table is not found'); + }); + + andThen(function () { + fillIn(find('.database-explorer .search-tables-text'), 'table'); + keyEvent(find('.database-explorer .search-tables-text'), 'keyup', 13); + }); + + andThen(function () { + assert.ok(find('.database-explorer .nav-tabs li:last').hasClass('active'), 'Search results tab is active'); + assert.ok(find('.database-explorer .databases .fa-database').length, 'Found databases are shown'); + assert.ok(find('.database-explorer .databases .tables').length, 'Found tables are shown'); + }); +}); http://git-wip-us.apache.org/repos/asf/ambari/blob/d4c83931/contrib/views/hive-next/src/main/resources/ui/hive-web/tests/integration/query-editor-test.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive-next/src/main/resources/ui/hive-web/tests/integration/query-editor-test.js b/contrib/views/hive-next/src/main/resources/ui/hive-web/tests/integration/query-editor-test.js index b409e12..3073013 100644 --- a/contrib/views/hive-next/src/main/resources/ui/hive-web/tests/integration/query-editor-test.js +++ b/contrib/views/hive-next/src/main/resources/ui/hive-web/tests/integration/query-editor-test.js @@ -20,6 +20,7 @@ import Ember from 'ember'; import { test } from 'ember-qunit'; import startApp from '../helpers/start-app'; import api from '../helpers/api-mock'; +import '../helpers/dbclick'; var App; var server; @@ -104,3 +105,22 @@ test('Can save query', function() { click('.modal-footer .btn-danger'); }); + +test('Can change tab title', function (assert) { + assert.expect(1); + + visit('/'); + + andThen(function () { + dblclick('.query-editor-panel tabs li:first a'); + + andThen(function () { + fillIn('.modal-body input', 'WS'); + click('.modal-footer .btn-success'); + + andThen(function () { + assert.equal(find('.query-editor-panel tabs li:first a').text().trim(), 'WS', 'Tab renamed'); + }); + }); + }); +}); http://git-wip-us.apache.org/repos/asf/ambari/blob/d4c83931/contrib/views/hive-next/src/main/resources/ui/hive-web/tests/integration/saved-queries-test.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive-next/src/main/resources/ui/hive-web/tests/integration/saved-queries-test.js b/contrib/views/hive-next/src/main/resources/ui/hive-web/tests/integration/saved-queries-test.js index c444523..fdbcd4e 100644 --- a/contrib/views/hive-next/src/main/resources/ui/hive-web/tests/integration/saved-queries-test.js +++ b/contrib/views/hive-next/src/main/resources/ui/hive-web/tests/integration/saved-queries-test.js @@ -117,10 +117,36 @@ test('Saved Query options menu', function() { expect(2); visit("/queries"); - click('.fa-gear'); + click('.fa-gear:first'); andThen(function() { equal(find('.dropdown-menu:visible').length, 1, 'Query menu is visible'); equal(find('.dropdown-menu:visible li').length, 2, 'Query menu has 2 options'); }); -}); \ No newline at end of file +}); + +test('User is able to see history for a query', function (assert) { + assert.expect(2); + + visit("/queries"); + click('.fa-gear:first'); + click('.dropdown-menu:visible li:first'); + + andThen(function () { + assert.equal(currentURL(), "/history", 'User is redirected to history'); + assert.equal(find('#content .table tbody tr').length, 1, 'Queries are filtered'); + }); +}); + +test('User is able to delete a query', function (assert) { + assert.expect(1); + + visit("/queries"); + click('.fa-gear:first'); + click('.dropdown-menu:visible li:last'); + click('.modal-footer .btn-success'); + + andThen(function () { + equal(find('#content .table tbody tr').length, 1, 'Query deleted'); + }); +}); http://git-wip-us.apache.org/repos/asf/ambari/blob/d4c83931/contrib/views/hive-next/src/main/resources/ui/hive-web/tests/integration/udfs-test.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive-next/src/main/resources/ui/hive-web/tests/integration/udfs-test.js b/contrib/views/hive-next/src/main/resources/ui/hive-web/tests/integration/udfs-test.js index 95a0043..526efc0 100644 --- a/contrib/views/hive-next/src/main/resources/ui/hive-web/tests/integration/udfs-test.js +++ b/contrib/views/hive-next/src/main/resources/ui/hive-web/tests/integration/udfs-test.js @@ -89,3 +89,21 @@ test('User is able to add udf', function() { equal(find('#content .table tbody tr').length, 3); }); }); + + +test('Can delete file resource', function (assert) { + assert.expect(1); + + visit('/udfs'); + click('.fa-gear:first'); + click('.dropdown-menu li:first'); + click('.dropdown-toggle:first'); + click('.fa-remove:first'); + + andThen(function () { + click('.modal-footer .btn-success'); + click('tr.ember-view:first .btn-success'); + }); + + assert.equal($('tr.ember-view:first td:first').text().trim().length, 0, 'File Resource Deleted'); +}); http://git-wip-us.apache.org/repos/asf/ambari/blob/d4c83931/contrib/views/hive-next/src/main/resources/ui/hive-web/tests/unit/components/udf-tr-view-test.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive-next/src/main/resources/ui/hive-web/tests/unit/components/udf-tr-view-test.js b/contrib/views/hive-next/src/main/resources/ui/hive-web/tests/unit/components/udf-tr-view-test.js new file mode 100644 index 0000000..18916de --- /dev/null +++ b/contrib/views/hive-next/src/main/resources/ui/hive-web/tests/unit/components/udf-tr-view-test.js @@ -0,0 +1,122 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import Ember from 'ember'; +import { moduleForComponent, test } from 'ember-qunit'; + +moduleForComponent('udf-tr-view', 'UdfTrViewComponent', { + unit: true, + needs: ['component:select-widget'] +}); + +test('Can send actions', function (assert) { + assert.expect(6); + + var targetObject = { + onDeleteUdf: function () { + assert.ok(true, 'onDeleteUdf called'); + }, + onAddFileResource: function () { + assert.ok(true, 'onAddFileResource called'); + }, + onDeleteFileResource: function () { + assert.ok(true, 'onDeleteFileResource called'); + }, + onSaveUdf: function () { + assert.ok(true, 'onSaveUdf called'); + }, + }; + + var component = this.subject({ + onDeleteUdf: 'onDeleteUdf', + onAddFileResource: 'onAddFileResource', + onDeleteFileResource: 'onDeleteFileResource', + onSaveUdf: 'onSaveUdf', + + targetObject: targetObject, + + udf: Ember.Object.create() + }); + + Ember.run(function () { + component.send('deleteUdf'); + component.send('addFileResource'); + component.send('deleteFileResource'); + component.send('save'); + + component.send('editUdf'); + component.send('editFileResource', {}); + }); + + assert.ok(component.get('udf.isEditing'), 'Can edit udf'); + assert.ok(component.get('udf.isEditingResource'), 'Can edit resource'); +}); + +test('It sets isEditing to true if udf.isNew', function (assert) { + assert.expect(1); + + var component = this.subject({ + udf: Ember.Object.create({ + isNew: true, + isEditing: false + }) + }); + + var $component = this.render(); + assert.ok(component.get('udf.isEditing'), 'isEditing set to true'); +}); + +test('Cancel edit whould rollback changes', function (assert) { + assert.expect(5); + + var backup = 'fileResource backup'; + var file = Ember.Object.create({ + rollback: function () { + assert.ok(true, 'file.rollback() called'); + } + }); + + var udf = Ember.Object.create({ + isEditing: true, + isEditingResource: true, + get: function () { + var defer = new Ember.RSVP.defer; + defer.resolve(file); + + return defer.promise; + }, + rollback: function () { + assert.ok(true, 'udf.rollback() called'); + } + }); + + var component = this.subject({ + file: file, + udf: udf, + fileBackup: backup + }); + + Ember.run(function () { + component.send('cancel'); + }); + + assert.ok(!component.get('udf.isEditing'), 'isEditing set to false'); + assert.ok(!component.get('udf.isEditingResource'), 'isEditingResource set to false'); + + assert.equal(component.get('udf.fileResource'), backup, 'backup is set as file resource'); +}); http://git-wip-us.apache.org/repos/asf/ambari/blob/d4c83931/contrib/views/hive-next/src/main/resources/ui/hive-web/tests/unit/controllers/udfs-test.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive-next/src/main/resources/ui/hive-web/tests/unit/controllers/udfs-test.js b/contrib/views/hive-next/src/main/resources/ui/hive-web/tests/unit/controllers/udfs-test.js index 5bd369e..2568d4a 100644 --- a/contrib/views/hive-next/src/main/resources/ui/hive-web/tests/unit/controllers/udfs-test.js +++ b/contrib/views/hive-next/src/main/resources/ui/hive-web/tests/unit/controllers/udfs-test.js @@ -19,7 +19,11 @@ import Ember from 'ember'; import { moduleFor, test } from 'ember-qunit'; -moduleFor('controller:udfs', 'UdfsController', {}); +moduleFor('controller:udfs', 'UdfsController', { + needs: [ + 'model:file-resource' + ] +}); test('controller is initialized', function() { expect(3); @@ -57,4 +61,22 @@ test('add', function() { Ember.run(function () { component.send('add'); }); -}); \ No newline at end of file +}); + +test('handleAddFileResource', function (assert) { + assert.expect(2); + + var udf = Ember.Object.create({ + isEditingResource: false, + fileResource: null + }); + + var controller = this.subject(); + + Ember.run(function () { + controller.send('handleAddFileResource', udf); + }); + + assert.ok(udf.get('fileResource'), 'File Resource created'); + assert.ok(udf.get('isEditingResource'), 'Editing mode in enabled'); +});
