From e0957107ff6b4613406311301d38f191cc19155a Mon Sep 17 00:00:00 2001 From: rajeshreeputra Date: Fri, 20 Dec 2024 18:47:31 +0530 Subject: [PATCH] ACMS-4373: Acquia Starter Kit Tour fix failing tests. --- .../acquia_cms_tour/acquia_cms_tour.install | 3 +-- .../src/Functional/AcquiaGoogleMapsTest.php | 26 +++++++++++++++++-- .../tests/src/Functional/GoogleTagManager.php | 18 ++----------- .../src/Functional/HelpIntegrationTest.php | 15 ----------- .../tests/src/Functional/RecaptchaTest.php | 15 ----------- .../src/Kernel/AcquiaTourDashboardTest.php | 15 ----------- 6 files changed, 27 insertions(+), 65 deletions(-) diff --git a/modules/acquia_cms_tour/acquia_cms_tour.install b/modules/acquia_cms_tour/acquia_cms_tour.install index c9c35aa76..d6e44b029 100644 --- a/modules/acquia_cms_tour/acquia_cms_tour.install +++ b/modules/acquia_cms_tour/acquia_cms_tour.install @@ -12,8 +12,7 @@ use Drupal\user\Entity\Role; */ function acquia_cms_tour_install($is_syncing) { if (!$is_syncing) { - $role = Role::load('content_administrator'); - if ($role) { + if (Role::load('content_administrator')) { user_role_grant_permissions('content_administrator', ['access acquia cms tour dashboard']); } } diff --git a/modules/acquia_cms_tour/tests/src/Functional/AcquiaGoogleMapsTest.php b/modules/acquia_cms_tour/tests/src/Functional/AcquiaGoogleMapsTest.php index 431acd8ca..e28a82747 100644 --- a/modules/acquia_cms_tour/tests/src/Functional/AcquiaGoogleMapsTest.php +++ b/modules/acquia_cms_tour/tests/src/Functional/AcquiaGoogleMapsTest.php @@ -48,6 +48,28 @@ class AcquiaGoogleMapsTest extends BrowserTestBase { public function testAcquiaGoogleMaps() { $assert_session = $this->assertSession(); + // Create an administrator account with all permissions. + $admin_user = $this->drupalCreateUser([], NULL, TRUE); + + // Log in the administrator account. + $this->drupalLogin($admin_user); + + $this->drupalGet('/admin/config/system/geocoder/geocoder-provider'); + $assert_session->statusCodeEquals(200); + // Select googlemaps option from dropdown. + $assert_session->elementExists('css', '[data-drupal-selector="edit-geocoder-provider"]') + ->selectOption('googlemaps'); + $assert_session->buttonExists('Add')->press(); + $assert_session->pageTextContains('Add a Geocoder provider'); + + $container = $assert_session->elementExists('css', '[data-drupal-selector="geocoder-provider-add-form"]'); + $container->fillField('edit-label', 'GoogleMaps'); + $container->fillField('edit-id', 'googlemaps'); + $container->fillField('edit-apikey', 'oldkey12345'); + $container->pressButton('Save'); + $assert_session->pageTextContains('Created new geocoder provider'); + + // Create user account with 'access acquia cms tour dashboard' permission. $account = $this->drupalCreateUser(['access acquia cms tour dashboard']); $this->drupalLogin($account); @@ -56,8 +78,8 @@ public function testAcquiaGoogleMaps() { $assert_session->statusCodeEquals(200); $container = $assert_session->elementExists('css', '[data-drupal-selector="edit-geocoder"]'); - // API key should be blank to start. - $assert_session->fieldValueEquals('maps_api_key', '', $container); + $assert_session->fieldValueEquals('maps_api_key', 'oldkey12345', $container); + $container->fillField('maps_api_key', ''); $container->pressButton('Save'); $assert_session->pageTextContains('Maps API key field is required.'); diff --git a/modules/acquia_cms_tour/tests/src/Functional/GoogleTagManager.php b/modules/acquia_cms_tour/tests/src/Functional/GoogleTagManager.php index d7084745a..712218028 100644 --- a/modules/acquia_cms_tour/tests/src/Functional/GoogleTagManager.php +++ b/modules/acquia_cms_tour/tests/src/Functional/GoogleTagManager.php @@ -25,21 +25,6 @@ class GoogleTagManager extends BrowserTestBase { 'google_tag', ]; - /** - * Disable strict config schema checks in this test. - * - * Cohesion has a lot of config schema errors, and until they are all fixed, - * this test cannot pass unless we disable strict config schema checking - * altogether. Since strict config schema isn't critically important in - * testing this functionality, it's okay to disable it for now, but it should - * be re-enabled (i.e., this property should be removed) as soon as possible. - * - * @var bool - */ - // @codingStandardsIgnoreStart - protected $strictConfigSchema = FALSE; - // @codingStandardsIgnoreEnd - /** * Tests the Google Tag Manager Form. */ @@ -61,7 +46,8 @@ public function testGoogleTagManager() { $container->pressButton('Save'); $assert_session->pageTextContains('The configuration options have been saved.'); // Test that the config values we expect are set correctly. - $tag_id = $this->config($this->config('google_tag.settings')->get('default_google_tag_entity'))->get('tag_container_ids'); + $tag = $this->config('google_tag.settings')->get('default_google_tag_entity'); + $tag_id = $this->config('google_tag.container.' . $tag)->get('tag_container_ids'); $this->assertEquals($tag_id, [$dummy_tag]); } diff --git a/modules/acquia_cms_tour/tests/src/Functional/HelpIntegrationTest.php b/modules/acquia_cms_tour/tests/src/Functional/HelpIntegrationTest.php index 3866da06f..0060fc8f7 100644 --- a/modules/acquia_cms_tour/tests/src/Functional/HelpIntegrationTest.php +++ b/modules/acquia_cms_tour/tests/src/Functional/HelpIntegrationTest.php @@ -26,21 +26,6 @@ class HelpIntegrationTest extends BrowserTestBase { 'toolbar', ]; - /** - * Disable strict config schema checks in this test. - * - * Scheduler has a config schema errors, and until it's fixed, - * this test cannot pass unless we disable strict config schema checking - * altogether. Since strict config schema isn't critically important in - * testing this functionality, it's okay to disable it for now, but it should - * be re-enabled (i.e., this property should be removed) as soon as possible. - * - * @var bool - */ - // @codingStandardsIgnoreStart - protected $strictConfigSchema = FALSE; - // @codingStandardsIgnoreEnd - /** * Tests the Acquia CMS Tour module's integration with the core Help module. */ diff --git a/modules/acquia_cms_tour/tests/src/Functional/RecaptchaTest.php b/modules/acquia_cms_tour/tests/src/Functional/RecaptchaTest.php index d6a9d45fa..6f5c7c228 100644 --- a/modules/acquia_cms_tour/tests/src/Functional/RecaptchaTest.php +++ b/modules/acquia_cms_tour/tests/src/Functional/RecaptchaTest.php @@ -25,21 +25,6 @@ class RecaptchaTest extends BrowserTestBase { 'recaptcha', ]; - /** - * Disable strict config schema checks in this test. - * - * Cohesion has a lot of config schema errors, and until they are all fixed, - * this test cannot pass unless we disable strict config schema checking - * altogether. Since strict config schema isn't critically important in - * testing this functionality, it's okay to disable it for now, but it should - * be re-enabled (i.e., this property should be removed) as soon as possible. - * - * @var bool - */ - // @codingStandardsIgnoreStart - protected $strictConfigSchema = FALSE; - // @codingStandardsIgnoreEnd - /** * Tests the Recaptcha Form. */ diff --git a/modules/acquia_cms_tour/tests/src/Kernel/AcquiaTourDashboardTest.php b/modules/acquia_cms_tour/tests/src/Kernel/AcquiaTourDashboardTest.php index dd86497aa..5d6f4fc9e 100644 --- a/modules/acquia_cms_tour/tests/src/Kernel/AcquiaTourDashboardTest.php +++ b/modules/acquia_cms_tour/tests/src/Kernel/AcquiaTourDashboardTest.php @@ -22,21 +22,6 @@ class AcquiaTourDashboardTest extends KernelTestBase { 'acquia_cms_tour', ]; - /** - * Disable strict config schema checks in this test. - * - * Cohesion has a lot of config schema errors, and until they are all fixed, - * this test cannot pass unless we disable strict config schema checking - * altogether. Since strict config schema isn't critically important in - * testing this functionality, it's okay to disable it for now, but it should - * be re-enabled (i.e., this property should be removed) as soon as possible. - * - * @var bool - */ - // @codingStandardsIgnoreStart - protected $strictConfigSchema = FALSE; - // @codingStandardsIgnoreEnd - /** * Tests AcquiaCMSTour plugins and make sure they are sorted per weights. */