2015-04-07 02:14:00 +08:00
|
|
|
import { acceptance } from "helpers/qunit-helpers";
|
2018-11-19 17:01:22 +08:00
|
|
|
import DiscourseURL from "discourse/lib/url";
|
2018-05-09 23:27:59 +08:00
|
|
|
|
2019-08-31 01:40:12 +08:00
|
|
|
acceptance("User Card", { loggedIn: true });
|
2014-10-21 00:11:36 +08:00
|
|
|
|
2018-07-19 22:40:12 +08:00
|
|
|
QUnit.test("user card", async assert => {
|
2019-03-25 20:37:17 +08:00
|
|
|
await visit("/t/internationalization-localization/280");
|
2020-02-13 17:58:17 +08:00
|
|
|
assert.ok(invisible(".user-card"), "user card is invisible by default");
|
2014-10-21 00:11:36 +08:00
|
|
|
|
2018-07-19 22:40:12 +08:00
|
|
|
await click("a[data-user-card=eviltrout]:first");
|
2020-02-13 17:58:17 +08:00
|
|
|
assert.ok(visible(".user-card"), "card should appear");
|
2019-12-31 02:26:23 +08:00
|
|
|
assert.equal(
|
2020-02-13 17:58:17 +08:00
|
|
|
find(".user-card .username")
|
2019-12-31 02:26:23 +08:00
|
|
|
.text()
|
|
|
|
.trim(),
|
|
|
|
"eviltrout",
|
|
|
|
"user card contains the data"
|
|
|
|
);
|
2018-11-19 17:01:22 +08:00
|
|
|
|
|
|
|
sandbox.stub(DiscourseURL, "routeTo");
|
2019-03-25 20:37:17 +08:00
|
|
|
await click(".card-content a.user-profile-link");
|
|
|
|
assert.ok(
|
|
|
|
DiscourseURL.routeTo.calledWith("/u/eviltrout"),
|
|
|
|
"it should navigate to the user profile"
|
|
|
|
);
|
2019-08-31 01:40:12 +08:00
|
|
|
|
|
|
|
await click("a[data-user-card=charlie]:first");
|
2020-02-13 17:58:17 +08:00
|
|
|
assert.ok(visible(".user-card"), "card should appear");
|
2019-12-31 02:26:23 +08:00
|
|
|
assert.equal(
|
2020-02-13 17:58:17 +08:00
|
|
|
find(".user-card .username")
|
2019-12-31 02:26:23 +08:00
|
|
|
.text()
|
|
|
|
.trim(),
|
|
|
|
"charlie",
|
|
|
|
"user card contains the data"
|
|
|
|
);
|
2019-08-31 01:40:12 +08:00
|
|
|
|
|
|
|
await click(".card-content .compose-pm button");
|
|
|
|
assert.ok(
|
2020-02-13 17:58:17 +08:00
|
|
|
invisible(".user-card"),
|
2019-08-31 01:40:12 +08:00
|
|
|
"user card dismissed after hitting Message button"
|
|
|
|
);
|
2019-12-31 02:26:23 +08:00
|
|
|
|
|
|
|
const mention = find("a.mention");
|
|
|
|
const icon = document.createElement("span");
|
|
|
|
icon.classList.add("icon");
|
|
|
|
mention.append(icon);
|
|
|
|
await click("a.mention .icon");
|
2020-02-13 17:58:17 +08:00
|
|
|
assert.ok(visible(".user-card"), "card should appear");
|
2019-12-31 02:26:23 +08:00
|
|
|
assert.equal(
|
2020-02-13 17:58:17 +08:00
|
|
|
find(".user-card .username")
|
2019-12-31 02:26:23 +08:00
|
|
|
.text()
|
|
|
|
.trim(),
|
|
|
|
"eviltrout",
|
|
|
|
"user card contains the data"
|
|
|
|
);
|
2018-04-18 06:52:23 +08:00
|
|
|
});
|