Skip to content

Commit 703523f

Browse files
committed
Detail view UI test: test action filter after refresh
1 parent 5510206 commit 703523f

1 file changed

Lines changed: 28 additions & 4 deletions

File tree

ui/tests/test.detailView.js

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,8 @@
624624
testListView: [{
625625
fieldA: 'fieldA-1',
626626
fieldB: 'fieldB-1',
627-
fieldC: 'fieldC-1'
627+
fieldC: 'fieldC-1',
628+
state: 'on'
628629
}]
629630
},
630631
actions: {
@@ -649,7 +650,8 @@
649650
args.complete({
650651
data: {
651652
fieldA: 'fieldA-2',
652-
fieldB: 'fieldB-2'
653+
fieldB: 'fieldB-2',
654+
state: 'off'
653655
}
654656
});
655657

@@ -660,9 +662,19 @@
660662
equal($detailView.find('tr.fieldA .value').html(), 'fieldA-2', 'Correct table value for fieldA');
661663
equal($detailView.find('tr.fieldB .value').html(), 'fieldB-2', 'Correct table value for fieldB');
662664
equal($detailView.find('tr.fieldC .value').html(), 'fieldC-1', 'Correct table value for fieldC');
665+
666+
equal($detailView.find('.action').size(), 1, 'Correct action count');
667+
equal($detailView.find('.action.updateDataTestAsync').size(), 1, 'updateDataTestAsync present');
668+
equal($detailView.find('.action.filteredAction').size(), 0, 'filteredAction not present');
663669
stop();
664670
}
665671
}
672+
},
673+
674+
filteredAction: {
675+
label: 'filteredAction',
676+
action: function() {},
677+
messages: { notification: function() { return 'notification'; } }
666678
}
667679
},
668680
tabs: {
@@ -675,7 +687,14 @@
675687
}],
676688
dataProvider: function(args) {
677689
args.response.success({
678-
data: args.context.testListView[0]
690+
data: args.context.testListView[0],
691+
actionFilter: function(args) {
692+
if (args.context.testListView[0].state == 'on') {
693+
return ['updateDataTestAsync', 'filteredAction'];
694+
}
695+
696+
return ['updateDataTestAsync'];
697+
}
679698
});
680699
}
681700
}
@@ -690,7 +709,6 @@
690709
}
691710
}).appendTo('#qunit-fixture');
692711

693-
stop();
694712
$.fn.dataTable = function() { return this; };
695713
$.fn.listView = function(args1, args2) {
696714
if (args1 == 'replaceItem')
@@ -707,6 +725,12 @@
707725
};
708726
$detailView.data('list-view-row', $listViewRow);
709727
$detailView.detailView(detailView);
728+
729+
equal($detailView.find('.action').size(), 2, 'Correct action count');
730+
equal($detailView.find('.action.updateDataTestAsync').size(), 1, 'updateDataTestAsync present');
731+
equal($detailView.find('.action.filteredAction').size(), 1, 'filteredAction present');
732+
733+
stop();
710734
$detailView.find('.action.updateDataTestAsync a').click();
711735
$detailView.data('view-args').actions.updateDataTestAsync.preAction = function(args) {
712736
start();

0 commit comments

Comments
 (0)