diff --git a/cms-test-server/src/main/java/com/condation/cms/test/e2e/HttpUtil.java b/cms-test-server/src/main/java/com/condation/cms/test/e2e/HttpUtil.java index ee17e1ab7..79440945e 100644 --- a/cms-test-server/src/main/java/com/condation/cms/test/e2e/HttpUtil.java +++ b/cms-test-server/src/main/java/com/condation/cms/test/e2e/HttpUtil.java @@ -64,10 +64,4 @@ public static String fetchText(String url) throws Exception { return response.body(); } - - // --- Beispielaufruf --- - public static void main(String[] args) throws Exception { - String inhalt = fetchText("https://example.com"); - System.out.println(inhalt); - } } diff --git a/integration-tests/src/test/java/com/condation/cms/e2e/ExampleModuleTest.java b/integration-tests/src/test/java/com/condation/cms/e2e/ExampleModuleTest.java new file mode 100644 index 000000000..d3b859027 --- /dev/null +++ b/integration-tests/src/test/java/com/condation/cms/e2e/ExampleModuleTest.java @@ -0,0 +1,61 @@ +package com.condation.cms.e2e; + +/*- + * #%L + * integration-tests + * %% + * Copyright (C) 2023 - 2026 CondationCMS + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * #L% + */ +import com.condation.cms.test.e2e.CMSServerExtension; +import com.condation.cms.test.e2e.HttpUtil; +import com.microsoft.playwright.Page; +import com.microsoft.playwright.junit.UsePlaywright; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +/** + * + * @author thmar + */ +@UsePlaywright +@ExtendWith(CMSServerExtension.class) +public class ExampleModuleTest { + + + @Test + void test_api() throws Exception { + Assertions.assertThat(HttpUtil.fetchText("http://localhost:2020/api/test-api")).isEqualTo("CondationCMS test api"); + } + + @Test + void test_hook (Page page) { + page.navigate("http://localhost:2020"); + Assertions.assertThat(page.locator("body").innerHTML()).contains(""); + } + + @Test + void test_http_module () throws Exception { + Assertions.assertThat(HttpUtil.fetchText("http://localhost:2020/module/example-module/world")).isEqualTo("Hello world!"); + } + + @Test + void test_shortcode (Page page) throws Exception { + page.navigate("http://localhost:2020"); + Assertions.assertThat(page.locator("body").innerHTML()).contains("example from module"); + } +} diff --git a/integration-tests/src/test/java/com/condation/cms/e2e/ExtensionsTest.java b/integration-tests/src/test/java/com/condation/cms/e2e/ExtensionsTest.java new file mode 100644 index 000000000..3855e8a9a --- /dev/null +++ b/integration-tests/src/test/java/com/condation/cms/e2e/ExtensionsTest.java @@ -0,0 +1,46 @@ +package com.condation.cms.e2e; + +/*- + * #%L + * integration-tests + * %% + * Copyright (C) 2023 - 2026 CondationCMS + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * #L% + */ +import com.condation.cms.test.e2e.CMSServerExtension; +import com.condation.cms.test.e2e.HttpUtil; +import com.microsoft.playwright.Page; +import com.microsoft.playwright.junit.UsePlaywright; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +/** + * + * @author thmar + */ +@UsePlaywright +@ExtendWith(CMSServerExtension.class) +public class ExtensionsTest { + + + + @Test + void test_template_function_node_paramter (Page page) throws Exception { + page.navigate("http://localhost:2020"); + Assertions.assertThat(page.locator("body").innerHTML()).contains("
TITLE: Startpage
"); + } +} diff --git a/modules/example-module/src/main/java/com/condation/cms/modules/example/ExampleTagExtension.java b/modules/example-module/src/main/java/com/condation/cms/modules/example/ExampleTagExtension.java index 8d8f2729f..8d9c8c051 100644 --- a/modules/example-module/src/main/java/com/condation/cms/modules/example/ExampleTagExtension.java +++ b/modules/example-module/src/main/java/com/condation/cms/modules/example/ExampleTagExtension.java @@ -22,15 +22,9 @@ */ -import com.condation.cms.api.annotations.Action; -import com.condation.cms.api.annotations.Scope; import com.condation.cms.api.annotations.ShortCode; import com.condation.cms.api.extensions.RegisterShortCodesExtensionPoint; -import com.condation.cms.api.model.Parameter; import com.condation.modules.api.annotation.Extension; -import java.util.HashMap; -import java.util.Map; -import java.util.function.Function; /** * diff --git a/test-server/hosts/demo/content/index.md b/test-server/hosts/demo/content/index.md index f8c92cd87..3aa94b4e4 100644 --- a/test-server/hosts/demo/content/index.md +++ b/test-server/hosts/demo/content/index.md @@ -62,4 +62,8 @@ System.out.println("Hello world!"); ### test ShortCode with content --- [[ext:bold_content]]This content will be bold[[/ext:bold_content]] ---- \ No newline at end of file +--- + + +### example from module +[[ext:example /]] \ No newline at end of file diff --git a/test-server/modules/example-module/libs/example-module-8.1.0.jar b/test-server/modules/example-module/libs/example-module-8.2.0.jar similarity index 58% rename from test-server/modules/example-module/libs/example-module-8.1.0.jar rename to test-server/modules/example-module/libs/example-module-8.2.0.jar index e08480f7a..a66b86c22 100644 Binary files a/test-server/modules/example-module/libs/example-module-8.1.0.jar and b/test-server/modules/example-module/libs/example-module-8.2.0.jar differ diff --git a/test-server/themes/demo/extensions/theme.extension.js b/test-server/themes/demo/extensions/theme.extension.js index 9202a2056..59fb0b9d5 100644 --- a/test-server/themes/demo/extensions/theme.extension.js +++ b/test-server/themes/demo/extensions/theme.extension.js @@ -23,6 +23,10 @@ $hooks.registerAction("system/template/function", ({functions}) => { "fn_message", ({color, message}) => `
MESSAGE: ${message}
` ) + functions.put( + "node", + ({node}) => `
TITLE: ${node.meta.title}
` + ) return null; }) diff --git a/test-server/themes/demo/templates/libs/fragments.html b/test-server/themes/demo/templates/libs/fragments.html index 69b41990f..b07e9b895 100644 --- a/test-server/themes/demo/templates/libs/fragments.html +++ b/test-server/themes/demo/templates/libs/fragments.html @@ -14,7 +14,7 @@ -{% if PREVIEW_MODE %} +{% if MANAGER %} {% endif %} diff --git a/test-server/themes/demo/templates/start.html b/test-server/themes/demo/templates/start.html index e31823c2e..9745cf892 100644 --- a/test-server/themes/demo/templates/start.html +++ b/test-server/themes/demo/templates/start.html @@ -97,6 +97,15 @@

Template component content test

--- + +
+

Template function with node as parameter

+
+ --- + {{ ext.node({'node': node}) | raw }} + --- +
+
{{ cms.hooks({'hook': 'theme/template/footer'}) | raw }}