-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(FSADT1-1517): CLIENT3 increment (#1203)
- Loading branch information
1 parent
36efbe6
commit abb5d03
Showing
35 changed files
with
1,527 additions
and
86 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
10 changes: 10 additions & 0 deletions
10
backend/src/main/java/ca/bc/gov/app/dto/client/ClientListDto.java
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,10 @@ | ||
package ca.bc.gov.app.dto.client; | ||
|
||
public record ClientListDto( | ||
String clientNumber, | ||
String clientAcronym, | ||
String clientFullName, | ||
String clientType, | ||
String city, | ||
String clientStatus) { | ||
} |
13 changes: 13 additions & 0 deletions
13
backend/src/main/java/ca/bc/gov/app/exception/MissingRequiredParameterException.java
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,13 @@ | ||
package ca.bc.gov.app.exception; | ||
|
||
import org.springframework.http.HttpStatus; | ||
import org.springframework.web.bind.annotation.ResponseStatus; | ||
import org.springframework.web.server.ResponseStatusException; | ||
|
||
@ResponseStatus(HttpStatus.EXPECTATION_FAILED) | ||
public class MissingRequiredParameterException extends ResponseStatusException { | ||
public MissingRequiredParameterException(String parameterName) { | ||
super(HttpStatus.EXPECTATION_FAILED, | ||
String.format("Missing value for parameter %s", parameterName)); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
import type { ClientSearchResult } from "@/dto/CommonTypesDto"; | ||
|
||
describe("Search Page", () => { | ||
const predictiveSearchCounter = { | ||
count: 0, | ||
}; | ||
|
||
const checkDisplayedResults = (clientList: ClientSearchResult[]) => { | ||
clientList.forEach((client) => { | ||
cy.get("#search-box") | ||
.find(`cds-combo-box-item[data-value^="${client.clientNumber}"]`) | ||
.should("exist"); | ||
}); | ||
}; | ||
beforeEach(() => { | ||
// reset counter | ||
predictiveSearchCounter.count = 0; | ||
|
||
cy.intercept("/api/clients/search?keyword=*", (req) => { | ||
predictiveSearchCounter.count++; | ||
req.continue(); | ||
}).as("predictiveSearch"); | ||
|
||
cy.viewport(1920, 1080); | ||
cy.visit("/"); | ||
|
||
cy.login("[email protected]", "Uat Test", "idir", { | ||
given_name: "James", | ||
family_name: "Baxter", | ||
"cognito:groups": ["CLIENT_VIEWER"], | ||
}); | ||
|
||
// Check if the Client search button is visible | ||
cy.get("#menu-list-search").should("be.visible").click(); | ||
|
||
cy.get("h1").should("be.visible").should("contain", "Client search"); | ||
|
||
cy.window().then((win) => { | ||
cy.stub(win, "open").as("windowOpen"); | ||
}); | ||
}); | ||
|
||
describe("when user fills in the search box with a valid value", () => { | ||
beforeEach(() => { | ||
cy.fillFormEntry("#search-box", "car", { skipBlur: true }); | ||
}); | ||
|
||
it("makes the API call with the entered keywords", () => { | ||
cy.wait("@predictiveSearch").then((interception) => { | ||
expect(interception.request.query.keyword).to.eq("car"); | ||
}); | ||
cy.wrap(predictiveSearchCounter).its("count").should("eq", 1); | ||
}); | ||
|
||
it("displays autocomplete results", () => { | ||
cy.wait("@predictiveSearch").then((interception) => { | ||
const data = interception.response.body; | ||
|
||
cy.wrap(data).should("be.an", "array").and("have.length.greaterThan", 0); | ||
|
||
cy.get("#search-box") | ||
.find("cds-combo-box-item") | ||
.should("have.length", data.length) | ||
.should("be.visible"); | ||
|
||
checkDisplayedResults(data); | ||
}); | ||
}); | ||
|
||
describe("and types more characters", () => { | ||
beforeEach(() => { | ||
cy.wait("@predictiveSearch"); | ||
cy.fillFormEntry("#search-box", "d", { skipBlur: true }); | ||
}); | ||
|
||
it("makes another the API call with the updated keywords", () => { | ||
cy.wait("@predictiveSearch").then((interception) => { | ||
expect(interception.request.query.keyword).to.eq("card"); | ||
}); | ||
cy.wrap(predictiveSearchCounter).its("count").should("eq", 2); | ||
}); | ||
|
||
it("updates the autocomplete results", () => { | ||
cy.wait("@predictiveSearch").then((interception) => { | ||
const data = interception.response.body; | ||
|
||
cy.wrap(data).should("be.an", "array").and("have.length.greaterThan", 0); | ||
|
||
cy.get("#search-box") | ||
.find("cds-combo-box-item") | ||
.should("have.length", data.length) | ||
.should("be.visible"); | ||
|
||
checkDisplayedResults(data); | ||
}); | ||
}); | ||
}); | ||
|
||
describe("and user clicks a result", () => { | ||
const clientNumber = "00054076"; | ||
beforeEach(() => { | ||
cy.get("#search-box") | ||
.find("cds-combo-box-item") | ||
.should("have.length.greaterThan", 0) | ||
.should("be.visible"); | ||
|
||
cy.get("#search-box").find(`cds-combo-box-item[data-value^="${clientNumber}"]`).click(); | ||
}); | ||
it("navigates to the client details", () => { | ||
const greenDomain = "green-domain.com"; | ||
cy.get("@windowOpen").should( | ||
"be.calledWith", | ||
`https://${greenDomain}/int/client/client02MaintenanceAction.do?bean.clientNumber=${clientNumber}`, | ||
"_blank", | ||
"noopener", | ||
); | ||
}); | ||
}); | ||
}); | ||
|
||
describe("when user fills in the search box with an invalid value", () => { | ||
beforeEach(() => { | ||
cy.fillFormEntry("#search-box", "até", { skipBlur: true }); | ||
}); | ||
|
||
it("shows an error message", () => { | ||
cy.contains("The search terms can only contain: A-Z, a-z, 0-9, space or common symbols"); | ||
}); | ||
it("makes no API call", () => { | ||
cy.wait(500); // This time has to be greater than the debouncing time | ||
cy.wrap(predictiveSearchCounter).its("count").should("eq", 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
Oops, something went wrong.