mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
List view UI: action filter tests
This commit is contained in:
parent
64a61f5ccb
commit
d08f1296e8
@ -340,7 +340,7 @@
|
|||||||
var $cloudStack = $('<div>').appendTo('#qunit-fixture');
|
var $cloudStack = $('<div>').appendTo('#qunit-fixture');
|
||||||
var listView = {
|
var listView = {
|
||||||
listView: {
|
listView: {
|
||||||
id: 'job123',
|
id: 'testAsyncListView',
|
||||||
fields: {
|
fields: {
|
||||||
fieldA: { label: 'testFieldA' },
|
fieldA: { label: 'testFieldA' },
|
||||||
fieldB: { label: 'testFieldB' }
|
fieldB: { label: 'testFieldB' }
|
||||||
@ -357,6 +357,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
action: function(args) {
|
action: function(args) {
|
||||||
|
ok($.isArray(args.context.testAsyncListView), 'List view context passed');
|
||||||
args.response.success({
|
args.response.success({
|
||||||
_custom: {
|
_custom: {
|
||||||
jobId: 'job123'
|
jobId: 'job123'
|
||||||
@ -426,4 +427,85 @@
|
|||||||
ok($('.notification-box ul li').hasClass('pending'), 'Notification has pending state');
|
ok($('.notification-box ul li').hasClass('pending'), 'Notification has pending state');
|
||||||
stop();
|
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));
|
}(jQuery));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user