From a891125b9264cc8cc871f039ffcecfa7544e16cb Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Mon, 20 Jun 2016 11:22:36 +0800 Subject: [PATCH] Add tests from discourse-tagging. --- .../acceptance/tag-hashtag-test.js.es6 | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 test/javascripts/acceptance/tag-hashtag-test.js.es6 diff --git a/test/javascripts/acceptance/tag-hashtag-test.js.es6 b/test/javascripts/acceptance/tag-hashtag-test.js.es6 new file mode 100644 index 000000000..27942f69a --- /dev/null +++ b/test/javascripts/acceptance/tag-hashtag-test.js.es6 @@ -0,0 +1,43 @@ +import { acceptance } from "helpers/qunit-helpers"; + +acceptance("Tag Hashtag", { + loggedIn: true, + settings: { tagging_enabled: true }, + setup() { + const response = (object) => { + return [ + 200, + {"Content-Type": "application/json"}, + object + ]; + }; + + server.get('/tags/filter/search', () => { //eslint-disable-line + return response({ results: [{ text: 'monkey', count: 1 }] }); + }); + + server.get('/category_hashtags/check', () => { //eslint-disable-line + return response({ valid: [] }); + }); + + server.get('/tags/check', () => { //eslint-disable-line + return response({ valid: [{ value: 'monkey', url: '/tags/monkey' }] }); + }); + } +}); + +test("tag is cooked properly", () => { + visit("/t/internationalization-localization/280"); + click('#topic-footer-buttons .btn.create'); + + fillIn('.d-editor-input', "this is a tag hashtag #monkey::tag"); + andThen(() => { + // TODO: Test that the autocomplete shows + equal(find('.d-editor-preview:visible').html().trim(), "

this is a tag hashtag #monkey

"); + }); + + click('#reply-control .btn.create'); + andThen(() => { + ok(find('.topic-post:last .cooked').html().trim().includes("

this is a tag hashtag #monkey

")); + }); +});