discourse/test/javascripts/acceptance/badges-test.js.es6
Robin Ward a8793d0d9a REFACTOR: Test Memory Usage Fixes (#7769)
* Calling `Discourse.reset()` creates a new container
We should run our de-initializers only after acceptance tests,
since initializers are not run outside of acceptance tests anyway,
and the container at this point can be passed properly to the
`teardown()` method.

* Remove `Discourse.reset` from tests
This would cause a new container to be created which leaks many objects.

* `updateCurrentUser` is more accurate than `replaceCurrentUser`
2019-06-14 14:54:20 +02:00

25 lines
892 B
JavaScript

import selectKit from "helpers/select-kit-helper";
import { acceptance } from "helpers/qunit-helpers";
acceptance("Badges", { loggedIn: true });
QUnit.test("Visit Badge Pages", async assert => {
await visit("/badges");
assert.ok($("body.badges-page").length, "has body class");
assert.ok(exists(".badge-groups .badge-card"), "has a list of badges");
await visit("/badges/9/autobiographer");
assert.ok(exists(".badge-card"), "has the badge in the listing");
assert.ok(exists(".user-info"), "has the list of users with that badge");
assert.ok(!exists(".badge-card:eq(0) script"));
});
QUnit.test("shows correct badge titles to choose from", async assert => {
const availableBadgeTitles = selectKit(".select-kit");
await visit("/badges/50/custombadge");
await availableBadgeTitles.expand();
assert.ok(availableBadgeTitles.rowByIndex(1).name() === "CustomBadge");
});