From e05cd5de8ffca12b9493c9a22d07d470128ad296 Mon Sep 17 00:00:00 2001 From: Alan Guo Xiang Tan Date: Tue, 22 Nov 2022 06:07:47 +0800 Subject: [PATCH] DEV: Add tests for sidebar accessibility changes (#19138) Accessibility is a feature which we do not want to regress on. Follow-up to e30df227162e08e3ff33e1217ef36051e615d726 --- .../tests/acceptance/sidebar-user-test.js | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-test.js b/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-test.js index 24e7473b181..a8d5f44b012 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-test.js @@ -195,5 +195,25 @@ acceptance( "the 3 topic tracking state change callbacks are removed" ); }); + + test("accessibility of sidebar section header", async function (assert) { + await visit("/"); + + assert.ok( + exists( + ".sidebar-section-community .sidebar-section-header[aria-expanded='true'][aria-controls='sidebar-section-content-community']" + ), + "accessibility attributes are set correctly on sidebar section header when section is expanded" + ); + + await click(".sidebar-section-header"); + + assert.ok( + exists( + ".sidebar-section-community .sidebar-section-header[aria-expanded='false'][aria-controls='sidebar-section-content-community']" + ), + "accessibility attributes are set correctly on sidebar section header when section is collapsed" + ); + }); } );