Issue #3276620 by catch, Spokje: Change NoJavaScriptAnonymousTest to use stark theme

merge-requests/2196/head
Gábor Hojtsy 2022-04-27 13:45:37 -07:00
parent b0d868fcfb
commit a9119bc74c
1 changed files with 58 additions and 5 deletions

View File

@ -6,15 +6,66 @@ use Drupal\node\NodeInterface;
use Drupal\Tests\BrowserTestBase; use Drupal\Tests\BrowserTestBase;
/** /**
* Tests that anonymous users are not served any JavaScript in the Standard * Tests that anonymous users are not served any JavaScript.
* installation profile. *
* This is tested with the core modules that are enabled in the 'standard'
* profile.
* *
* @group Common * @group Common
*/ */
class NoJavaScriptAnonymousTest extends BrowserTestBase { class NoJavaScriptAnonymousTest extends BrowserTestBase {
protected $profile = 'standard'; /**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* Modules to enable.
*
* This is a list of modules that are enabled in the 'standard' profile.
*
* @var array
*/
protected static $modules = [
'node',
'history',
'block',
'breakpoint',
'ckeditor',
'config',
'comment',
'contextual',
'contact',
'menu_link_content',
'datetime',
'block_content',
'editor',
'help',
'image',
'menu_ui',
'options',
'path',
'page_cache',
'dynamic_page_cache',
'big_pipe',
'taxonomy',
'dblog',
'search',
'shortcut',
'toolbar',
'field_ui',
'file',
'rdf',
'views',
'views_ui',
'tour',
'automated_cron',
];
/**
* {@inheritdoc}
*/
protected function setUp(): void { protected function setUp(): void {
parent::setUp(); parent::setUp();
@ -26,11 +77,12 @@ class NoJavaScriptAnonymousTest extends BrowserTestBase {
* Tests that anonymous users are not served any JavaScript. * Tests that anonymous users are not served any JavaScript.
*/ */
public function testNoJavaScript() { public function testNoJavaScript() {
// Create a node that is listed on the frontpage. // Create a node of content type 'article' that is listed on the frontpage.
$this->drupalCreateContentType(['type' => 'article']);
$this->drupalCreateNode([ $this->drupalCreateNode([
'type' => 'article',
'promote' => NodeInterface::PROMOTED, 'promote' => NodeInterface::PROMOTED,
]); ]);
$user = $this->drupalCreateUser();
// Test frontpage. // Test frontpage.
$this->drupalGet(''); $this->drupalGet('');
@ -41,6 +93,7 @@ class NoJavaScriptAnonymousTest extends BrowserTestBase {
$this->assertNoJavaScript(); $this->assertNoJavaScript();
// Test user profile page. // Test user profile page.
$user = $this->drupalCreateUser();
$this->drupalGet('user/' . $user->id()); $this->drupalGet('user/' . $user->id());
$this->assertNoJavaScript(); $this->assertNoJavaScript();
} }