When a post returns enqueued don't insert it in the stream and notify
- Includes removal of a lot of modal boilerplate
This commit is contained in:
@@ -81,9 +81,31 @@ test("Create a Topic", () => {
|
||||
});
|
||||
});
|
||||
|
||||
test("Create an enqueued Topic", () => {
|
||||
visit("/");
|
||||
click('#create-topic');
|
||||
fillIn('#reply-title', "Internationalization Localization");
|
||||
fillIn('#wmd-input', "enqueue this content please");
|
||||
click('#reply-control button.create');
|
||||
andThen(() => {
|
||||
ok(visible('#discourse-modal'), 'it pops up a modal');
|
||||
equal(currentURL(), "/", "it doesn't change routes");
|
||||
});
|
||||
|
||||
click('.modal-footer button');
|
||||
andThen(() => {
|
||||
ok(invisible('#discourse-modal'), 'the modal can be dismissed');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
test("Create a Reply", () => {
|
||||
visit("/t/internationalization-localization/280");
|
||||
|
||||
andThen(() => {
|
||||
ok(!exists('article[data-post-id=12345]'), 'the post is not in the DOM');
|
||||
});
|
||||
|
||||
click('#topic-footer-buttons .btn.create');
|
||||
andThen(() => {
|
||||
ok(exists('#wmd-input'), 'the composer input is visible');
|
||||
@@ -93,7 +115,32 @@ test("Create a Reply", () => {
|
||||
fillIn('#wmd-input', 'this is the content of my reply');
|
||||
click('#reply-control button.create');
|
||||
andThen(() => {
|
||||
exists('#post_12345', 'it inserts the post into the document');
|
||||
equal(find('.cooked:last p').text(), 'this is the content of my reply');
|
||||
});
|
||||
});
|
||||
|
||||
test("Create an enqueued Reply", () => {
|
||||
visit("/t/internationalization-localization/280");
|
||||
|
||||
click('#topic-footer-buttons .btn.create');
|
||||
andThen(() => {
|
||||
ok(exists('#wmd-input'), 'the composer input is visible');
|
||||
ok(!exists('#reply-title'), 'there is no title since this is a reply');
|
||||
});
|
||||
|
||||
fillIn('#wmd-input', 'enqueue this content please');
|
||||
click('#reply-control button.create');
|
||||
andThen(() => {
|
||||
ok(find('.cooked:last p').text() !== 'enqueue this content please', "it doesn't insert the post");
|
||||
});
|
||||
|
||||
andThen(() => {
|
||||
ok(visible('#discourse-modal'), 'it pops up a modal');
|
||||
});
|
||||
|
||||
click('.modal-footer button');
|
||||
andThen(() => {
|
||||
ok(invisible('#discourse-modal'), 'the modal can be dismissed');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -118,3 +165,4 @@ test("Edit the first post", () => {
|
||||
ok(find('.topic-post:eq(0) .cooked').text().indexOf('This is the new text for the post') !== -1, 'it updates the post');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -88,6 +88,8 @@ export default function() {
|
||||
return [200, {"Content-Type": "text/html"}, "<div class='page-not-found'>not found</div>"];
|
||||
});
|
||||
|
||||
this.delete('/draft.json', success);
|
||||
|
||||
this.get('/draft.json', function() {
|
||||
return response({});
|
||||
});
|
||||
@@ -148,13 +150,17 @@ export default function() {
|
||||
|
||||
if (data.title === "this title triggers an error") {
|
||||
return response(422, {errors: ['That title has already been taken']});
|
||||
} else {
|
||||
return response(200, {
|
||||
success: true,
|
||||
action: 'create_post',
|
||||
post: {id: 12345, topic_id: 280, topic_slug: 'internationalization-localization'}
|
||||
});
|
||||
}
|
||||
|
||||
if (data.raw === "enqueue this content please") {
|
||||
return response(200, { success: true, action: 'enqueued' });
|
||||
}
|
||||
|
||||
return response(200, {
|
||||
success: true,
|
||||
action: 'create_post',
|
||||
post: {id: 12345, topic_id: 280, topic_slug: 'internationalization-localization'}
|
||||
});
|
||||
});
|
||||
|
||||
this.get('/widgets/:widget_id', function(request) {
|
||||
|
||||
Reference in New Issue
Block a user