diff options
| author | antoliny0919 <antoliny0919@gmail.com> | 2025-07-28 07:59:26 +0900 |
|---|---|---|
| committer | Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> | 2025-08-19 16:35:56 +0200 |
| commit | 4187da258fe212d494cb578a0bc2b52c4979ab95 (patch) | |
| tree | 67f6205a16b1f6785f1ed4e06348d332c36a50f3 /js_tests | |
| parent | ad4a9e0f3b1de261409bc083aa49dba705531824 (diff) | |
Fixed #35892 -- Supported Widget.use_fieldset in admin forms.
Diffstat (limited to 'js_tests')
| -rw-r--r-- | js_tests/admin/DateTimeShortcuts.test.js | 21 | ||||
| -rw-r--r-- | js_tests/admin/SelectFilter2.test.js | 8 |
2 files changed, 25 insertions, 4 deletions
diff --git a/js_tests/admin/DateTimeShortcuts.test.js b/js_tests/admin/DateTimeShortcuts.test.js index 9a8cb8d311..6cb534610c 100644 --- a/js_tests/admin/DateTimeShortcuts.test.js +++ b/js_tests/admin/DateTimeShortcuts.test.js @@ -30,13 +30,30 @@ QUnit.test('custom time shortcuts', function(assert) { assert.equal($('.clockbox').find('a').first().text(), '3 a.m.'); }); -QUnit.test('time zone offset warning', function(assert) { +QUnit.test('time zone offset warning - single field', function(assert) { const $ = django.jQuery; const savedOffset = $('body').attr('data-admin-utc-offset'); - const timeField = $('<input type="text" name="time_test" class="vTimeField">'); + // Single date or time field. + const timeField = $('<input id="id_updated_at" type="text" name="updated_at" class="vTimeField">'); $('#qunit-fixture').append(timeField); $('body').attr('data-admin-utc-offset', new Date().getTimezoneOffset() * -60 + 3600); DateTimeShortcuts.init(); $('body').attr('data-admin-utc-offset', savedOffset); assert.equal($('.timezonewarning').text(), 'Note: You are 1 hour behind server time.'); + assert.equal($('.timezonewarning').attr("id"), "id_updated_at_timezone_warning_helptext"); +}); + +QUnit.test('time zone offset warning - date and time field', function(assert) { + const $ = django.jQuery; + const savedOffset = $('body').attr('data-admin-utc-offset'); + // DateTimeField with fieldset containing date and time inputs. + const dateTimeField = '<p class="datetime">' + + '<input id="id_updated_at_0" type="text" name="updated_at_0" class="vDateField">' + + '<input id="id_updated_at_1" type="text" name="updated_at_1" class="vTimeField">' + + '</p>'; + $('#qunit-fixture').append($(dateTimeField)); + $('body').attr('data-admin-utc-offset', new Date().getTimezoneOffset() * -60 + 3600); + DateTimeShortcuts.init(); + $('body').attr('data-admin-utc-offset', savedOffset); + assert.equal($('.timezonewarning').attr("id"), "id_updated_at_timezone_warning_helptext"); }); diff --git a/js_tests/admin/SelectFilter2.test.js b/js_tests/admin/SelectFilter2.test.js index 1fd46bd0ce..533c24811c 100644 --- a/js_tests/admin/SelectFilter2.test.js +++ b/js_tests/admin/SelectFilter2.test.js @@ -13,7 +13,9 @@ QUnit.test('init', function(assert) { assert.equal($('#test').children().first().prop("tagName"), "DIV"); assert.equal($('#test').children().first().attr("class"), "selector"); assert.equal($('.selector-available label').text().trim(), "Available things"); + assert.equal($('.selector-available label').attr("id"), "id_from_label"); assert.equal($('.selector-chosen label').text().trim(), "Chosen things"); + assert.equal($('.selector-chosen label').attr("id"), "id_to_label"); assert.equal($('.selector-chosen select')[0].getAttribute('multiple'), ''); assert.equal($('.selector-chooseall').text(), "Choose all things"); assert.equal($('.selector-chooseall').prop("tagName"), "BUTTON"); @@ -23,10 +25,12 @@ QUnit.test('init', function(assert) { assert.equal($('.selector-remove').prop("tagName"), "BUTTON"); assert.equal($('.selector-clearall').text(), "Remove all things"); assert.equal($('.selector-clearall').prop("tagName"), "BUTTON"); - assert.equal($('.selector-available .filtered').attr("aria-labelledby"), "id_from_title"); + assert.equal($('.selector-available .filtered').attr("aria-labelledby"), "id_from_label"); + assert.equal($('.selector-available .filtered').attr("aria-describedby"), "id_helptext id_choose_helptext"); assert.equal($('.selector-available .selector-available-title label').text(), "Available things "); assert.equal($('.selector-available .selector-available-title .helptext').text(), 'Choose things by selecting them and then select the "Choose" arrow button.'); - assert.equal($('.selector-chosen .filtered').attr("aria-labelledby"), "id_to_title"); + assert.equal($('.selector-chosen .filtered').attr("aria-labelledby"), "id_to_label"); + assert.equal($('.selector-chosen .filtered').attr("aria-describedby"), "id_helptext id_remove_helptext"); assert.equal($('.selector-chosen .selector-chosen-title label').text(), "Chosen things "); assert.equal($('.selector-chosen .selector-chosen-title .helptext').text(), 'Remove things by selecting them and then select the "Remove" arrow button.'); assert.equal($('.selector-filter label .help-tooltip')[0].getAttribute("aria-label"), "Type into this box to filter down the list of available things."); |
