2019-06-14 08:54:20 -04:00
|
|
|
import { acceptance, updateCurrentUser } from "helpers/qunit-helpers";
|
2016-12-08 16:08:44 -05:00
|
|
|
|
|
|
|
acceptance("Composer topic featured links", {
|
|
|
|
loggedIn: true,
|
|
|
|
settings: {
|
2017-05-18 12:32:35 -04:00
|
|
|
topic_featured_link_enabled: true,
|
2018-02-01 00:16:14 -05:00
|
|
|
max_topic_title_length: 80,
|
2018-06-15 11:03:24 -04:00
|
|
|
enable_markdown_linkify: true
|
2016-12-08 16:08:44 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-07-19 05:40:42 -04:00
|
|
|
QUnit.test("onebox with title", async assert => {
|
|
|
|
await visit("/");
|
|
|
|
await click("#create-topic");
|
|
|
|
await fillIn("#reply-title", "http://www.example.com/has-title.html");
|
|
|
|
assert.ok(
|
|
|
|
find(".d-editor-preview")
|
|
|
|
.html()
|
|
|
|
.trim()
|
|
|
|
.indexOf("onebox") > 0,
|
|
|
|
"it pastes the link into the body and previews it"
|
|
|
|
);
|
|
|
|
assert.ok(
|
|
|
|
exists(".d-editor-textarea-wrapper .popup-tip.good"),
|
|
|
|
"the body is now good"
|
|
|
|
);
|
|
|
|
assert.equal(
|
|
|
|
find(".title-input input").val(),
|
|
|
|
"An interesting article",
|
|
|
|
"title is from the oneboxed article"
|
|
|
|
);
|
2016-12-08 16:08:44 -05:00
|
|
|
});
|
|
|
|
|
2018-07-19 05:40:42 -04:00
|
|
|
QUnit.test("onebox result doesn't include a title", async assert => {
|
|
|
|
await visit("/");
|
|
|
|
await click("#create-topic");
|
|
|
|
await fillIn("#reply-title", "http://www.example.com/no-title.html");
|
|
|
|
assert.ok(
|
|
|
|
find(".d-editor-preview")
|
|
|
|
.html()
|
|
|
|
.trim()
|
|
|
|
.indexOf("onebox") > 0,
|
|
|
|
"it pastes the link into the body and previews it"
|
|
|
|
);
|
|
|
|
assert.ok(
|
|
|
|
exists(".d-editor-textarea-wrapper .popup-tip.good"),
|
|
|
|
"the body is now good"
|
|
|
|
);
|
|
|
|
assert.equal(
|
|
|
|
find(".title-input input").val(),
|
|
|
|
"http://www.example.com/no-title.html",
|
|
|
|
"title is unchanged"
|
|
|
|
);
|
2016-12-08 16:08:44 -05:00
|
|
|
});
|
|
|
|
|
2018-07-19 05:40:42 -04:00
|
|
|
QUnit.test("no onebox result", async assert => {
|
|
|
|
await visit("/");
|
|
|
|
await click("#create-topic");
|
|
|
|
await fillIn("#reply-title", "http://www.example.com/nope-onebox.html");
|
|
|
|
assert.ok(
|
|
|
|
find(".d-editor-preview")
|
|
|
|
.html()
|
|
|
|
.trim()
|
|
|
|
.indexOf("onebox") > 0,
|
|
|
|
"it pastes the link into the body and previews it"
|
|
|
|
);
|
|
|
|
assert.ok(
|
|
|
|
exists(".d-editor-textarea-wrapper .popup-tip.good"),
|
|
|
|
"link is pasted into body"
|
|
|
|
);
|
|
|
|
assert.equal(
|
|
|
|
find(".title-input input").val(),
|
|
|
|
"http://www.example.com/nope-onebox.html",
|
|
|
|
"title is unchanged"
|
|
|
|
);
|
2016-12-08 16:08:44 -05:00
|
|
|
});
|
2017-02-08 15:34:42 -05:00
|
|
|
|
2018-07-19 05:40:42 -04:00
|
|
|
QUnit.test("ignore internal links", async assert => {
|
|
|
|
await visit("/");
|
|
|
|
await click("#create-topic");
|
2017-02-08 15:34:42 -05:00
|
|
|
const title = "http://" + window.location.hostname + "/internal-page.html";
|
2018-07-19 05:40:42 -04:00
|
|
|
await fillIn("#reply-title", title);
|
|
|
|
assert.equal(
|
|
|
|
find(".d-editor-preview")
|
|
|
|
.html()
|
|
|
|
.trim()
|
|
|
|
.indexOf("onebox"),
|
|
|
|
-1,
|
|
|
|
"onebox preview doesn't show"
|
|
|
|
);
|
|
|
|
assert.equal(
|
|
|
|
find(".d-editor-input").val().length,
|
|
|
|
0,
|
|
|
|
"link isn't put into the post"
|
|
|
|
);
|
|
|
|
assert.equal(find(".title-input input").val(), title, "title is unchanged");
|
2017-02-08 15:34:42 -05:00
|
|
|
});
|
2017-05-18 12:32:35 -04:00
|
|
|
|
2018-07-19 05:40:42 -04:00
|
|
|
QUnit.test("link is longer than max title length", async assert => {
|
|
|
|
await visit("/");
|
|
|
|
await click("#create-topic");
|
|
|
|
await fillIn(
|
2018-06-15 11:03:24 -04:00
|
|
|
"#reply-title",
|
|
|
|
"http://www.example.com/has-title-and-a-url-that-is-more-than-80-characters-because-thats-good-for-seo-i-guess.html"
|
|
|
|
);
|
2018-07-19 05:40:42 -04:00
|
|
|
assert.ok(
|
|
|
|
find(".d-editor-preview")
|
|
|
|
.html()
|
|
|
|
.trim()
|
|
|
|
.indexOf("onebox") > 0,
|
|
|
|
"it pastes the link into the body and previews it"
|
|
|
|
);
|
|
|
|
assert.ok(
|
|
|
|
exists(".d-editor-textarea-wrapper .popup-tip.good"),
|
|
|
|
"the body is now good"
|
|
|
|
);
|
|
|
|
assert.equal(
|
|
|
|
find(".title-input input").val(),
|
|
|
|
"An interesting article",
|
|
|
|
"title is from the oneboxed article"
|
|
|
|
);
|
2017-12-04 14:21:08 -05:00
|
|
|
});
|
|
|
|
|
2018-07-19 05:40:42 -04:00
|
|
|
QUnit.test("onebox with title but extra words in title field", async assert => {
|
|
|
|
await visit("/");
|
|
|
|
await click("#create-topic");
|
|
|
|
await fillIn("#reply-title", "http://www.example.com/has-title.html test");
|
|
|
|
assert.equal(
|
|
|
|
find(".d-editor-preview")
|
|
|
|
.html()
|
|
|
|
.trim()
|
|
|
|
.indexOf("onebox"),
|
|
|
|
-1,
|
|
|
|
"onebox preview doesn't show"
|
|
|
|
);
|
|
|
|
assert.equal(
|
|
|
|
find(".d-editor-input").val().length,
|
|
|
|
0,
|
|
|
|
"link isn't put into the post"
|
|
|
|
);
|
|
|
|
assert.equal(
|
|
|
|
find(".title-input input").val(),
|
|
|
|
"http://www.example.com/has-title.html test",
|
|
|
|
"title is unchanged"
|
|
|
|
);
|
2017-12-04 14:21:08 -05:00
|
|
|
});
|
2018-04-10 19:31:20 -04:00
|
|
|
|
|
|
|
acceptance("Composer topic featured links when uncategorized is not allowed", {
|
|
|
|
loggedIn: true,
|
|
|
|
settings: {
|
|
|
|
topic_featured_link_enabled: true,
|
|
|
|
max_topic_title_length: 80,
|
|
|
|
enable_markdown_linkify: true,
|
|
|
|
allow_uncategorized_topics: false
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-07-19 05:40:42 -04:00
|
|
|
QUnit.test("Pasting a link enables the text input area", async assert => {
|
2019-06-14 08:54:20 -04:00
|
|
|
updateCurrentUser({ admin: false, staff: false, trust_level: 1 });
|
2018-04-10 19:31:20 -04:00
|
|
|
|
2018-07-19 05:40:42 -04:00
|
|
|
await visit("/");
|
|
|
|
await click("#create-topic");
|
|
|
|
assert.ok(
|
|
|
|
find(".d-editor-textarea-wrapper.disabled").length,
|
|
|
|
"textarea is disabled"
|
|
|
|
);
|
|
|
|
await fillIn("#reply-title", "http://www.example.com/has-title.html");
|
|
|
|
assert.ok(
|
|
|
|
find(".d-editor-preview")
|
|
|
|
.html()
|
|
|
|
.trim()
|
|
|
|
.indexOf("onebox") > 0,
|
|
|
|
"it pastes the link into the body and previews it"
|
|
|
|
);
|
|
|
|
assert.ok(
|
|
|
|
exists(".d-editor-textarea-wrapper .popup-tip.good"),
|
|
|
|
"the body is now good"
|
|
|
|
);
|
|
|
|
assert.equal(
|
|
|
|
find(".title-input input").val(),
|
|
|
|
"An interesting article",
|
|
|
|
"title is from the oneboxed article"
|
|
|
|
);
|
|
|
|
assert.ok(
|
|
|
|
find(".d-editor-textarea-wrapper.disabled").length === 0,
|
|
|
|
"textarea is enabled"
|
|
|
|
);
|
2018-04-10 19:31:20 -04:00
|
|
|
});
|