Skip to content

Commit

Permalink
updated from upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
imonroe committed Apr 26, 2024
1 parent 51557ba commit 47e887f
Show file tree
Hide file tree
Showing 99 changed files with 19,052 additions and 13,640 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -327,4 +327,5 @@ content:
third_party_settings: { }
hidden:
label: true
su_site_algolia_ui: true
su_site_renewal_due: true
20 changes: 15 additions & 5 deletions config/sync/core.entity_view_display.media.video.default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ dependencies:
- field.field.media.video.su_media_category
- media.type.video
module:
- oembed_lazyload
- empty_fields
- field_formatter_class
- field_label
- media
_core:
default_config_hash: Lcpr93rB3W6kcI48KJ3MhzP4Kg3HObfdAS8RDpoIyTg
id: media.video.default
Expand All @@ -16,14 +19,21 @@ bundle: video
mode: default
content:
field_media_oembed_video:
type: lazyload_oembed
type: oembed
label: hidden
settings:
max_width: 0
max_height: 0
strategy: intersection_observer
intersection_observer_margin: ''
third_party_settings: { }
loading:
attribute: lazy
third_party_settings:
empty_fields:
handler: ''
field_formatter_class:
class: ''
field_label:
label_value: ''
label_tag: ''
weight: 0
region: content
hidden:
Expand Down
1 change: 1 addition & 0 deletions config/sync/stanford_samlauth.settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ role_mapping:
workgroup_api:
cert: ''
key: ''
timeout: 30
reevaluate: new
mapping:
-
Expand Down
6 changes: 5 additions & 1 deletion content/node/0b83d1e9-688a-4475-9673-a4c385f26247.yml
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,14 @@ default:
behavior_settings:
-
value:
list_paragraph: { }
list_paragraph:
hide_heading: true
layout_paragraphs:
parent_uuid: 251bde6a-fb54-459c-bfe8-a612830e0f34
region: main
su_list_headline:
-
value: "News"
su_list_view:
-
target_id: stanford_news
Expand Down
6 changes: 5 additions & 1 deletion content/node/14768832-f763-4d27-8df6-7cd784886d57.yml
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,14 @@ default:
behavior_settings:
-
value:
list_paragraph: { }
list_paragraph:
hide_heading: true
layout_paragraphs:
parent_uuid: 57582f54-3af7-45d0-a930-8977f8b05be8
region: main
su_list_headline:
-
value: "Courses"
su_list_view:
-
target_id: stanford_courses
Expand Down
6 changes: 5 additions & 1 deletion content/node/673a8fb8-39ac-49df-94c2-ed8d04db16a7.yml
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,14 @@ default:
behavior_settings:
-
value:
list_paragraph: { }
list_paragraph:
hide_heading: true
layout_paragraphs:
parent_uuid: 901576db-04e5-46c2-ab4c-ac64980a578e
region: main
su_list_headline:
-
value: "People"
su_list_view:
-
target_id: stanford_person
Expand Down
5 changes: 3 additions & 2 deletions content/node/8ba98fcf-d390-4014-92de-c77a59b30f3b.yml
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,13 @@ default:
value:
list_paragraph:
empty_message: 'No events at this time.'
hide_heading: true
layout_paragraphs:
parent_uuid: baa69328-f537-441e-8ad5-fe66a3ba944d
region: main
revision_translation_affected:
su_list_headline:
-
value: true
value: "Events"
su_list_view:
-
target_id: stanford_events
Expand Down
16 changes: 16 additions & 0 deletions src/Config/ConfigOverrides.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,25 @@ public function loadOverrides($names) {
if (in_array('stanford_samlauth.settings', $names)) {
$this->setSamlOverrides($overrides);
}

if (in_array('system.file', $names)) {
$overrides['system.file']['allow_insecure_uploads'] = self::canUploadJs();
}
return $overrides;
}

/**
* Allow js files to be uploaded only on the one route and only for admins.
*
* @return bool
* If allowed to uplaod JS.
*/
protected static function canUploadJs(): bool {
$route = \Drupal::routeMatch()->getRouteName();
return $route == 'config_pages.stanford_basic_site_settings' &&
in_array('administrator', \Drupal::currentUser()->getRoles());
}

/**
* Set the saml config overrides.
*
Expand Down
7 changes: 4 additions & 3 deletions src/EventSubscriber/EventSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Drupal\Core\Installer\InstallerKernel;
use Drupal\Core\Logger\LoggerChannelFactoryInterface;
use Drupal\Core\Messenger\MessengerInterface;
use Drupal\Core\Site\Settings;
use Drupal\Core\StreamWrapper\StreamWrapperManager;
use Drupal\Core\Url;
use Drupal\core_event_dispatcher\EntityHookEvents;
Expand Down Expand Up @@ -117,15 +118,16 @@ public function onEntityPreSave(EntityPresaveEvent $event) {
*/
public function onKernelRequest(RequestEvent $event) {
$current_uri = $event->getRequest()->getRequestUri();

if (
$event->getRequestType() == HttpKernelInterface::MAIN_REQUEST &&
!getenv('LANDO') &&
(Settings::get('stanford_capture_ownership', FALSE)) &&
!str_starts_with($current_uri, '/admin/config/system/basic-site-settings') &&
self::redirectUser()
) {
$config_page_url = Url::fromRoute('config_pages.stanford_basic_site_settings', [], ['query' => ['destination' => $current_uri]]);
$this->messenger->addWarning('Please update or verify the site contact information on the "Site Contacts" tab.');
$event->setResponse(new RedirectResponse($config_page_url->toString() . '#contact'));
$event->setResponse(new RedirectResponse($config_page_url->toString(TRUE)->getGeneratedUrl() . '#contact'));
}
}

Expand Down Expand Up @@ -156,7 +158,6 @@ protected static function redirectUser() {

// Check for config page edit access and ignore if the user is an
// administrator. That way devs don't get forced into submitting the form.

$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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ public function testTaxonomyOverviewPage(AcceptanceTester $I) {
Role::load('site_manager')
->grantPermission('create terms in ' . $vocab->id())
->save();
$I->logInWithRole('administrator');
$I->amOnPage('/admin/structure/taxonomy');
$I->canSee($vocab->label());
}
Expand Down
9 changes: 2 additions & 7 deletions tests/codeception/acceptance/Content/NewsCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,6 @@ public function testMetaData(AcceptanceTester $I) {
],
], 'media');

$time = \Drupal::time()->getCurrentTime();
$date_string = \Drupal::service('date.formatter')
->format($time, 'custom', 'Y-m-d');
$metadata_date = \Drupal::service('date.formatter')
->format($time, 'custom', 'Y-m-d');

/** @var \Drupal\node\NodeInterface $node */
$node = $I->createEntity([
'title' => $this->faker->words(3, TRUE),
Expand All @@ -220,7 +214,8 @@ public function testMetaData(AcceptanceTester $I) {
$I->assertEquals($node->label(), $I->grabAttributeFrom('meta[property="og:title"]', 'content'), 'Metadata "og:title" should match.');
$I->assertEquals($node->label(), $I->grabAttributeFrom('meta[name="twitter:title"]', 'content'), 'Metadata "twitter:title" should match.');
$I->assertEquals('article', $I->grabAttributeFrom('meta[property="og:type"]', 'content'), 'Metadata "og:type" should match.');
$I->assertEquals("{$metadata_date}T04:00:00-08:00", $I->grabAttributeFrom('meta[property="article:published_time"]', 'content'), 'Metadata "article:published_time" should match.');

$I->assertEquals($metadata_date, $I->grabAttributeFrom('meta[property="article:published_time"]', 'content'), 'Metadata "article:published_time" should match.');

$I->cantSeeElement('meta', ['name' => 'description']);
$I->cantSeeElement('meta', ['property' => 'og:image']);
Expand Down
23 changes: 23 additions & 0 deletions tests/codeception/acceptance/Content/PersonCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,29 @@ public function __construct() {
$this->faker = Factory::create();
}

/**
* Sidebar "Contact" header should only appear once.
*/
public function testDoubleHeader(AcceptanceTester $I){
$node = $I->createEntity([
'type' => 'stanford_person',
'title' => 'Foo Bar',
'su_person_first_name' => 'Foo',
'su_person_last_name' => 'Bar',
'su_person_telephone' => '1234567890',
]);
$I->amOnPage($node->toUrl()->toString());
$I->canSee('Foo Bar', 'h1');
$headers = $I->grabMultiple('h2');
$contacts = 0;
foreach ($headers as $header) {
if (strpos(strtolower($header), 'contact') !== FALSE) {
$contacts++;
}
}
$I->assertEquals(1, $contacts);
}

/**
* Test that the default content has installed and is unpublished.
*/
Expand Down
9 changes: 5 additions & 4 deletions tests/codeception/acceptance/Content/PublicationsCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Class PublicationsCest.
*
* @group content
* @group publications
*/
class PublicationsCest {

Expand Down Expand Up @@ -34,13 +35,13 @@ public function __construct() {
* Create a book citation
*/
public function testBookCitation(AcceptanceTester $I) {
$this->values['term_name'] = $this->faker->words(3, TRUE);
$this->values['node_title'] = $this->faker->words(3, TRUE);
$this->values['term_name'] = $this->faker->words(2, TRUE);
$this->values['node_title'] = $this->faker->words(2, TRUE);
$term = $I->createEntity([
'vid' => 'stanford_publication_topics',
'name' => $this->values['term_name'],
], 'taxonomy_term');

$I->runDrush('cache:rebuild');
$I->logInWithRole('site_manager');
$I->amOnPage('/node/add/stanford_publication');
$I->fillField('Title', $this->values['node_title']);
Expand Down Expand Up @@ -79,7 +80,7 @@ public function testAllPublicationListPage(AcceptanceTester $I) {
], 'taxonomy_term');
$I->amOnPage($term->toUrl('edit-form')->toString());
$I->click('Save');

$I->runDrush('cache:rebuild');
$I->amOnPage('/publications');
$I->canSeeLink($term->label());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function testCustomLocalFooter(AcceptanceTester $I) {

$I->selectOption('State', 'New York');
$fields = [
// 'Company' => 'Drupal',
'Organization' => 'Drupal',
'Street address' => '123 Drupal Dr',
'City' => 'New York',
'Zip code' => 12345,
Expand Down
4 changes: 4 additions & 0 deletions tests/codeception/acceptance/Media/MediaPermissionsCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ public function testSiteEmbedderPerms(AcceptanceTester $I) {
$I->canSeeResponseCodeIs(200);
$I->canSee('oEmbed URL');
$I->canSee('Embed Code');
$I->fillField('Name', $this->faker->words(3, TRUE));
$I->fillField('Embed Code', '<script>console.log("test")</script>');
$I->click('Save');
$I->canSee('has been created');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/codeception/acceptance/Paragraphs/ListsCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public function testListParagraphNews(AcceptanceTester $I) {
$I->canSee('Headliner', 'h2');
$I->canSee('Lorem Ipsum');
$I->canSeeLink('Google', 'http://google.com');
$I->canSee($title);
$I->canSee($title, 'h3');

$I->amOnPage('/jsonapi/views/stanford_news/block_1?page[limit]=99');
$json_data = json_decode($I->grabPageSource(), TRUE, 512, JSON_THROW_ON_ERROR);
Expand Down
6 changes: 3 additions & 3 deletions tests/codeception/acceptance/Paragraphs/StanfordCardCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function __construct() {
/**
* Test a card with a button link.
*/
public function testCardButtonLinkText(\AcceptanceTester $I) {
public function testCardButtonLinkText(AcceptanceTester $I) {
$node = $this->createNodeWithLink($I);
$I->amOnPage($node->toUrl()->toString());
$I->canSeeLink('It\'s a "test" link & title', 'http://google.com');
Expand All @@ -33,7 +33,7 @@ public function testCardButtonLinkText(\AcceptanceTester $I) {
/**
* Test a card with an action link.
*/
public function testCardActionLinkText(\AcceptanceTester $I) {
public function testCardActionLinkText(AcceptanceTester $I) {
$node = $this->createNodeWithLink($I, 'action');
$I->amOnPage($node->toUrl()->toString());
$I->canSeeLink('It\'s a "test" link & title', 'http://google.com');
Expand All @@ -42,7 +42,7 @@ public function testCardActionLinkText(\AcceptanceTester $I) {
/**
* Generate a node with a paragraph that contains a link.
*/
protected function createNodeWithLink(\AcceptanceTester $I, $link_type = 'button') {
protected function createNodeWithLink(AcceptanceTester $I, $link_type = 'button') {
/** @var \Drupal\paragraphs\ParagraphInterface $paragraph */
$paragraph = $I->createEntity([
'type' => 'stanford_card',
Expand Down
15 changes: 13 additions & 2 deletions tests/codeception/acceptance/SystemCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ public function testSiteStatus(AcceptanceTester $I) {
$I->amOnPage('/admin/reports/status');
$I->canSee('10.2', '.system-status-general-info');
if ($I->grabMultiple('.system-status-counter--error')) {
// $I->canSee('3 Errors', '.system-status-counter--error');
// $I->canSee('Access to update.php ', '.system-status-report__status-icon--error');
$I->canSee('1 Error', '.system-status-counter--error');
$I->canSee('Access to update.php ', '.system-status-report__status-icon--error');
}

if (\Drupal::moduleHandler()->moduleExists('chosen')) {
Expand All @@ -26,4 +26,15 @@ public function testSiteStatus(AcceptanceTester $I) {
}
}

/**
* Test the login page.
*
* @group 403-redirect
*/
public function testLoginPage(AcceptanceTester $I){
$I->amOnPage('/admin/config');
$I->canSeeInCurrentUrl('/user/login');
$I->canSeeNumberOfElements('h1', 1);
}

}
Empty file modified tests/codeception/acceptance/assets/test.pdf
100644 → 100755
Empty file.
3 changes: 1 addition & 2 deletions tests/codeception/functional/Paragraphs/BannerCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,14 @@ public function testBannerBehaviors(FunctionalTester $I) {
$I->canSeeLink($field_values['title'], $field_values['uri']);

$I->cantSeeElement('.overlay-right');

return;
$I->logInWithRole('site_manager');

// Overlay position and h3 heading.
$I->amOnPage($node->toUrl('edit-form')->toString());
$I->scrollTo('.js-lpb-component', 0, -100);
$I->moveMouseOver('.js-lpb-component', 10, 10);
$I->click('Edit', '.lpb-controls');
return;
$I->waitForText('Behaviors');
$I->clickWithLeftButton('.lpb-behavior-plugins summary');
$I->selectOption('Text Overlay Position', 'Right');;
Expand Down
4 changes: 2 additions & 2 deletions tests/codeception/functional/Paragraphs/WYSIWYGCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public function testImageCategory(FunctionalTester $I) {
$I->waitForElementVisible('.ck-toolbar');

// Wait a second for any click events to be applied.
$I->wait(1);
$I->wait(2);
$I->click('[data-cke-tooltip-text="Insert Media"]');
$I->waitForElementVisible('.dropzone');

Expand Down Expand Up @@ -255,7 +255,7 @@ public function testEmbeddedVideo(FunctionalTester $I) {
$I->click('Save', '.ui-dialog-buttonpane');
$I->waitForElementNotVisible('.ui-dialog');
$I->click('Save');
$I->scrollTo('.oembed-lazyload', 0, 100);
$I->scrollTo('.field-media-oembed-video', 0, 100);
$I->waitForElementVisible('iframe');
$I->canSeeNumberOfElements('iframe', 1);
$I->canSeeNumberOfElements('iframe[loading="lazy"]', 1);
Expand Down
Loading

0 comments on commit 47e887f

Please sign in to comment.