diff --git a/test/acceptance/table-builder-test.js b/test/acceptance/table-builder-test.js new file mode 100644 index 0000000..4e291c0 --- /dev/null +++ b/test/acceptance/table-builder-test.js @@ -0,0 +1,34 @@ +import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers"; +import { click, visit } from "@ember/test-helpers"; +import { test } from "qunit"; +import { clearPopupMenuOptionsCallback } from "discourse/controllers/composer"; +import selectKit from "discourse/tests/helpers/select-kit-helper"; + +acceptance("Table Builder", function (needs) { + needs.user(); + needs.hooks.beforeEach(() => clearPopupMenuOptionsCallback()); + + test("Can see table builder button when creating a topic", async function (assert) { + await visit("/"); + await click("#create-topic"); + await click(".d-editor-button-bar .options"); + await selectKit(".toolbar-popup-menu-options").expand(); + assert.ok( + exists(".select-kit-row[data-value='showTableBuilder']"), + "it shows the builder button" + ); + }); + + test("Can see table builder button when editing 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")); + await click(".d-editor-button-bar .options"); + await selectKit(".toolbar-popup-menu-options").expand(); + assert.ok( + exists(".select-kit-row[data-value='showTableBuilder']"), + "it shows the builder button" + ); + }); +}); diff --git a/test/acceptance/table-builder.js b/test/acceptance/table-builder.js deleted file mode 100644 index 73c0e7b..0000000 --- a/test/acceptance/table-builder.js +++ /dev/null @@ -1,32 +0,0 @@ -import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers"; -import { click, visit } from "@ember/test-helpers"; -import { test } from "qunit"; - -acceptance("Table Builder", function (needs) { - needs.user(); - - test("Can open table builder when creating a topic", async function (assert) { - await visit("/"); - await click("#create-topic"); - click(".table-builder"); - assert.ok(exists(".table-builder-modal")); - }); - - test("Can build table", async function (assert) { - await visit("/"); - await click("#create-topic"); - click(".btn-build-table"); - assert.ok(exists(".d-editor-preview .md-table")); - }); - - test("Can build table when editing 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")); - click(".table-builder"); - assert.ok(exists(".table-builder-modal")); - click(".btn-build-table"); - assert.ok(exists(".d-editor-preview .md-table")); - }); -});