Add acceptance tests for all mobile templates

This commit is contained in:
Robin Ward
2016-05-05 12:49:12 -04:00
parent 22d7ea1192
commit 0fcfc6bed9
9 changed files with 78 additions and 29 deletions

View File

@@ -0,0 +1,15 @@
import { acceptance } from "helpers/qunit-helpers";
acceptance("Topic Discovery - Mobile", { mobileView: true });
test("Visit Discovery Pages", () => {
visit("/");
andThen(() => {
ok(exists(".topic-list"), "The list of topics was rendered");
ok(exists('.topic-list .topic-list-item'), "has topics");
});
visit("/categories");
andThen(() => {
ok(exists('.category'), "has a list of categories");
});
});

View File

@@ -0,0 +1,11 @@
import { acceptance } from "helpers/qunit-helpers";
acceptance("Signing In - Mobile", { mobileView: true });
test("sign in", () => {
visit("/");
click("header .login-button");
andThen(() => {
ok(exists('#login-form'), "it shows the login modal");
});
});

View File

@@ -0,0 +1,10 @@
import { acceptance } from "helpers/qunit-helpers";
acceptance("User Directory - Mobile", { mobileView: true });
test("Visit Page", () => {
visit("/users");
andThen(() => {
ok(exists('.directory .user'), "has a list of users");
});
});

View File

@@ -3,6 +3,7 @@
import sessionFixtures from 'fixtures/session-fixtures';
import siteFixtures from 'fixtures/site-fixtures';
import HeaderComponent from 'discourse/components/site-header';
import { forceMobile, resetMobile } from 'discourse/lib/mobile';
function currentUser() {
return Discourse.User.create(sessionFixtures['/session/current.json'].current_user);
@@ -36,19 +37,25 @@ var oldAvatar = Discourse.Utilities.avatarImg;
function acceptance(name, options) {
module("Acceptance: " + name, {
setup: function() {
setup() {
resetMobile();
// Don't render avatars in acceptance tests, it's faster and no 404s
Discourse.Utilities.avatarImg = () => "";
// For now don't do scrolling stuff in Test Mode
HeaderComponent.reopen({examineDockHeader: Ember.K});
var siteJson = siteFixtures['site.json'].site;
const siteJson = siteFixtures['site.json'].site;
if (options) {
if (options.setup) {
options.setup.call(this);
}
if (options.mobileView) {
forceMobile();
}
if (options.loggedIn) {
logIn();
}
@@ -65,7 +72,7 @@ function acceptance(name, options) {
Discourse.reset();
},
teardown: function() {
teardown() {
if (options && options.teardown) {
options.teardown.call(this);
}