Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
automatic_updates-3435918
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
Issue forks
automatic_updates-3435918
Commits
2bfe0e0a
Commit
2bfe0e0a
authored
1 year ago
by
Ted Bowman
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3406812
: Ensure that errors are shown on form updates in core 10.1.x
parent
104361e1
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
automatic_updates.module
+17
-1
17 additions, 1 deletion
automatic_updates.module
tests/src/FunctionalJavascript/UpdateErrorTest.php
+97
-0
97 additions, 0 deletions
tests/src/FunctionalJavascript/UpdateErrorTest.php
with
114 additions
and
1 deletion
automatic_updates.module
+
17
−
1
View file @
2bfe0e0a
...
...
@@ -120,7 +120,23 @@ function automatic_updates_mail(string $key, array &$message, array $params): vo
/**
* Implements hook_page_top().
*/
function
automatic_updates_page_top
()
{
function
automatic_updates_page_top
(
array
&
$page_top
)
{
// Ensure error messages will be displayed on the batch page.
// @todo Remove this work around when https://drupal.org/i/3406612 is fixed.
if
(
\Drupal
::
routeMatch
()
->
getRouteName
()
===
'system.batch_page.html'
)
{
// Directly render a status message placeholder without any messages.
// Messages are not intended to be show on the batch page, but in the event
// an error in a AJAX callback the messages will be displayed.
$page_top
[
'messages'
]
=
[
'#theme'
=>
'status_messages'
,
'#message_list'
=>
[],
'#status_headings'
=>
[
'status'
=>
t
(
'Status message'
),
'error'
=>
t
(
'Error message'
),
'warning'
=>
t
(
'Warning message'
),
],
];
}
/** @var \Drupal\automatic_updates\Validation\AdminStatusCheckMessages $status_check_messages */
$status_check_messages
=
\Drupal
::
classResolver
(
AdminStatusCheckMessages
::
class
);
$status_check_messages
->
displayAdminPageMessages
();
...
...
This diff is collapsed.
Click to expand it.
tests/src/FunctionalJavascript/UpdateErrorTest.php
0 → 100644
+
97
−
0
View file @
2bfe0e0a
<?php
namespace
Drupal\Tests\automatic_updates\FunctionalJavascript
;
use
Drupal\FunctionalJavascriptTests\WebDriverTestBase
;
use
Drupal\package_manager
\Event\PreCreateEvent
;
use
Drupal\package_manager
\ValidationResult
;
use
Drupal\package_manager_test_validation
\EventSubscriber\TestSubscriber
;
use
Drupal\Tests\automatic_updates
\Traits\TestSetUpTrait
;
/**
* Tests errors when JavaScript is enabled.
*
* @group automatic_updates
*/
class
UpdateErrorTest
extends
WebDriverTestBase
{
use
TestSetUpTrait
;
/**
* {@inheritdoc}
*/
protected
$defaultTheme
=
'olivero'
;
/**
* {@inheritdoc}
*/
protected
static
$modules
=
[
'block'
,
'automatic_updates'
,
'automatic_updates_test'
,
];
/**
* {@inheritdoc}
*/
public
function
setUp
():
void
{
parent
::
setUp
();
$this
->
setReleaseMetadata
(
__DIR__
.
'/../../../package_manager/tests/fixtures/release-history/drupal.9.8.1-security.xml'
);
$user
=
$this
->
createUser
([
'administer site configuration'
,
'administer software updates'
,
'access administration pages'
,
'access site in maintenance mode'
,
'administer modules'
,
'access site reports'
,
'view update notifications'
,
]);
$this
->
drupalLogin
(
$user
);
$this
->
mockActiveCoreVersion
(
'9.8.0'
);
$this
->
checkForUpdates
();
}
/**
* Checks for available updates.
*
* Assumes that a user with appropriate permissions is logged in.
*/
protected
function
checkForUpdates
():
void
{
$this
->
drupalGet
(
'/admin/reports/updates'
);
$this
->
getSession
()
->
getPage
()
->
clickLink
(
'Check manually'
);
$this
->
checkForMetaRefresh
();
}
/**
* Mocks the current (running) version of core, as known to the Update module.
*
* @todo Remove this function with use of the trait from the Update module in
* https://drupal.org/i/3348234.
*
* @param string $version
* The version of core to mock.
*/
protected
function
mockActiveCoreVersion
(
string
$version
):
void
{
$this
->
config
(
'update_test.settings'
)
->
set
(
'system_info.#all.version'
,
$version
)
->
save
();
}
/**
* Tests that the update error page is displayed.
*/
public
function
testUpdateErrorPage
():
void
{
$error
=
ValidationResult
::
createError
([
t
(
'Error during pre-create event'
)]);
TestSubscriber
::
setTestResult
([
$error
],
PreCreateEvent
::
class
);
$page
=
$this
->
getSession
()
->
getPage
();
$this
->
drupalGet
(
'/admin/modules/update'
);
$assert_session
=
$this
->
assertSession
();
$page
->
pressButton
(
'Update to 9.8.1'
);
$this
->
assertNotNull
(
$assert_session
->
waitForLink
(
'the error page'
,
100000
));
$assert_session
->
responseContains
(
'Error during pre-create event'
);
$this
->
clickLink
(
'the error page'
);
$assert_session
->
responseContains
(
'Error during pre-create event'
);
}
}
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