2023-10-22 20:09:06 -04:00
|
|
|
import I18n from "discourse-i18n";
|
2022-01-18 09:52:51 -05:00
|
|
|
import {
|
|
|
|
acceptance,
|
|
|
|
exists,
|
|
|
|
query,
|
|
|
|
} from "discourse/tests/helpers/qunit-helpers";
|
2022-01-18 09:18:21 -05:00
|
|
|
import { click, visit } from "@ember/test-helpers";
|
|
|
|
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
|
|
|
import { test } from "qunit";
|
|
|
|
|
|
|
|
acceptance("DiscoTOC - Composer", function (needs) {
|
|
|
|
needs.user();
|
2023-01-02 05:07:50 -05:00
|
|
|
needs.settings({
|
|
|
|
general_category_id: 1,
|
|
|
|
default_composer_category: 1,
|
|
|
|
});
|
2022-01-18 09:18:21 -05:00
|
|
|
|
|
|
|
test("Can use TOC when creating a topic", async function (assert) {
|
|
|
|
await visit("/");
|
|
|
|
await click("#create-topic");
|
|
|
|
const toolbarPopupMenu = selectKit(".toolbar-popup-menu-options");
|
|
|
|
await toolbarPopupMenu.expand();
|
2023-10-22 20:09:06 -04:00
|
|
|
await toolbarPopupMenu.selectRowByName(
|
|
|
|
I18n.t(themePrefix("insert_table_of_contents"))
|
|
|
|
);
|
2022-01-18 09:18:21 -05:00
|
|
|
|
|
|
|
assert.ok(query(".d-editor-input").value.includes('data-theme-toc="true"'));
|
|
|
|
});
|
|
|
|
|
2022-01-18 09:52:51 -05:00
|
|
|
test("Can use TOC when editing first post", async function (assert) {
|
|
|
|
await visit("/t/internationalization-localization/280");
|
|
|
|
await click("#post_1 .show-more-actions");
|
|
|
|
await click("#post_1 .edit");
|
|
|
|
|
|
|
|
assert.ok(exists("#reply-control"));
|
|
|
|
|
|
|
|
const toolbarPopupMenu = selectKit(".toolbar-popup-menu-options");
|
|
|
|
await toolbarPopupMenu.expand();
|
2023-10-22 20:09:06 -04:00
|
|
|
await toolbarPopupMenu.selectRowByName(
|
|
|
|
I18n.t(themePrefix("insert_table_of_contents"))
|
|
|
|
);
|
2022-01-18 09:52:51 -05:00
|
|
|
|
|
|
|
assert.ok(query(".d-editor-input").value.includes('data-theme-toc="true"'));
|
|
|
|
});
|
|
|
|
|
2022-01-18 09:18:21 -05:00
|
|
|
test("no TOC option when replying", async function (assert) {
|
|
|
|
await visit("/t/internationalization-localization/280");
|
|
|
|
await click(".create.reply");
|
|
|
|
const toolbarPopupMenu = selectKit(".toolbar-popup-menu-options");
|
|
|
|
await toolbarPopupMenu.expand();
|
|
|
|
|
2023-10-16 03:23:04 -04:00
|
|
|
assert.notOk(toolbarPopupMenu.rowByValue("insertDtoc").exists());
|
2022-01-18 09:18:21 -05:00
|
|
|
});
|
|
|
|
});
|