Skip to content
Snippets Groups Projects
Commit 5c8f309b authored by David Suissa's avatar David Suissa Committed by Louis Cuny
Browse files

Issue #3412960 by DYdave, louis-cuny: GitLab CI: PHPUnit, FunctionalJavascript...

Issue #3412960 by DYdave, louis-cuny: GitLab CI: PHPUnit, FunctionalJavascript tests failing with 'RuntimeException: Unable to complete AJAX request.' on D10.2
parent 51a15a1b
No related branches found
No related tags found
1 merge request!30Issue #3412960 by DYdave: GitLab CI: Fixed Composer job failing due to project...
Pipeline #77086 passed
......@@ -8,12 +8,12 @@
"php": ">=7.1"
},
"require-dev": {
"drush/drush": "^9 || ^10 || ^11"
"drush/drush": "^9 || ^10 || ^11 || ^12"
},
"extra": {
"drush": {
"services": {
"drush.services.yml": "^9 || ^10 || ^11"
"drush.services.yml": "^9 || ^10 || ^11 || ^12"
}
}
}
......
......@@ -187,35 +187,33 @@ public function importMenuLinks(array $form, FormStateInterface $form_state = NU
// Get menu links from config.
$menusConfig = $this->config->get('menus');
$menus = $menusConfig ? $menusConfig : [];
if (isset($menusSelected)) {
foreach ($menusConfig as $menu) {
if (in_array($menu['menu_name'], array_keys($menusSelected))) {
$menus[] = $menu;
}
}
// Importing with no config should print out a log message.
if (empty($menusConfig)) {
$message = $this->t("No menu exported: Nothing to import.\nMenus need to be exported first before they can be imported.");
StructureSyncHelper::logMessage($message);
return;
}
// Drush import: Process all menu items stored in config.
if (array_key_exists('drush', $form) && $form['drush'] === TRUE) {
$context = [];
$context['drush'] = TRUE;
switch ($style) {
case 'full':
self::deleteDeletedMenuLinks($menus, $context);
self::importMenuLinksFull($menus, $context);
self::deleteDeletedMenuLinks($menusConfig, $context);
self::importMenuLinksFull($menusConfig, $context);
self::menuLinksImportFinishedCallback(NULL, NULL, NULL);
break;
case 'safe':
self::importMenuLinksSafe($menus, $context);
self::importMenuLinksSafe($menusConfig, $context);
self::menuLinksImportFinishedCallback(NULL, NULL, NULL);
break;
case 'force':
self::deleteMenuLinks($context);
self::importMenuLinksForce($menus, $context);
self::importMenuLinksForce($menusConfig, $context);
self::menuLinksImportFinishedCallback(NULL, NULL, NULL);
break;
}
......@@ -223,7 +221,19 @@ public function importMenuLinks(array $form, FormStateInterface $form_state = NU
return;
}
// Import the menu links with the chosen style of importing.
// Form import: Check if any menu was selected for import.
if (empty($menusSelected)) {
$message = $this->t('No menu selected for import: Nothing to import.');
StructureSyncHelper::logMessage($message);
$this->messenger()->addWarning($message);
return;
}
// Filter menus saved in config with the ones selected for the import.
$menus = array_filter($menusConfig, function ($menu_link_item) use ($menusSelected) {
return in_array($menu_link_item['menu_name'], $menusSelected);
});
// Import the selected menu links with the chosen style of import.
switch ($style) {
case 'full':
$batch = [
......
......@@ -23,6 +23,7 @@ class StructureSyncMenuLinksDrushTest extends BrowserTestBase {
* @var array
*/
protected static $modules = [
'dblog',
'structure_sync',
'menu_link_content',
];
......@@ -101,6 +102,12 @@ public function testMenuLinksExportImportUsingDrush(): void {
// "Oxygen" menu link should be updated by a full import.
$oxygenMenuLinks = $this->menuLinkStorage->loadByProperties(['uuid' => 'd2385dc8-e70d-490f-8ec7-d95c828c98ac']);
$this->assertEquals('Oxygen gas', reset($oxygenMenuLinks)->description->value);
// Importing with no config should print out a log message.
$this->drush('config:delete "structure_sync.data"');
$this->drush('import:menus --choice=safe');
$this->drush('watchdog:show --count=1 --field=message');
$this->assertEquals("No menu exported: Nothing to import.\\nMenus need to be exported first before they can be imported.", $this->getOutput());
}
}
......@@ -98,7 +98,8 @@ public function testBlocksExportImportUsingAdmin(): void {
// Importing blocks using safe mode.
$this->drupalGet('admin/structure/structure-sync/blocks');
$this->click('#edit-import-blocks-safe');
$this->assertSession()->assertWaitOnAjaxRequest();
// Wait for the import batch to complete so the buttons are visible again.
$this->assertSession()->waitForElementVisible('css', '#edit-import-blocks-full');
// Deleted block item should be imported.
$tigGasBlockContents = $this->blockContentStorage->loadByProperties(['info' => 'Argon']);
......@@ -118,7 +119,8 @@ public function testBlocksExportImportUsingAdmin(): void {
// Importing blocks using full mode.
$this->click('#edit-import-blocks-full');
$this->assertSession()->assertWaitOnAjaxRequest();
// Wait for the import batch to complete so the buttons are visible again.
$this->assertSession()->waitForElementVisible('css', '#edit-import-blocks-force');
// "Electrode" block content should be deleted by full import.
$electrodeBlockContents = $this->blockContentStorage->loadByProperties(['info' => 'Electrode']);
......@@ -130,7 +132,8 @@ public function testBlocksExportImportUsingAdmin(): void {
// Importing blocks using force mode.
$this->click('#edit-import-blocks-force');
$this->assertSession()->assertWaitOnAjaxRequest();
// Wait for the import batch to complete so the buttons are visible again.
$this->assertSession()->waitForElementVisible('css', '#edit-import-blocks-force');
// "Oxygen" block content should be updated by a full import.
$oxygenBlockContents = $this->blockContentStorage->loadByProperties(['info' => 'Oxygen']);
......
......@@ -87,7 +87,8 @@ public function testMenuLinksExportImportUsingAdmin(): void {
])->save();
$this->click('#edit-import-menus-safe');
$this->assertSession()->assertWaitOnAjaxRequest();
// Wait for the import batch to complete so the buttons are visible again.
$this->assertSession()->waitForElementVisible('css', '#edit-import-menus-full');
// Deleted menu item should be imported.
$tigGasMenuLink = $this->menuLinkStorage->loadByProperties(['uuid' => '48062c1c-132b-476e-bc3c-8511fb8896e4']);
......@@ -107,7 +108,8 @@ public function testMenuLinksExportImportUsingAdmin(): void {
// Importing menus using full mode.
$this->click('#edit-import-menus-full');
$this->assertSession()->assertWaitOnAjaxRequest();
// Wait for the import batch to complete so the buttons are visible again.
$this->assertSession()->waitForElementVisible('css', '#edit-import-menus-force');
// "Electrode" menu link should be deleted by full import.
$electrodeMenuLinks = $this->menuLinkStorage->loadByProperties(['uuid' => '9a49342a-45e0-4d15-a251-83d704371c79']);
......@@ -119,7 +121,8 @@ public function testMenuLinksExportImportUsingAdmin(): void {
// Importing menus using full mode.
$this->click('#edit-import-menus-force');
$this->assertSession()->assertWaitOnAjaxRequest();
// Wait for the import batch to complete so the buttons are visible again.
$this->assertSession()->waitForElementVisible('css', '#edit-import-menus-force');
// "Oxygen" menu link should be updated by a force import.
$oxygenMenuLinks = $this->menuLinkStorage->loadByProperties(['uuid' => 'd2385dc8-e70d-490f-8ec7-d95c828c98ac']);
......
......@@ -81,7 +81,8 @@ public function testTaxonomiesExportImportUsingAdmin(): void {
])->save();
$this->click('#edit-import-taxonomies-safe');
$this->assertSession()->assertWaitOnAjaxRequest();
// Wait for the import batch to complete so the buttons are visible again.
$this->assertSession()->waitForElementVisible('css', '#edit-import-taxonomies-full');
// Deleted menu item should be imported.
$tigGasTerms = $this->taxonomyTermStorage->loadByProperties(['name' => 'Argon']);
......@@ -93,7 +94,8 @@ public function testTaxonomiesExportImportUsingAdmin(): void {
// Trying full.
$this->click('#edit-import-taxonomies-full');
$this->assertSession()->assertWaitOnAjaxRequest();
// Wait for the import batch to complete so the buttons are visible again.
$this->assertSession()->waitForElementVisible('css', '#edit-import-taxonomies-full');
// "Tig gas" should be correctly imported.
$tigGasTaxonomies = $this->taxonomyTermStorage->loadByProperties(['name' => 'Argon']);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment