Skip to content
Snippets Groups Projects
Commit 097be7ab authored by catch's avatar catch
Browse files

Issue #3372678 by lauriii, Berdir: Ajax state leaking to Views bulk operations

(cherry picked from commit 2ea053b3)
parent fedfc75e
No related branches found
No related tags found
20 merge requests!11628Update file MediaLibraryWidget.php,!7564Revert "Issue #3364773 by roshnichordiya, Chris Matthews, thakurnishant_06,...,!5752Issue #3275828 by joachim, quietone, bradjones1, Berdir: document the reason...,!5627Issue #3261805: Field not saved when change of 0 on string start,!5427Issue #3338518: send credentials in ajax if configured in CORS settings.,!5395Issue #3387916 by fjgarlin, Spokje: Each GitLab job exposes user email,!5217Issue #3386607 by alexpott: Improve spell checking in commit-code-check.sh,!5064Issue #3379522 by finnsky, Gauravvvv, kostyashupenko, smustgrave, Chi: Revert...,!5040SDC ComponentElement: Transform slots scalar values to #plain_text instead of throwing an exception,!4958Issue #3392147: Whitelist IP for a Ban module.,!4894Issue #3280279: Add API to allow sites to opt in to upload SVG images in CKEditor 5,!4857Issue #3336994: StringFormatter always displays links to entity even if the user in context does not have access,!4856Issue #3336994: StringFormatter always displays links to entity even if the user in context does not have access,!4788Issue #3272985: RSS Feed header reverts to text/html when cached,!4716Issue #3362929: Improve 400 responses for broken/invalid image style routes,!4553Draft: Issue #2980951: Permission to see own unpublished comments in comment thread,!3679Issue #115801: Allow password on registration without disabling e-mail verification,!3106Issue #3017548: "Filtered HTML" text format does not support manual teaser break (<!--break-->),!925Issue #2339235: Remove taxonomy hard dependency on node module,!872Draft: Issue #3221319: Race condition when creating menu links and editing content deletes menu links
......@@ -157,7 +157,7 @@ public function buildForm(array $form, FormStateInterface $form_state, ViewExecu
$form = [];
$query = $this->requestStack->getCurrentRequest()->query->all();
$query = UrlHelper::filterQueryParameters($query, ['_wrapper_format'], '');
$query = UrlHelper::filterQueryParameters($query, ['_wrapper_format', 'ajax_page_state'], '');
$options = ['query' => $query];
$form['#action'] = $view->hasUrl() ? $view->getUrl()->setOptions($options)->toString() : Url::fromRoute('<current>')->setOptions($options)->toString();
......
<?php
namespace Drupal\Tests\views\FunctionalJavascript\Plugin;
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
/**
* Tests the bulk operations.
*
* @group views
*/
class BulkOperationsTest extends WebDriverTestBase {
/**
* Modules to enable.
*
* @var array
*/
protected static $modules = ['node', 'views'];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* {@inheritdoc}
*/
protected function setUp(): void {
parent::setUp();
// Enable AJAX on the /admin/content View.
\Drupal::configFactory()->getEditable('views.view.content')
->set('display.default.display_options.use_ajax', TRUE)
->save();
$this->drupalCreateContentType(['type' => 'page']);
$this->drupalLogin($this->createUser(['bypass node access', 'administer nodes', 'access content overview']));
}
public function testBulkOperations() {
$node_1 = $this->drupalCreateNode([
'type' => 'page',
'title' => 'The first node',
'changed' => \Drupal::time()->getRequestTime() - 180,
]);
$node_2 = $this->drupalCreateNode([
'type' => 'page',
'title' => 'The second node',
'changed' => \Drupal::time()->getRequestTime() - 120,
]);
// Login as administrator and go to admin/content.
$this->drupalGet('admin/content');
$this->assertSession()->pageTextContains($node_1->getTitle());
// Filter the list.
$this->assertSession()->pageTextContains($node_1->getTitle());
$this->assertSession()->pageTextContains($node_2->getTitle());
$this->submitForm(['title' => 'The first node'], 'Filter');
$this->assertSession()->assertWaitOnAjaxRequest();
$this->assertSession()->pageTextContains($node_1->getTitle());
$this->assertSession()->pageTextNotContains($node_2->getTitle());
// Select the node deletion action.
$action_select = $this->getSession()->getPage()->find('css', '[data-drupal-selector="edit-action"]');
$action_select_name = $action_select->getAttribute('name');
$this->getSession()->getPage()->selectFieldOption($action_select_name, 'node_delete_action');
// Now click 'Apply to selected items' and assert the first node is selected
// on the confirm form.
$this->submitForm(['node_bulk_form[0]' => TRUE], 'Apply to selected items');
$this->assertSession()->pageTextContains($node_1->getTitle());
$this->assertSession()->pageTextNotContains($node_2->getTitle());
$this->getSession()->getPage()->pressButton('Delete');
// Confirm that the first node was deleted.
$this->assertSession()->pageTextNotContains($node_1->getTitle());
$this->assertSession()->pageTextNotContains($node_2->getTitle());
// Ensure that assets are loaded on the page. This confirms that the page
// was loaded without ajax state.
$this->assertSession()->responseContains('/core/misc/ajax.js');
// Confirm that second node exists.
$this->submitForm([], 'Reset');
$this->assertSession()->pageTextContains($node_2->getTitle());
// Select the node unpublish action.
$action_select = $this->getSession()->getPage()->find('css', '[data-drupal-selector="edit-action"]');
$action_select_name = $action_select->getAttribute('name');
$this->getSession()->getPage()->selectFieldOption($action_select_name, 'node_unpublish_action');
// Ensure that assets are loaded on the page. This confirms that the page
// was loaded without ajax state.
$this->assertSession()->responseContains('/core/misc/ajax.js');
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment