UI: update custom message filter so params don't persist between tabs (#14592) (#14605)

* Ensure that the other params dont persist when switching tabs for custom messages

* Add acceptance tests

Co-authored-by: Kianna <30884335+kiannaquach@users.noreply.github.com>
This commit is contained in:
Vault Automation 2026-05-07 08:54:03 -06:00 committed by GitHub
parent 5ec71e45ab
commit 16268e4e70
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 61 additions and 3 deletions

View File

@ -27,7 +27,7 @@
<LinkTo
class={{if @authenticated "active"}}
@route="messages"
@query={{hash authenticated=true page=1}}
@query={{hash authenticated=true page=1 pageFilter=null status=null type=null}}
data-test-custom-messages-tab="After user logs in"
>
After user logs in
@ -37,7 +37,7 @@
<LinkTo
class={{unless @authenticated "active"}}
@route="messages"
@query={{hash authenticated=false page=1}}
@query={{hash authenticated=false page=1 pageFilter=null status=null type=null}}
data-test-custom-messages-tab="On login page"
>
On login page

View File

@ -6,7 +6,7 @@
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
import { setupMirage } from 'ember-cli-mirage/test-support';
import { click, visit, fillIn, findAll, waitFor } from '@ember/test-helpers';
import { click, visit, fillIn, findAll, waitFor, currentURL } from '@ember/test-helpers';
import { login } from 'vault/tests/helpers/auth/auth-helpers';
import { runCmd } from 'vault/tests/helpers/commands';
import { format, addDays, startOfDay } from 'date-fns';
@ -205,6 +205,64 @@ module('Acceptance | Enterprise | config-ui/message', function (hooks) {
await this.deleteMessages();
});
test('it should clear filter params when switching between tabs', async function (assert) {
await this.createMessageRepl({ title: 'tab-switch-test-1', type: 'banner', authenticated: true });
await this.createMessageRepl({ title: 'tab-switch-test-2', type: 'modal', authenticated: false });
// Start on authenticated tab with filters applied
await visit('vault/config-ui/messages?authenticated=true&pageFilter=test&status=active&type=banner');
// Verify filters are applied
assert.dom(GENERAL.filter('pageFilter')).hasValue('test', 'pageFilter is set');
assert.dom(GENERAL.filter('status')).hasValue('active', 'status filter is set');
assert.dom(GENERAL.filter('type')).hasValue('banner', 'type filter is set');
// Switch to unauthenticated tab
await click(CUSTOM_MESSAGES.tab('On login page'));
// Verify filters are cleared after tab switch
assert.dom(GENERAL.filter('pageFilter')).hasValue('', 'pageFilter is cleared after tab switch');
assert.dom(GENERAL.filter('status')).hasValue('', 'status filter is cleared after tab switch');
assert.dom(GENERAL.filter('type')).hasValue('', 'type filter is cleared after tab switch');
// Verify URL params are cleared (except authenticated and page)
const unauthenticatedUrl = currentURL();
assert.true(unauthenticatedUrl.includes('authenticated=false'), 'authenticated param is set to false');
assert.false(unauthenticatedUrl.includes('pageFilter'), 'pageFilter param is not in URL');
assert.false(unauthenticatedUrl.includes('status'), 'status param is not in URL');
assert.false(unauthenticatedUrl.includes('type'), 'type param is not in URL');
// Apply filters on unauthenticated tab
await fillIn(GENERAL.filter('pageFilter'), 'modal-test');
await fillIn(GENERAL.filter('type'), 'modal');
await click(GENERAL.submitButton);
// Verify filters are applied
assert
.dom(GENERAL.filter('pageFilter'))
.hasValue('modal-test', 'pageFilter is set on unauthenticated tab');
assert.dom(GENERAL.filter('type')).hasValue('modal', 'type filter is set on unauthenticated tab');
// Switch back to authenticated tab
await click(CUSTOM_MESSAGES.tab('After user logs in'));
// Verify filters are cleared again
assert.dom(GENERAL.filter('pageFilter')).hasValue('', 'pageFilter is cleared when switching back');
assert.dom(GENERAL.filter('type')).hasValue('', 'type filter is cleared when switching back');
// Verify URL params are cleared
const authenticated = currentURL();
const authenticatedParam =
authenticated.includes('authenticated=true') || !authenticated.includes('authenticated=false');
assert.true(authenticatedParam, 'authenticated param is set to true or uses default');
assert.false(authenticated.includes('pageFilter'), 'pageFilter param is not in URL after switching back');
assert.false(authenticated.includes('status'), 'status param is not in URL after switching back');
assert.false(authenticated.includes('type'), 'type param is not in URL after switching back');
// delete the created messages
await this.deleteMessages();
});
test('it should display preview a message when all required fields are filled out', async function (assert) {
await click(GENERAL.navLink('Operational tools'));
await click(CUSTOM_MESSAGES.navLink);