From b656df7d7273fabcb2b1f056dbc351e67f54eeb3 Mon Sep 17 00:00:00 2001 From: Fernando Terra <79578735+fterra-encora@users.noreply.github.com> Date: Mon, 28 Oct 2024 23:38:41 -0300 Subject: [PATCH] feat(fe:FSADT1-1523): Apply design styling to Search screen (#1282) * feat: add slot for custom item component on the Auto Complete * feat: customize predictive search result items * feat: allow custom size for Auto Complete * feat: display no results message * feat: update search-line paddings * feat: update placeholder color * fix: update function toTitleCase * test: display no results message * fix: prevent reading from undefined * chore: update stubs * fix: remove unnecessary css code --------- Co-authored-by: Maria Martinez <77364706+mamartinezmejia@users.noreply.github.com> --- frontend/cypress/e2e/pages/SearchPage.cy.ts | 34 ++- frontend/src/assets/styles/global.scss | 30 ++- .../forms/AutoCompleteInputComponent.vue | 19 +- frontend/src/dto/CommonTypesDto.ts | 4 + frontend/src/pages/SearchPage.vue | 54 +++-- frontend/src/services/ForestClientService.ts | 17 +- .../__files/response-client-search-page0.json | 4 +- .../services/ForestClientService.spec.ts | 197 ++++++++++-------- 8 files changed, 239 insertions(+), 120 deletions(-) diff --git a/frontend/cypress/e2e/pages/SearchPage.cy.ts b/frontend/cypress/e2e/pages/SearchPage.cy.ts index cfe6e589b5..a715a9b1b5 100644 --- a/frontend/cypress/e2e/pages/SearchPage.cy.ts +++ b/frontend/cypress/e2e/pages/SearchPage.cy.ts @@ -157,7 +157,7 @@ describe("Search Page", () => { .should("have.length.greaterThan", 0) .should("be.visible"); - cy.get("#search-box").find(`cds-combo-box-item[data-value^="${clientNumber}"]`).click(); + cy.get("#search-box").find(`cds-combo-box-item[data-id="${clientNumber}"]`).click(); }); it("navigates to the client details", () => { const greenDomain = "green-domain.com"; @@ -396,4 +396,36 @@ describe("Search Page", () => { }); }); }); + + describe("when the API finds no matching results", () => { + beforeEach(() => { + // The "empty" value actually triggers the empty array response + cy.fillFormEntry("#search-box", "empty"); + }); + describe("and user clicks the Search button", () => { + beforeEach(() => { + cy.get("#search-button").click(); + }); + + it('displays a "No results" message that includes the submitted search value', () => { + cy.wait("@fullSearch"); + + cy.contains("No results for “empty”"); + }); + + describe("and the user types something else in the search box but does not re-submit the full search", () => { + beforeEach(() => { + cy.wait("@fullSearch"); + + cy.fillFormEntry("#search-box", "other"); + }); + + it('still displays the "No results" message with the value that was previously submitted', () => { + cy.wait(200); + + cy.contains("No results for “empty”"); + }); + }); + }); + }); }); diff --git a/frontend/src/assets/styles/global.scss b/frontend/src/assets/styles/global.scss index 43e8aca81b..50681690d1 100644 --- a/frontend/src/assets/styles/global.scss +++ b/frontend/src/assets/styles/global.scss @@ -1641,14 +1641,42 @@ div.internal-grouping-01:has(svg.warning) span.body-compact-01 { } #search-line { + --lg-size: 3rem; + --padding-size: 2.5rem; + display: flex; - align-items: flex-end; + align-items: flex-start; + min-height: calc(var(--lg-size) + var(--padding-size)); + padding: 0 var(--padding-size); .grouping-02 { flex-grow: 1; } } +#search-box { + --row-height: 2.875rem; + + cds-combo-box-item { + block-size: var(--row-height); + } + + &::part(cds--combo-box), &::part(input) { + border-bottom-width: 0; + } + + &::part(input)::placeholder { + color: var(--light-theme-text-text-primary); + } +} + +.search-result-item { + display: flex; + gap: 1rem; + align-items: center; + margin: -0.0625rem 0; +} + #search-button { width: 7.875rem; } diff --git a/frontend/src/components/forms/AutoCompleteInputComponent.vue b/frontend/src/components/forms/AutoCompleteInputComponent.vue index a6a3833b83..c71f634a46 100644 --- a/frontend/src/components/forms/AutoCompleteInputComponent.vue +++ b/frontend/src/components/forms/AutoCompleteInputComponent.vue @@ -1,4 +1,4 @@ -