2013-11-08 11:38:35 -05:00
|
|
|
integration("Header", {
|
2013-11-05 11:56:13 -05:00
|
|
|
setup: function() {
|
|
|
|
sinon.stub(I18n, "t", function(scope, options) {
|
|
|
|
if (options) {
|
2013-11-21 14:38:56 -05:00
|
|
|
if (options.count) {
|
|
|
|
return [scope, options.count].join(" ");
|
|
|
|
} else {
|
|
|
|
return [scope, options.username, options.link].join(" ").trim();
|
|
|
|
}
|
2013-11-05 11:56:13 -05:00
|
|
|
}
|
|
|
|
return scope;
|
|
|
|
});
|
2013-11-21 14:38:56 -05:00
|
|
|
|
2013-11-29 15:01:46 -05:00
|
|
|
var originalCategories = Discourse.Category.list();
|
|
|
|
sinon.stub(Discourse.Category, "list").returns(originalCategories);
|
2013-11-21 14:38:56 -05:00
|
|
|
|
|
|
|
var originalUser = Discourse.User.current();
|
|
|
|
sinon.stub(Discourse.User, "current").returns(originalUser);
|
2013-11-05 11:56:13 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
teardown: function() {
|
|
|
|
I18n.t.restore();
|
2013-11-21 14:38:56 -05:00
|
|
|
Discourse.Category.list.restore();
|
|
|
|
Discourse.User.current.restore();
|
2013-11-05 11:56:13 -05:00
|
|
|
}
|
|
|
|
});
|
2013-06-12 11:56:59 -04:00
|
|
|
|
2013-10-31 12:27:28 -04:00
|
|
|
test("header", function() {
|
|
|
|
expect(1);
|
2013-10-29 12:33:53 -04:00
|
|
|
|
|
|
|
visit("/").then(function() {
|
2013-10-31 12:27:28 -04:00
|
|
|
ok(exists("header"), "is rendered");
|
2013-10-29 12:33:53 -04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2013-10-31 12:27:28 -04:00
|
|
|
test("logo", function() {
|
2013-10-29 12:33:53 -04:00
|
|
|
expect(2);
|
|
|
|
|
|
|
|
visit("/").then(function() {
|
2013-10-31 12:27:28 -04:00
|
|
|
ok(exists(".logo-big"), "is rendered");
|
2013-10-29 12:33:53 -04:00
|
|
|
|
|
|
|
Ember.run(function() {
|
2013-10-31 12:27:28 -04:00
|
|
|
controllerFor("header").set("showExtraInfo", true);
|
2013-10-29 12:33:53 -04:00
|
|
|
});
|
2013-10-31 12:27:28 -04:00
|
|
|
ok(exists(".logo-small"), "is properly wired to showExtraInfo property (when showExtraInfo value changes, logo size also changes)");
|
2013-10-29 12:33:53 -04:00
|
|
|
});
|
|
|
|
});
|
2013-11-05 11:56:13 -05:00
|
|
|
|
2013-11-11 15:51:49 -05:00
|
|
|
test("notifications dropdown", function() {
|
|
|
|
expect(4);
|
2013-11-05 11:56:13 -05:00
|
|
|
|
2013-11-11 15:51:49 -05:00
|
|
|
var itemSelector = "#notifications-dropdown li";
|
2013-11-05 11:56:13 -05:00
|
|
|
|
|
|
|
Ember.run(function() {
|
2013-11-11 15:51:49 -05:00
|
|
|
Discourse.URL_FIXTURES["/notifications"] = [
|
|
|
|
{
|
|
|
|
notification_type: 2, //replied
|
|
|
|
read: true,
|
|
|
|
post_number: 2,
|
|
|
|
topic_id: 1234,
|
|
|
|
slug: "a-slug",
|
|
|
|
data: {
|
|
|
|
topic_title: "some title",
|
|
|
|
display_username: "velesin"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
];
|
2013-11-05 11:56:13 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
visit("/")
|
2013-11-11 15:51:49 -05:00
|
|
|
.then(function() {
|
|
|
|
ok(!exists($(itemSelector)), "initially is empty");
|
|
|
|
})
|
2013-11-05 11:56:13 -05:00
|
|
|
.click("#user-notifications")
|
|
|
|
.then(function() {
|
2013-11-11 15:51:49 -05:00
|
|
|
var $items = $(itemSelector);
|
2013-11-05 11:56:13 -05:00
|
|
|
|
2013-11-11 15:51:49 -05:00
|
|
|
ok(exists($items), "is lazily populated after user opens it");
|
|
|
|
ok($items.first().hasClass("read"), "correctly binds items' 'read' class");
|
|
|
|
equal($items.first().html(), 'notifications.replied velesin <a href="/t/a-slug/1234/2">some title</a>', "correctly generates items' content");
|
2013-11-05 11:56:13 -05:00
|
|
|
});
|
|
|
|
});
|
2013-11-21 14:38:56 -05:00
|
|
|
|
2013-11-29 15:01:46 -05:00
|
|
|
test("sitemap dropdown", function() {
|
|
|
|
expect(8);
|
2013-11-21 14:38:56 -05:00
|
|
|
|
|
|
|
Discourse.SiteSettings.faq_url = "faq-url";
|
|
|
|
Discourse.SiteSettings.enable_mobile_theme = true;
|
|
|
|
|
2013-11-29 15:01:46 -05:00
|
|
|
Discourse.User.current.returns({
|
|
|
|
staff: true,
|
|
|
|
site_flagged_posts_count: 1
|
2013-11-21 14:38:56 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
Discourse.Category.list.returns([
|
2013-11-29 15:01:46 -05:00
|
|
|
Discourse.Category.create({
|
|
|
|
newTopics: 20
|
|
|
|
})
|
2013-11-21 14:38:56 -05:00
|
|
|
]);
|
|
|
|
|
2013-11-29 15:01:46 -05:00
|
|
|
var siteMapDropdownSelector = "#site-map-dropdown";
|
2013-11-21 14:38:56 -05:00
|
|
|
|
|
|
|
visit("/")
|
|
|
|
.then(function() {
|
2013-11-29 15:01:46 -05:00
|
|
|
ok(!exists($(siteMapDropdownSelector)), "initially is not rendered");
|
|
|
|
})
|
|
|
|
.click("#site-map")
|
|
|
|
.then(function() {
|
|
|
|
var $siteMapDropdown = $(siteMapDropdownSelector);
|
2013-11-21 14:38:56 -05:00
|
|
|
|
2013-11-29 15:01:46 -05:00
|
|
|
ok(exists($siteMapDropdown), "is lazily rendered after user opens it");
|
2013-11-21 14:38:56 -05:00
|
|
|
|
2013-11-29 15:01:46 -05:00
|
|
|
ok(exists($siteMapDropdown.find(".admin-link")), "has showing / hiding admin links correctly bound");
|
|
|
|
ok(exists($siteMapDropdown.find(".flagged-posts.badge-notification")), "has displaying flagged posts badge correctly bound");
|
|
|
|
equal($siteMapDropdown.find(".faq-link").attr("href"), "faq-url", "is correctly bound to the FAQ url site config");
|
|
|
|
notEqual($siteMapDropdown.find(".mobile-toggle-link").text().indexOf("mobile_view"), -1, "has displaying mobile theme toggle link correctly bound");
|
2013-11-21 14:38:56 -05:00
|
|
|
|
2013-11-29 15:01:46 -05:00
|
|
|
ok(exists($siteMapDropdown.find(".category-links")), "has categories correctly bound");
|
|
|
|
ok(exists($siteMapDropdown.find(".new-posts")), "has displaying category badges correctly bound");
|
2013-11-21 14:38:56 -05:00
|
|
|
});
|
|
|
|
});
|