Fix action sort comparator and test
Change-Id: I0af2ce63ff6b638ad95521b0ce42c2c7ce2c1878
diff --git a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.js b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.js
index 331c3c5..8a52e33 100644
--- a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.js
+++ b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.js
@@ -700,10 +700,10 @@
}
// Change actions appear before revision actions.
- if (actionA.__type === 'change' && actionB.__type === 'revision') {
- return -1;
- } else if (actionA.__type === 'revision' && actionB.__type === 'change') {
+ if (actionA.__type === 'change' && actionB.__type === 'revision') {
return 1;
+ } else if (actionA.__type === 'revision' && actionB.__type === 'change') {
+ return -1;
}
// Otherwise, sort by the button label.
diff --git a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions_test.html b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions_test.html
index dbdf00f..b855dcc 100644
--- a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions_test.html
+++ b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions_test.html
@@ -203,13 +203,17 @@
test('_actionComparator sort order', function() {
var actions = [
- {label: '123', type: 'change', __key: 'review'},
- {label: 'abc',type: 'revision'},
- {label: 'abc',type: 'change'},
- {label: 'def', type: 'change'},
- {label: 'def', type: 'change',__primary: true},
+ {label: '123', __type: 'change', __key: 'review'},
+ {label: 'abc', __type: 'revision'},
+ {label: 'abc', __type: 'change'},
+ {label: 'def', __type: 'change'},
+ {label: 'def', __type: 'change', __primary: true},
];
- var result = actions.slice().sort(element._actionComparator);
+
+ var result = actions.slice()
+ result.reverse();
+ result.sort(element._actionComparator);
+
assert.deepEqual(result, actions);
});