Add acceptance tests for all mobile templates
This commit is contained in:
parent
22d7ea1192
commit
0fcfc6bed9
|
@ -39,7 +39,6 @@ function parseName(fullName) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Ember.DefaultResolver.extend({
|
export default Ember.DefaultResolver.extend({
|
||||||
|
|
||||||
parseName: parseName,
|
parseName: parseName,
|
||||||
|
|
||||||
normalize(fullName) {
|
normalize(fullName) {
|
||||||
|
|
|
@ -16,4 +16,3 @@ export default {
|
||||||
app.registry.resolver.__resolver__.mobileView = Mobile.mobileView;
|
app.registry.resolver.__resolver__.mobileView = Mobile.mobileView;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
let mobileForced = false;
|
||||||
|
|
||||||
// An object that is responsible for logic related to mobile devices.
|
// An object that is responsible for logic related to mobile devices.
|
||||||
const Mobile = {
|
const Mobile = {
|
||||||
isMobileDevice: false,
|
isMobileDevice: false,
|
||||||
|
@ -5,8 +7,10 @@ const Mobile = {
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
const $html = $('html');
|
const $html = $('html');
|
||||||
this.isMobileDevice = $html.hasClass('mobile-device');
|
this.isMobileDevice = mobileForced || $html.hasClass('mobile-device');
|
||||||
this.mobileView = $html.hasClass('mobile-view');
|
this.mobileView = mobileForced || $html.hasClass('mobile-view');
|
||||||
|
|
||||||
|
if (mobileForced) { return; }
|
||||||
|
|
||||||
try{
|
try{
|
||||||
if (window.location.search.match(/mobile_view=1/)){
|
if (window.location.search.match(/mobile_view=1/)){
|
||||||
|
@ -27,8 +31,8 @@ const Mobile = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleMobileView: function() {
|
toggleMobileView() {
|
||||||
try{
|
try {
|
||||||
if (localStorage) {
|
if (localStorage) {
|
||||||
localStorage.mobileView = !this.mobileView;
|
localStorage.mobileView = !this.mobileView;
|
||||||
}
|
}
|
||||||
|
@ -38,11 +42,19 @@ const Mobile = {
|
||||||
this.reloadPage(!this.mobileView);
|
this.reloadPage(!this.mobileView);
|
||||||
},
|
},
|
||||||
|
|
||||||
reloadPage: function(mobile) {
|
reloadPage(mobile) {
|
||||||
window.location.assign(window.location.pathname + '?mobile_view=' + (mobile ? '1' : '0'));
|
window.location.assign(window.location.pathname + '?mobile_view=' + (mobile ? '1' : '0'));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export function forceMobile() {
|
||||||
|
mobileForced = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function resetMobile() {
|
||||||
|
mobileForced = false;
|
||||||
|
}
|
||||||
|
|
||||||
// Backwards compatibiltity, deprecated
|
// Backwards compatibiltity, deprecated
|
||||||
Object.defineProperty(Discourse, 'Mobile', {
|
Object.defineProperty(Discourse, 'Mobile', {
|
||||||
get: function() {
|
get: function() {
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
{{user-info user=item.user}}
|
||||||
|
{{user-stat value=item.likes_received label="directory.likes_received" icon="heart"}}
|
||||||
|
{{user-stat value=item.likes_given label="directory.likes_given" icon="heart"}}
|
||||||
|
{{user-stat value=item.topic_count label="directory.topic_count"}}
|
||||||
|
{{user-stat value=item.post_count label="directory.post_count"}}
|
||||||
|
{{user-stat value=item.topics_entered label="directory.topics_entered"}}
|
||||||
|
{{user-stat value=item.posts_read label="directory.posts_read"}}
|
||||||
|
{{user-stat value=item.days_visited label="directory.days_visited"}}
|
||||||
|
{{#if showTimeRead}}
|
||||||
|
<div class='time-read'>{{unbound item.time_read}}</div>
|
||||||
|
{{/if}}
|
|
@ -9,23 +9,8 @@
|
||||||
{{#conditional-loading-spinner condition=model.loading}}
|
{{#conditional-loading-spinner condition=model.loading}}
|
||||||
{{#if model.length}}
|
{{#if model.length}}
|
||||||
<div class='total-rows'>{{i18n "directory.total_rows" count=model.totalRows}}</div>
|
<div class='total-rows'>{{i18n "directory.total_rows" count=model.totalRows}}</div>
|
||||||
|
{{#each model as |item|}}
|
||||||
{{#each model itemController="directory-item"}}
|
{{directory-item tagName="div" class="user" item=item showTimeRead=showTimeRead}}
|
||||||
<div class="user {{if ic.me 'me'}}">
|
|
||||||
{{#with ic.model as |it|}}
|
|
||||||
{{user-info user=it.user}}
|
|
||||||
{{user-stat value=it.likes_received label="directory.likes_received" icon="heart"}}
|
|
||||||
{{user-stat value=it.likes_given label="directory.likes_given" icon="heart"}}
|
|
||||||
{{user-stat value=it.topic_count label="directory.topic_count"}}
|
|
||||||
{{user-stat value=it.post_count label="directory.post_count"}}
|
|
||||||
{{user-stat value=it.topics_entered label="directory.topics_entered"}}
|
|
||||||
{{user-stat value=it.posts_read label="directory.posts_read"}}
|
|
||||||
{{user-stat value=it.days_visited label="directory.days_visited"}}
|
|
||||||
{{#if showTimeRead}}
|
|
||||||
<div class='time-read'>{{unbound it.time_read}}</div>
|
|
||||||
{{/if}}
|
|
||||||
{{/with}}
|
|
||||||
</div>
|
|
||||||
{{/each}}
|
{{/each}}
|
||||||
|
|
||||||
{{conditional-loading-spinner condition=model.loadingMore}}
|
{{conditional-loading-spinner condition=model.loadingMore}}
|
||||||
|
|
|
@ -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");
|
||||||
|
});
|
||||||
|
});
|
|
@ -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");
|
||||||
|
});
|
||||||
|
});
|
|
@ -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");
|
||||||
|
});
|
||||||
|
});
|
|
@ -3,6 +3,7 @@
|
||||||
import sessionFixtures from 'fixtures/session-fixtures';
|
import sessionFixtures from 'fixtures/session-fixtures';
|
||||||
import siteFixtures from 'fixtures/site-fixtures';
|
import siteFixtures from 'fixtures/site-fixtures';
|
||||||
import HeaderComponent from 'discourse/components/site-header';
|
import HeaderComponent from 'discourse/components/site-header';
|
||||||
|
import { forceMobile, resetMobile } from 'discourse/lib/mobile';
|
||||||
|
|
||||||
function currentUser() {
|
function currentUser() {
|
||||||
return Discourse.User.create(sessionFixtures['/session/current.json'].current_user);
|
return Discourse.User.create(sessionFixtures['/session/current.json'].current_user);
|
||||||
|
@ -36,19 +37,25 @@ var oldAvatar = Discourse.Utilities.avatarImg;
|
||||||
|
|
||||||
function acceptance(name, options) {
|
function acceptance(name, options) {
|
||||||
module("Acceptance: " + name, {
|
module("Acceptance: " + name, {
|
||||||
setup: function() {
|
setup() {
|
||||||
|
resetMobile();
|
||||||
|
|
||||||
// Don't render avatars in acceptance tests, it's faster and no 404s
|
// Don't render avatars in acceptance tests, it's faster and no 404s
|
||||||
Discourse.Utilities.avatarImg = () => "";
|
Discourse.Utilities.avatarImg = () => "";
|
||||||
|
|
||||||
// For now don't do scrolling stuff in Test Mode
|
// For now don't do scrolling stuff in Test Mode
|
||||||
HeaderComponent.reopen({examineDockHeader: Ember.K});
|
HeaderComponent.reopen({examineDockHeader: Ember.K});
|
||||||
|
|
||||||
var siteJson = siteFixtures['site.json'].site;
|
const siteJson = siteFixtures['site.json'].site;
|
||||||
if (options) {
|
if (options) {
|
||||||
if (options.setup) {
|
if (options.setup) {
|
||||||
options.setup.call(this);
|
options.setup.call(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options.mobileView) {
|
||||||
|
forceMobile();
|
||||||
|
}
|
||||||
|
|
||||||
if (options.loggedIn) {
|
if (options.loggedIn) {
|
||||||
logIn();
|
logIn();
|
||||||
}
|
}
|
||||||
|
@ -65,7 +72,7 @@ function acceptance(name, options) {
|
||||||
Discourse.reset();
|
Discourse.reset();
|
||||||
},
|
},
|
||||||
|
|
||||||
teardown: function() {
|
teardown() {
|
||||||
if (options && options.teardown) {
|
if (options && options.teardown) {
|
||||||
options.teardown.call(this);
|
options.teardown.call(this);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue