FIX: Allow adding TOC when editing first post (#20)

This commit is contained in:
Penar Musaraj 2022-01-18 09:52:51 -05:00 committed by GitHub
parent 20366c671d
commit 86b9960263
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 2 deletions

View File

@ -38,7 +38,7 @@ export default {
action: "insertDtoc", action: "insertDtoc",
icon: "align-left", icon: "align-left",
label: themePrefix("insert_table_of_contents"), label: themePrefix("insert_table_of_contents"),
condition: controller.get("model.creatingTopic"), condition: controller.get("model.topicFirstPost"),
}; };
}); });
} }

View File

@ -1,4 +1,8 @@
import { acceptance, query } from "discourse/tests/helpers/qunit-helpers"; import {
acceptance,
exists,
query,
} from "discourse/tests/helpers/qunit-helpers";
import { click, visit } from "@ember/test-helpers"; import { click, visit } from "@ember/test-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper"; import selectKit from "discourse/tests/helpers/select-kit-helper";
import { test } from "qunit"; import { test } from "qunit";
@ -16,6 +20,20 @@ acceptance("DiscoTOC - Composer", function (needs) {
assert.ok(query(".d-editor-input").value.includes('data-theme-toc="true"')); assert.ok(query(".d-editor-input").value.includes('data-theme-toc="true"'));
}); });
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();
await toolbarPopupMenu.selectRowByValue("insertDtoc");
assert.ok(query(".d-editor-input").value.includes('data-theme-toc="true"'));
});
test("no TOC option when replying", async function (assert) { test("no TOC option when replying", async function (assert) {
await visit("/t/internationalization-localization/280"); await visit("/t/internationalization-localization/280");
await click(".create.reply"); await click(".create.reply");