[MM-63007][MM-63004][MM-63020][MM-63009][MM-63008] More accessibility fixes around Search (#31409)

* [MM-63008] Make collapse button on search bar an actual button

* [MM-63004][MM-63020] Convert search box to floating-ui, fix some of the roles and labels that were incorrect

* [MM-63009] Add radiogroup and radio roles to the search box types

* [MM-63007] Ensure search box reads out number of results with suggestion items

* Fix playwright tests

* PR feedback

* Remove floating ui overlay

* Remove unnecessary .first() by being more specific about the search box

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
Devin Binnie
2025-06-17 17:47:30 -04:00
коммит произвёл GitHub
родитель e367872c0b
Коммит df1b278f62
35 изменённых файлов: 204 добавлений и 147 удалений

Просмотреть файл

@@ -126,7 +126,7 @@ describe('Verify Quick Navigation support across different regions in the app',
it('MM-T1460_8 Verify Navigation Support in Search Results', () => {
// # Search for some text
cy.uiGetSearchContainer().click();
cy.uiGetSearchBox().should('be.visible').first().type('hello {enter}');
cy.uiGetSearchBox().should('be.visible').type('hello {enter}');
// # Change the focus to search results
cy.get('#searchContainer').within(() => {

Просмотреть файл

@@ -65,7 +65,7 @@ describe('Archived channels', () => {
// # Search for "Test archive reaction"
cy.get('body').type('{esc}');
cy.uiGetSearchContainer().click();
cy.uiGetSearchBox().should('be.visible').first().type(messageText).type('{enter}');
cy.uiGetSearchBox().should('be.visible').type(messageText).type('{enter}');
// # Click on post dot menu so we can check for reaction icon
cy.clickPostDotMenu(postId, 'SEARCH');

Просмотреть файл

@@ -61,7 +61,7 @@ describe('archive tests while preventing viewing archived channels', () => {
// # Search for the post from step 1')
cy.uiGetSearchContainer().click();
cy.uiGetSearchBox().first().clear().type(`${messageText}{enter}`);
cy.uiGetSearchBox().clear().type(`${messageText}{enter}`);
// * Post is returned by search, since it's not archived anymore
cy.get('#searchContainer').should('be.visible');
@@ -96,7 +96,7 @@ describe('archive tests while preventing viewing archived channels', () => {
// # Archive dialogue message reads "This will archive the channel from the team and make its contents inaccessible for all users" (Mobile dialogue makes no mention of the data will be accessible)
cy.uiGetSearchContainer().click();
cy.uiGetSearchBox().first().clear().type(`${testArchivedMessage}{enter}`);
cy.uiGetSearchBox().clear().type(`${testArchivedMessage}{enter}`);
// * Post is not returned by search
cy.get('#searchContainer').should('be.visible');
@@ -112,7 +112,7 @@ describe('archive tests while preventing viewing archived channels', () => {
// # Search for the string of text from step 1
cy.uiGetSearchContainer().click();
cy.uiGetSearchBox().first().clear().type(`${messageText}{enter}`);
cy.uiGetSearchBox().clear().type(`${messageText}{enter}`);
// * Post is returned by search, since it's not archived anymore
cy.get('#searchContainer').should('be.visible');
@@ -131,7 +131,7 @@ describe('archive tests while preventing viewing archived channels', () => {
// # Archive a channel and make a mental note of the channel name
// # Type "in:" and note the list of channels that appear
cy.uiGetSearchContainer().click();
cy.uiGetSearchBox().first().clear().type(`in:${testChannel.name}`);
cy.uiGetSearchBox().clear().type(`in:${testChannel.name}`);
cy.findByTestId(testChannel.name).should('not.exist');
});
});

Просмотреть файл

@@ -42,7 +42,7 @@ describe('Leave an archived channel', () => {
// # Search for a post in an archived channel
cy.uiGetSearchContainer().click();
cy.uiGetSearchBox().first().clear().type(`${testArchivedMessage}{enter}`);
cy.uiGetSearchBox().clear().type(`${testArchivedMessage}{enter}`);
// # Open the archived channel by selecting Jump from search results and then selecting the link to move to the most recent posts in the channel
cy.uiGetSearchContainer().should('be.visible');
@@ -113,7 +113,7 @@ describe('Leave an archived channel', () => {
createArchivedChannel({prefix: 'archived-search-for'}, messageList).then(({name}) => {
// # Locate the post in a search
cy.uiGetSearchContainer().click();
cy.uiGetSearchBox().first().clear().type(`${messageList[1]}{enter}`);
cy.uiGetSearchBox().clear().type(`${messageList[1]}{enter}`);
// # Click jump to open an archive post in permalink view
cy.uiGetSearchContainer().should('be.visible');

Просмотреть файл

@@ -97,7 +97,7 @@ describe('Leave an archived channel', () => {
// # Search for content from an archived channel
cy.uiGetSearchContainer().click();
cy.uiGetSearchBox().first().clear().type(`${messageD}{enter}`);
cy.uiGetSearchBox().clear().type(`${messageD}{enter}`);
// # Open the channel from search results
cy.get('#searchContainer').should('be.visible');
@@ -109,7 +109,7 @@ describe('Leave an archived channel', () => {
// # Search for content from a different archived channel
cy.uiGetSearchContainer().click();
cy.uiGetSearchBox().first().clear().type(`${messageC}{enter}`);
cy.uiGetSearchBox().clear().type(`${messageC}{enter}`);
// # Open the channel from search result by clicking Jump
cy.get('#searchContainer').should('be.visible').findByText('Jump').click().wait(TIMEOUTS.ONE_SEC);

Просмотреть файл

@@ -134,7 +134,7 @@ describe('Channel RHS', () => {
// # Enter the search terms and hit enter to start the search
cy.uiGetSearchContainer().click();
cy.uiGetSearchBox().first().clear().type(MESSAGES.TINY).type('{enter}');
cy.uiGetSearchBox().clear().type(MESSAGES.TINY).type('{enter}');
// * Verify that the search results is opened in RHS
verifyRHSisOpenAndHasTitle('Search Results');

Просмотреть файл

@@ -89,7 +89,7 @@ describe('Verify Accessibility Support in different input fields', () => {
cy.uiGetSearchBox().type('from:').wait(TIMEOUTS.ONE_SEC);
// # Trigger the user autocomplete again
cy.uiGetSearchBox().first().clear().type('from:').wait(TIMEOUTS.ONE_SEC).type('{downarrow}{downarrow}');
cy.uiGetSearchBox().clear().type('from:').wait(TIMEOUTS.ONE_SEC).type('{downarrow}{downarrow}');
// * Verify Accessibility Support in search autocomplete
verifySearchAutocomplete(2);
@@ -103,10 +103,10 @@ describe('Verify Accessibility Support in different input fields', () => {
verifySearchAutocomplete(3);
// # Type the in: filter and ensure channel list is cached once
cy.uiGetSearchBox().first().clear().type('in:').wait(TIMEOUTS.ONE_SEC);
cy.uiGetSearchBox().clear().type('in:').wait(TIMEOUTS.ONE_SEC);
// # Trigger the channel autocomplete again
cy.uiGetSearchBox().first().clear().type('in:').wait(TIMEOUTS.ONE_SEC).type('{downarrow}{downarrow}');
cy.uiGetSearchBox().clear().type('in:').wait(TIMEOUTS.ONE_SEC).type('{downarrow}{downarrow}');
// * Verify Accessibility Support in search autocomplete
verifySearchAutocomplete(2, 'channel');

Просмотреть файл

@@ -72,7 +72,7 @@ describe('Upload Files - Settings', () => {
cy.get('#searchHints').find('.search-hint__search-type-selector button > .icon-file-text-outline').should('not.exist');
// # Search for posts
cy.uiGetSearchBox().first().type('sample').type('{enter}');
cy.uiGetSearchBox().type('sample').type('{enter}');
// * Verify search results do not have File button
cy.get('.files-tab').should('not.exist');

Просмотреть файл

@@ -43,7 +43,7 @@ describe('Keyboard Shortcuts', () => {
it('MM-T1250 CTRL/CMD+SHIFT+L - Set focus to center channel message box (with SEARCH RHS open)', () => {
// # Search
cy.uiGetSearchContainer().click();
cy.uiGetSearchBox().first().type('test{enter}');
cy.uiGetSearchBox().type('test{enter}');
// * Wait for the RHS to open and the search results to appear
cy.contains('.sidebar--right__header', 'Search Results').should('be.visible');

Просмотреть файл

@@ -720,7 +720,7 @@ describe('Messaging', () => {
cy.getLastPostId().then((postId) => {
// # Search for the posted message
cy.uiGetSearchContainer().click();
cy.uiGetSearchBox().should('be.visible').first().type(messageX).type('{enter}').wait(TIMEOUTS.HALF_SEC);
cy.uiGetSearchBox().should('be.visible').type(messageX).type('{enter}').wait(TIMEOUTS.HALF_SEC);
// # Click on post dot menu so we can edit
cy.clickPostDotMenu(postId, 'SEARCH');

Просмотреть файл

@@ -55,7 +55,7 @@ describe('Message permalink', () => {
// # Search for a message in the current channel
cy.uiGetSearchContainer().click();
cy.uiGetSearchBox().first().clear().type('in:town-square').wait(TIMEOUTS.HALF_SEC).type('{enter}{enter}');
cy.uiGetSearchBox().clear().type('in:town-square').wait(TIMEOUTS.HALF_SEC).type('{enter}{enter}');
// # Jump to first permalink view (most recent message)
cy.get('.search-item__jump').first().click();
@@ -73,7 +73,7 @@ describe('Message permalink', () => {
// # Search for a message in the current channel
cy.uiGetSearchContainer().click();
cy.uiGetSearchBox().first().clear().type('in:town-square').wait(TIMEOUTS.HALF_SEC).type('{enter}{enter}');
cy.uiGetSearchBox().clear().type('in:town-square').wait(TIMEOUTS.HALF_SEC).type('{enter}{enter}');
// # Jump to first permalink view (most recent message)
cy.get('.search-item__jump').first().click();

Просмотреть файл

@@ -71,7 +71,7 @@ describe('Permalink message edit', () => {
// # Find searchWord and verify edited post
cy.uiGetSearchContainer().click();
cy.uiGetSearchBox().should('be.visible').first().type(searchWord).type('{enter}');
cy.uiGetSearchBox().should('be.visible').type(searchWord).type('{enter}');
cy.get('.search-item__jump').first().click();
// # Check if url include the permalink

Просмотреть файл

@@ -187,7 +187,7 @@ describe('Post PreHeader', () => {
// # Search for the channel.
cy.uiGetSearchContainer().click();
cy.uiGetSearchBox().first().type('test both pinned and saved {enter}');
cy.uiGetSearchBox().type('test both pinned and saved {enter}');
// * Check that the post pre-header has both pinned and saved links in RHS search results
cy.get('#searchContainer').should('be.visible').within(() => {

Просмотреть файл

@@ -26,7 +26,7 @@ describe('Search', () => {
cy.uiGetSearchContainer().click();
// # Write something on the input
cy.uiGetSearchBox().first().clear().wait(TIMEOUTS.HALF_SEC).type('abc').wait(TIMEOUTS.HALF_SEC).type('{enter}');
cy.uiGetSearchBox().clear().wait(TIMEOUTS.HALF_SEC).type('abc').wait(TIMEOUTS.HALF_SEC).type('{enter}');
cy.uiGetSearchContainer().click();
@@ -55,7 +55,7 @@ describe('Search', () => {
// * Verify search input field exists and not search button, as inputs contains placeholder not buttons/icons
// and then type in a search text
cy.uiGetSearchContainer().click();
cy.uiGetSearchBox().first().clear().wait(TIMEOUTS.HALF_SEC).type(searchText + '{enter}').wait(TIMEOUTS.HALF_SEC);
cy.uiGetSearchBox().clear().wait(TIMEOUTS.HALF_SEC).type(searchText + '{enter}').wait(TIMEOUTS.HALF_SEC);
// # Now click on the saved post button from the header
cy.uiGetSavedPostButton().click();

Просмотреть файл

@@ -48,7 +48,7 @@ describe('Search', () => {
// # Click on "x" displayed on searchbox
cy.uiGetSearchBox().parent().siblings('.input-clear-x').wait(TIMEOUTS.ONE_SEC).click({force: true});
cy.uiGetSearchBox().parents('[class*="SearchInputContainer"]').siblings('#searchHints').should('be.visible');
cy.uiGetSearchBox().first().focus().type('{esc}');
cy.uiGetSearchBox().focus().type('{esc}');
// # RHS should be visible with search results
cy.get('#search-items-container').should('be.visible');
@@ -134,7 +134,7 @@ describe('Search', () => {
assertSearchHint();
// # Clear search box
cy.uiGetSearchBox().get('.input-clear-x').first().click({force: true}).wait(TIMEOUTS.HALF_SEC);
cy.uiGetSearchBox().get('.input-clear-x').click({force: true}).wait(TIMEOUTS.HALF_SEC);
// # Search for search term in:town-square{enter}
cy.uiGetSearchBox().type('in:town-square').wait(TIMEOUTS.HALF_SEC);

Просмотреть файл

@@ -37,7 +37,7 @@ describe('Search', () => {
// # Search for "apple"
cy.uiGetSearchContainer().click();
cy.uiGetSearchBox().should('be.visible').first().type(apple).type('{enter}');
cy.uiGetSearchBox().should('be.visible').type(apple).type('{enter}');
// # Get last postId
cy.getLastPostId().as('lastPostId');
@@ -50,7 +50,7 @@ describe('Search', () => {
cy.uiGetSearchContainer().click();
// * Type banana on search box but don't hit search
cy.uiGetSearchBox().first().clear({force: true}).type(banana, {force: true});
cy.uiGetSearchBox().clear({force: true}).type(banana, {force: true});
// * Search result should not change and remain as one result with highlight still on apple
cy.get('@lastPostId').then((postId) => {

Просмотреть файл

@@ -68,7 +68,7 @@ describe('Search', () => {
//# Search for the message
cy.uiGetSearchContainer().should('be.visible').click();
cy.uiGetSearchBox().first().clear().type(`${message}{enter}`);
cy.uiGetSearchBox().clear().type(`${message}{enter}`);
// * Should return exactly one result from the group channel and matches the message
cy.findAllByTestId('search-item-container').should('be.visible').and('have.length', 1).within(() => {

Просмотреть файл

@@ -54,7 +54,7 @@ describe('Search Date Filter', () => {
// # Type before: in search field
cy.uiGetSearchContainer().should('be.visible').click();
cy.uiGetSearchBox().first().clear().type('before:');
cy.uiGetSearchBox().clear().type('before:');
// * Day picker should be visible
cy.get('.rdp').
@@ -74,7 +74,7 @@ describe('Search Date Filter', () => {
cy.uiGetSearchBox().parent('.input-wrapper').siblings('.input-clear-x').click({force: true});
// * The "x" to clear the search query has disappeared
cy.uiGetSearchBox().first().should('have.value', '');
cy.uiGetSearchBox().should('have.value', '');
cy.uiGetSearchContainer().should('be.visible').click();
});
@@ -84,7 +84,7 @@ describe('Search Date Filter', () => {
// # Type before: in search field
cy.uiGetSearchContainer().should('be.visible').click();
cy.uiGetSearchBox().first().clear().type('before:');
cy.uiGetSearchBox().clear().type('before:');
// * Date picker should be visible
cy.get('.rdp').
@@ -135,7 +135,7 @@ describe('Search Date Filter', () => {
should('have.value', '');
// # Enter query to search box and then click "x" to the right of the search term
cy.uiGetSearchBox().first().clear().wait(TIMEOUTS.HALF_SEC).type(queryString);
cy.uiGetSearchBox().clear().wait(TIMEOUTS.HALF_SEC).type(queryString);
cy.uiGetSearchBox().parent('.input-wrapper').siblings('.input-clear-x').click({force: true});
// * The "x" to clear the search query has disappeared

Просмотреть файл

@@ -66,7 +66,7 @@ describe('Negative search filters will omit results', () => {
function search(query) {
cy.reload();
cy.uiGetSearchContainer().should('be.visible').click();
cy.uiGetSearchBox().first().clear().wait(TIMEOUTS.HALF_SEC).type(query).wait(TIMEOUTS.HALF_SEC).type('{enter}');
cy.uiGetSearchBox().clear().wait(TIMEOUTS.HALF_SEC).type(query).wait(TIMEOUTS.HALF_SEC).type('{enter}');
cy.get('#loadingSpinner').should('not.exist');
cy.uiGetRHSSearchContainer();