This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/tests/integration/widgets/button-test.js
Vinoth Kannan 1b99f99ff7
UX: remove aria-label for buttons when title attribute exists. (#14529)
Both `aria-label` and `title` have the same value and NVDA reading both the texts while navigating between buttons. NVDA already has an open issue https://github.com/nvaccess/nvda/issues/7841. We're removing `aria-label` until they fix it.
2021-10-12 23:55:59 +05:30

81 lines
2.1 KiB
JavaScript

import componentTest, {
setupRenderingTest,
} from "discourse/tests/helpers/component-test";
import {
discourseModule,
exists,
query,
} from "discourse/tests/helpers/qunit-helpers";
import hbs from "htmlbars-inline-precompile";
discourseModule("Integration | Component | Widget | button", function (hooks) {
setupRenderingTest(hooks);
componentTest("icon only button", {
template: hbs`{{mount-widget widget="button" args=args}}`,
beforeEach() {
this.set("args", { icon: "far-smile" });
},
test(assert) {
assert.ok(
exists("button.btn.btn-icon.no-text"),
"it has all the classes"
);
assert.ok(exists("button .d-icon.d-icon-far-smile"), "it has the icon");
},
});
componentTest("icon and text button", {
template: hbs`{{mount-widget widget="button" args=args}}`,
beforeEach() {
this.set("args", { icon: "plus", label: "topic.create" });
},
test(assert) {
assert.ok(exists("button.btn.btn-icon-text"), "it has all the classes");
assert.ok(exists("button .d-icon.d-icon-plus"), "it has the icon");
assert.ok(exists("button span.d-button-label"), "it has the label");
},
});
componentTest("text only button", {
template: hbs`{{mount-widget widget="button" args=args}}`,
beforeEach() {
this.set("args", { label: "topic.create" });
},
test(assert) {
assert.ok(exists("button.btn.btn-text"), "it has all the classes");
assert.ok(exists("button span.d-button-label"), "it has the label");
},
});
componentTest("translatedLabel", {
template: hbs`{{mount-widget widget="button" args=args}}`,
beforeEach() {
this.set("args", { translatedLabel: "foo bar" });
},
test(assert) {
assert.equal(query("button span.d-button-label").innerText, "foo bar");
},
});
componentTest("translatedTitle", {
template: hbs`{{mount-widget widget="button" args=args}}`,
beforeEach() {
this.set("args", { label: "topic.create", translatedTitle: "foo bar" });
},
test(assert) {
assert.equal(query("button").title, "foo bar");
},
});
});