Skip to content

Commit

Permalink
Updated acceptance tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pookmish committed Oct 9, 2023
1 parent 30924c2 commit 21fda2c
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/EventSubscriber/EventSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
) {
Expand Down Expand Up @@ -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;
Expand Down
18 changes: 18 additions & 0 deletions tests/codeception/acceptance/Content/SearchBlockCest.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,40 @@
<?php

use Faker\Factory;

/**
* Test for custom block types.
*
* @group block
*/
class SearchBlockCest {

/**
* Test Constructor.
*/
public function __construct() {
$this->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');
Expand Down
18 changes: 18 additions & 0 deletions tests/codeception/acceptance/SystemSiteConfigCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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',
Expand All @@ -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');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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']);
Expand Down

0 comments on commit 21fda2c

Please sign in to comment.