public function SpaComponentTest::testMultipleV3ComponentsInSpaMode in Decoupled Blocks: Vue.js 8
Test multiple Vue3 SPA components added.
File
- tests/
src/ Functional/ SpaComponentTest.php, line 74
Class
- SpaComponentTest
- Test the vue_spa_component component.
Namespace
Drupal\Tests\pdb_vue\FunctionalCode
public function testMultipleV3ComponentsInSpaMode() {
$assert = $this
->assertSession();
$config = $this
->config('pdb_vue.settings');
// Set the values the user submitted in the form.
$config
->set('version', 'vue3');
$config
->set('development_mode', TRUE);
$config
->set('use_spa', TRUE);
$config
->save();
// Create administrative user.
$this
->drupalLogin($this
->drupalCreateUser([
'access administration pages',
'administer blocks',
]));
// Go to the block instance configuration.
$this
->drupalGet('admin/structure/block/add/vue_component%3Avue3_spa_component/stark');
// Check that the pdb_configuration options are available.
$assert
->responseContains('Component Settings');
$assert
->fieldExists('settings[pdb_configuration][textField]');
// Save the block.
$this
->submitForm([
'settings[pdb_configuration][textField]' => 'Test Config',
'region' => 'content',
], 'Save block');
// Add a second block.
$this
->drupalPlaceBlock('vue_component:vue3_spa_component');
// Go to the home page.
$this
->drupalGet('<front>');
// Assert that the blocks were placed and have the correct tag and property.
$assert
->responseContains('<vue3-spa-component text-field="Test Config" instance-id=');
$assert
->responseContains('<vue3-spa-component instance-id=');
// Check that the spa-init.js library is added after the component js.
$assert
->responseMatches('/vue3-spa-component\\.js(.|\\n)+spa-init\\.js/');
}