From 3cf060bf379d651980f3b0e4b10b5ad98ea7337d Mon Sep 17 00:00:00 2001 From: "Romain B." <8530352+Rom1-B@users.noreply.github.com> Date: Fri, 27 Nov 2026 14:55:27 +0100 Subject: [PATCH] feat: make plugin CSP compliant (#89) --- CHANGELOG.md | 4 ++ public/js/reservation_question.js | 56 +++++++++++++++ public/js/reservation_request_timeline.js | 56 +++++++++++++++ public/js/table_config.js | 72 +++++++++++++++++++ public/js/table_end_user.js | 56 +++++++++++++++ public/js/tree_cascade_dropdown.js | 64 +++++++++++++++++ public/js/tree_cascade_dropdown_children.js | 49 +++++++++++++ setup.php | 1 + .../question_types/table_config.html.twig | 39 +++------- templates/reservation_question.html.twig | 9 +-- templates/table_end_user.html.twig | 6 +- .../timeline/reservation_request.html.twig | 11 +-- templates/tree_cascade_dropdown.html.twig | 60 +++++----------- .../tree_cascade_dropdown_children.html.twig | 14 ++-- .../QuestionType/ReservationQuestionTest.php | 7 +- .../TableQuestionRenderingTest.php | 7 +- tests/Service/TimelineManagerTest.php | 2 +- 17 files changed, 396 insertions(+), 117 deletions(-) create mode 100644 public/js/reservation_question.js create mode 100644 public/js/reservation_request_timeline.js create mode 100644 public/js/table_config.js create mode 100644 public/js/table_end_user.js create mode 100644 public/js/tree_cascade_dropdown.js create mode 100644 public/js/tree_cascade_dropdown_children.js diff --git a/CHANGELOG.md b/CHANGELOG.md index e6a0cb0..dcee482 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Add "Allow specific languages" form access policy - Add "GLPI system information" and "GLPI core or plugins concerned" question types +### Changed + +- Make the plugin compatible with the Content Security Policy + ### Fixed - Fix GLPI compatibility constraint in plugin XML diff --git a/public/js/reservation_question.js b/public/js/reservation_question.js new file mode 100644 index 0000000..fb1f577 --- /dev/null +++ b/public/js/reservation_question.js @@ -0,0 +1,56 @@ +/** + * ------------------------------------------------------------------------- + * advancedforms plugin for GLPI + * ------------------------------------------------------------------------- + * + * MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * ------------------------------------------------------------------------- + * @copyright Copyright (C) 2025 by the advancedforms plugin team. + * @license MIT https://opensource.org/licenses/mit-license.php + * @link https://github.com/pluginsGLPI/advancedforms + * ------------------------------------------------------------------------- + */ + +/** + * Loaded right after the reservation question markup (templates/reservation_question.html.twig). + * Waits for DOM ready on full pages, like the former inline module did. + */ +(function () { + const ready_attr = 'data-reservation-question-widget-ready'; + + const init = () => { + const els = [...document.querySelectorAll('[data-reservation-question-widget]:not([' + ready_attr + '])')]; + if (els.length === 0) { + return; + } + els.forEach((el) => el.setAttribute(ready_attr, '')); + + import('/plugins/advancedforms/js/modules/ReservationQuestionWidget.js').then(({ ReservationQuestionWidget }) => { + els.forEach((el) => new ReservationQuestionWidget(el)); + }); + }; + + if (document.readyState === 'loading') { + document.addEventListener('DOMContentLoaded', init, { once: true }); + } else { + init(); + } +})(); diff --git a/public/js/reservation_request_timeline.js b/public/js/reservation_request_timeline.js new file mode 100644 index 0000000..0c871ff --- /dev/null +++ b/public/js/reservation_request_timeline.js @@ -0,0 +1,56 @@ +/** + * ------------------------------------------------------------------------- + * advancedforms plugin for GLPI + * ------------------------------------------------------------------------- + * + * MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * ------------------------------------------------------------------------- + * @copyright Copyright (C) 2025 by the advancedforms plugin team. + * @license MIT https://opensource.org/licenses/mit-license.php + * @link https://github.com/pluginsGLPI/advancedforms + * ------------------------------------------------------------------------- + */ + +/** + * Loaded after each reservation request timeline card, on full pages and on AJAX-reloaded timelines. + * Idempotent: each card is initialised once. + */ +(function () { + const ready_attr = 'data-af-reservation-request-timeline-ready'; + + const init = () => { + const els = [...document.querySelectorAll('[data-af-reservation-request-timeline]:not([' + ready_attr + '])')]; + if (els.length === 0) { + return; + } + els.forEach((el) => el.setAttribute(ready_attr, '')); + + import('/plugins/advancedforms/js/modules/ReservationRequestTimelineActions.js').then(({ ReservationRequestTimelineActions }) => { + els.forEach((el) => new ReservationRequestTimelineActions(el)); + }); + }; + + if (document.readyState === 'loading') { + document.addEventListener('DOMContentLoaded', init, { once: true }); + } else { + init(); + } +})(); diff --git a/public/js/table_config.js b/public/js/table_config.js new file mode 100644 index 0000000..a35f0d5 --- /dev/null +++ b/public/js/table_config.js @@ -0,0 +1,72 @@ +/** + * ------------------------------------------------------------------------- + * advancedforms plugin for GLPI + * ------------------------------------------------------------------------- + * + * MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * ------------------------------------------------------------------------- + * @copyright Copyright (C) 2025 by the advancedforms plugin team. + * @license MIT https://opensource.org/licenses/mit-license.php + * @link https://github.com/pluginsGLPI/advancedforms + * ------------------------------------------------------------------------- + */ + +/** + * Loaded right after the table question config markup (templates/editor/question_types/table_config.html.twig). + * Idempotent: each markup block is initialised once, even when rendered again. + */ +(function () { + const ready_attr = 'data-af-table-config-ready'; + const els = [...document.querySelectorAll('[data-af-table-config]:not([' + ready_attr + '])')]; + if (els.length === 0) { + return; + } + els.forEach((el) => el.setAttribute(ready_attr, '')); + + window.select2_configs = window.select2_configs || {}; + els.forEach((el) => { + const icons = JSON.parse(el.dataset.afTableConfigIcons); + window.afTableColumnTypeTemplate = window.afTableColumnTypeTemplate || function (item) { + if (!item.id || !icons[item.id]) { + return item.text; + } + return $('', { 'class': 'd-flex align-items-center gap-1' }) + .append($('', { 'class': icons[item.id] })) + .append(document.createTextNode(' ' + item.text)); + }; + + const field_id = 'af-table-type-template-' + el.dataset.afTableConfig; + window.select2_configs[field_id] = { + type: 'adapt', + field_id: field_id, + width: '200px', + dropdown_css_class: '', + placeholder: '', + ajax_limit_count: Number(el.dataset.afTableConfigAjaxLimit), + templateresult: window.afTableColumnTypeTemplate, + templateselection: window.afTableColumnTypeTemplate, + }; + }); + + import('/plugins/advancedforms/js/modules/AfTableQuestionConfig.js').then(({ AfTableQuestionConfig }) => { + new AfTableQuestionConfig(); + }); +})(); diff --git a/public/js/table_end_user.js b/public/js/table_end_user.js new file mode 100644 index 0000000..4074334 --- /dev/null +++ b/public/js/table_end_user.js @@ -0,0 +1,56 @@ +/** + * ------------------------------------------------------------------------- + * advancedforms plugin for GLPI + * ------------------------------------------------------------------------- + * + * MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * ------------------------------------------------------------------------- + * @copyright Copyright (C) 2025 by the advancedforms plugin team. + * @license MIT https://opensource.org/licenses/mit-license.php + * @link https://github.com/pluginsGLPI/advancedforms + * ------------------------------------------------------------------------- + */ + +/** + * Loaded right after the end user table question markup (templates/table_end_user.html.twig). + * Waits for DOM ready on full pages, like the former inline module did. + */ +(function () { + const ready_attr = 'data-af-table-question-ready'; + + const init = () => { + const els = [...document.querySelectorAll('[data-af-table-question]:not([' + ready_attr + '])')]; + if (els.length === 0) { + return; + } + els.forEach((el) => el.setAttribute(ready_attr, '')); + + import('/plugins/advancedforms/js/modules/AfTableQuestion.js').then(({ AfTableQuestion }) => { + els.forEach((el) => new AfTableQuestion(el)); + }); + }; + + if (document.readyState === 'loading') { + document.addEventListener('DOMContentLoaded', init, { once: true }); + } else { + init(); + } +})(); diff --git a/public/js/tree_cascade_dropdown.js b/public/js/tree_cascade_dropdown.js new file mode 100644 index 0000000..dec10f3 --- /dev/null +++ b/public/js/tree_cascade_dropdown.js @@ -0,0 +1,64 @@ +/** + * ------------------------------------------------------------------------- + * advancedforms plugin for GLPI + * ------------------------------------------------------------------------- + * + * MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * ------------------------------------------------------------------------- + * @copyright Copyright (C) 2025 by the advancedforms plugin team. + * @license MIT https://opensource.org/licenses/mit-license.php + * @link https://github.com/pluginsGLPI/advancedforms + * ------------------------------------------------------------------------- + */ + +/** + * Loaded after the tree cascade dropdown markup (templates/tree_cascade_dropdown.html.twig). + * Each select carries its own config in data attributes. + * Waits for DOM ready on full pages, like the former inline modules did. + */ +(function () { + const ready_attr = 'data-af-tree-cascade-ready'; + + const init = () => { + const els = [...document.querySelectorAll('select[data-af-tree-cascade]:not([' + ready_attr + '])')]; + if (els.length === 0) { + return; + } + els.forEach((el) => el.setAttribute(ready_attr, '')); + + import('/plugins/advancedforms/js/modules/AfTreeCascadeDropdown.js').then(({ AfTreeCascadeDropdown }) => { + els.forEach((el) => new AfTreeCascadeDropdown({ + selector_id: el.id, + questions_id: Number(el.dataset.afTreeQuestionsId), + ajax_limit_count: Number(el.dataset.afTreeAjaxLimit), + level: Number(el.dataset.afTreeLevel || 1), + next_container_id: el.dataset.afTreeNextContainer, + auto_load_parent_id: Number(el.dataset.afTreeAutoLoadParent || 0), + })); + }); + }; + + if (document.readyState === 'loading') { + document.addEventListener('DOMContentLoaded', init, { once: true }); + } else { + init(); + } +})(); diff --git a/public/js/tree_cascade_dropdown_children.js b/public/js/tree_cascade_dropdown_children.js new file mode 100644 index 0000000..0952baa --- /dev/null +++ b/public/js/tree_cascade_dropdown_children.js @@ -0,0 +1,49 @@ +/** + * ------------------------------------------------------------------------- + * advancedforms plugin for GLPI + * ------------------------------------------------------------------------- + * + * MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * ------------------------------------------------------------------------- + * @copyright Copyright (C) 2025 by the advancedforms plugin team. + * @license MIT https://opensource.org/licenses/mit-license.php + * @link https://github.com/pluginsGLPI/advancedforms + * ------------------------------------------------------------------------- + */ + +/** + * Loaded after the children select of a tree cascade dropdown, rendered by AJAX. + * Triggers the change event once so the first child is applied, as the former inline script did. + */ +(function () { + const ready_attr = 'data-af-tree-autoselect-ready'; + const els = [...document.querySelectorAll('select[data-af-tree-autoselect]:not([' + ready_attr + '])')]; + + els.forEach((el) => { + el.setAttribute(ready_attr, ''); + setTimeout(() => { + const select = document.getElementById(el.id); + if (select) { + select.dispatchEvent(new Event('change', { bubbles: true })); + } + }, 50); + }); +})(); diff --git a/setup.php b/setup.php index a33e426..c6488d1 100644 --- a/setup.php +++ b/setup.php @@ -93,6 +93,7 @@ function plugin_version_advancedforms(): array 'author' => 'Teclib\'', 'license' => '', 'homepage' => '', + 'csp_compliant' => true, 'requirements' => [ 'glpi' => [ 'min' => PLUGIN_ADVANCEDFORMS_MIN_GLPI_VERSION, diff --git a/templates/editor/question_types/table_config.html.twig b/templates/editor/question_types/table_config.html.twig index d53a701..b452f60 100644 --- a/templates/editor/question_types/table_config.html.twig +++ b/templates/editor/question_types/table_config.html.twig @@ -31,19 +31,13 @@ {% set rand = random() %} - - - - +{{ call('Html::script', ['/plugins/advancedforms/js/reservation_question.js', {'version': constant('PLUGIN_ADVANCEDFORMS_VERSION')}, false])|raw }} diff --git a/templates/table_end_user.html.twig b/templates/table_end_user.html.twig index e000dfd..e49df01 100644 --- a/templates/table_end_user.html.twig +++ b/templates/table_end_user.html.twig @@ -205,8 +205,4 @@ > - +{{ call('Html::script', ['/plugins/advancedforms/js/table_end_user.js', {'version': constant('PLUGIN_ADVANCEDFORMS_VERSION')}, false])|raw }} diff --git a/templates/timeline/reservation_request.html.twig b/templates/timeline/reservation_request.html.twig index aa7a3f2..d30caa2 100644 --- a/templates/timeline/reservation_request.html.twig +++ b/templates/timeline/reservation_request.html.twig @@ -43,7 +43,7 @@ (constant(request_class ~ '::STATUS_CANCELED')): __('Canceled', 'advancedforms'), } %} -
+
@@ -104,13 +104,6 @@
- + {{ call('Html::script', ['/plugins/advancedforms/js/reservation_request_timeline.js', {'version': constant('PLUGIN_ADVANCEDFORMS_VERSION')}, false])|raw }} {% endif %}
diff --git a/templates/tree_cascade_dropdown.html.twig b/templates/tree_cascade_dropdown.html.twig index e49b9fb..0835495 100644 --- a/templates/tree_cascade_dropdown.html.twig +++ b/templates/tree_cascade_dropdown.html.twig @@ -47,28 +47,18 @@ data-af-tree-questions-id="{{ question.fields['id'] }}" data-af-tree-field-name="{{ final_items_id_name }}" data-af-tree-ajax-limit="{{ ajax_limit_count }}" + data-af-tree-cascade + data-af-tree-level="1" + {% if root_is_preselected and ancestor_chain|length == 0 %} + data-af-tree-next-container="{{ level2_container }}" + data-af-tree-auto-load-parent="{{ root_items_id }}" + {% endif %} >
- - {% if root_is_preselected and ancestor_chain|length == 0 %}
{% endif %} @@ -89,6 +79,12 @@ data-af-tree-questions-id="{{ question.fields['id'] }}" data-af-tree-field-name="{{ final_items_id_name }}" data-af-tree-ajax-limit="{{ ajax_limit_count }}" + data-af-tree-cascade + data-af-tree-level="{{ level_num }}" + {% if is_last %} + data-af-tree-next-container="{{ level2_container }}" + data-af-tree-auto-load-parent="{{ node.id }}" + {% endif %} > {% for sibling in node.siblings %} @@ -97,22 +93,6 @@
- - {% if is_last %}
{% endif %} @@ -128,6 +108,8 @@ data-af-tree-questions-id="{{ question.fields['id'] }}" data-af-tree-field-name="{{ final_items_id_name }}" data-af-tree-ajax-limit="{{ ajax_limit_count }}" + data-af-tree-cascade + data-af-tree-next-container="{{ level2_container }}" > {% for item in first_level_items %} @@ -137,16 +119,6 @@
- - {% endif %} + +{{ call('Html::script', ['/plugins/advancedforms/js/tree_cascade_dropdown.js', {'version': constant('PLUGIN_ADVANCEDFORMS_VERSION')}, false])|raw }} diff --git a/templates/tree_cascade_dropdown_children.html.twig b/templates/tree_cascade_dropdown_children.html.twig index 6bfc84c..dbd927c 100644 --- a/templates/tree_cascade_dropdown_children.html.twig +++ b/templates/tree_cascade_dropdown_children.html.twig @@ -37,6 +37,9 @@ data-af-tree-questions-id="{{ questions_id }}" data-af-tree-field-name="{{ final_field_name }}" data-af-tree-ajax-limit="{{ ajax_limit_count }}" + {% if not parent_is_selectable and children|length > 0 %} + data-af-tree-autoselect + {% endif %} > {% if parent_is_selectable %} @@ -47,13 +50,4 @@ -{% if not parent_is_selectable and children|length > 0 %} - -{% endif %} +{{ call('Html::script', ['/plugins/advancedforms/js/tree_cascade_dropdown_children.js', {'version': constant('PLUGIN_ADVANCEDFORMS_VERSION')}, false])|raw }} diff --git a/tests/Model/QuestionType/ReservationQuestionTest.php b/tests/Model/QuestionType/ReservationQuestionTest.php index 67e66a6..3ad33cd 100644 --- a/tests/Model/QuestionType/ReservationQuestionTest.php +++ b/tests/Model/QuestionType/ReservationQuestionTest.php @@ -71,11 +71,10 @@ protected function validateHelpdeskRenderingWhenEnabled( $this->assertGreaterThan(0, $html->filter('input[name$="[begin]"]')->count()); $this->assertGreaterThan(0, $html->filter('input[name$="[end]"]')->count()); - $module_scripts_text = implode( - "\n", - $html->filter('script[type="module"]')->each(fn(Crawler $node) => $node->text()), + $this->assertGreaterThan( + 0, + $html->filter('script[src*="/plugins/advancedforms/js/reservation_question.js"]')->count(), ); - $this->assertStringContainsString("ReservationQuestionWidget.js", $module_scripts_text); } #[Override] diff --git a/tests/Model/QuestionType/TableQuestionRenderingTest.php b/tests/Model/QuestionType/TableQuestionRenderingTest.php index df7752a..fa67062 100644 --- a/tests/Model/QuestionType/TableQuestionRenderingTest.php +++ b/tests/Model/QuestionType/TableQuestionRenderingTest.php @@ -251,14 +251,11 @@ public function testASingleContainerIsProvidedForServerErrors(): void * would not match that key, and would cost both the content-based cache * busting and the root_doc prefix. */ - public function testTheJsModuleIsImportedThroughTheImportMap(): void + public function testTheJsModuleLoaderIsIncluded(): void { $html = $this->render([$this->column('Name', QuestionTypeShortText::class)]); - $this->assertStringContainsString( - "from '" . self::MODULE_PATH . "'", - $html, - ); + $this->assertStringContainsString('/plugins/advancedforms/js/table_end_user.js', $html); } public function testTheImportMapVersionsTheModuleOnItsContent(): void diff --git a/tests/Service/TimelineManagerTest.php b/tests/Service/TimelineManagerTest.php index cec9860..2ac2364 100644 --- a/tests/Service/TimelineManagerTest.php +++ b/tests/Service/TimelineManagerTest.php @@ -100,7 +100,7 @@ public function testAddTimelineItemsWiresApproveRefuseButtonsToController(): voi $this->assertArrayHasKey($key, $timeline); $content = $timeline[$key]['item']['content']; - $this->assertStringContainsString('ReservationRequestTimelineActions.js', $content); + $this->assertStringContainsString('reservation_request_timeline.js', $content); $this->assertStringContainsString('data-reservation-request-action="approve"', $content); }