View source
<?php
namespace Drupal\Tests\pdb_vue\FunctionalJavascript;
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
class VueRenderTest extends WebDriverTestBase {
public static $modules = [
'block',
'pdb',
'pdb_vue',
];
protected $defaultTheme = 'stark';
public function testExample1Renders() {
$assert = $this
->assertSession();
$config = $this
->config('pdb_vue.settings');
$config
->set('version', 'vue2');
$config
->set('development_mode', TRUE);
$config
->save();
$this
->drupalPlaceBlock('vue_component:vue_example_1');
$this
->drupalGet('<front>');
$assert
->waitForElement('css', '.test');
$assert
->pageTextContains("Hello Vue");
}
public function testExample1V3Renders() {
$assert = $this
->assertSession();
$config = $this
->config('pdb_vue.settings');
$config
->set('version', 'vue3');
$config
->set('development_mode', TRUE);
$config
->save();
$this
->drupalPlaceBlock('vue_component:vue3_example_1');
$this
->drupalGet('<front>');
$assert
->waitForElement('css', '.test');
$assert
->pageTextContains("Hello Vue");
}
public function testSpaComponentsRenders() {
$assert = $this
->assertSession();
$config = $this
->config('pdb_vue.settings');
$config
->set('version', 'vue2');
$config
->set('development_mode', TRUE);
$config
->set('use_spa', TRUE);
$config
->set('spa_element', 'main');
$config
->save();
$this
->drupalPlaceBlock('vue_component:vue_spa_component', [
'pdb_configuration' => [
'textField' => 'component 1',
],
]);
$this
->drupalPlaceBlock('vue_component:vue_spa_component', [
'pdb_configuration' => [
'textField' => 'component 2',
],
]);
$this
->drupalPlaceBlock('vue_component:vue_spa_component', [
'pdb_configuration' => [
'textField' => 'component 3',
],
]);
$this
->drupalGet('<front>');
$assert
->waitForElement('css', '.test');
$assert
->pageTextContains("component 1");
$assert
->pageTextContains("component 2");
$assert
->pageTextContains("component 3");
}
public function testSpaV3ComponentsRenders() {
$assert = $this
->assertSession();
$config = $this
->config('pdb_vue.settings');
$config
->set('version', 'vue3');
$config
->set('development_mode', TRUE);
$config
->set('use_spa', TRUE);
$config
->set('spa_element', 'main');
$config
->save();
$this
->drupalPlaceBlock('vue_component:vue3_spa_component', [
'pdb_configuration' => [
'textField' => 'component 1',
],
]);
$this
->drupalPlaceBlock('vue_component:vue3_spa_component', [
'pdb_configuration' => [
'textField' => 'component 2',
],
]);
$this
->drupalPlaceBlock('vue_component:vue3_spa_component', [
'pdb_configuration' => [
'textField' => 'component 3',
],
]);
$this
->drupalGet('<front>');
$assert
->waitForElement('css', '.test');
$assert
->pageTextContains("component 1");
$assert
->pageTextContains("component 2");
$assert
->pageTextContains("component 3");
}
}