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/acceptance/user-anonymous-test.js
Robin Ward 71d37953d5 REFACTOR: Import QUnit and related helpers rather than globals
We used many global functions to handle tests when they should be
imported like other libraries in our application. This also gets us
closer to the way Ember CLI prefers our tests to be laid out.
2020-10-07 11:50:49 -04:00

50 lines
1.5 KiB
JavaScript

import { test } from "qunit";
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
acceptance("User Anonymous");
function hasStream(assert) {
assert.ok(exists(".user-main .about"), "it has the about section");
assert.ok(count(".user-stream .item") > 0, "it has stream items");
}
function hasTopicList(assert) {
assert.equal(count(".user-stream .item"), 0, "has no stream displayed");
assert.ok(count(".topic-list tr") > 0, "it has a topic list");
}
test("Root URL", async (assert) => {
await visit("/u/eviltrout");
assert.ok($("body.user-summary-page").length, "has the body class");
assert.equal(currentPath(), "user.summary", "it defaults to summary");
});
test("Filters", async (assert) => {
await visit("/u/eviltrout/activity");
assert.ok($("body.user-activity-page").length, "has the body class");
hasStream(assert);
await visit("/u/eviltrout/activity/topics");
await hasTopicList(assert);
await visit("/u/eviltrout/activity/replies");
hasStream(assert);
assert.ok(exists(".user-stream.filter-5"), "stream has filter class");
});
test("Badges", async (assert) => {
await visit("/u/eviltrout/badges");
assert.ok($("body.user-badges-page").length, "has the body class");
assert.ok(exists(".user-badges-list .badge-card"), "shows a badge");
});
test("Restricted Routes", async (assert) => {
await visit("/u/eviltrout/preferences");
assert.equal(
currentURL(),
"/u/eviltrout/activity",
"it redirects from preferences"
);
});