From 4187da258fe212d494cb578a0bc2b52c4979ab95 Mon Sep 17 00:00:00 2001 From: antoliny0919 Date: Mon, 28 Jul 2025 07:59:26 +0900 Subject: Fixed #35892 -- Supported Widget.use_fieldset in admin forms. --- js_tests/admin/DateTimeShortcuts.test.js | 21 +++++++++++++++++++-- js_tests/admin/SelectFilter2.test.js | 8 ++++++-- 2 files changed, 25 insertions(+), 4 deletions(-) (limited to 'js_tests') 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 = $(''); + // Single date or time field. + const timeField = $(''); $('#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 = '

' + + '' + + '' + + '

'; + $('#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."); -- cgit v1.3