Icu 18518 UI add sorting support to cache daemon handler (#3168)
* feat: 🎸 add sorting support & sort feature on targets name column * test: 💍 cleanup and add tests * refactor: 💡 remove log * fix: 🐛 dont add undefined/null values from sort to query ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-18518
This commit is contained in:
1 parent
9e069ffc0c
commit
772857dbad
7 files changed
+192
-92
No files matched your search
@@ -49,6 +49,12 @@ module('Acceptance | projects | targets | index', function (hooks) {
|
||||
const TARGET_OPEN_BUTTON = (id) => `[data-test-targets-open-button="${id}"]`;
|
||||
const TARGET_CONNECT_BUTTON = (id) =>
|
||||
`[data-test-targets-connect-button="${id}"]`;
|
||||
const TABLE_SORT_BTN = 'thead tr th:nth-child(1) button';
|
||||
const TABLE_SORT_BTN_ARROW_UP =
|
||||
'thead tr th:nth-child(1) button .hds-icon-arrow-up';
|
||||
const TABLE_SORT_BTN_ARROW_DOWN =
|
||||
'thead tr th:nth-child(1) button .hds-icon-arrow-down';
|
||||
|
||||
const instances = {
|
||||
scopes: {
|
||||
global: null,
|
||||
@@ -874,4 +880,37 @@ module('Acceptance | projects | targets | index', function (hooks) {
|
||||
// Assert that the confirm modal appears
|
||||
assert.dom(HDS_DIALOG_MODAL).isVisible();
|
||||
});
|
||||
|
||||
test('sorting by target name updates url', async function (assert) {
|
||||
this.stubCacheDaemonSearch(
|
||||
'sessions',
|
||||
'targets',
|
||||
'aliases',
|
||||
'sessions',
|
||||
|
||||
'sessions',
|
||||
'targets',
|
||||
'aliases',
|
||||
'sessions',
|
||||
|
||||
'sessions',
|
||||
'targets',
|
||||
'aliases',
|
||||
'sessions',
|
||||
);
|
||||
await visit(urls.projects);
|
||||
|
||||
await click(`[href="${urls.targets}"]`);
|
||||
await click(TABLE_SORT_BTN);
|
||||
|
||||
assert.true(currentURL().includes('sortAttribute=name'));
|
||||
assert.true(currentURL().includes('sortDirection=asc'));
|
||||
assert.dom(TABLE_SORT_BTN_ARROW_UP).isVisible();
|
||||
|
||||
await click(TABLE_SORT_BTN);
|
||||
|
||||
assert.true(currentURL().includes('sortAttribute=name'));
|
||||
assert.true(currentURL().includes('sortDirection=desc'));
|
||||
assert.dom(TABLE_SORT_BTN_ARROW_DOWN).isVisible();
|
||||
});
|
||||
});
|
||||
@@ -256,5 +256,17 @@ module(
|
||||
|
||||
assert.strictEqual(session.status, STATUS_SESSION_CANCELING);
|
||||
});
|
||||
|
||||
test('onSort action sets expected values correctly', async function (assert) {
|
||||
this.stubCacheDaemonSearch();
|
||||
assert.notOk(controller.sortAttribute);
|
||||
assert.notOk(controller.sortDirection);
|
||||
|
||||
controller.onSort('name', 'desc');
|
||||
|
||||
assert.strictEqual(controller.page, 1);
|
||||
assert.strictEqual(controller.sortAttribute, 'name');
|
||||
assert.strictEqual(controller.sortDirection, 'desc');
|
||||
});
|
||||
},
|
||||
);
|
||||
Reference in new issue
Block a user