Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
refreshless
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
refreshless
Commits
d88e5580
Commit
d88e5580
authored
4 months ago
by
ambient.impact
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3401146
: Added basic drupalSettings merging test.
parent
1bdd51f6
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Pipeline
#390137
passed
4 months ago
Stage: build
Stage: validate
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/refreshless_turbo/tests/src/FunctionalJavascript/DrupalSettingsTest.php
+115
-0
115 additions, 0 deletions
...rbo/tests/src/FunctionalJavascript/DrupalSettingsTest.php
with
115 additions
and
0 deletions
modules/refreshless_turbo/tests/src/FunctionalJavascript/DrupalSettingsTest.php
0 → 100644
+
115
−
0
View file @
d88e5580
<?php
declare
(
strict_types
=
1
);
namespace
Drupal\Tests\refreshless_turbo\FunctionalJavascript
;
use
Drupal\Core\Url
;
use
Drupal\FunctionalJavascriptTests\WebDriverTestBase
;
use
Drupal\Tests\refreshless_turbo
\FunctionalJavascript\TurboAssertTrait
;
use
Drupal\Tests\refreshless_turbo
\FunctionalJavascript\TurboHtmlDebugTrait
;
/**
* drupalSettings updater tests.
*
* @group refreshless
*
* @group refreshless_turbo
*/
class
DrupalSettingsTest
extends
WebDriverTestBase
{
use
TurboAssertTrait
;
use
TurboHtmlDebugTrait
;
/**
* {@inheritdoc}
*/
protected
$defaultTheme
=
'stark'
;
/**
* {@inheritdoc}
*/
protected
static
$modules
=
[
'block'
,
'refreshless_turbo'
,
'system'
];
/**
* Assert that a drupalSettings property equals an expected value.
*
* @param string $propertyName
* The property name. Note that 'drupalSettings.' is prepended automatically
* and so should not be included.
*
* @param string $expectedValue
* The expected value of the property.
*/
protected
function
assertDrupalSettingsValue
(
string
$propertyName
,
string
$expectedValue
,
):
void
{
$actualValue
=
$this
->
getSession
()
->
evaluateScript
(
<<<JS
return drupalSettings.{$propertyName};
JS
);
$this
->
assertEquals
(
$expectedValue
,
$actualValue
,
"drupalSettings.
$propertyName
was expected to equal
\"
$expectedValue
\"
but got
\"
$actualValue
\"
!"
,
);
}
/**
* Test that drupalSettings updates are merged when navigating to new pages.
*/
public
function
testMerging
():
void
{
$this
->
drupalPlaceBlock
(
'local_tasks_block'
,
[
'region'
=>
'content'
,
'id'
=>
'local-tasks-block'
,
]);
$loginUrl
=
Url
::
fromRoute
(
'user.login'
);
$registerUrl
=
Url
::
fromRoute
(
'user.register'
);
$resetPasswordUrl
=
Url
::
fromRoute
(
'user.pass'
);
$this
->
drupalGet
(
$loginUrl
);
$this
->
assertSession
()
->
assertTurboIsPresent
();
$this
->
assertSession
()
->
startTurboPersist
();
$this
->
assertDrupalSettingsValue
(
'path.currentPath'
,
$loginUrl
->
getInternalPath
(),
);
$this
->
click
(
'[data-drupal-link-system-path="'
.
$registerUrl
->
getInternalPath
()
.
'"]'
);
$this
->
assertSession
()
->
assertWaitOnTurboRequest
();
$this
->
assertSession
()
->
assertTurboPersisted
();
$this
->
assertDrupalSettingsValue
(
'path.currentPath'
,
$registerUrl
->
getInternalPath
(),
);
$this
->
turboHtmlOutput
();
$this
->
click
(
'[data-drupal-link-system-path="'
.
$resetPasswordUrl
->
getInternalPath
()
.
'"]'
);
$this
->
assertSession
()
->
assertWaitOnTurboRequest
();
$this
->
assertSession
()
->
assertTurboPersisted
();
$this
->
assertDrupalSettingsValue
(
'path.currentPath'
,
$resetPasswordUrl
->
getInternalPath
(),
);
$this
->
turboHtmlOutput
();
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment