-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(atomic): added textarea search box (#3118)
* feat(atomic): added text area * feat(atomic): added search text area * feat(atomic): added new buttons * feat(atomic): absolute positioning * feat(atomic): layout * feat(atomic): removed need for fixed height * feat(atomic): spacer in own function * feat(atomic): added full searchbox test suite * feat(atomic): added tsdoc for new prop * feat(atomic): udpated prop in test * Add generated files * feat(atomic): moved z-index out * feat(atomic): calling handlers * feat(atomic): apply new styles only when textarea prop * feat(atomic): feedback implementation * feat(atomic): feedback implementation * feat(atomic): fixed undefined parent error --------- Co-authored-by: GitHub Actions Bot <>
- Loading branch information
Showing
18 changed files
with
596 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 9 additions & 4 deletions
13
packages/atomic/cypress/e2e/search-box/search-box-assertions.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
159 changes: 159 additions & 0 deletions
159
packages/atomic/cypress/e2e/search-box/text-area-search-box.cypress.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
import { | ||
SafeStorage, | ||
StorageItems, | ||
} from '../../../src/utils/local-storage-utils'; | ||
import {RouteAlias} from '../../fixtures/fixture-common'; | ||
import {TestFixture} from '../../fixtures/test-fixture'; | ||
import * as CommonAssertions from '../common-assertions'; | ||
import {selectIdleCheckboxValueAt} from '../facets/facet-common-actions'; | ||
import * as FacetCommonAssertions from '../facets/facet-common-assertions'; | ||
import {addFacet, field} from '../facets/facet/facet-actions'; | ||
import {FacetSelectors} from '../facets/facet/facet-selectors'; | ||
import {addQuerySummary} from '../query-summary-actions'; | ||
import * as QuerySummaryAssertions from '../query-summary-assertions'; | ||
import { | ||
addSearchBox, | ||
AddSearchBoxOptions, | ||
typeSearchTextArea, | ||
} from './search-box-actions'; | ||
import * as SearchBoxAssertions from './search-box-assertions'; | ||
import {searchBoxComponent, SearchBoxSelectors} from './search-box-selectors'; | ||
|
||
const setSuggestions = (count: number) => () => { | ||
cy.intercept( | ||
{method: 'POST', path: '**/rest/search/v2/querySuggest?*'}, | ||
(request) => { | ||
request.reply((response) => { | ||
const newResponse = response.body; | ||
newResponse.completions = Array.from({length: count}, (_, i) => ({ | ||
expression: `query-suggestion-${i}`, | ||
executableConfidence: 0, | ||
highlighted: `Suggestion ${i}`, | ||
score: 0, | ||
})); | ||
response.send(200, newResponse); | ||
}); | ||
} | ||
).as(TestFixture.interceptAliases.QuerySuggestions.substring(1)); | ||
}; | ||
|
||
const setRecentQueries = (count: number) => () => { | ||
new SafeStorage().setJSON( | ||
StorageItems.RECENT_QUERIES, | ||
Array.from({length: count}, (_, i) => `Recent query ${i}`) | ||
); | ||
}; | ||
|
||
const addTextAreaSearchBox = (options: AddSearchBoxOptions = {}) => { | ||
const textAreaProp = {textarea: 'true'}; | ||
const props = options?.props | ||
? {...options.props, ...textAreaProp} | ||
: textAreaProp; | ||
return addSearchBox(options ? {...options, props} : {props}); | ||
}; | ||
|
||
describe('TextArea Search Box Test Suites', () => { | ||
describe('with no suggestions nor recentQueries', () => { | ||
beforeEach(() => { | ||
new TestFixture() | ||
.with(setSuggestions(0)) | ||
.with(setRecentQueries(0)) | ||
.with(addTextAreaSearchBox()) | ||
.init(); | ||
}); | ||
|
||
it('should be accessible', () => { | ||
SearchBoxSelectors.textArea().click(); | ||
CommonAssertions.assertAriaLiveMessage( | ||
SearchBoxSelectors.searchBoxAriaLive, | ||
' no ' | ||
); | ||
CommonAssertions.assertAccessibility(searchBoxComponent); | ||
}); | ||
}); | ||
|
||
describe('with default textarea search box', () => { | ||
beforeEach(() => { | ||
new TestFixture() | ||
.with(addTextAreaSearchBox()) | ||
.with(addQuerySummary()) | ||
.withoutFirstAutomaticSearch() | ||
.init(); | ||
SearchBoxSelectors.textArea().click(); | ||
SearchBoxSelectors.textArea().type('test{enter}', {force: true}); | ||
cy.wait(RouteAlias.UA); | ||
}); | ||
|
||
it('search button is enabled to start with', () => { | ||
SearchBoxSelectors.textArea().should('be.empty'); | ||
SearchBoxSelectors.submitButton().should('be.enabled'); | ||
}); | ||
|
||
CommonAssertions.assertConsoleError(false); | ||
}); | ||
|
||
describe('with disableSearch set to true', () => { | ||
beforeEach(() => { | ||
new TestFixture() | ||
.with( | ||
addTextAreaSearchBox({ | ||
props: { | ||
'disable-search': 'true', | ||
'minimum-query-length': 1, // disable-search should override this setting | ||
}, | ||
}) | ||
) | ||
.with(addQuerySummary()) | ||
.withoutFirstAutomaticSearch() | ||
.init(); | ||
}); | ||
|
||
it('should be accessible', () => { | ||
CommonAssertions.assertAccessibility(searchBoxComponent); | ||
}); | ||
|
||
it('there are no search suggestions or errors on query input', () => { | ||
typeSearchTextArea('test'); | ||
SearchBoxSelectors.submitButton().should('be.disabled'); | ||
SearchBoxAssertions.assertNoSuggestionGenerated(); | ||
QuerySummaryAssertions.assertHasPlaceholder(); | ||
CommonAssertions.assertConsoleError(false); | ||
}); | ||
}); | ||
|
||
describe('with a facet & clear-filters set to false', () => { | ||
beforeEach(() => { | ||
new TestFixture() | ||
.with(addTextAreaSearchBox({props: {'clear-filters': 'false'}})) | ||
.with(addFacet({field})) | ||
.init(); | ||
selectIdleCheckboxValueAt(FacetSelectors, 0); | ||
cy.wait(TestFixture.interceptAliases.Search); | ||
SearchBoxSelectors.submitButton().click({force: true}); | ||
cy.wait(TestFixture.interceptAliases.Search); | ||
}); | ||
|
||
FacetCommonAssertions.assertNumberOfSelectedCheckboxValues( | ||
FacetSelectors, | ||
1 | ||
); | ||
}); | ||
|
||
describe('with a facet & clear-filters set to true', () => { | ||
beforeEach(() => { | ||
new TestFixture() | ||
.with(addTextAreaSearchBox({props: {'clear-filters': 'true'}})) | ||
.with(addFacet({field})) | ||
.init(); | ||
selectIdleCheckboxValueAt(FacetSelectors, 0); | ||
cy.wait(TestFixture.interceptAliases.Search); | ||
SearchBoxSelectors.submitButton().click({force: true}); | ||
cy.wait(TestFixture.interceptAliases.Search); | ||
}); | ||
|
||
FacetCommonAssertions.assertNumberOfSelectedCheckboxValues( | ||
FacetSelectors, | ||
0 | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.