mirror of https://github.com/apache/cloudstack.git
Remove old/obsolete UI qunit tests
This commit is contained in:
parent
4215d69753
commit
2893120f2a
|
|
@ -34,70 +34,11 @@ under the License.
|
|||
|
||||
<!-- jQuery -->
|
||||
<script src="../lib/jquery.js" type="text/javascript"></script>
|
||||
<script src="../lib/jquery.easing.js" type="text/javascript"></script>
|
||||
<script src="../lib/jquery.validate.js" type="text/javascript"></script>
|
||||
<script src="../lib/jquery-ui/js/jquery-ui.js" type="text/javascript"></script>
|
||||
|
||||
<!-- Flot -->
|
||||
<script src="../lib/excanvas.js"></script>
|
||||
<script src="../lib/flot/jquery.flot.js" type="text/javascript"></script>
|
||||
<script src="../lib/flot/jquery.colorhelpers.js" type="text/javascript"></script>
|
||||
<script src="../lib/flot/jquery.flot.crosshair.js" type="text/javascript"></script>
|
||||
<script src="../lib/flot/jquery.flot.fillbetween.js" type="text/javascript"></script>
|
||||
<script src="../lib/flot/jquery.flot.image.js" type="text/javascript"></script>
|
||||
<script src="../lib/flot/jquery.flot.navigate.js" type="text/javascript"></script>
|
||||
<script src="../lib/flot/jquery.flot.pie.js" type="text/javascript"></script>
|
||||
<script src="../lib/flot/jquery.flot.resize.js" type="text/javascript"></script>
|
||||
<script src="../lib/flot/jquery.flot.selection.js" type="text/javascript"></script>
|
||||
<script src="../lib/flot/jquery.flot.stack.js" type="text/javascript"></script>
|
||||
<script src="../lib/flot/jquery.flot.symbol.js" type="text/javascript"></script>
|
||||
<script src="../lib/flot/jquery.flot.threshold.js" type="text/javascript"></script>
|
||||
|
||||
<!-- UI -->
|
||||
<script src="../scripts/ui/core.js" type="text/javascript"></script>
|
||||
<script src="../scripts/ui/utils.js" type="text/javascript"></script>
|
||||
<script src="../scripts/ui/events.js" type="text/javascript"></script>
|
||||
<script src="../scripts/ui/dialog.js" type="text/javascript"></script>
|
||||
|
||||
<!-- UI - Widgets -->
|
||||
<script src="../scripts/ui/widgets/multiEdit.js" type="text/javascript"></script>
|
||||
<script src="../scripts/ui/widgets/overlay.js" type="text/javascript"></script>
|
||||
<script src="../scripts/ui/widgets/dataTable.js" type="text/javascript"></script>
|
||||
<script src="../scripts/ui/widgets/cloudBrowser.js" type="text/javascript"></script>
|
||||
<script src="../scripts/ui/widgets/listView.js" type="text/javascript"></script>
|
||||
<script src="../scripts/ui/widgets/detailView.js" type="text/javascript"></script>
|
||||
<script src="../scripts/ui/widgets/treeView.js" type="text/javascript"></script>
|
||||
<script src="../scripts/ui/widgets/notifications.js" type="text/javascript"></script>
|
||||
|
||||
<!-- Common libraries -->
|
||||
<script src="../lib/date.js" type="text/javascript"></script>
|
||||
<script src="../lib/jquery.cookies.js" type="text/javascript"></script>
|
||||
<script src="../lib/jquery.timers.js" type="text/javascript"></script>
|
||||
<script src="../lib/jquery.md5.js" type="text/javascript" ></script>
|
||||
|
||||
<!-- CloudStack -->
|
||||
<script src="../scripts/ui-custom/login.js" type="text/javascript"></script>
|
||||
<script src="../scripts/ui-custom/projects.js" type="text/javascript"></script>
|
||||
<script src="../scripts/ui-custom/zoneChart.js" type="text/javascript"></script>
|
||||
<script src="../scripts/ui-custom/dashboard.js" type="text/javascript"></script>
|
||||
<script src="../scripts/ui-custom/installWizard.js" type="text/javascript"></script>
|
||||
<script src="../scripts/ui-custom/instanceWizard.js" type="text/javascript"></script>
|
||||
<script src="../scripts/ui-custom/ipRules.js" type="text/javascript"></script>
|
||||
<script src="../scripts/ui-custom/enableStaticNAT.js" type="text/javascript"></script>
|
||||
<script src="../scripts/ui-custom/securityRules.js" type="text/javascript"></script>
|
||||
<script src="../scripts/ui-custom/recurringSnapshots.js" type="text/javascript"></script>
|
||||
<script src="../scripts/ui-custom/physicalResources.js" type="text/javascript"></script>
|
||||
<script src="../scripts/ui-custom/zoneWizard.js" type="text/javascript"></script>
|
||||
|
||||
<!-- qunit -->
|
||||
<script src="../lib/qunit/qunit.js" type="text/javascript"></script>
|
||||
|
||||
<!-- Tests -->
|
||||
<script src="test.core.js" type="text/javascript"></script>
|
||||
<script src="test.cloudBrowser.js" type="text/javascript"></script>
|
||||
<script src="test.notifications.js" type="text/javascript"></script>
|
||||
<script src="test.listView.js" type="text/javascript"></script>
|
||||
<script src="test.detailView.js" type="text/javascript"></script>
|
||||
<script src="test.multiEdit.js" type="text/javascript"></script>
|
||||
<!---->
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -1,116 +0,0 @@
|
|||
// 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.
|
||||
(function($) {
|
||||
var $browser, $breadcrumbs, $browserContainer;
|
||||
|
||||
module('Browser', {
|
||||
setup: function() {
|
||||
$.fx.off = true;
|
||||
$browser = $('<div>').addClass('browser-test').appendTo('#qunit-fixture');
|
||||
$breadcrumbs = $('<div>').attr('id', 'breadcrumbs').appendTo($browser);
|
||||
$browserContainer = $('<div>').addClass('container').appendTo($browser);
|
||||
ok($browserContainer.cloudBrowser(), 'Browser initialized');
|
||||
equal($breadcrumbs.find('ul').size(), 1, 'Breadcrumbs initialized');
|
||||
}
|
||||
});
|
||||
|
||||
// Browser tests
|
||||
test('Add panel', function() {
|
||||
ok($browserContainer.cloudBrowser('addPanel', { title: 'testPanel123' }), 'Add panel');
|
||||
equal($browser.find('.panel').size(), 1, 'Browser has 1 panel');
|
||||
equal($breadcrumbs.find('ul li').size(), 1, 'Browser has 1 breadcrumb');
|
||||
equal($breadcrumbs.find('ul li:first span').html(), 'testPanel123', 'Panel has correct title');
|
||||
});
|
||||
|
||||
test('Add a second panel', function() {
|
||||
ok($browserContainer.cloudBrowser('addPanel', { title: 'testPanel123' }), 'Add first panel');
|
||||
ok($browserContainer.cloudBrowser('addPanel', { title: 'testPanel456' }), 'Add second panel');
|
||||
equal($browser.find('.panel').size(), 2, 'Browser has 2 panels');
|
||||
equal($breadcrumbs.find('ul li').size(), 2, 'Browser has 2 breadcrumbs');
|
||||
equal($breadcrumbs.find('ul li:last span').html(), 'testPanel456', 'New panel has correct title');
|
||||
equal($breadcrumbs.find('ul li:first span').html(), 'testPanel123', 'First panel still has correct title');
|
||||
});
|
||||
|
||||
test('Add maximized panel', function() {
|
||||
var $maximizedPanel, $normalPanel;
|
||||
|
||||
ok($browserContainer.cloudBrowser('addPanel', { title: 'testPanel123' }, 'Add first panel'));
|
||||
ok($browserContainer.cloudBrowser('addPanel', { title: 'testPanel456' }, 'Add normal-sized-panel'));
|
||||
ok($browserContainer.cloudBrowser('addPanel', { title: 'testPanel789', maximizeIfSelected: true }), 'Add maximized panel');
|
||||
|
||||
$maximizedPanel = $browserContainer.find('.panel:last');
|
||||
$normalPanel = $browserContainer.find('.panel:first').next();
|
||||
|
||||
ok($maximizedPanel.hasClass('always-maximized'), 'Maximized panel has maximized class');
|
||||
ok(!$normalPanel.hasClass('always-maximized'), 'Normal panel has maximized class');
|
||||
equal($maximizedPanel.width(), $browserContainer.width(), 'Maximized panel covers full width of browser container');
|
||||
notEqual($normalPanel.width(), $browserContainer.width(), 'Normal panel doesn\'t have maximized appearance');
|
||||
});
|
||||
|
||||
test('Select panel', function() {
|
||||
ok($browserContainer.cloudBrowser('addPanel', { title: 'testPanel123' }), 'Add first panel');
|
||||
ok($browserContainer.cloudBrowser('addPanel', { title: 'testPanel456' }), 'Add second panel');
|
||||
ok($browserContainer.cloudBrowser('addPanel', { title: 'testPanel789' }), 'Add third panel');
|
||||
|
||||
stop();
|
||||
$browserContainer.cloudBrowser('selectPanel', {
|
||||
panel: $browser.find('.panel:first').next(),
|
||||
complete: function() {
|
||||
start();
|
||||
ok(true, 'Select second panel');
|
||||
}
|
||||
});
|
||||
|
||||
equal($browser.find('.panel').size(), 2, 'Browser has 2 panels');
|
||||
equal($breadcrumbs.find('ul li:first span').html(), 'testPanel123', 'First panel still has correct title');
|
||||
equal($breadcrumbs.find('ul li:last span').html(), 'testPanel456', 'Second panel still has correct title');
|
||||
equal($breadcrumbs.find('ul li').size(), 2, 'Browser has 2 breadcrumbs');
|
||||
|
||||
stop();
|
||||
$browserContainer.cloudBrowser('selectPanel', {
|
||||
panel: $browser.find('.panel:first'),
|
||||
complete: function() {
|
||||
start();
|
||||
ok(true, 'Select first panel');
|
||||
}
|
||||
});
|
||||
|
||||
equal($browser.find('.panel').size(), 1, 'Browser has 1 panel');
|
||||
equal($breadcrumbs.find('ul li:first span').html(), 'testPanel123', 'First panel still has correct title');
|
||||
equal($breadcrumbs.find('ul li').size(), 1, 'Browser has 1 breadcrumb');
|
||||
});
|
||||
|
||||
test('Remove all panels', function() {
|
||||
ok($browserContainer.cloudBrowser('addPanel', { title: 'testPanel123' }), 'Add first panel');
|
||||
ok($browserContainer.cloudBrowser('addPanel', { title: 'testPanel456' }), 'Add second panel');
|
||||
ok($browserContainer.cloudBrowser('addPanel', { title: 'testPanel789' }), 'Add third panel');
|
||||
equal($browserContainer.find('.panel').size(), 3, 'Correct # of panels');
|
||||
ok($browserContainer.cloudBrowser('removeAllPanels'), 'Remove all panels');
|
||||
equal($browserContainer.find('.panel').size(), 0, 'All panels removed');
|
||||
ok($browserContainer.cloudBrowser('addPanel', { title: 'testPanel123' }), 'Add 1 panel');
|
||||
equal($browserContainer.find('.panel').size(), 1, 'Correct # of panels');
|
||||
});
|
||||
|
||||
test('Maximize panel', function() {
|
||||
ok($browserContainer.cloudBrowser('addPanel', { title: 'testPanel123' }), 'Add first panel');
|
||||
ok($browserContainer.cloudBrowser('addPanel', { title: 'testPanel456' }), 'Add second panel');
|
||||
equal($browserContainer.find('.panel').size(), 2, 'Correct # of panels');
|
||||
ok($browserContainer.cloudBrowser('toggleMaximizePanel', { panel: $browserContainer.find('.panel:first')}), 'Maximize first panel');
|
||||
ok($browserContainer.find('.panel:first').hasClass('maximized'), 'First panel has maximized style');
|
||||
ok(!$browserContainer.find('.panel:last').hasClass('maximized'), 'Last panel has correct style');
|
||||
});
|
||||
}(jQuery));
|
||||
|
|
@ -1,79 +0,0 @@
|
|||
// 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.
|
||||
(function($) {
|
||||
var $cloudStack, cloudStack;
|
||||
|
||||
module('Core widget', {
|
||||
setup: function() {
|
||||
cloudStack = {
|
||||
sections: {
|
||||
home: {
|
||||
show: function() { return $('<div>').addClass('test123'); }
|
||||
},
|
||||
sectionA: {},
|
||||
sectionB: {},
|
||||
sectionC: {}
|
||||
},
|
||||
|
||||
home: 'home'
|
||||
};
|
||||
|
||||
$cloudStack = $('<div>');
|
||||
ok($cloudStack.cloudStack(cloudStack), 'Basic widget initialized');
|
||||
}
|
||||
});
|
||||
|
||||
test('Container/wrappers', function() {
|
||||
equal($cloudStack.find('[cloudStack-container]').size(), 1, 'Main sub-container present');
|
||||
equal($cloudStack.find('#main-area').size(), 1, 'Main area present');
|
||||
});
|
||||
|
||||
test('Header', function() {
|
||||
var $header = $cloudStack.find('#header');
|
||||
var $userOptions = $cloudStack.find('#user-options');
|
||||
var $notifications = $header.find('.button.notifications');
|
||||
var $notificationTotal = $notifications.find('.total span');
|
||||
var $viewSwitcher = $header.find('.button.view-switcher');
|
||||
|
||||
equal($header.size(), 1, 'Header present');
|
||||
equal($userOptions.size(), 1, 'User options present');
|
||||
equal($userOptions.find('a').size(), 2, 'User options has correct # of options');
|
||||
equal($notifications.size(), 1, 'Notifications present');
|
||||
equal($notificationTotal.html(), '0', 'Notifications initialized properly');
|
||||
equal($viewSwitcher.size(), 1, 'View switcher present');
|
||||
});
|
||||
|
||||
test('Navigation', function() {
|
||||
var $navigation = $cloudStack.find('#navigation');
|
||||
|
||||
equal($navigation.size(), 1, 'Navigation present');
|
||||
equal($navigation.find('li').size(), 4, 'Navigation has correct # of nav items');
|
||||
});
|
||||
|
||||
test('Browser / page generation', function() {
|
||||
var $browser = $cloudStack.find('#browser');
|
||||
var $browserContainer = $browser.find('.container');
|
||||
var $homePage = $browserContainer.find('.panel div.test123');
|
||||
var $breadcrumbs = $browser.find('#breadcrumbs li');
|
||||
var $homeBreadcrumb = $browser.find('#breadcrumbs .home');
|
||||
|
||||
equal($browser.size(), 1, 'Browser intialized');
|
||||
equal($homePage.size(), 1, 'Home page is visible');
|
||||
equal($breadcrumbs.size(), 0, 'No initial breadcrumbs');
|
||||
equal($homeBreadcrumb.size(), 1, 'Home breadcrumb active');
|
||||
});
|
||||
}(jQuery));
|
||||
|
|
@ -1,799 +0,0 @@
|
|||
// 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.
|
||||
(function($) {
|
||||
module('Detail view', {
|
||||
setup: function() {
|
||||
cloudStack.dialog.__confirm = cloudStack.dialog.confirm;
|
||||
cloudStack.ui.notifications.__add = cloudStack.ui.notifications.add;
|
||||
$.fn.__cloudBrowser = $.fn.cloudBrowser;
|
||||
$.fn.__listView = $.fn.listView;
|
||||
$.fn.__dataTable = $.fn.dataTable;
|
||||
$.fn.__is = $.fn.is;
|
||||
|
||||
$.fn.is = function(args) {
|
||||
if (args == ':visible')
|
||||
return true; // No test elems will ever be shown, so just pretend they are visible
|
||||
|
||||
return true;
|
||||
};
|
||||
},
|
||||
|
||||
teardown: function() {
|
||||
cloudStack.dialog.confirm = cloudStack.dialog.__confirm;
|
||||
cloudStack.ui.notifications.add = cloudStack.ui.notifications.__add;
|
||||
$.fn.cloudBrowser = $.fn.__cloudBrowser;
|
||||
$.fn.listView = $.fn.__listView;
|
||||
$.fn.dataTable = $.fn.__dataTable;
|
||||
$.fn.is = $.fn.__is;
|
||||
}
|
||||
});
|
||||
|
||||
test('Basic', function() {
|
||||
var detailView = {
|
||||
tabs: {
|
||||
tabA: {
|
||||
title: 'tabA',
|
||||
fields: [{}],
|
||||
dataProvider: function() {}
|
||||
},
|
||||
tabB: {
|
||||
title: 'tabB',
|
||||
fields: [{}],
|
||||
dataProvider: function() {}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var $detailView = $('<div>');
|
||||
|
||||
ok($detailView.detailView(detailView), 'Create detail view');
|
||||
equal($detailView.find('.ui-tabs-nav li').size(), 2, 'Detail view has correct tab count');
|
||||
equal($detailView.find('.ui-tabs-nav li:first a').html(), 'tabA', 'First tab has correct title');
|
||||
equal($detailView.find('.ui-tabs-nav li:last a').html(), 'tabB', 'Last tab has correct title');
|
||||
});
|
||||
|
||||
test('Data provider', function() {
|
||||
var detailView = {
|
||||
tabs: {
|
||||
tabA: {
|
||||
title: 'tabA',
|
||||
fields: [{
|
||||
fieldA: { label: 'fieldA' },
|
||||
fieldB: { label: 'fieldB' }
|
||||
}],
|
||||
dataProvider: function(args) {
|
||||
start();
|
||||
ok(args.response.success({
|
||||
data: {
|
||||
fieldA: 'dataProviderFieldA',
|
||||
fieldB: 'dataProviderFieldB'
|
||||
}
|
||||
}), 'Call success');
|
||||
equal($detailView.find('tr').size(), 2, 'Correct fields rendered');
|
||||
equal($detailView.find('tr:first td:first').html(), 'fieldA', 'First field has correct label');
|
||||
equal($detailView.find('tr:first td:last').html(), 'dataProviderFieldA', 'First field has correct content');
|
||||
equal($detailView.find('tr:last td:first').html(), 'fieldB', 'Last field has correct label');
|
||||
equal($detailView.find('tr:last td:last').html(), 'dataProviderFieldB', 'Last field has correct content');
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
var $detailView = $('<div>');
|
||||
|
||||
stop();
|
||||
|
||||
// Test first tab
|
||||
$detailView = $detailView.detailView(detailView);
|
||||
|
||||
// Test last tab
|
||||
$detailView.find('.ui-tabs-nav li:last').click();
|
||||
});
|
||||
|
||||
test('Data provider, multiple tabs', function() {
|
||||
var detailView = {
|
||||
tabs: {
|
||||
tabA: {
|
||||
title: 'tabA',
|
||||
fields: [{
|
||||
fieldA: { label: 'fieldA' },
|
||||
fieldB: { label: 'fieldB' }
|
||||
}],
|
||||
dataProvider: function(args) {
|
||||
start();
|
||||
ok(args.response.success({
|
||||
data: {
|
||||
fieldA: 'dataProviderFieldA',
|
||||
fieldB: 'dataProviderFieldB'
|
||||
}
|
||||
}), 'Call success');
|
||||
equal($detailView.find('tr').size(), 2, 'Correct fields rendered');
|
||||
equal($detailView.find('tr:first td:first').html(), 'fieldA', 'First field has correct label');
|
||||
equal($detailView.find('tr:first td:last').html(), 'dataProviderFieldA', 'First field has correct content');
|
||||
equal($detailView.find('tr:last td:first').html(), 'fieldB', 'Last field has correct label');
|
||||
equal($detailView.find('tr:last td:last').html(), 'dataProviderFieldB', 'Last field has correct content');
|
||||
}
|
||||
},
|
||||
|
||||
tabB: {
|
||||
title: 'tabB',
|
||||
fields: [{
|
||||
fieldC: { label: 'fieldC' },
|
||||
fieldD: { label: 'fieldD' },
|
||||
fieldC: { label: 'fieldE' },
|
||||
fieldD: { label: 'fieldF' }
|
||||
}],
|
||||
dataProvider: function(args) {
|
||||
start();
|
||||
ok(args.response.success({
|
||||
data: {
|
||||
fieldC: 'dataProviderFieldC',
|
||||
fieldD: 'dataProviderFieldD',
|
||||
fieldE: 'dataProviderFieldE',
|
||||
fieldF: 'dataProviderFieldF'
|
||||
}
|
||||
}), 'Call success');
|
||||
equal($detailView.find('tr').size(), 4, 'Correct fields rendered');
|
||||
equal($detailView.find('tr:first td:first').html(), 'fieldC', 'First field has correct label');
|
||||
equal($detailView.find('tr:first td:last').html(), 'dataProviderFieldC', 'First field has correct content');
|
||||
equal($detailView.find('tr:last td:first').html(), 'fieldF', 'Last field has correct label');
|
||||
equal($detailView.find('tr:last td:last').html(), 'dataProviderFieldF', 'Last field has correct content');
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
var $detailView = $('<div>');
|
||||
|
||||
stop();
|
||||
|
||||
// Test first tab
|
||||
$detailView = $detailView.detailView(detailView);
|
||||
|
||||
// Test last tab
|
||||
$detailView.find('.ui-tabs-nav li:last').click();
|
||||
});
|
||||
|
||||
test('Field pre-filter', function() {
|
||||
var detailView = {
|
||||
tabs: {
|
||||
tabA: {
|
||||
title: 'tabA',
|
||||
fields: {
|
||||
fieldA: { label: 'fieldA' },
|
||||
fieldB: { label: 'fieldB' },
|
||||
fieldC: { label: 'fieldC' },
|
||||
fieldD: { label: 'fieldD' }
|
||||
},
|
||||
preFilter: function(args) {
|
||||
return ['fieldB', 'fieldC'];
|
||||
},
|
||||
dataProvider: function (args) {
|
||||
args.response.success({
|
||||
data: {
|
||||
fieldA: 'fieldAContent',
|
||||
fieldB: 'fieldBContent',
|
||||
fieldC: 'fieldCContent',
|
||||
fieldD: 'fieldDContent'
|
||||
}
|
||||
});
|
||||
|
||||
start();
|
||||
equal($detailView.find('tr').size(), 2, 'Correct fields rendered');
|
||||
equal($detailView.find('tr:first td:first').html(), 'fieldA', 'First field has correct label');
|
||||
equal($detailView.find('tr:first td:last').html(), 'fieldAContent', 'First field has correct content');
|
||||
equal($detailView.find('tr:last td:first').html(), 'fieldD', 'Last field has correct label');
|
||||
equal($detailView.find('tr:last td:last').html(), 'fieldDContent', 'Last field has correct content');
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
var $detailView = $('<div>');
|
||||
|
||||
stop();
|
||||
|
||||
$detailView.detailView(detailView);
|
||||
});
|
||||
|
||||
test('Action', function() {
|
||||
var detailView = {
|
||||
actions: {
|
||||
actionA: {
|
||||
label: 'testActionA',
|
||||
action: function(args) {
|
||||
start();
|
||||
ok(args.response.success(), 'Call success from action A');
|
||||
},
|
||||
messages: {
|
||||
confirm: function() { return 'testActionAConfirm'; },
|
||||
notification: function() { return 'testActionANotification'; }
|
||||
}
|
||||
},
|
||||
actionB: {
|
||||
label: 'testActionB',
|
||||
action: function(args) {
|
||||
start();
|
||||
ok(args.response.success(), 'Call success from action B');
|
||||
},
|
||||
messages: {
|
||||
confirm: function() { return 'testActionBConfirm'; },
|
||||
notification: function() { return 'testActionBNotification'; }
|
||||
},
|
||||
notification: {
|
||||
poll: function(args) {
|
||||
start();
|
||||
ok(args.complete(), 'Call complete from async action B');
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
tabs: {
|
||||
tabA: {
|
||||
title: 'tabA',
|
||||
fields: {
|
||||
fieldA: { label: 'fieldA' },
|
||||
fieldB: { label: 'fieldB' }
|
||||
},
|
||||
dataProvider: function(args) {
|
||||
args.response.success({
|
||||
data: {
|
||||
fieldA: 'fieldAContent',
|
||||
fieldB: 'fieldBContent'
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
var $detailView = $('<div>');
|
||||
|
||||
$detailView.detailView(detailView).appendTo('#qunit-fixture');
|
||||
|
||||
equal($detailView.find('.detail-actions').size(), 1, 'Action container present');
|
||||
equal($detailView.find('.detail-actions .action').size(), 2, 'Correct action count');
|
||||
equal($detailView.find('.detail-actions .action.actionA').size(), 1, 'actionA present');
|
||||
equal($detailView.find('.detail-actions .action.actionB').size(), 1, 'actionB present');
|
||||
|
||||
cloudStack.dialog.confirm = function(args) {
|
||||
start();
|
||||
equal(args.message, 'testActionAConfirm', 'Correct confirmation message for action A');
|
||||
stop();
|
||||
|
||||
args.action(); // Perform action
|
||||
};
|
||||
|
||||
cloudStack.ui.notifications.add = function(notification, success, successArgs) {
|
||||
stop();
|
||||
equal(notification.desc, 'testActionANotification', 'Correct notification message for action A');
|
||||
start();
|
||||
};
|
||||
|
||||
$detailView.find('.detail-actions .action.actionA a').click(); // <a> triggers action, not action's container
|
||||
|
||||
cloudStack.dialog.confirm = function(args) {
|
||||
start();
|
||||
equal(args.message, 'testActionBConfirm', 'Correct confirmation message for action B');
|
||||
stop();
|
||||
|
||||
args.action(); // Perform action
|
||||
};
|
||||
|
||||
cloudStack.ui.notifications.add = function(notification, success, successArgs) {
|
||||
start();
|
||||
equal(notification.desc, 'testActionBNotification', 'Correct notification message for action B');
|
||||
stop();
|
||||
notification.poll({ complete: function() { return true; } });
|
||||
};
|
||||
|
||||
$detailView.find('.detail-actions .action.actionB a').click(); // <a> triggers action, not action's container
|
||||
});
|
||||
|
||||
test('Action filter', function() {
|
||||
var detailView = {
|
||||
actions: {
|
||||
actionA: {
|
||||
label: 'testActionA',
|
||||
action: function(args) {}
|
||||
},
|
||||
actionB: {
|
||||
label: 'testActionB',
|
||||
action: function(args) {}
|
||||
}
|
||||
},
|
||||
tabs: {
|
||||
tabA: {
|
||||
title: 'tabA',
|
||||
fields: {
|
||||
fieldA: { label: 'fieldA' },
|
||||
fieldB: { label: 'fieldB' }
|
||||
},
|
||||
dataProvider: function(args) {
|
||||
args.response.success({
|
||||
actionFilter: function() {
|
||||
return ['actionA'];
|
||||
},
|
||||
data: {
|
||||
fieldA: 'fieldAContent',
|
||||
fieldB: 'fieldBContent'
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
var $detailView = $('<div>');
|
||||
|
||||
$detailView.detailView(detailView).appendTo('#qunit-fixture');
|
||||
|
||||
equal($detailView.find('.detail-actions .action').size(), 1, 'Correct action count');
|
||||
equal($detailView.find('.detail-actions .action.actionA').size(), 1, 'actionA present');
|
||||
notEqual($detailView.find('.detail-actions .action.actionB').size(), 1, 'actionB not present');
|
||||
});
|
||||
|
||||
test('Refresh', function() {
|
||||
var dataA = ['dataLoad1A', 'dataLoad2A'];
|
||||
var dataB = ['dataLoad1B', 'dataLoad2B'];
|
||||
var index = 0;
|
||||
|
||||
var detailView = {
|
||||
tabs: {
|
||||
tabA: {
|
||||
title: 'tabA',
|
||||
fields: {
|
||||
fieldA: { label: 'fieldA' }
|
||||
},
|
||||
dataProvider: function(args) {
|
||||
args.response.success({ data: { fieldA: dataA[index] }});
|
||||
start();
|
||||
equal($detailView.find('tr td:last').html(), dataA[index], 'Tab A data correct for load ' + (index + 1));
|
||||
index++;
|
||||
}
|
||||
},
|
||||
tabB: {
|
||||
title: 'tabB',
|
||||
fields: {
|
||||
fieldB: { label: 'fieldB' }
|
||||
},
|
||||
dataProvider: function(args) {
|
||||
args.response.success({ data: { fieldB: dataB[index] }});
|
||||
start();
|
||||
equal($detailView.find('tr td:last').html(), dataB[index], 'Tab B data correct for load ' + (index + 1));
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
var $detailView = $('<div>');
|
||||
|
||||
stop();
|
||||
$detailView.detailView(detailView).appendTo('#qunit-fixture');
|
||||
|
||||
stop();
|
||||
$detailView.find('.button.refresh').click();
|
||||
|
||||
stop();
|
||||
index = 0;
|
||||
$detailView.find('.ui-tabs-nav li.last a').click();
|
||||
|
||||
stop();
|
||||
$detailView.find('.button.refresh').click();
|
||||
});
|
||||
|
||||
test('View all, 1 section', function() {
|
||||
var $browser = $('<div>').appendTo('#qunit-fixture');
|
||||
var detailView = {
|
||||
$browser: $browser,
|
||||
context: {},
|
||||
viewAll: { label: 'testListView', path: 'testListView' },
|
||||
tabs: {
|
||||
tabA: {
|
||||
title: 'tabA',
|
||||
fields: [{ fieldA: { label: 'fieldA' }}],
|
||||
dataProvider: function(args) { args.response.success({ data: { fieldA: 'fieldAContent' } }); start(); }
|
||||
}
|
||||
}
|
||||
};
|
||||
var testListView = {};
|
||||
var $detailView = $('<div>').appendTo('#qunit-fixture');
|
||||
|
||||
$('<div>').attr('cloudStack-container', true).data('cloudStack-args', {
|
||||
sections: {
|
||||
testListView: testListView
|
||||
}
|
||||
}).appendTo('#qunit-fixture');
|
||||
|
||||
stop();
|
||||
|
||||
$.fn.cloudBrowser = function(cmd, args) {};
|
||||
$browser.cloudBrowser();
|
||||
$detailView.detailView(detailView);
|
||||
|
||||
equal($detailView.find('.detail-group.actions td.view-all').size(), 1, 'Detail view has view all button');
|
||||
|
||||
stop();
|
||||
|
||||
$.fn.listView = function(args, options) {
|
||||
start();
|
||||
ok(true, 'List view called');
|
||||
equal(args, testListView, 'Correct list view passed');
|
||||
ok(args.$browser.size(), 'Browser passed in args');
|
||||
ok($.isPlainObject(args.ref), 'Ref passed in args');
|
||||
equal(args.id, 'testListView', 'Correct section ID');
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
$.fn.cloudBrowser = function(cmd, args) {
|
||||
start();
|
||||
equal(cmd, 'addPanel', 'Browser add panel called');
|
||||
stop();
|
||||
args.complete($('<div>'));
|
||||
};
|
||||
|
||||
$detailView.find('.view-all a').click();
|
||||
});
|
||||
|
||||
test('View all, subsections', function() {
|
||||
var $browser = $('<div>').appendTo('#qunit-fixture');
|
||||
var detailView = {
|
||||
$browser: $browser,
|
||||
context: {},
|
||||
viewAll: { label: 'testListView', path: 'testSection.listViewB' },
|
||||
tabs: {
|
||||
tabA: {
|
||||
title: 'tabA',
|
||||
fields: [{ fieldA: { label: 'fieldA' }}],
|
||||
dataProvider: function(args) { args.response.success({ data: { fieldA: 'fieldAContent' } }); start(); }
|
||||
}
|
||||
}
|
||||
};
|
||||
var listViewA = {};
|
||||
var listViewB = {};
|
||||
var $detailView = $('<div>').appendTo('#qunit-fixture');
|
||||
|
||||
$('<div>').attr('cloudStack-container', true).data('cloudStack-args', {
|
||||
sections: {
|
||||
testSection: {
|
||||
sections: {
|
||||
listViewA: { listView: listViewA },
|
||||
listViewB: { listView: listViewB }
|
||||
}
|
||||
}
|
||||
}
|
||||
}).appendTo('#qunit-fixture');
|
||||
|
||||
stop();
|
||||
|
||||
$.fn.cloudBrowser = function(cmd, args) {};
|
||||
$browser.cloudBrowser();
|
||||
$detailView.detailView(detailView);
|
||||
|
||||
equal($detailView.find('.detail-group.actions td.view-all').size(), 1, 'Detail view has view all button');
|
||||
|
||||
stop();
|
||||
|
||||
$.fn.listView = function(args, options) {
|
||||
start();
|
||||
ok(true, 'List view called');
|
||||
equal(args.listView, listViewB, 'Correct list view passed');
|
||||
ok(args.$browser.size(), 'Browser passed in args');
|
||||
ok($.isPlainObject(args.ref), 'Ref passed in args');
|
||||
equal(args.id, 'testSection', 'Correct section ID');
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
$.fn.cloudBrowser = function(cmd, args) {
|
||||
start();
|
||||
equal(cmd, 'addPanel', 'Browser add panel called');
|
||||
stop();
|
||||
args.complete($('<div>'));
|
||||
};
|
||||
|
||||
$detailView.find('.view-all a').click();
|
||||
});
|
||||
|
||||
test('Pre-action', function() {
|
||||
var detailView = {
|
||||
actions: {
|
||||
test: {
|
||||
label: 'test',
|
||||
preAction: function() {
|
||||
start();
|
||||
ok(true, 'Pre-action called');
|
||||
|
||||
return false;
|
||||
},
|
||||
action: function() {
|
||||
ok(false, 'Action called; pre-action should have blocked it');
|
||||
},
|
||||
messages: { notification: function() { return 'notification'; }}
|
||||
}
|
||||
},
|
||||
tabs: {
|
||||
test: {
|
||||
title: 'test',
|
||||
label: 'testAction',
|
||||
fields: [{
|
||||
fieldA: { label: 'fieldA' },
|
||||
fieldB: { label: 'fieldB' }
|
||||
}],
|
||||
dataProvider: function(args) { args.response.success({ data: {} }); }
|
||||
}
|
||||
}
|
||||
};
|
||||
var $detailView = $('<div>');
|
||||
|
||||
stop();
|
||||
$detailView.detailView(detailView);
|
||||
$detailView.find('.action.test a').click();
|
||||
});
|
||||
|
||||
test('Update data, from list view row', function() {
|
||||
var detailView = {
|
||||
section: 'testListView',
|
||||
context: {
|
||||
testListView: [{
|
||||
fieldA: 'fieldA-1',
|
||||
fieldB: 'fieldB-1',
|
||||
fieldC: 'fieldC-1'
|
||||
}]
|
||||
},
|
||||
actions: {
|
||||
updateDataTestSync: {
|
||||
label: 'updateDataTestSync',
|
||||
preAction: function(args) { return true; },
|
||||
action: function(args) {
|
||||
args.response.success({
|
||||
data: {
|
||||
fieldA: 'fieldA-2',
|
||||
fieldB: 'fieldB-2'
|
||||
}
|
||||
});
|
||||
|
||||
start();
|
||||
equal($detailView.data('view-args').context.testListView[0].fieldA, 'fieldA-2', 'Correct context value for fieldA');
|
||||
equal($detailView.data('view-args').context.testListView[0].fieldB, 'fieldB-2', 'Correct context value for fieldB');
|
||||
equal($detailView.data('view-args').context.testListView[0].fieldC, 'fieldC-1', 'Correct context value for fieldC');
|
||||
equal($detailView.find('tr.fieldA .value').html(), 'fieldA-2', 'Correct table value for fieldA');
|
||||
equal($detailView.find('tr.fieldB .value').html(), 'fieldB-2', 'Correct table value for fieldB');
|
||||
equal($detailView.find('tr.fieldC .value').html(), 'fieldC-1', 'Correct table value for fieldC');
|
||||
},
|
||||
messages: { notification: function() { return 'notification'; }}
|
||||
}
|
||||
},
|
||||
tabs: {
|
||||
test: {
|
||||
title: 'test',
|
||||
fields: [{
|
||||
fieldA: { label: 'fieldA' },
|
||||
fieldB: { label: 'fieldB' },
|
||||
fieldC: { label: 'fieldC' }
|
||||
}],
|
||||
dataProvider: function(args) {
|
||||
args.response.success({
|
||||
data: args.context.testListView[0]
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
var $detailView = $('<div>');
|
||||
var $listView = $('<div>').addClass('list-view');
|
||||
var $listViewRow = $('<div>').data('json-obj', detailView.context.testListView[0]).appendTo($listView);
|
||||
var $cloudStackContainer = $('<div>').attr('cloudStack-container', true).data('cloudStack-args', {
|
||||
sections: {
|
||||
testListView: {}
|
||||
}
|
||||
}).appendTo('#qunit-fixture');
|
||||
|
||||
$.fn.dataTable = function() { return this; };
|
||||
$.fn.listView = function(args1, args2) {
|
||||
if (args1 == 'replaceItem')
|
||||
args2.after(args2.$row.data('json-obj', args2.data));
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
cloudStack.ui.notifications.add = function(notification, complete) {
|
||||
complete();
|
||||
};
|
||||
cloudStack.dialog.confirm = function(args) {
|
||||
args.action();
|
||||
};
|
||||
$detailView.data('list-view-row', $listViewRow);
|
||||
$detailView.detailView(detailView);
|
||||
|
||||
stop();
|
||||
$detailView.find('.action.updateDataTestSync a').click();
|
||||
});
|
||||
|
||||
|
||||
test('Update data async, from list view row', function() {
|
||||
var detailView = {
|
||||
section: 'testListView',
|
||||
context: {
|
||||
testListView: [{
|
||||
fieldA: 'fieldA-1',
|
||||
fieldB: 'fieldB-1',
|
||||
fieldC: 'fieldC-1',
|
||||
state: 'on'
|
||||
}]
|
||||
},
|
||||
actions: {
|
||||
updateDataTestAsync: {
|
||||
label: 'updateDataTestAsync',
|
||||
preAction: function(args) {
|
||||
start();
|
||||
ok(true, 'Pre-action called');
|
||||
equal($detailView.data('view-args').context.testListView[0].fieldA, 'fieldA-1', 'Pre-action: Correct context value for fieldA');
|
||||
equal($detailView.data('view-args').context.testListView[0].fieldB, 'fieldB-1', 'Pre-action: Correct context value for fieldB');
|
||||
equal($detailView.data('view-args').context.testListView[0].fieldC, 'fieldC-1', 'Pre-action: Correct context value for fieldC');
|
||||
stop();
|
||||
|
||||
return true;
|
||||
},
|
||||
action: function(args) {
|
||||
args.response.success();
|
||||
},
|
||||
messages: { notification: function() { return 'notification'; }},
|
||||
notification: {
|
||||
poll: function(args) {
|
||||
args.complete({
|
||||
data: {
|
||||
fieldA: 'fieldA-2',
|
||||
fieldB: 'fieldB-2',
|
||||
state: 'off'
|
||||
}
|
||||
});
|
||||
|
||||
start();
|
||||
equal($detailView.data('view-args').context.testListView[0].fieldA, 'fieldA-2', 'Correct context value for fieldA');
|
||||
equal($detailView.data('view-args').context.testListView[0].fieldB, 'fieldB-2', 'Correct context value for fieldB');
|
||||
equal($detailView.data('view-args').context.testListView[0].fieldC, 'fieldC-1', 'Correct context value for fieldC');
|
||||
equal($detailView.find('tr.fieldA .value').html(), 'fieldA-2', 'Correct table value for fieldA');
|
||||
equal($detailView.find('tr.fieldB .value').html(), 'fieldB-2', 'Correct table value for fieldB');
|
||||
equal($detailView.find('tr.fieldC .value').html(), 'fieldC-1', 'Correct table value for fieldC');
|
||||
|
||||
equal($detailView.find('.action').size(), 1, 'Correct action count');
|
||||
equal($detailView.find('.action.updateDataTestAsync').size(), 1, 'updateDataTestAsync present');
|
||||
equal($detailView.find('.action.filteredAction').size(), 0, 'filteredAction not present');
|
||||
stop();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
filteredAction: {
|
||||
label: 'filteredAction',
|
||||
action: function() {},
|
||||
messages: { notification: function() { return 'notification'; } }
|
||||
}
|
||||
},
|
||||
tabs: {
|
||||
test: {
|
||||
title: 'test',
|
||||
fields: [{
|
||||
fieldA: { label: 'fieldA' },
|
||||
fieldB: { label: 'fieldB' },
|
||||
fieldC: { label: 'fieldC' }
|
||||
}],
|
||||
dataProvider: function(args) {
|
||||
args.response.success({
|
||||
data: args.context.testListView[0],
|
||||
actionFilter: function(args) {
|
||||
if (args.context.testListView[0].state == 'on') {
|
||||
return ['updateDataTestAsync', 'filteredAction'];
|
||||
}
|
||||
|
||||
return ['updateDataTestAsync'];
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
var $detailView = $('<div>');
|
||||
var $listView = $('<div>').addClass('list-view');
|
||||
var $listViewRow = $('<div>').data('json-obj', detailView.context.testListView[0]).appendTo($listView);
|
||||
var $cloudStackContainer = $('<div>').attr('cloudStack-container', true).data('cloudStack-args', {
|
||||
sections: {
|
||||
testListView: {}
|
||||
}
|
||||
}).appendTo('#qunit-fixture');
|
||||
|
||||
$.fn.dataTable = function() { return this; };
|
||||
$.fn.listView = function(args1, args2) {
|
||||
if (args1 == 'replaceItem')
|
||||
args2.after(args2.$row.data('json-obj', args2.data));
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
cloudStack.ui.notifications.add = function(notification, complete) {
|
||||
notification.poll({ complete: complete });
|
||||
};
|
||||
cloudStack.dialog.confirm = function(args) {
|
||||
args.action();
|
||||
};
|
||||
$detailView.data('list-view-row', $listViewRow);
|
||||
$detailView.detailView(detailView);
|
||||
|
||||
equal($detailView.find('.action').size(), 2, 'Correct action count');
|
||||
equal($detailView.find('.action.updateDataTestAsync').size(), 1, 'updateDataTestAsync present');
|
||||
equal($detailView.find('.action.filteredAction').size(), 1, 'filteredAction present');
|
||||
|
||||
stop();
|
||||
$detailView.find('.action.updateDataTestAsync a').click();
|
||||
$detailView.data('view-args').actions.updateDataTestAsync.preAction = function(args) {
|
||||
start();
|
||||
equal($detailView.data('view-args').context.testListView[0].fieldA, 'fieldA-2', 'Pre-action: Correct context value for fieldA');
|
||||
equal($detailView.data('view-args').context.testListView[0].fieldB, 'fieldB-2', 'Pre-action: Correct context value for fieldB');
|
||||
equal($detailView.data('view-args').context.testListView[0].fieldC, 'fieldC-1', 'Pre-action: Correct context value for fieldC');
|
||||
ok(true, 'Pre-action called');
|
||||
|
||||
return false;
|
||||
};
|
||||
$detailView.find('.action.updateDataTestAsync a').click();
|
||||
});
|
||||
|
||||
test('Update context', function() {
|
||||
var detailView = {
|
||||
context: {
|
||||
listViewItemA: [
|
||||
{ fieldA: 'fieldAContent' }
|
||||
]
|
||||
// listViewItemB [not stored yet]
|
||||
},
|
||||
|
||||
tabFilter: function(args) {
|
||||
start();
|
||||
ok($.isArray(args.context.listViewItemB), 'updateContext called before tabFilter');
|
||||
stop();
|
||||
|
||||
return [];
|
||||
},
|
||||
|
||||
// updateContext is executed every time a data provider is called
|
||||
updateContext: function(args) {
|
||||
start();
|
||||
ok(true, 'updateContext called');
|
||||
equal(args.context.listViewItemA[0].fieldA, 'fieldAContent', 'updateContext: Item A present in context');
|
||||
stop();
|
||||
|
||||
return {
|
||||
listViewItemB: [
|
||||
{ fieldB: 'fieldBContent' }
|
||||
]
|
||||
};
|
||||
},
|
||||
|
||||
tabs: {
|
||||
test: {
|
||||
title: 'test',
|
||||
fields: { fieldA: { label: 'fieldA'}, fieldB: { label: 'fieldB' }},
|
||||
dataProvider: function(args) {
|
||||
start();
|
||||
equal(args.context.listViewItemA[0].fieldA, 'fieldAContent', 'dataProvider: Item A present in context');
|
||||
equal(args.context.listViewItemB[0].fieldB, 'fieldBContent', 'dataProvider: Item B present in context');
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
var $detailView = $('<div></div>');
|
||||
|
||||
stop();
|
||||
$detailView.detailView(detailView);
|
||||
});
|
||||
}(jQuery));
|
||||
|
|
@ -1,527 +0,0 @@
|
|||
// 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.
|
||||
(function($) {
|
||||
module('List view', {
|
||||
setup: function() {
|
||||
$.fx.off = true;
|
||||
cloudStack.debug = true;
|
||||
},
|
||||
teardown: function() {
|
||||
// Cleanup notification box
|
||||
$('.notification-box').remove();
|
||||
}
|
||||
});
|
||||
|
||||
test('Basic', function() {
|
||||
var listView = {
|
||||
listView: {
|
||||
section: 'test123',
|
||||
fields: {
|
||||
fieldA: { label: 'testFieldA' },
|
||||
fieldB: { label: 'testFieldB' }
|
||||
},
|
||||
dataProvider: function(args) {
|
||||
args.response.success({
|
||||
data: []
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
var $listView;
|
||||
|
||||
ok($listView = $('<div>').listView(listView), 'Initialize list view');
|
||||
equal($listView.find('.list-view').size(), 1, 'List view has container div');
|
||||
equal($listView.find('.list-view.test123').size(), 1, 'Container div has section ID as CSS class');
|
||||
equal($listView.find('.list-view table').size(), 2, 'List view has split tables');
|
||||
equal($listView.find('.list-view .fixed-header table thead tr').size(), 1, 'List view has fixed table header');
|
||||
equal($listView.find('.list-view .fixed-header table thead th').size(), 2, 'List view has correct column headers');
|
||||
equal($listView.find('.list-view .fixed-header table thead th:first').html(), 'testFieldA', 'First header has correct label');
|
||||
ok($listView.find('.list-view .fixed-header table thead th:first').hasClass('fieldA'), 'First header has correct class');
|
||||
ok($listView.find('.list-view .fixed-header table thead th:last').hasClass('fieldB'), 'First header has correct class');
|
||||
equal($listView.find('.list-view .fixed-header table thead th:last').html(), 'testFieldB', 'First header has correct label');
|
||||
equal($listView.find('.list-view table tbody tr').size(), 1, 'List view has table body');
|
||||
equal($listView.find('.toolbar').size(), 1, 'List view has toolbar');
|
||||
equal($listView.find('.toolbar .text-search .search-bar input[type=text]').size(), 1, 'Toolbar has search box');
|
||||
equal($listView.find('.toolbar .text-search .search-bar input[type=text]').size(), 1, 'Toolbar has search box');
|
||||
equal($listView.find('.toolbar .text-search .button.search').size(), 1, 'Toolbar has search button');
|
||||
ok(!$listView.find('.toolbar .filters').size(), 'Toolbar doesn\'t have filters');
|
||||
});
|
||||
|
||||
test('Data provider', function() {
|
||||
var $listView = $('<div>');
|
||||
|
||||
stop();
|
||||
$listView.listView({
|
||||
context: {
|
||||
tests: []
|
||||
},
|
||||
listView: {
|
||||
section: 'test',
|
||||
fields: {
|
||||
fieldA: { label: 'testFieldA' },
|
||||
fieldB: { label: 'testFieldB' }
|
||||
},
|
||||
dataProvider: function(args) {
|
||||
start();
|
||||
equal(args.page, 1, 'Correct page # passed');
|
||||
equal(args.filterBy.search.value, '', 'No search params specified');
|
||||
ok($.isArray(args.context.tests), 'Context passed');
|
||||
args.response.success({
|
||||
data: [
|
||||
{
|
||||
fieldA: '1A',
|
||||
fieldB: '1B'
|
||||
},
|
||||
{
|
||||
fieldA: '2A',
|
||||
fieldB: '2B'
|
||||
},
|
||||
{
|
||||
fieldA: '3A',
|
||||
fieldB: '3B'
|
||||
}
|
||||
]
|
||||
});
|
||||
stop();
|
||||
setTimeout(function() {
|
||||
start();
|
||||
equal($listView.find('tbody tr').size(), 3, 'Data row count is correct');
|
||||
equal($listView.find('tbody tr:first td.fieldA span').html(), '1A', 'Correct table item value for first row');
|
||||
equal($listView.find('tbody tr:first td.fieldB span').html(), '1B', 'Correct table item value for first row');
|
||||
equal($listView.find('tbody tr:last td.fieldA span').html(), '3A', 'Correct table item value for last row');
|
||||
equal($listView.find('tbody tr:last td.fieldB span').html(), '3B', 'Correct table item value for last row');
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
test('Pre-filter', function() {
|
||||
var $listView = $('<div>');
|
||||
|
||||
stop();
|
||||
$listView.listView({
|
||||
listView: {
|
||||
section: 'test',
|
||||
fields: {
|
||||
fieldA: { label: 'testFieldA' },
|
||||
fieldB: { label: 'testFieldB' },
|
||||
fieldC: { label: 'testFieldC' }
|
||||
},
|
||||
preFilter: function(args) {
|
||||
return ['fieldC'];
|
||||
},
|
||||
dataProvider: function(args) {
|
||||
args.response.success({
|
||||
data: [
|
||||
{
|
||||
fieldA: '1A',
|
||||
fieldB: '1B',
|
||||
fieldC: '1C'
|
||||
}
|
||||
]
|
||||
});
|
||||
setTimeout(function() {
|
||||
start();
|
||||
equal($listView.find('thead th').size(), 2, 'Correct # of filtered columns present');
|
||||
equal($listView.find('tbody tr:first td').size(), 2, 'Correct # of body columns present');
|
||||
equal($listView.find('tbody tr:first td.fieldA span').html(), '1A', 'Correct table item value for data row');
|
||||
equal($listView.find('tbody tr:first td.fieldB span').html(), '1B', 'Correct table item value for data row');
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
test('Section select', function() {
|
||||
var $listView = $('<div>');
|
||||
|
||||
ok($listView.listView({
|
||||
sectionSelect: {
|
||||
label: 'testSectionSelect'
|
||||
},
|
||||
sections: {
|
||||
sectionA: {
|
||||
type: 'select',
|
||||
title: 'sectionA',
|
||||
listView: {
|
||||
fields: {
|
||||
fieldA: { label: 'testFieldA' },
|
||||
fieldB: { label: 'testFieldB' }
|
||||
},
|
||||
dataProvider: function(args) {
|
||||
args.response.success({
|
||||
data: [
|
||||
{
|
||||
fieldA: '1A',
|
||||
fieldB: '1B'
|
||||
},
|
||||
{
|
||||
fieldA: '2A',
|
||||
fieldB: '2B'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
sectionB: {
|
||||
type: 'select',
|
||||
title: 'sectionB',
|
||||
listView: {
|
||||
fields: {
|
||||
fieldC: { label: 'testFieldC' },
|
||||
fieldD: { label: 'testFieldD' },
|
||||
fieldE: { label: 'testFieldE' }
|
||||
},
|
||||
dataProvider: function(args) {
|
||||
args.response.success({
|
||||
data: [
|
||||
{
|
||||
fieldC: '1C',
|
||||
fieldD: '1D',
|
||||
fieldE: '1E'
|
||||
},
|
||||
{
|
||||
fieldC: '2C',
|
||||
fieldD: '2D',
|
||||
fieldE: '2E'
|
||||
},
|
||||
{
|
||||
fieldC: '3C',
|
||||
fieldD: '3D',
|
||||
fieldE: '3E'
|
||||
},
|
||||
{
|
||||
fieldC: '4C',
|
||||
fieldD: '4D',
|
||||
fieldE: '4E'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
equal($listView.find('.toolbar .section-switcher').size(), 1,
|
||||
'Section switcher present in toolbar');
|
||||
equal($listView.find('.toolbar .section-switcher .section-select select').size(), 1,
|
||||
'Section select present');
|
||||
equal($listView.find('.toolbar .section-switcher .section-select label').html(),
|
||||
'testSectionSelect' + ':',
|
||||
'Section select label is correct');
|
||||
equal($listView.find('.toolbar .section-switcher .section-select select option').size(), 2,
|
||||
'Selectable sections present as options');
|
||||
equal($listView.find('.toolbar .section-switcher .section-select select option:first').html(), 'sectionA',
|
||||
'First select has correct title');
|
||||
equal($listView.find('.toolbar .section-switcher .section-select select option:selected')[0],
|
||||
$listView.find('.toolbar .section-switcher .section-select select option:first')[0],
|
||||
'First section option is selected by default');
|
||||
equal($listView.find('.toolbar .section-switcher .section-select select option:last').html(), 'sectionB', 'Last select has correct title');
|
||||
equal($listView.find('.list-view thead th').size(), 2, 'Correct list view column count present');
|
||||
equal($listView.find('.list-view thead th:first').html(), 'testFieldA', 'Column 1 is labeled correctly');
|
||||
equal($listView.find('.list-view thead th:last').html(), 'testFieldB', 'Column 2 is labeled correctly');
|
||||
equal($listView.find('.list-view tbody tr').size(), 2, 'Correct # of data rows present');
|
||||
equal($listView.find('.list-view tbody tr:first td').size(), 2, 'Correct # of data columns present');
|
||||
|
||||
$listView.find('.toolbar .section-switcher select').val('sectionB');
|
||||
stop();
|
||||
ok($listView.find('.toolbar .section-switcher select').change(), 'Change section');
|
||||
start();
|
||||
|
||||
equal($listView.find('.list-view thead th').size(), 3, 'Correct list view column count present');
|
||||
equal($listView.find('.list-view thead th:first').html(), 'testFieldC', 'Column 1 is labeled correctly');
|
||||
equal($($listView.find('.list-view thead th')[1]).html(), 'testFieldD', 'Column 2 is labeled correctly');
|
||||
equal($listView.find('.list-view thead th:last').html(), 'testFieldE', 'Column 3 is labeled correctly');
|
||||
equal($listView.find('.list-view tbody tr').size(), 4, 'Correct # of data rows present');
|
||||
equal($listView.find('.list-view tbody tr:first td').size(), 3, 'Correct # of data columns present');
|
||||
equal($listView.find('.list-view tbody tr:first td:first span').html(), '1C', 'First table cell has correct data');
|
||||
equal($listView.find('.list-view tbody tr:last td:last span').html(), '4E', 'Last table cell has correct data');
|
||||
|
||||
$listView.find('.toolbar .section-switcher select').val('sectionA');
|
||||
stop();
|
||||
ok($listView.find('.toolbar .section-switcher select').change(), 'Change section');
|
||||
start();
|
||||
equal($listView.find('.toolbar .section-switcher .section-select select option:last').html(), 'sectionB', 'Last select has correct title');
|
||||
equal($listView.find('.list-view thead th').size(), 2, 'Correct list view column count present');
|
||||
equal($listView.find('.list-view thead th:first').html(), 'testFieldA', 'Column 1 is labeled correctly');
|
||||
equal($listView.find('.list-view thead th:last').html(), 'testFieldB', 'Column 2 is labeled correctly');
|
||||
equal($listView.find('.list-view tbody tr').size(), 2, 'Correct # of data rows present');
|
||||
equal($listView.find('.list-view tbody tr:first td').size(), 2, 'Correct # of data columns present');
|
||||
equal($listView.find('.list-view tbody tr:first td:first span').html(), '1A', 'First table cell has correct data');
|
||||
equal($listView.find('.list-view tbody tr:last td:last span').html(), '2B', 'Last table cell has correct data');
|
||||
});
|
||||
|
||||
test('Basic sync action', function() {
|
||||
var $cloudStack = $('<div>').appendTo('#qunit-fixture');
|
||||
var listView = {
|
||||
listView: {
|
||||
section: 'test123',
|
||||
fields: {
|
||||
fieldA: { label: 'testFieldA' },
|
||||
fieldB: { label: 'testFieldB' }
|
||||
},
|
||||
actions: {
|
||||
basicSync: {
|
||||
label: 'basicAction',
|
||||
messages: {
|
||||
confirm: function() {
|
||||
return 'basicActionConfirm';
|
||||
},
|
||||
notification: function() {
|
||||
return 'basicActionNotification';
|
||||
}
|
||||
},
|
||||
action: function(args) {
|
||||
args.response.success();
|
||||
}
|
||||
}
|
||||
},
|
||||
dataProvider: function(args) {
|
||||
args.response.success({
|
||||
data: [
|
||||
{
|
||||
fieldA: '1A',
|
||||
fieldB: '1B',
|
||||
fieldC: '1C'
|
||||
},
|
||||
{
|
||||
fieldA: '2A',
|
||||
fieldB: '2B',
|
||||
fieldC: '2C'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// CloudStack object is needed for notification handling for actions
|
||||
var cloudStack = {
|
||||
sections: {
|
||||
testActions: listView
|
||||
},
|
||||
|
||||
home: 'testActions'
|
||||
};
|
||||
|
||||
ok($cloudStack.cloudStack(cloudStack), 'Initialize cloudStack widget w/ list view');
|
||||
|
||||
var $listView = $cloudStack.find('.list-view');
|
||||
|
||||
equal($listView.find('table thead th').size(), 3, 'Correct header column count');
|
||||
equal($listView.find('table thead th.actions').size(), 1, 'Action header column present');
|
||||
equal($listView.find('table tbody tr:first td').size(), 3, 'Correct data column count');
|
||||
equal($listView.find('table tbody tr:first td.actions').size(), 1, 'Action data column present');
|
||||
equal($listView.find('table tbody tr:first td.actions .action').size(), 1, 'Correct action count');
|
||||
equal($listView.find('table tbody tr:first td.actions .action:first .icon').size(), 1, 'Action has icon');
|
||||
ok($listView.find('table tbody tr:first td.actions .action:first').hasClass('basicSync'),
|
||||
'First action has ID as CSS class');
|
||||
ok($listView.find('td.actions .action:first').click(), 'Click first action');
|
||||
equal($('.ui-dialog.confirm .message').html(), 'basicActionConfirm', 'Confirmation message present');
|
||||
|
||||
// Make sure dialog is cleaned up -- always put below all confirm tests
|
||||
$(':ui-dialog, .overlay').appendTo('#qunit-fixture');
|
||||
|
||||
ok($('.ui-dialog.confirm .ui-button.ok').click(), 'Confirm action');
|
||||
equal($cloudStack.find('.notifications .total span').html(), '1', 'Notification total increased');
|
||||
equal($('.notification-box ul li').size(), 1, 'Notification list has 1 item');
|
||||
equal($('.notification-box ul li span').html(), 'basicActionNotification', 'Notification list item has correct label');
|
||||
ok($('.notification-box ul li').hasClass('pending'), 'Notification has pending state');
|
||||
stop();
|
||||
setTimeout(function() {
|
||||
start();
|
||||
ok(!$('.notification-box ul li').hasClass('pending'), 'Notification has completed state');
|
||||
});
|
||||
});
|
||||
|
||||
test('Async action', function() {
|
||||
var $cloudStack = $('<div>').appendTo('#qunit-fixture');
|
||||
var listView = {
|
||||
listView: {
|
||||
id: 'testAsyncListView',
|
||||
fields: {
|
||||
fieldA: { label: 'testFieldA' },
|
||||
fieldB: { label: 'testFieldB' }
|
||||
},
|
||||
actions: {
|
||||
asyncTest: {
|
||||
label: 'asyncAction',
|
||||
messages: {
|
||||
confirm: function() {
|
||||
return 'asyncActionConfirm';
|
||||
},
|
||||
notification: function() {
|
||||
return 'asyncActionNotification';
|
||||
}
|
||||
},
|
||||
action: function(args) {
|
||||
ok($.isArray(args.context.testAsyncListView), 'List view context passed');
|
||||
args.response.success({
|
||||
_custom: {
|
||||
jobId: 'job123'
|
||||
}
|
||||
});
|
||||
},
|
||||
notification: {
|
||||
interval: 0,
|
||||
poll: function(args) {
|
||||
start();
|
||||
equal(args._custom.jobId, 'job123', 'Job ID passed correctly');
|
||||
args.complete();
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
dataProvider: function(args) {
|
||||
args.response.success({
|
||||
data: [
|
||||
{
|
||||
fieldA: '1A',
|
||||
fieldB: '1B',
|
||||
fieldC: '1C'
|
||||
},
|
||||
{
|
||||
fieldA: '2A',
|
||||
fieldB: '2B',
|
||||
fieldC: '2C'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// CloudStack object is needed for notification handling for actions
|
||||
var cloudStack = {
|
||||
sections: {
|
||||
testActions: listView
|
||||
},
|
||||
|
||||
home: 'testActions'
|
||||
};
|
||||
|
||||
ok($cloudStack.cloudStack(cloudStack), 'Initialize cloudStack widget w/ list view');
|
||||
|
||||
var $listView = $cloudStack.find('.list-view');
|
||||
|
||||
equal($listView.find('table thead th').size(), 3, 'Correct header column count');
|
||||
equal($listView.find('table thead th.actions').size(), 1, 'Action header column present');
|
||||
equal($listView.find('table tbody tr:first td').size(), 3, 'Correct data column count');
|
||||
equal($listView.find('table tbody tr:first td.actions').size(), 1, 'Action data column present');
|
||||
equal($listView.find('table tbody tr:first td.actions .action').size(), 1, 'Correct action count');
|
||||
equal($listView.find('table tbody tr:first td.actions .action:first .icon').size(), 1, 'Action has icon');
|
||||
ok($listView.find('table tbody tr:first td.actions .action:first').hasClass('asyncTest'),
|
||||
'First action has ID as CSS class');
|
||||
ok($listView.find('td.actions .action:first').click(), 'Click first action');
|
||||
equal($('.ui-dialog.confirm .message').html(), 'asyncActionConfirm', 'Confirmation message present');
|
||||
|
||||
// Make sure dialog is cleaned up -- always put below all confirm tests
|
||||
$(':ui-dialog, .overlay').appendTo('#qunit-fixture');
|
||||
|
||||
ok($('.ui-dialog.confirm .ui-button.ok').click(), 'Confirm action');
|
||||
equal($cloudStack.find('.notifications .total span').html(), '1', 'Notification total increased');
|
||||
equal($('.notification-box ul li').size(), 1, 'Notification list has 1 item');
|
||||
equal($('.notification-box ul li span').html(), 'asyncActionNotification', 'Notification list item has correct label');
|
||||
ok($('.notification-box ul li').hasClass('pending'), 'Notification has pending state');
|
||||
stop();
|
||||
});
|
||||
|
||||
test('Action filter', function() {
|
||||
var $cloudStack = $('<div>').appendTo('#qunit-fixture');
|
||||
var listView = {
|
||||
listView: {
|
||||
id: 'testAsyncListView',
|
||||
fields: {
|
||||
fieldA: { label: 'testFieldA' },
|
||||
fieldB: { label: 'testFieldB' }
|
||||
},
|
||||
actions: {
|
||||
actionA: {
|
||||
label: 'actionA',
|
||||
messages: {
|
||||
confirm: function() { return ''; },
|
||||
notification: function() { return ''; }
|
||||
},
|
||||
action: function(args) { args.response.success(); }
|
||||
},
|
||||
actionB: {
|
||||
label: 'actionB [HIDDEN]',
|
||||
messages: {
|
||||
confirm: function() { return ''; },
|
||||
notification: function() { return ''; }
|
||||
},
|
||||
action: function(args) { args.response.success(); }
|
||||
},
|
||||
actionC: {
|
||||
label: 'actionC',
|
||||
messages: {
|
||||
confirm: function() { return ''; },
|
||||
notification: function() { return ''; }
|
||||
},
|
||||
action: function(args) { args.response.success(); }
|
||||
}
|
||||
},
|
||||
dataProvider: function(args) {
|
||||
args.response.success({
|
||||
actionFilter: function() {
|
||||
return ['actionA', 'actionC'];
|
||||
},
|
||||
data: [
|
||||
{
|
||||
fieldA: '1A',
|
||||
fieldB: '1B',
|
||||
fieldC: '1C'
|
||||
},
|
||||
{
|
||||
fieldA: '2A',
|
||||
fieldB: '2B',
|
||||
fieldC: '2C'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// CloudStack object is needed for notification handling for actions
|
||||
var cloudStack = {
|
||||
sections: {
|
||||
testActions: listView
|
||||
},
|
||||
|
||||
home: 'testActions'
|
||||
};
|
||||
|
||||
ok($cloudStack.cloudStack(cloudStack), 'Initialize cloudStack widget w/ list view');
|
||||
|
||||
var $listView = $cloudStack.find('.list-view');
|
||||
|
||||
equal($listView.find('table thead th').size(), 3, 'Correct header column count');
|
||||
equal($listView.find('table thead th.actions').size(), 1, 'Action header column present');
|
||||
equal($listView.find('table tbody tr:first td.actions').size(), 1, 'Action data column present');
|
||||
equal($listView.find('table tbody tr:first td.actions .action').size(), 3, 'Correct action count (all)');
|
||||
equal($listView.find('table tbody tr:first td.actions .action:not(.disabled)').size(), 2, 'Correct action count (enabled)');
|
||||
ok($listView.find('table tbody tr:first td.actions .action:first').hasClass('actionA'),
|
||||
'First action has correct ID');
|
||||
ok($listView.find('table tbody tr:first td.actions .action:last').hasClass('actionC'),
|
||||
'Last action has correct ID');
|
||||
});
|
||||
}(jQuery));
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
// 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.
|
||||
(function($) {
|
||||
module('Mutli-edit');
|
||||
|
||||
test('Basic', function() {
|
||||
var multiEdit = {
|
||||
fields: {
|
||||
fieldA: { edit: true, label: 'fieldA' },
|
||||
fieldB: { edit: true, label: 'fieldB' },
|
||||
add: { label: 'add', addButton: true }
|
||||
},
|
||||
add: {
|
||||
label: 'addAction',
|
||||
action: function() {}
|
||||
},
|
||||
dataProvider: function() {}
|
||||
};
|
||||
var $multiEdit = $('<div>');
|
||||
|
||||
ok($multiEdit.multiEdit(multiEdit), 'Initialize multi-edit');
|
||||
equal($multiEdit.find('div.multi-edit').size(), 1, 'Main container div correct');
|
||||
equal($multiEdit.find('.multi-edit form').size(), 1, 'Multi-edit has form');
|
||||
equal($multiEdit.find('.multi-edit form table.multi-edit').size(), 1, 'Form has table');
|
||||
equal($multiEdit.find('.multi-edit form table thead tr').size(), 1, 'Header present');
|
||||
equal($multiEdit.find('.multi-edit form table tbody tr').size(), 1, 'Form body present');
|
||||
equal($multiEdit.find('.multi-edit .data .data-body').size(), 1, 'Data body present');
|
||||
|
||||
// Header items
|
||||
equal($multiEdit.find('.multi-edit form table thead th.fieldA[rel=fieldA]').html(), 'fieldA', 'fieldA has correct header');
|
||||
equal($multiEdit.find('.multi-edit form table thead th.fieldB[rel=fieldB]').html(), 'fieldB', 'fieldB has correct header');
|
||||
equal($multiEdit.find('.multi-edit form table thead th.add[rel=add]').html(), 'add', 'Add action column has correct header');
|
||||
|
||||
// Form items
|
||||
equal($multiEdit.find('.multi-edit form table tbody td.fieldA[rel=fieldA] input[name=fieldA]').size(), 1, 'fieldA has correct input');
|
||||
equal($multiEdit.find('.multi-edit form table tbody td.fieldA[rel=fieldA] input[type=text]').size(), 1, 'fieldA has text-based input');
|
||||
equal($multiEdit.find('.multi-edit form table tbody td.fieldB[rel=fieldB] input[name=fieldB]').size(), 1, 'fieldB has correct input');
|
||||
equal($multiEdit.find('.multi-edit form table tbody td.fieldB[rel=fieldB] input[type=text]').size(), 1, 'fieldB has text-based input');
|
||||
equal($multiEdit.find('.multi-edit form table tbody td.add[rel=add] .button.add-vm').html(), 'addAction', 'Add action column has correct content');
|
||||
});
|
||||
}(jQuery));
|
||||
|
|
@ -1,107 +0,0 @@
|
|||
// 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.
|
||||
(function($) {
|
||||
var $notifications, $notificationBox,
|
||||
$cloudStack, cloudStack;
|
||||
|
||||
module('Notifications', {
|
||||
setup: function() {
|
||||
$.fx.off = true;
|
||||
|
||||
cloudStack = {
|
||||
sections: {
|
||||
home: {
|
||||
show: function() { return $('<div>').addClass('test123'); }
|
||||
},
|
||||
sectionA: {
|
||||
show: function() { return $('<div>').addClass('notification123'); }
|
||||
}
|
||||
},
|
||||
|
||||
home: 'home'
|
||||
};
|
||||
|
||||
$cloudStack = $('<div>').appendTo($('#qunit-fixture'));
|
||||
ok($cloudStack.cloudStack(cloudStack), 'Basic widget initialized');
|
||||
|
||||
// Need to cleanup here -- not handled by widget
|
||||
$('.notification-box').remove();
|
||||
|
||||
$notifications = $('<div>').appendTo($cloudStack);
|
||||
ok($notifications.notifications(), 'Initialize notifications widget');
|
||||
$notificationBox = $('.notification-box');
|
||||
}
|
||||
});
|
||||
|
||||
test('Widget setup', function() {
|
||||
ok($notifications.hasClass('notifications'), 'Correct styling assigned');
|
||||
equal($notificationBox.size(), 1, 'Notification box present');
|
||||
});
|
||||
|
||||
test('Add notification via widget', function() {
|
||||
stop();
|
||||
$notifications.notifications('add', { // Basic notification
|
||||
desc: 'testNotification123',
|
||||
interval: 0,
|
||||
poll: function(args) {
|
||||
var $li = $notificationBox.find('li');
|
||||
|
||||
start();
|
||||
equal($li.size(), 1, 'Notification added to list');
|
||||
equal($li.find('span').html(), 'testNotification123', 'Notification description correct');
|
||||
ok($li.hasClass('pending'), 'Notification item has pending state');
|
||||
ok($notificationBox.find('.button.clear-list').click(), 'Clear list button click');
|
||||
equal($notificationBox.find('li').size(), 1, 'Notification list still has correct number of items');
|
||||
args.complete();
|
||||
ok(!$li.hasClass('pending'), 'Notification item has non-pending (complete) state');
|
||||
|
||||
stop();
|
||||
$notifications.notifications('add', { // More comprehensive notification
|
||||
desc: 'testNotification456',
|
||||
interval: 0,
|
||||
_custom: {
|
||||
attrA: '123',
|
||||
attrB: '456'
|
||||
},
|
||||
section: 'sectionA',
|
||||
poll: function(args) {
|
||||
var $li = $notificationBox.find('li');
|
||||
|
||||
start();
|
||||
equal($li.size(), 2, 'Notification list is correct');
|
||||
ok($.isPlainObject(args._custom), '_custom present');
|
||||
equal(args._custom.attrA, '123', '_custom attr A correct');
|
||||
equal(args._custom.attrB, '456', '_custom attr B correct');
|
||||
ok($li.filter(':last').hasClass('pending'), 'New notification item has pending state');
|
||||
ok(!$li.filter(':first').hasClass('pending'), 'First notification item still has non-pending (complete) state');
|
||||
ok($notificationBox.find('.button.clear-list').click(), 'Clear list button click');
|
||||
ok(!$notificationBox.find('li:first').is(':visible'), 'First (completed) notification item cleared');
|
||||
args.complete();
|
||||
ok(!$li.hasClass('pending'), 'All notifications item has non-pending (complete) state');
|
||||
equal($li.filter(':last').data('notification-section'), 'sectionA', 'Section data is correct in last notification');
|
||||
equal($li.filter(':first').find('span').html(), 'testNotification123', 'First notification description correct');
|
||||
equal($li.filter(':last').find('span').html(), 'testNotification456', 'Second notification description correct');
|
||||
$li.filter(':last').find('span').click();
|
||||
equal($cloudStack.find('.notification123').size(), 1, 'Notification item text goes to correct section on click');
|
||||
ok($li.filter(':last').find('.remove').click(), 'Remove first item');
|
||||
equal($notificationBox.find('li').size(), 0, 'Notification list has no items anymore');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}(jQuery));
|
||||
Loading…
Reference in New Issue