Skip to content

Commit

Permalink
updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
imonroe committed Apr 23, 2024
1 parent be70927 commit 2451f39
Show file tree
Hide file tree
Showing 11 changed files with 49 additions and 11 deletions.
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
3 changes: 2 additions & 1 deletion tests/codeception/acceptance/Content/NewsCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,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
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
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
11 changes: 11 additions & 0 deletions tests/codeception/acceptance/SystemCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion tests/codeception/functional/Paragraphs/WYSIWYGCest.php
Original file line number Diff line number Diff line change
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
7 changes: 6 additions & 1 deletion tests/src/Kernel/EventSubscriber/EventSubscriberTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Drupal\consumers\Entity\Consumer;
use Drupal\Core\Session\AccountProxyInterface;
use Drupal\core_event_dispatcher\Event\Entity\EntityInsertEvent;
use Drupal\Core\Site\Settings;
use Drupal\default_content\Event\ImportEvent;
use Drupal\file\Entity\File;
use Drupal\KernelTests\KernelTestBase;
Expand Down Expand Up @@ -139,8 +140,12 @@ public function testKernelRequest() {
$ci = getenv('CI');
putenv('CI');

$config_page_loader = $this->createMock(ConfigPagesLoaderServiceInterface::class);
$site_settings = [
'stanford_capture_ownership' => TRUE,
];
new Settings($site_settings);

$config_page_loader = $this->createMock(ConfigPagesLoaderServiceInterface::class);
\Drupal::getContainer()->set('config_pages.loader', $config_page_loader);

$account = $this->createMock(AccountProxyInterface::class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ProfileConnectSectionTest extends UnitTestCase {
/**
* {@inheritDoc}
*/
public function setup(): void {
public function setUp(): void {
parent::setUp();
$container = new ContainerBuilder();
$container->set('string_translation', $this->getStringTranslationStub());
Expand Down

0 comments on commit 2451f39

Please sign in to comment.