2015-04-07 02:14:00 +08:00
import { acceptance } from "helpers/qunit-helpers";
2015-04-17 01:53:30 +08:00
acceptance("Topic", { loggedIn: true });
2013-06-21 03:02:02 +08:00
2017-06-15 01:57:58 +08:00
QUnit.test("Share Popup", assert => {
2016-11-12 03:13:19 +08:00
visit("/t/internationalization-localization/280");
andThen(() => {
2017-06-15 01:57:58 +08:00
assert.ok(!exists('#share-link.visible'), 'it is not visible');
2016-11-12 03:13:19 +08:00
});
2017-05-04 10:30:16 +08:00
click("button[data-share-url]");
2016-11-12 03:13:19 +08:00
andThen(() => {
2017-06-15 01:57:58 +08:00
assert.ok(exists('#share-link.visible'), 'it shows the popup');
2016-11-12 03:13:19 +08:00
});
click('#share-link .close-share');
andThen(() => {
2017-06-15 01:57:58 +08:00
assert.ok(!exists('#share-link.visible'), 'it closes the popup');
2016-11-12 03:13:19 +08:00
});
2017-05-04 10:30:16 +08:00
2017-05-04 16:49:12 +08:00
// TODO tgxworld This fails on Travis but we need to push the security fix out
// first.
// click('#topic-footer-buttons .btn.create');
// fillIn('.d-editor-input', '<h2><div data-share-url="something">Click</button><h2>');
//
// click('#reply-control .btn.create');
// click('h2 div[data-share-url]');
//
// andThen(() => {
// ok(!exists('#share-link.visible'), 'it does not show the popup');
// });
2016-11-12 03:13:19 +08:00
});
2017-06-15 01:57:58 +08:00
QUnit.test("Showing and hiding the edit controls", assert => {
2015-04-17 01:53:30 +08:00
visit("/t/internationalization-localization/280");
2017-11-24 01:15:37 +08:00
click('#topic-title .d-icon-pencil');
2015-04-17 01:53:30 +08:00
andThen(() => {
2017-06-15 01:57:58 +08:00
assert.ok(exists('#edit-title'), 'it shows the editing controls');
2017-11-23 03:53:35 +08:00
assert.ok(!exists('.title-wrapper .remove-featured-link'), 'link to remove featured link is not shown');
2015-04-17 01:53:30 +08:00
});
fillIn('#edit-title', 'this is the new title');
click('#topic-title .cancel-edit');
2015-03-19 19:22:56 +08:00
andThen(() => {
2017-06-15 01:57:58 +08:00
assert.ok(!exists('#edit-title'), 'it hides the editing controls');
2013-06-21 03:02:02 +08:00
});
});
2014-09-17 23:18:41 +08:00
2017-06-15 01:57:58 +08:00
QUnit.test("Updating the topic title and category", assert => {
2017-12-22 20:08:12 +08:00
const categoryChooser = selectKit('.title-wrapper .category-chooser');
2015-04-17 01:53:30 +08:00
visit("/t/internationalization-localization/280");
2017-09-15 01:50:32 +08:00
2017-11-24 01:15:37 +08:00
click('#topic-title .d-icon-pencil');
2015-04-17 01:53:30 +08:00
fillIn('#edit-title', 'this is the new title');
2017-12-22 20:08:12 +08:00
categoryChooser.expand().selectRowByValue(4);
2015-04-17 01:53:30 +08:00
click('#topic-title .submit-edit');
2015-03-19 19:22:56 +08:00
andThen(() => {
2017-06-15 01:57:58 +08:00
assert.equal(find('#topic-title .badge-category').text(), 'faq', 'it displays the new category');
assert.equal(find('.fancy-title').text().trim(), 'this is the new title', 'it displays the new title');
2014-09-17 23:18:41 +08:00
});
});
2017-01-25 14:33:16 +08:00
2017-06-15 01:57:58 +08:00
QUnit.test("Marking a topic as wiki", assert => {
2017-01-25 14:33:16 +08:00
server.put('/posts/398/wiki', () => { // eslint-disable-line no-undef
return [
200,
{ "Content-Type": "application/json" },
{}
];
});
visit("/t/internationalization-localization/280");
andThen(() => {
2017-06-15 01:57:58 +08:00
assert.ok(find('a.wiki').length === 0, 'it does not show the wiki icon');
2017-01-25 14:33:16 +08:00
});
click('.topic-post:eq(0) button.show-more-actions');
click('.topic-post:eq(0) button.show-post-admin-menu');
click('.btn.wiki');
andThen(() => {
2017-06-15 01:57:58 +08:00
assert.ok(find('a.wiki').length === 1, 'it shows the wiki icon');
2017-01-25 14:33:16 +08:00
});
});
2016-11-30 01:59:42 +08:00
2017-06-15 01:57:58 +08:00
QUnit.test("Reply as new topic", assert => {
2016-11-30 01:59:42 +08:00
visit("/t/internationalization-localization/280");
click("button.share:eq(0)");
click(".reply-as-new-topic a");
andThen(() => {
2017-06-15 01:57:58 +08:00
assert.ok(exists('.d-editor-input'), 'the composer input is visible');
2016-11-30 01:59:42 +08:00
2017-06-15 01:57:58 +08:00
assert.equal(
2016-11-30 01:59:42 +08:00
find('.d-editor-input').val().trim(),
2017-02-03 12:09:30 +08:00
`Continuing the discussion from [Internationalization / localization](${window.location.origin}/t/internationalization-localization/280):`,
2016-11-30 01:59:42 +08:00
"it fills composer with the ring string"
);
2017-06-15 01:57:58 +08:00
assert.equal(
2017-12-22 20:08:12 +08:00
selectKit('.category-chooser').header().value(), "2",
2016-11-30 01:59:42 +08:00
"it fills category selector with the right category"
);
});
});
2017-06-15 01:57:58 +08:00
QUnit.test("Reply as new message", assert => {
2016-11-30 01:59:42 +08:00
visit("/t/pm-for-testing/12");
click("button.share:eq(0)");
click(".reply-as-new-topic a");
andThen(() => {
2017-06-15 01:57:58 +08:00
assert.ok(exists('.d-editor-input'), 'the composer input is visible');
2016-11-30 01:59:42 +08:00
2017-06-15 01:57:58 +08:00
assert.equal(
2016-11-30 01:59:42 +08:00
find('.d-editor-input').val().trim(),
2017-02-03 12:09:30 +08:00
`Continuing the discussion from [PM for testing](${window.location.origin}/t/pm-for-testing/12):`,
2016-11-30 01:59:42 +08:00
"it fills composer with the ring string"
);
const targets = find('.item span', '.composer-fields');
2017-06-15 01:57:58 +08:00
assert.equal(
2016-11-30 01:59:42 +08:00
$(targets[0]).text(), "someguy",
"it fills up the composer with the right user to start the PM to"
);
2017-06-15 01:57:58 +08:00
assert.equal(
2016-11-30 01:59:42 +08:00
$(targets[1]).text(), "test",
"it fills up the composer with the right user to start the PM to"
);
2017-06-15 01:57:58 +08:00
assert.equal(
2016-11-30 01:59:42 +08:00
$(targets[2]).text(), "Group",
"it fills up the composer with the right group to start the PM to"
);
});
});
2017-06-05 20:06:23 +08:00
2017-09-29 14:02:58 +08:00
QUnit.test("Visit topic routes", assert => {
visit("/t/12");
andThen(() => {
assert.equal(
find('.fancy-title').text().trim(), 'PM for testing',
'it routes to the right topic'
);
});
visit("/t/280/20");
andThen(() => {
assert.equal(
find('.fancy-title').text().trim(), 'Internationalization / localization',
'it routes to the right topic'
);
});
});
2017-06-15 01:57:58 +08:00
QUnit.test("Updating the topic title with emojis", assert => {
2017-06-05 20:06:23 +08:00
visit("/t/internationalization-localization/280");
2017-11-24 01:15:37 +08:00
click('#topic-title .d-icon-pencil');
2017-06-05 20:06:23 +08:00
fillIn('#edit-title', 'emojis title :bike: :blonde_woman:t6:');
click('#topic-title .submit-edit');
andThen(() => {
2017-06-15 01:57:58 +08:00
assert.equal(find('.fancy-title').html().trim(), 'emojis title <img src=\"/images/emoji/emoji_one/bike.png?v=5\" title=\"bike\" alt=\"bike\" class=\"emoji\"> <img src=\"/images/emoji/emoji_one/blonde_woman/6.png?v=5\" title=\"blonde_woman:t6\" alt=\"blonde_woman:t6\" class=\"emoji\">', 'it displays the new title with emojis');
2017-06-05 20:06:23 +08:00
});
2017-07-27 04:33:17 +08:00
});
2017-11-23 03:53:35 +08:00
acceptance("Topic featured links", {
loggedIn: true,
settings: {
topic_featured_link_enabled: true,
max_topic_title_length: 80
}
});
QUnit.test("remove featured link", assert => {
visit("/t/299/1");
andThen(() => {
assert.ok(exists('.title-wrapper .topic-featured-link'), 'link is shown with topic title');
});
click('.title-wrapper .edit-topic');
andThen(() => {
assert.ok(exists('.title-wrapper .remove-featured-link'), 'link to remove featured link');
});
2017-11-23 04:23:06 +08:00
// this test only works in a browser:
// click('.title-wrapper .remove-featured-link');
// click('.title-wrapper .submit-edit');
// andThen(() => {
// assert.ok(!exists('.title-wrapper .topic-featured-link'), 'link is gone');
// });
2017-11-23 03:53:35 +08:00
});