VarbaseWorkflowTest.php in Varbase Workflow 2.0.x
File
tests/src/FunctionalJavascript/VarbaseWorkflowTest.php
View source
<?php
namespace Drupal\Tests\varbase_workflow\FunctionalJavascript;
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
use Drupal\Core\StringTranslation\StringTranslationTrait;
class VarbaseWorkflowTest extends WebDriverTestBase {
use StringTranslationTrait;
protected $profile = 'standard';
protected $defaultTheme = 'olivero';
protected $strictConfigSchema = FALSE;
protected static $modules = [
'workflows',
'content_moderation',
'moderation_sidebar',
'scheduler_content_moderation_integration',
'admin_audit_trail_workflows',
'varbase_workflow',
];
protected function setUp() : void {
parent::setUp();
$this->container
->get('theme_installer')
->install([
'claro',
]);
$this
->config('system.theme')
->set('admin', 'claro')
->save();
drupal_flush_all_caches();
}
public function testCheckVarbaseWorkflowModeration() {
$this
->drupalLogin($this->rootUser);
$this
->drupalGet('admin/config/workflow/workflows');
$this
->assertSession()
->pageTextContains('Simple');
$this
->assertSession()
->pageTextContains('Editorial');
$this
->drupalGet('admin/structure/types/add');
$this
->assertSession()
->pageTextContains('Add content type');
$page = $this
->getSession()
->getPage();
$page
->fillField('name', 'Post');
$this
->assertSession()
->assertWaitOnAjaxRequest();
$edit_type_button = $this
->assertSession()
->waitForElementVisible('css', '#edit-name-machine-name-suffix .link');
$edit_type_button
->click();
$this
->assertSession()
->assertWaitOnAjaxRequest();
$page
->fillField('type', 'post');
$submit = $page
->findButton('op');
$submit
->click();
drupal_flush_all_caches();
$this
->drupalGet('admin/config/workflow/workflows/manage/varbase_editorial_workflow');
$this
->assertSession()
->pageTextContains('Edit Editorial workflow');
$this
->assertSession()
->pageTextContains('Draft');
$this
->assertSession()
->pageTextContains('In review');
$this
->assertSession()
->pageTextContains('Published');
$this
->assertSession()
->pageTextContains('Archived / Unpublished');
$this
->assertSession()
->pageTextContains('Create new draft');
$this
->assertSession()
->pageTextContains('Send to review');
$this
->assertSession()
->pageTextContains('Publish');
$this
->assertSession()
->pageTextContains('Archive / Unpublish');
$this
->assertSession()
->pageTextContains('Restore from archive');
$this
->assertSession()
->pageTextNotContains('Post');
$this
->drupalGet('admin/config/workflow/workflows/manage/varbase_simple_workflow');
$this
->assertSession()
->pageTextContains('Draft');
$this
->assertSession()
->pageTextNotContains('In review');
$this
->assertSession()
->pageTextContains('Published');
$this
->assertSession()
->pageTextContains('Archived / Unpublished');
$this
->assertSession()
->pageTextContains('Create new draft');
$this
->assertSession()
->pageTextNotContains('Send to review');
$this
->assertSession()
->pageTextContains('Publish');
$this
->assertSession()
->pageTextContains('Archive / Unpublish');
$this
->assertSession()
->pageTextContains('Restore from archive');
$this
->assertSession()
->pageTextContains('Post');
}
public function testCheckVarbaseWorkflowModerationSidebar() {
$this
->drupalLogin($this->rootUser);
$this
->drupalGet('admin/structure/types/add');
$this
->assertSession()
->pageTextContains('Add content type');
$page = $this
->getSession()
->getPage();
$page
->fillField('name', 'News');
$this
->assertSession()
->assertWaitOnAjaxRequest();
$edit_type_button = $this
->assertSession()
->waitForElementVisible('css', '#edit-name-machine-name-suffix .link');
$edit_type_button
->click();
$this
->assertSession()
->assertWaitOnAjaxRequest();
$page
->fillField('type', 'news');
$submit = $page
->findButton('op');
$submit
->click();
drupal_flush_all_caches();
$this
->drupalCreateNode([
'title' => 'Test News Contnet',
'type' => 'news',
'body' => [
[
'value' => 'Test body for test news content.',
],
],
]);
$this
->drupalGet('admin/content');
$this
->assertSession()
->pageTextContains('Test News Contnet');
$this
->clickLink('Test News Contnet');
$this
->assertSession()
->pageTextContains('Tasks');
}
}