From 16268e4e70c0eb0f3dee303bb70ee415f479a49b Mon Sep 17 00:00:00 2001 From: Vault Automation Date: Thu, 7 May 2026 08:54:03 -0600 Subject: [PATCH] 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> --- .../components/messages/tab-page-header.hbs | 4 +- .../config-ui/messages/messages-test.js | 60 ++++++++++++++++++- 2 files changed, 61 insertions(+), 3 deletions(-) diff --git a/ui/lib/config-ui/addon/components/messages/tab-page-header.hbs b/ui/lib/config-ui/addon/components/messages/tab-page-header.hbs index 56bded4928..90c4a7f091 100644 --- a/ui/lib/config-ui/addon/components/messages/tab-page-header.hbs +++ b/ui/lib/config-ui/addon/components/messages/tab-page-header.hbs @@ -27,7 +27,7 @@ After user logs in @@ -37,7 +37,7 @@ On login page diff --git a/ui/tests/acceptance/config-ui/messages/messages-test.js b/ui/tests/acceptance/config-ui/messages/messages-test.js index 49a5f23126..0dfed9db25 100644 --- a/ui/tests/acceptance/config-ui/messages/messages-test.js +++ b/ui/tests/acceptance/config-ui/messages/messages-test.js @@ -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);