Skip to content

Commit d08f129

Browse files
committed
List view UI: action filter tests
1 parent 64a61f5 commit d08f129

1 file changed

Lines changed: 83 additions & 1 deletion

File tree

‎ui/tests/test.listView.js‎

Lines changed: 83 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@
340340
var $cloudStack = $('<div>').appendTo('#qunit-fixture');
341341
var listView = {
342342
listView: {
343-
id: 'job123',
343+
id: 'testAsyncListView',
344344
fields: {
345345
fieldA: { label: 'testFieldA' },
346346
fieldB: { label: 'testFieldB' }
@@ -357,6 +357,7 @@
357357
}
358358
},
359359
action: function(args) {
360+
ok($.isArray(args.context.testAsyncListView), 'List view context passed');
360361
args.response.success({
361362
_custom: {
362363
jobId: 'job123'
@@ -426,4 +427,85 @@
426427
ok($('.notification-box ul li').hasClass('pending'), 'Notification has pending state');
427428
stop();
428429
});
430+
431+
test('Action filter', function() {
432+
var $cloudStack = $('<div>').appendTo('#qunit-fixture');
433+
var listView = {
434+
listView: {
435+
id: 'testAsyncListView',
436+
fields: {
437+
fieldA: { label: 'testFieldA' },
438+
fieldB: { label: 'testFieldB' }
439+
},
440+
actions: {
441+
actionA: {
442+
label: 'actionA',
443+
messages: {
444+
confirm: function() { return ''; },
445+
notification: function() { return ''; }
446+
},
447+
action: function(args) { args.response.success(); }
448+
},
449+
actionB: {
450+
label: 'actionB [HIDDEN]',
451+
messages: {
452+
confirm: function() { return ''; },
453+
notification: function() { return ''; }
454+
},
455+
action: function(args) { args.response.success(); }
456+
},
457+
actionC: {
458+
label: 'actionC',
459+
messages: {
460+
confirm: function() { return ''; },
461+
notification: function() { return ''; }
462+
},
463+
action: function(args) { args.response.success(); }
464+
}
465+
},
466+
dataProvider: function(args) {
467+
args.response.success({
468+
actionFilter: function() {
469+
return ['actionA', 'actionC'];
470+
},
471+
data: [
472+
{
473+
fieldA: '1A',
474+
fieldB: '1B',
475+
fieldC: '1C'
476+
},
477+
{
478+
fieldA: '2A',
479+
fieldB: '2B',
480+
fieldC: '2C'
481+
}
482+
]
483+
});
484+
}
485+
}
486+
};
487+
488+
// CloudStack object is needed for notification handling for actions
489+
var cloudStack = {
490+
sections: {
491+
testActions: listView
492+
},
493+
494+
home: 'testActions'
495+
};
496+
497+
ok($cloudStack.cloudStack(cloudStack), 'Initialize cloudStack widget w/ list view');
498+
499+
var $listView = $cloudStack.find('.list-view');
500+
501+
equal($listView.find('table thead th').size(), 3, 'Correct header column count');
502+
equal($listView.find('table thead th.actions').size(), 1, 'Action header column present');
503+
equal($listView.find('table tbody tr:first td.actions').size(), 1, 'Action data column present');
504+
equal($listView.find('table tbody tr:first td.actions .action').size(), 3, 'Correct action count (all)');
505+
equal($listView.find('table tbody tr:first td.actions .action:not(.disabled)').size(), 2, 'Correct action count (enabled)');
506+
ok($listView.find('table tbody tr:first td.actions .action:first').hasClass('actionA'),
507+
'First action has correct ID');
508+
ok($listView.find('table tbody tr:first td.actions .action:last').hasClass('actionC'),
509+
'Last action has correct ID');
510+
});
429511
}(jQuery));

0 commit comments

Comments
 (0)