2016-06-17 01:27:14 -04:00
|
|
|
import { acceptance } from "helpers/qunit-helpers";
|
|
|
|
|
2016-06-17 04:30:55 -04:00
|
|
|
acceptance('Details Button', { loggedIn: true });
|
2016-06-17 01:27:14 -04:00
|
|
|
|
|
|
|
function findTextarea() {
|
|
|
|
return find(".d-editor-input")[0];
|
|
|
|
}
|
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
test('details button', (assert) => {
|
2016-06-17 01:27:14 -04:00
|
|
|
visit("/");
|
|
|
|
|
|
|
|
click('#create-topic');
|
|
|
|
click('button.options');
|
2017-07-26 16:33:17 -04:00
|
|
|
click('.popup-menu .d-icon-caret-right');
|
2016-06-17 01:27:14 -04:00
|
|
|
|
|
|
|
andThen(() => {
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.equal(
|
2016-06-17 01:27:14 -04:00
|
|
|
find(".d-editor-input").val(),
|
2017-07-11 12:25:53 -04:00
|
|
|
`\n[details=${I18n.t("composer.details_title")}]\n${I18n.t("composer.details_text")}\n[/details]\n`,
|
2016-06-17 01:27:14 -04:00
|
|
|
'it should contain the right output'
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
fillIn('.d-editor-input', "This is my title");
|
|
|
|
|
|
|
|
andThen(() => {
|
|
|
|
const textarea = findTextarea();
|
|
|
|
textarea.selectionStart = 0;
|
|
|
|
textarea.selectionEnd = textarea.value.length;
|
|
|
|
});
|
|
|
|
|
|
|
|
click('button.options');
|
2017-07-26 16:33:17 -04:00
|
|
|
click('.popup-menu .d-icon-caret-right');
|
2016-06-17 01:27:14 -04:00
|
|
|
|
|
|
|
andThen(() => {
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.equal(
|
2016-06-17 01:27:14 -04:00
|
|
|
find(".d-editor-input").val(),
|
2017-07-11 12:25:53 -04:00
|
|
|
`\n[details=${I18n.t("composer.details_title")}]\nThis is my title\n[/details]\n`,
|
2016-12-19 11:19:10 -05:00
|
|
|
'it should contain the right selected output'
|
2016-06-17 01:27:14 -04:00
|
|
|
);
|
|
|
|
|
|
|
|
const textarea = findTextarea();
|
2017-07-11 12:25:53 -04:00
|
|
|
assert.equal(textarea.selectionStart, 19, 'it should start highlighting at the right position');
|
|
|
|
assert.equal(textarea.selectionEnd, 35, 'it should end highlighting at the right position');
|
2016-06-17 01:27:14 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
fillIn('.d-editor-input', "Before some text in between After");
|
|
|
|
|
|
|
|
andThen(() => {
|
|
|
|
const textarea = findTextarea();
|
|
|
|
textarea.selectionStart = 7;
|
|
|
|
textarea.selectionEnd = 28;
|
|
|
|
});
|
|
|
|
|
|
|
|
click('button.options');
|
2017-07-26 16:33:17 -04:00
|
|
|
click('.popup-menu .d-icon-caret-right');
|
2016-06-17 01:27:14 -04:00
|
|
|
|
|
|
|
andThen(() => {
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.equal(
|
2016-06-17 01:27:14 -04:00
|
|
|
find(".d-editor-input").val(),
|
2017-07-11 17:43:33 -04:00
|
|
|
`Before \n[details=${I18n.t("composer.details_title")}]\nsome text in between\n[/details]\n After`,
|
2016-06-17 01:27:14 -04:00
|
|
|
'it should contain the right output'
|
|
|
|
);
|
|
|
|
|
|
|
|
const textarea = findTextarea();
|
2017-07-11 12:25:53 -04:00
|
|
|
assert.equal(textarea.selectionStart, 26, 'it should start highlighting at the right position');
|
|
|
|
assert.equal(textarea.selectionEnd, 46, 'it should end highlighting at the right position');
|
2016-06-17 01:27:14 -04:00
|
|
|
});
|
|
|
|
|
2017-07-11 17:43:33 -04:00
|
|
|
fillIn('.d-editor-input', "Before \nsome text in between\n After");
|
2016-06-17 01:27:14 -04:00
|
|
|
|
|
|
|
andThen(() => {
|
|
|
|
const textarea = findTextarea();
|
2017-07-11 17:43:33 -04:00
|
|
|
textarea.selectionStart = 8;
|
|
|
|
textarea.selectionEnd = 29;
|
2016-06-17 01:27:14 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
click('button.options');
|
2017-07-26 16:33:17 -04:00
|
|
|
click('.popup-menu .d-icon-caret-right');
|
2016-06-17 01:27:14 -04:00
|
|
|
|
|
|
|
andThen(() => {
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.equal(
|
2016-06-17 01:27:14 -04:00
|
|
|
find(".d-editor-input").val(),
|
2017-07-11 17:43:33 -04:00
|
|
|
`Before \n\n[details=${I18n.t("composer.details_title")}]\nsome text in between\n[/details]\n\n After`,
|
2016-06-17 01:27:14 -04:00
|
|
|
'it should contain the right output'
|
|
|
|
);
|
|
|
|
|
|
|
|
const textarea = findTextarea();
|
2017-07-11 17:43:33 -04:00
|
|
|
assert.equal(textarea.selectionStart, 27, 'it should start highlighting at the right position');
|
|
|
|
assert.equal(textarea.selectionEnd, 47, 'it should end highlighting at the right position');
|
2016-06-17 01:27:14 -04:00
|
|
|
});
|
|
|
|
});
|