From 21fda2c2256d6e6b5a21a52d70045785b8af69fe Mon Sep 17 00:00:00 2001 From: Mike Decker Date: Mon, 9 Oct 2023 11:07:25 -0700 Subject: [PATCH] Updated acceptance tests --- src/EventSubscriber/EventSubscriber.php | 3 +-- .../acceptance/Content/SearchBlockCest.php | 18 ++++++++++++++++++ .../acceptance/SystemSiteConfigCest.php | 18 ++++++++++++++++++ .../Navigation/NavigationDropDownsCest.php | 9 +++++++++ 4 files changed, 46 insertions(+), 2 deletions(-) diff --git a/src/EventSubscriber/EventSubscriber.php b/src/EventSubscriber/EventSubscriber.php index 06b9365a1..0fceca2be 100644 --- a/src/EventSubscriber/EventSubscriber.php +++ b/src/EventSubscriber/EventSubscriber.php @@ -116,7 +116,6 @@ public function onKernelRequest(RequestEvent $event) { $current_uri = $event->getRequest()->getRequestUri(); if ( - !getenv('CI') && $current_uri != '/admin/config/system/basic-site-settings' && self::redirectUser() ) { @@ -148,7 +147,7 @@ protected static function redirectUser() { $site_manager = $current_user->hasPermission('edit stanford_basic_site_settings config page entity') && !in_array('administrator', $current_user->getRoles()); // If the renewal date has passed, they should be redirected. - $needs_renewal = $site_manager && (strtotime($renewal_date) - time() < 60 * 60 * 24); + $needs_renewal = !getenv('CI') && $site_manager && (strtotime($renewal_date) - time() < 60 * 60 * 24); $cache->set('su_renew_site', $needs_renewal, time() + 60 * 60 * 24); return $needs_renewal; diff --git a/tests/codeception/acceptance/Content/SearchBlockCest.php b/tests/codeception/acceptance/Content/SearchBlockCest.php index 21fa91fd7..322c8c9ca 100644 --- a/tests/codeception/acceptance/Content/SearchBlockCest.php +++ b/tests/codeception/acceptance/Content/SearchBlockCest.php @@ -1,5 +1,7 @@ faker = Factory::create(); + } + /** * Site managers should be able to disable the search block. */ public function testHideSearchBlock(AcceptanceTester $I) { + $org_term = $I->createEntity([ + 'vid' => 'site_owner_orgs', + 'name' => $this->faker->words(2, TRUE), + ], 'taxonomy_term'); + $I->logInWithRole('site_manager'); $I->amOnPage('/'); $I->seeElement('.su-site-search__input'); $I->amOnPage('/admin/config/system/basic-site-settings'); $I->see('Hide Site Search'); $I->checkOption('Hide Site Search'); + $I->fillField('Site Owner Contact (value 1)', $this->faker->email); + $I->fillField('Technical Contact (value 1)', $this->faker->email); + $I->fillField('Accessibility Contact (value 1)', $this->faker->email); + $I->selectOption('Organization', $org_term->id()); $I->click('Save'); // The settings might have been created or updated. $I->see('Site Settings has been'); diff --git a/tests/codeception/acceptance/SystemSiteConfigCest.php b/tests/codeception/acceptance/SystemSiteConfigCest.php index f6fbc7b21..a2ebf3305 100644 --- a/tests/codeception/acceptance/SystemSiteConfigCest.php +++ b/tests/codeception/acceptance/SystemSiteConfigCest.php @@ -37,12 +37,21 @@ public function __after(AcceptanceTester $I) { * The site manager should be able to change the site name. */ public function testBasicSiteSettings(AcceptanceTester $I) { + $org_term = $I->createEntity([ + 'vid' => 'site_owner_orgs', + 'name' => $this->faker->words(2, TRUE), + ], 'taxonomy_term'); + $I->logInWithRole('site_manager'); $I->amOnPage('/'); $I->cantSee('Foo Bar Site'); $I->amOnPage('/admin/config/system/basic-site-settings'); $I->cantSee('Site URL'); $I->fillField('Site Name', 'Foo Bar Site'); + $I->fillField('Site Owner Contact (value 1)', $this->faker->email); + $I->fillField('Technical Contact (value 1)', $this->faker->email); + $I->fillField('Accessibility Contact (value 1)', $this->faker->email); + $I->selectOption('Organization', $org_term->id()); $I->click('Save'); $I->amOnPage('/user/logout'); @@ -61,6 +70,11 @@ public function testBasicSiteSettings(AcceptanceTester $I) { * Site settings config should change the home, 404, and 403 pages. */ public function testSitePages(AcceptanceTester $I) { + $org_term = $I->createEntity([ + 'vid' => 'site_owner_orgs', + 'name' => $this->faker->words(2, TRUE), + ], 'taxonomy_term'); + $text = $this->faker->paragraph; $paragraph = $I->createEntity([ 'type' => 'stanford_wysiwyg', @@ -85,6 +99,10 @@ public function testSitePages(AcceptanceTester $I) { $I->logInWithRole('administrator'); $I->amOnPage('/admin/config/system/basic-site-settings'); $I->selectOption('Home Page', $node->label()); + $I->fillField('Site Owner Contact (value 1)', $this->faker->email); + $I->fillField('Technical Contact (value 1)', $this->faker->email); + $I->fillField('Accessibility Contact (value 1)', $this->faker->email); + $I->selectOption('Organization', $org_term->id()); $I->click('Save'); $I->canSee('Site Settings has been'); diff --git a/tests/codeception/functional/Navigation/NavigationDropDownsCest.php b/tests/codeception/functional/Navigation/NavigationDropDownsCest.php index 8a882d09e..f9ab2ef52 100644 --- a/tests/codeception/functional/Navigation/NavigationDropDownsCest.php +++ b/tests/codeception/functional/Navigation/NavigationDropDownsCest.php @@ -40,6 +40,11 @@ public function __after(FunctionalTester $I) { * @group menu_link_weight */ public function testDropdownMenus(FunctionalTester $I) { + $org_term = $I->createEntity([ + 'vid' => 'site_owner_orgs', + 'name' => $this->faker->words(2, TRUE), + ], 'taxonomy_term'); + $parent_menu_title = $this->faker->word; $I->createEntity([ 'title' => $parent_menu_title, @@ -51,6 +56,10 @@ public function testDropdownMenus(FunctionalTester $I) { $I->resizeWindow(1400, 700); $I->amOnPage('/admin/config/system/basic-site-settings'); $I->uncheckOption('Use drop down menus'); + $I->fillField('Site Owner Contact (value 1)', $this->faker->email); + $I->fillField('Technical Contact (value 1)', $this->faker->email); + $I->fillField('Accessibility Contact (value 1)', $this->faker->email); + $I->selectOption('Organization', $org_term->id()); $I->click('Save'); $I->amOnPage('/'); $I->cantSeeElement('button', ['class' => 'su-nav-toggle']);