mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Fixed #32204 -- Added quick filter to admin's navigation sidebar.
This commit is contained in:
committed by
Mariusz Felisiak
parent
7248afe12f
commit
d915dd1c58
24
js_tests/admin/navigation.test.js
Normal file
24
js_tests/admin/navigation.test.js
Normal file
@@ -0,0 +1,24 @@
|
||||
/* global QUnit */
|
||||
'use strict';
|
||||
|
||||
QUnit.module('admin.sidebar: filter', {
|
||||
beforeEach: function() {
|
||||
const $ = django.jQuery;
|
||||
$('#qunit-fixture').append($('#nav-sidebar-filter').text());
|
||||
this.navSidebar = $('#nav-sidebar');
|
||||
this.navFilter = $('#nav-filter');
|
||||
initSidebarQuickFilter();
|
||||
}
|
||||
});
|
||||
|
||||
QUnit.test('filter by a model name', function(assert) {
|
||||
assert.equal(this.navSidebar.find('th[scope=row] a').length, 2);
|
||||
|
||||
this.navFilter.val('us'); // Matches 'users'.
|
||||
this.navFilter[0].dispatchEvent(new Event('change'));
|
||||
assert.equal(this.navSidebar.find('tr[class^="model-"]:visible').length, 1);
|
||||
|
||||
this.navFilter.val('nonexistent');
|
||||
this.navFilter[0].dispatchEvent(new Event('change'));
|
||||
assert.equal(this.navSidebar.find('tr[class^="model-"]:visible').length, 0);
|
||||
});
|
||||
Reference in New Issue
Block a user