Skip to content

Commit

Permalink
Tests for page title banner
Browse files Browse the repository at this point in the history
  • Loading branch information
pookmish committed Jan 22, 2024
1 parent 127c593 commit 3dbeb20
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 1 deletion.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
"su-sws/stanford_fields": "^8.2",
"su-sws/stanford_media": "^11.0",
"su-sws/stanford_migrate": "^8.3",
"su-sws/stanford_profile_helper": "9.x-dev",
"su-sws/stanford_profile_helper": "dev-D8CORE-7207--page-title-banner-paragraph",
"su-sws/stanford_samlauth": "^1.0"
},
"config": {
Expand Down
61 changes: 61 additions & 0 deletions tests/codeception/acceptance/Paragraphs/PageTitleBannerCest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php

use Faker\Factory;

/**
* Test the page title banner paragraph.
*
* @group page-title-banner
*/
class PageTitleBannerCest {

use TestFilesTrait;

/**
* Faker service.
*
* @var \Faker\Generator
*/
protected $faker;

/**
* Test constructor.
*/
public function __construct() {
$this->faker = Factory::create();
}

/**
* Test the title banner title is auto generated.
*/
public function testAutoTitle(AcceptanceTester $I) {
$this->prepareImage();
$node = $I->createEntity([
'type' => 'stanford_page',
'title' => $this->faker->words(3, TRUE),
]);
$file = $I->createEntity(['uri' => $this->logoPath], 'file');
$media = $I->createEntity([
'bundle' => 'image',
'field_media_image' => ['target_id' => $file->id()],
], 'media');
$I->logInWithRole('contributor');
$I->amOnPage($node->toUrl('edit-form')->toString());
$I->seeInField('Title', $node->label());
$I->click('Add Page Title Banner');
$I->fillField('[name="su_page_banner[0][subform][su_title_banner_image][media_library_selection]"]', $media->id());
$I->click('Update widget');
$I->click('Save');
$I->canSeeInCurrentUrl($node->toUrl()->toString());
$I->canSee($node->label(), '.ptype-stanford-page-title-banner h1');
$I->canSeeElement('.ptype-stanford-page-title-banner img');

// Edit the node and change the title.
$I->amOnPage($node->toUrl('edit-form')->toString());
$new_title = $this->faker->words(4, TRUE);
$I->fillField('Title', $new_title);
$I->click('Save');
$I->canSee($new_title, '.ptype-stanford-page-title-banner h1');
}

}

0 comments on commit 3dbeb20

Please sign in to comment.