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/components/user-info-test.js
Bianca Nenciu 3206452d78
FIX: Prioritize names and usernames consistently (#16686)
The prioritize_username_in_ux site settings controls if the username or
name will be prioritized in the user interface. On the user directory
page the name was never displayed if the user and username were very
similar, being completely different from all the other places where the
username or name is displayed.
2022-05-09 18:46:27 +03:00

72 lines
1.8 KiB
JavaScript

import componentTest, {
setupRenderingTest,
} from "discourse/tests/helpers/component-test";
import hbs from "htmlbars-inline-precompile";
import {
discourseModule,
exists,
query,
} from "discourse/tests/helpers/qunit-helpers";
discourseModule("Integration | Component | user-info", function (hooks) {
setupRenderingTest(hooks);
componentTest("prioritized name", {
template: hbs`{{user-info user=currentUser}}`,
beforeEach() {
this.siteSettings.prioritize_username_in_ux = false;
this.currentUser.name = "Evil Trout";
},
async test(assert) {
assert.equal(query(".name.bold").innerText.trim(), "Evil Trout");
assert.equal(query(".username.margin").innerText.trim(), "eviltrout");
},
});
componentTest("prioritized username", {
template: hbs`{{user-info user=currentUser}}`,
beforeEach() {
this.siteSettings.prioritize_username_in_ux = true;
this.currentUser.name = "Evil Trout";
},
async test(assert) {
assert.equal(query(".username.bold").innerText.trim(), "eviltrout");
assert.equal(query(".name.margin").innerText.trim(), "Evil Trout");
},
});
componentTest("includeLink", {
template: hbs`{{user-info user=currentUser includeLink=includeLink}}`,
async test(assert) {
this.set("includeLink", true);
assert.ok(exists(`.username a[href="/u/${this.currentUser.username}"]`));
this.set("includeLink", false);
assert.notOk(
exists(`.username a[href="/u/${this.currentUser.username}"]`)
);
},
});
componentTest("includeAvatar", {
template: hbs`{{user-info user=currentUser includeAvatar=includeAvatar}}`,
async test(assert) {
this.set("includeAvatar", true);
assert.ok(exists(".user-image"));
this.set("includeAvatar", false);
assert.notOk(exists(".user-image"));
},
});
});