Skip to content

A platform for community discussion. Free, open, simple.

DEV: Add test for plugin-outlet whitespace (#32805)

David Taylor1a959cf9ccdb
diff --git a/app/assets/javascripts/discourse/tests/integration/components/plugin-outlet-test.gjs b/app/assets/javascripts/discourse/tests/integration/components/plugin-outlet-test.gjs
index 9e9711b5060..b2f044d0809 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/plugin-outlet-test.gjs
+++ b/app/assets/javascripts/discourse/tests/integration/components/plugin-outlet-test.gjs
@@ -1134,3 +1134,56 @@ module(
});
}
);
+
+module(
+ "Integration | Component | plugin-outlet | whitespace",
+ function (hooks) {
+ setupRenderingTest(hooks);
+
+ test("no whitespace for unused outlet", async function (assert) {
+ await render(
+ <template>
+ <div class="test-wrapper"><PluginOutlet @name="test-name" /></div>
+ </template>
+ );
+ assert.dom(".test-wrapper").hasText(/^$/, "no whitespace"); // using regex to avoid hasText builtin strip
+ });
+
+ test("no whitespace for used outlet", async function (assert) {
+ extraConnectorComponent("test-name", <template></template>);
+
+ await render(
+ <template>
+ <div class="test-wrapper"><PluginOutlet @name="test-name" /></div>
+ </template>
+ );
+ assert.dom(".test-wrapper").hasText(/^$/, "no whitespace"); // using regex to avoid hasText builtin strip
+ });
+
+ test("no whitespace for unused wrapper outlet", async function (assert) {
+ await render(
+ <template>
+ <div class="test-wrapper"><PluginOutlet
+ @name="test-name"
+ >foo</PluginOutlet></div>
+ </template>
+ );
+ assert.dom(".test-wrapper").hasText(/^foo$/, "no whitespace"); // using regex to avoid hasText builtin strip
+ });
+
+ test("no whitespace for used wrapper outlet", async function (assert) {
+ extraConnectorComponent(
+ "test-name",
+ <template>{{! template-lint-disable no-yield-only }}{{yield}}</template>
+ );
+ await render(
+ <template>
+ <div class="test-wrapper"><PluginOutlet
+ @name="test-name"
+ >foo</PluginOutlet></div>
+ </template>
+ );
+ assert.dom(".test-wrapper").hasText(/^foo$/, "no whitespace"); // using regex to avoid hasText builtin strip
+ });
+ }
+);