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.
72 lines
1.8 KiB
JavaScript
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"));
|
|
},
|
|
});
|
|
});
|