Files
threshold-ui/ui/admin/tests/test-helper.js
T
Carlos Alcaide CorvoandLisbet Alvarez 5b72a916e4 (HACK WEEK 2025) A11y admin test helper (#2937)
* chore: 🤖 add a11y audit test helper config

* chore: 🤖 remove report files

* refactor: 💡 remove console.log

* Apply PR feedback

* Delete the flag --server when running a11y tests

---------

Co-authored-by: Lisbet Alvarez <lisbet.alvarez@hashicorp.com>
2025-08-19 10:51:44 -05:00

67 lines
1.5 KiB
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
import Application from 'admin/app';
import config from 'admin/config/environment';
import * as QUnit from 'qunit';
import { setApplication } from '@ember/test-helpers';
import { setup } from 'qunit-dom';
import start from 'ember-exam/test-support/start';
import {
DEFAULT_A11Y_TEST_HELPER_NAMES,
setRunOptions,
setupGlobalA11yHooks,
setupQUnitA11yAuditToggle,
shouldForceAudit,
setEnableA11yAudit,
useMiddlewareReporter,
setupMiddlewareReporter,
} from 'ember-a11y-testing/test-support';
setApplication(Application.create(config.APP));
setupGlobalA11yHooks(() => true, {
helpers: [
...DEFAULT_A11Y_TEST_HELPER_NAMES,
'fillIn',
'render',
'tab',
'focus',
'select',
],
});
setupQUnitA11yAuditToggle(QUnit);
setRunOptions({
runOnly: {
type: 'tag',
values: [
'wcag2a',
'wcag2aa',
'wcag21a',
'wcag21aa',
'wcag22aa',
'best-practice',
],
},
include: [['#ember-testing-container']],
exclude: [['.flight-sprite-container']],
});
if (shouldForceAudit()) {
setEnableA11yAudit(true);
}
// Note, as a convenience, useMiddlewareReporter automatically forces audits, thus explicitly specifying the enableA11yAudit query param or the ENABLE_A11Y_AUDIT environment variable is unnecessary.
if (useMiddlewareReporter()) {
// Only runs if `enableA11yMiddlewareReporter` is set in URL
setupMiddlewareReporter();
}
setup(QUnit.assert);
start();