From 3dbeb2052405e5c050aa58e57389658feda576af Mon Sep 17 00:00:00 2001 From: Mike Decker Date: Mon, 22 Jan 2024 14:05:36 -0800 Subject: [PATCH] Tests for page title banner --- composer.json | 2 +- .../Paragraphs/PageTitleBannerCest.php | 61 +++++++++++++++++++ 2 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 tests/codeception/acceptance/Paragraphs/PageTitleBannerCest.php diff --git a/composer.json b/composer.json index 46e3cd843..44aed131f 100644 --- a/composer.json +++ b/composer.json @@ -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": { diff --git a/tests/codeception/acceptance/Paragraphs/PageTitleBannerCest.php b/tests/codeception/acceptance/Paragraphs/PageTitleBannerCest.php new file mode 100644 index 000000000..8a654bf17 --- /dev/null +++ b/tests/codeception/acceptance/Paragraphs/PageTitleBannerCest.php @@ -0,0 +1,61 @@ +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'); + } + +}