You are here

public function DashboardTasksTest::testLateTasks in farmOS 2.x

Test the late tasks view on the dashboard.

File

modules/core/ui/views/tests/src/Functional/DashboardTasksTest.php, line 107

Class

DashboardTasksTest
Tests the farm_ui_views dashboard panes.

Namespace

Drupal\Tests\farm_ui_views\Functional

Code

public function testLateTasks() {
  $this
    ->drupalGet('/dashboard');
  $this
    ->assertSession()
    ->statusCodeEquals(200);

  // Assert that the upcoming tasks view was not added.
  $this
    ->assertSession()
    ->pageTextNotContains('Late tasks');

  // Grant the user permission to view any log.
  $this->user
    ->addRole($this->role);
  $this->user
    ->save();

  // Assert that the upcoming tasks view is added.
  $this
    ->drupalGet('/dashboard');
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->assertSession()
    ->pageTextContains('Late tasks');

  // Assert that the log is not displayed.
  $this
    ->assertSession()
    ->pageTextContains('No logs found.');

  // Mark the log as pending in the past.
  $this->log->status = 'pending';
  $this->log->timestamp = \Drupal::time()
    ->getCurrentTime() - 86400;
  $this->log
    ->save();

  // Assert that the upcoming tasks view is added.
  $this
    ->drupalGet('/dashboard');
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->assertSession()
    ->pageTextContains('Late tasks');

  // Assert that the log is displayed.
  $this
    ->assertSession()
    ->pageTextContains($this->log
    ->label());
}