You are here

public function WorkspaceTest::testWorkspaceManagePage in Drupal 9

Tests the manage workspace page.

@group failing

File

core/modules/workspaces/tests/src/Functional/WorkspaceTest.php, line 170

Class

WorkspaceTest
Test the workspace entity.

Namespace

Drupal\Tests\workspaces\Functional

Code

public function testWorkspaceManagePage() {
  $this
    ->drupalLogin($this->rootUser);
  $this
    ->setupWorkspaceSwitcherBlock();
  $assert_session = $this
    ->assertSession();
  $test_1 = $this
    ->createWorkspaceThroughUi('Test 1', 'test_1');
  $test_2 = $this
    ->createWorkspaceThroughUi('Test 2', 'test_2');
  $this
    ->switchToWorkspace($test_1);

  // Check that the 'test_1' workspace doesn't contain any changes initially.
  $this
    ->drupalGet($test_1
    ->toUrl()
    ->toString());
  $assert_session
    ->pageTextContains('This workspace has no changes.');

  // Check that the 'Switch to this workspace' action link is not displayed on
  // the manage page of the currently active workspace.
  $assert_session
    ->linkNotExists('Switch to this workspace');
  $this
    ->drupalGet($test_2
    ->toUrl()
    ->toString());
  $assert_session
    ->linkExists('Switch to this workspace');

  // Create some test content.
  $this
    ->drupalCreateContentType([
    'type' => 'test',
    'label' => 'Test',
  ]);
  $this
    ->createNodeThroughUi('Node 1', 'test');
  $this
    ->createNodeThroughUi('Node 2', 'test');
  $vocabulary = $this
    ->createVocabulary();
  $edit = [
    'name[0][value]' => 'Term 1',
  ];
  $this
    ->drupalGet('admin/structure/taxonomy/manage/' . $vocabulary
    ->id() . '/add');
  $this
    ->submitForm($edit, 'Save');
  $this
    ->drupalGet($test_1
    ->toUrl()
    ->toString());
  $assert_session
    ->pageTextContains('2 content items, 1 taxonomy term');
  $assert_session
    ->linkExists('Node 1');
  $assert_session
    ->linkExists('Node 2');
  $assert_session
    ->linkExists('Term 1');
}