Skip to content

Commit

Permalink
feat(test): Dashboard tests (#1124)
Browse files Browse the repository at this point in the history
* added test for Dashboard
* refactored tests for SpasList and WaiversList to remove code duplication
* misc clean up
  • Loading branch information
thetif authored Feb 5, 2025
1 parent 89dba5b commit affc73b
Show file tree
Hide file tree
Showing 11 changed files with 744 additions and 1,306 deletions.
27 changes: 14 additions & 13 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,24 @@ jobs:
echo "ERROR: Your branch name, $STAGE_NAME, is not a valid Serverless Framework stage name." && exit 1
fi
test:
runs-on: ubuntu-20.04
needs:
- init
environment:
name: ${{ startsWith(github.ref_name, 'snyk-') && 'snyk' || github.ref_name }}
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: ./.github/actions/setup
- name: Test
run: run test

deploy:
runs-on: ubuntu-20.04
needs:
- init
- test
environment:
name: ${{ startsWith(github.ref_name, 'snyk-') && 'snyk' || github.ref_name }}
outputs:
Expand Down Expand Up @@ -96,19 +110,6 @@ jobs:
run: |
echo "Kibana URL: ${{ needs.deploy.outputs.kibana-url }}"
test:
runs-on: ubuntu-20.04
needs:
- init
environment:
name: ${{ startsWith(github.ref_name, 'snyk-') && 'snyk' || github.ref_name }}
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: ./.github/actions/setup
- name: Test
run: run test

e2e:
runs-on: ubuntu-20.04
needs:
Expand Down
2 changes: 1 addition & 1 deletion mocks/handlers/api/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const defaultApiSearchHandler = http.post<PathParams, SearchQueryBody>(
},
hits: {
total: {
value: 654,
value: itemList.length,
relation: "eq",
},
max_score: 1,
Expand Down
2 changes: 1 addition & 1 deletion react-app/src/components/ErrorAlert/ErrorAlert.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe("ErrorAlert", () => {
render(<ErrorAlert error={{} as ReactQueryApiError} />);

expect(screen.queryByText("Error")).toBeInTheDocument();
expect(screen.queryByText("An error has occured")).toBeInTheDocument();
expect(screen.queryByText("An error has occurred")).toBeInTheDocument();
});

it("renders with error message", () => {
Expand Down
2 changes: 1 addition & 1 deletion react-app/src/components/ErrorAlert/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { XCircleIcon } from "lucide-react";
import { ReactQueryApiError } from "shared-types";

export const ErrorAlert = ({ error }: { error: ReactQueryApiError }) => {
let message = "An error has occured";
let message = "An error has occurred";

if (error?.response?.data?.message) {
message = error.response.data.message;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ describe("FilterChips", () => {

it("should handle clearing all", async () => {
const { user } = setup(DEFAULT_FILTERS);
screen.debug();

await user.click(screen.getByText("Clear All").parentElement);
expect(screen.queryByText("State: Maryland, MD")).toBeNull();
expect(screen.queryByText("Authority: CHIP SPA")).toBeNull();
Expand Down
2 changes: 1 addition & 1 deletion react-app/src/components/Opensearch/main/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ describe("OsMainView", () => {
const recordsSelect = within(screen.getByTestId("pagination")).getByLabelText(
"Records per page:",
);
screen.debug(recordsSelect);

await user.selectOptions(recordsSelect, ["50"]);
expect(recordsSelect).toHaveValue("50");
const expectedQueryString = getDashboardQueryString({
Expand Down
Loading

0 comments on commit affc73b

Please sign in to comment.