Fix redirection after action in search results

This commit is contained in:
Nicolas Lœuillet 2024-11-18 15:24:29 +01:00
parent 89db5690a0
commit 82430b50c6
4 changed files with 35 additions and 3 deletions

View file

@ -7,7 +7,7 @@
</div> </div>
</div> </div>
{% set current_path = path(app.request.attributes.get('_route'), app.request.attributes.get('_route_params')) %} {% set current_path = app.request.requesturi %}
<ul class="tools right"> <ul class="tools right">
<li> <li>

View file

@ -10,7 +10,7 @@
{% endif %} {% endif %}
{% include "@WallabagCore/Entry/Card/_content.html.twig" with {'entry': entry, 'withMetadata': true, 'subClass': 'metadata'} only %} {% include "@WallabagCore/Entry/Card/_content.html.twig" with {'entry': entry, 'withMetadata': true, 'subClass': 'metadata'} only %}
{% set current_path = path(app.request.attributes.get('_route'), app.request.attributes.get('_route_params')) %} {% set current_path = app.request.requesturi %}
<ul class="tools-list hide-on-small-only"> <ul class="tools-list hide-on-small-only">
<li> <li>

View file

@ -19,7 +19,7 @@
{% endblock %} {% endblock %}
{% block content %} {% block content %}
{% set current_path = path(app.request.attributes.get('_route'), app.request.attributes.get('_route_params')) %} {% set current_path = app.request.requesturi %}
{% set list_mode = app.user.config.listMode %} {% set list_mode = app.user.config.listMode %}
{% set entries_with_archived_class_routes = ['tag_entries', 'search', 'all'] %} {% set entries_with_archived_class_routes = ['tag_entries', 'search', 'all'] %}
{% set current_route = app.request.attributes.get('_route') %} {% set current_route = app.request.attributes.get('_route') %}

View file

@ -1475,6 +1475,38 @@ class EntryControllerTest extends WallabagCoreTestCase
$this->assertCount(1, $crawler->filter($this->entryDataTestAttribute)); $this->assertCount(1, $crawler->filter($this->entryDataTestAttribute));
} }
public function testActionInSearchResults()
{
$this->logInAs('admin');
$client = $this->getTestClient();
$config = $this->getLoggedInUser()->getConfig();
$config->setActionMarkAsRead(ConfigEntity::REDIRECT_TO_CURRENT_PAGE);
$this->getEntityManager()->persist($config);
$entry = new Entry($this->getLoggedInUser());
$entry->setUrl($this->url);
$entry->setTitle('ActionInSearchResults');
$this->getEntityManager()->persist($entry);
$this->getEntityManager()->flush();
// Search on unread list
$crawler = $client->request('GET', '/unread/list');
$form = $crawler->filter('form[name=search]')->form();
$data = [
'search_entry[term]' => 'ActionInSearchResults',
];
$crawler = $client->submit($form, $data);
$currentUrl = $client->getRequest()->getUri();
$element = $crawler->filter('a[data-action="delete"]')->link();
$client->click($element);
$client->followRedirect();
$nextUrl = $client->getRequest()->getUri();
$this->assertSame($currentUrl, $nextUrl);
}
public function dataForLanguage() public function dataForLanguage()
{ {
return [ return [