|
340 | 340 | var $cloudStack = $('<div>').appendTo('#qunit-fixture'); |
341 | 341 | var listView = { |
342 | 342 | listView: { |
343 | | - id: 'job123', |
| 343 | + id: 'testAsyncListView', |
344 | 344 | fields: { |
345 | 345 | fieldA: { label: 'testFieldA' }, |
346 | 346 | fieldB: { label: 'testFieldB' } |
|
357 | 357 | } |
358 | 358 | }, |
359 | 359 | action: function(args) { |
| 360 | + ok($.isArray(args.context.testAsyncListView), 'List view context passed'); |
360 | 361 | args.response.success({ |
361 | 362 | _custom: { |
362 | 363 | jobId: 'job123' |
|
426 | 427 | ok($('.notification-box ul li').hasClass('pending'), 'Notification has pending state'); |
427 | 428 | stop(); |
428 | 429 | }); |
| 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 | + }); |
429 | 511 | }(jQuery)); |
0 commit comments