From 801a48f79c1781dd86e00c015f2e28b73120ad49 Mon Sep 17 00:00:00 2001 From: Santeri Hurnanen Date: Mon, 15 Jan 2024 13:21:41 +0200 Subject: [PATCH] UHF-9239: Fix core/drupalSettings not loaded in tests --- helfi_navigation.module | 3 +++ 1 file changed, 3 insertions(+) diff --git a/helfi_navigation.module b/helfi_navigation.module index 05e2a8a..827e152 100644 --- a/helfi_navigation.module +++ b/helfi_navigation.module @@ -153,6 +153,9 @@ function helfi_navigation_page_attachments(array &$attachments) : void { $apiManager = Drupal::service('helfi_navigation.api_manager'); try { + // Ensure that drupalSettings library is enabled (menu library is not loaded in all tests). + $attachments['#attached']['library'][] = 'core/drupalSettings'; + $attachments['#attached']['drupalSettings']['helfi_navigation'] = [ 'links' => [ 'api' => $apiManager->getUrl('js', $langcode, ['endpoint' => '/api/v1/global-mobile-menu']),