discourse/test/javascripts/acceptance/queued-posts-test.js.es6

76 lines
2.1 KiB
Plaintext
Raw Normal View History

2015-04-11 05:00:50 +08:00
import { acceptance } from "helpers/qunit-helpers";
acceptance("Queued Posts", { loggedIn: true });
test("approve a post", () => {
visit("/queued-posts");
click('.queued-post:eq(0) button.approve');
2015-04-11 05:00:50 +08:00
andThen(() => {
ok(!exists('.queued-post'), 'it removes the post');
2015-04-11 05:00:50 +08:00
});
});
2015-04-11 05:00:50 +08:00
test("reject a post", () => {
visit("/queued-posts");
click('.queued-post:eq(0) button.reject');
2015-04-11 05:00:50 +08:00
andThen(() => {
ok(!exists('.queued-post'), 'it removes the post');
});
});
test("delete user", () => {
visit("/queued-posts");
click('.queued-post:eq(0) button.delete-user');
andThen(() => {
ok(exists('.bootbox.modal'), 'it pops up a confirmation dialog');
});
click('.modal-footer a:eq(1)');
andThen(() => {
ok(!exists('.bootbox.modal'), 'it dismisses the modal');
ok(exists('.queued-post'), "it doesn't remove the post");
});
click('.queued-post:eq(0) button.delete-user');
click('.modal-footer a:eq(0)');
andThen(() => {
ok(!exists('.bootbox.modal'), 'it dismisses the modal');
ok(!exists('.queued-post'), "it removes the post");
});
});
2015-04-11 05:00:50 +08:00
test("edit a post - cancel", () => {
2015-04-11 05:00:50 +08:00
visit("/queued-posts");
click('.queued-post:eq(0) button.edit');
2015-04-11 05:00:50 +08:00
andThen(() => {
equal(find('.queued-post:eq(0) textarea').val(), 'queued post text', 'it shows an editor');
2015-04-11 05:00:50 +08:00
});
fillIn('.queued-post:eq(0) textarea', 'new post text');
click('.queued-post:eq(0) button.cancel');
2015-04-11 05:00:50 +08:00
andThen(() => {
ok(!exists('textarea'), 'it disables editing');
equal(find('.queued-post:eq(0) .body p').text(), 'queued post text', 'it reverts the new text');
});
});
test("edit a post - confirm", () => {
visit("/queued-posts");
click('.queued-post:eq(0) button.edit');
andThen(() => {
equal(find('.queued-post:eq(0) textarea').val(), 'queued post text', 'it shows an editor');
});
fillIn('.queued-post:eq(0) textarea', 'new post text');
click('.queued-post:eq(0) button.confirm');
andThen(() => {
ok(!exists('textarea'), 'it disables editing');
equal(find('.queued-post:eq(0) .body p').text(), 'new post text', 'it has the new text');
2015-04-11 05:00:50 +08:00
});
});