Category List and Topic View Integration Test

This commit is contained in:
Robin Ward 2013-06-20 15:02:02 -04:00
parent 3775a9c11d
commit 3257bef387
7 changed files with 43 additions and 4 deletions

View file

@ -22,6 +22,9 @@ Discourse = Ember.Application.createWithMixins({
// The highest seen post number by topic
highestSeenByTopic: {},
// Helps with integration tests
URL_FIXTURES: {},
getURL: function(url) {
// If it's a non relative URL, return it.

View file

@ -388,7 +388,10 @@ Discourse.TopicView = Discourse.View.extend(Discourse.Scrolling, {
nonUrgentPositionUpdate: Discourse.debounce(function(opts) {
Discourse.ScreenTrack.instance().scrolled();
this.set('controller.currentPost', opts.currentPost);
var model = this.get('controller.model');
if (model) {
this.set('controller.currentPost', opts.currentPost);
}
},500),
scrolled: function(){

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,14 +1,25 @@
integration("List Topics");
test("/", function() {
test("Default List", function() {
visit("/").then(function() {
expect(2);
ok(exists("#topic-list"), "The list of topics was rendered");
ok(count('#topic-list .topic-list-item') > 0, "has topics");
ok(exists('#topic-list .topic-list-item'), "has topics");
});
});
test("Categories List", function() {
visit("/categories").then(function() {
expect(1);
ok(exists('.category-list-item'), "has a list of categories");
});
});

View file

@ -0,0 +1,12 @@
integration("View Topic");
test("View a Topic", function() {
visit("/t/internationalization-localization/280").then(function() {
expect(2);
ok(exists("#topic"), "The was rendered");
ok(exists("#topic .topic-post"), "The topic has posts");
});
});

View file

@ -51,6 +51,14 @@ sinon.config = {
useFakeServer: false
};
window.assetPath = function() { return null };
var oldAjax = $.ajax;
$.ajax = function() {
console.error("Discourse.Ajax called in test environment (" + arguments[0] + ")");
return oldAjax.apply(this, arguments);
};
// Trick JSHint into allow document.write
var d = document;
d.write('<div id="qunit-scratch" style="display:none"></div>');