From 24314874f5ba18b7f54f6fecb0a5231a544f7411 Mon Sep 17 00:00:00 2001 From: "Mat.Busby" Date: Thu, 19 Dec 2024 16:10:40 -0700 Subject: [PATCH] update snapshots --- .../src/redux/reducers/partiesReducer.ts | 2 +- .../resources/test_user_list_resource.py | 40 +++++++++ .../Forms/PermitAmendmentForm.spec.js | 8 +- .../Forms/Securities/BondForm.spec.js | 2 +- .../__snapshots__/BondForm.spec.js.snap | 2 +- .../AddPartyRelationshipForm.spec.js.snap | 2 +- .../__snapshots__/AddPermitForm.spec.js.snap | 85 +++++++------------ .../AddTailingsForm.spec.js.snap | 2 +- .../PermitAmendmentForm.spec.js.snap | 2 +- .../common/PartySelectField.spec.js | 26 ------ .../common/PartySelectField.spec.tsx | 25 ++++++ .../PartySelectField.spec.js.snap | 54 ------------ .../PartySelectField.spec.tsx.snap | 21 +++++ 13 files changed, 131 insertions(+), 140 deletions(-) create mode 100644 services/core-api/tests/users/resources/test_user_list_resource.py delete mode 100644 services/core-web/src/tests/components/common/PartySelectField.spec.js create mode 100644 services/core-web/src/tests/components/common/PartySelectField.spec.tsx delete mode 100644 services/core-web/src/tests/components/common/__snapshots__/PartySelectField.spec.js.snap create mode 100644 services/core-web/src/tests/components/common/__snapshots__/PartySelectField.spec.tsx.snap diff --git a/services/common/src/redux/reducers/partiesReducer.ts b/services/common/src/redux/reducers/partiesReducer.ts index 8e6a0429d4..cdb79b5b6a 100644 --- a/services/common/src/redux/reducers/partiesReducer.ts +++ b/services/common/src/redux/reducers/partiesReducer.ts @@ -3,7 +3,7 @@ import * as actionTypes from "@mds/common/constants/actionTypes"; import { PARTIES } from "@mds/common/constants/reducerTypes"; import { createItemMap, createItemIdsArray } from "../utils/helpers"; import { RootState } from "@mds/common/redux/rootState"; -import { IParty, ItemMap, IPartyAppt, IPageData, IAddPartyFormState, IOption } from "@mds/common"; +import { IParty, ItemMap, IPartyAppt, IPageData, IAddPartyFormState, IOption } from "@mds/common/interfaces"; /** * @file partiesReducer.js diff --git a/services/core-api/tests/users/resources/test_user_list_resource.py b/services/core-api/tests/users/resources/test_user_list_resource.py new file mode 100644 index 0000000000..c8adc5dd3e --- /dev/null +++ b/services/core-api/tests/users/resources/test_user_list_resource.py @@ -0,0 +1,40 @@ +import pytest +import json + +from tests.factories import UserFactory + + +def test_get_users_list_with_search_term(test_client, db_session, auth_headers): + """Test retrieving a list of users matching a search term.""" + # Create a batch of users + UserFactory.create_batch(size=3) + + # Create a specific user we want to match with the search term + user_to_match = UserFactory(given_name="SpecificName", family_name="Match") + + # Send a GET request with the search term + search_term = "SpecificName" + get_resp = test_client.get(f'/users?search_term={search_term}', headers=auth_headers['full_auth_header']) + get_data = json.loads(get_resp.data.decode()) + + # Assert the status code and results + assert get_resp.status_code == 200, get_resp.response + assert len(get_data) == 1 + assert get_data[0]['given_name'] == user_to_match.given_name + assert get_data[0]['family_name'] == user_to_match.family_name + assert get_data[0]['email'] == user_to_match.email + + +def test_get_users_list_no_results_found(test_client, db_session, auth_headers): + """Test retrieving an empty list when no users match the search term.""" + # Create a batch of users + UserFactory.create_batch(size=5) + + # Send a GET request with a search term that doesn't match any users + search_term = "NonMatchingSearch" + get_resp = test_client.get(f'/users?search_term={search_term}', headers=auth_headers['full_auth_header']) + get_data = json.loads(get_resp.data.decode()) + + # Assert the status code and empty results + assert get_resp.status_code == 200, get_resp.response + assert len(get_data) == 0 \ No newline at end of file diff --git a/services/core-web/src/tests/components/Forms/PermitAmendmentForm.spec.js b/services/core-web/src/tests/components/Forms/PermitAmendmentForm.spec.js index e684581e2b..4a8894898b 100644 --- a/services/core-web/src/tests/components/Forms/PermitAmendmentForm.spec.js +++ b/services/core-web/src/tests/components/Forms/PermitAmendmentForm.spec.js @@ -26,7 +26,13 @@ beforeEach(() => { describe("PermitAmendmentForm", () => { it("renders properly", () => { - const component = shallow(); + const component = shallow( + + ); expect(component).toMatchSnapshot(); }); }); diff --git a/services/core-web/src/tests/components/Forms/Securities/BondForm.spec.js b/services/core-web/src/tests/components/Forms/Securities/BondForm.spec.js index 23b65ac2ae..5fa6defee4 100644 --- a/services/core-web/src/tests/components/Forms/Securities/BondForm.spec.js +++ b/services/core-web/src/tests/components/Forms/Securities/BondForm.spec.js @@ -28,7 +28,7 @@ beforeEach(() => { describe("BondForm", () => { it("renders properly", () => { - const component = shallow(); + const component = shallow(); expect(component).toMatchSnapshot(); }); }); diff --git a/services/core-web/src/tests/components/Forms/Securities/__snapshots__/BondForm.spec.js.snap b/services/core-web/src/tests/components/Forms/Securities/__snapshots__/BondForm.spec.js.snap index aca35a00f3..11abcd8fd2 100644 --- a/services/core-web/src/tests/components/Forms/Securities/__snapshots__/BondForm.spec.js.snap +++ b/services/core-web/src/tests/components/Forms/Securities/__snapshots__/BondForm.spec.js.snap @@ -77,7 +77,7 @@ exports[`BondForm renders properly 1`] = ` - - @@ -15,25 +13,19 @@ exports[`AddPermitForm renders properly 1`] = ` md={12} sm={24} > - - - - + + - - + + - - + + - - + + - - + + - + - - - +

- - + + - + - - +

- + `; diff --git a/services/core-web/src/tests/components/Forms/__snapshots__/AddTailingsForm.spec.js.snap b/services/core-web/src/tests/components/Forms/__snapshots__/AddTailingsForm.spec.js.snap index d7a71e4116..2db6eddcf9 100644 --- a/services/core-web/src/tests/components/Forms/__snapshots__/AddTailingsForm.spec.js.snap +++ b/services/core-web/src/tests/components/Forms/__snapshots__/AddTailingsForm.spec.js.snap @@ -147,7 +147,7 @@ exports[`AddTailingsForm renders properly 1`] = ` - - { - dispatchProps.fetchSearchResults = jest.fn(); -}; - -const setupProps = () => { - props.initialValues = { label: "Mock Party", value: "29489218432" }; -}; - -beforeEach(() => { - setupDispatchProps(); - setupProps(); -}); - -describe("PartySelectField", () => { - it("renders properly", () => { - const wrapper = shallow(); - expect(wrapper).toMatchSnapshot(); - }); -}); diff --git a/services/core-web/src/tests/components/common/PartySelectField.spec.tsx b/services/core-web/src/tests/components/common/PartySelectField.spec.tsx new file mode 100644 index 0000000000..e4ef40f4e3 --- /dev/null +++ b/services/core-web/src/tests/components/common/PartySelectField.spec.tsx @@ -0,0 +1,25 @@ +import React from "react"; +import { PartySelectField } from "@/components/common/PartySelectField"; +import { render } from "@testing-library/react"; +import { ReduxWrapper } from "@mds/common/tests/utils/ReduxWrapper"; +import { SEARCH, PARTIES } from "@mds/common/constants/reducerTypes"; +import * as MOCK from "@mds/common/tests/mocks/dataMocks"; +import FormWrapper from "@mds/common/components/forms/FormWrapper"; + +const initialState = { + [SEARCH]: { searchValues: { label: "Mock Party", value: "29489218432" } }, + [PARTIES]: MOCK.PARTY.parties[0], +}; + +describe("PartySelectField", () => { + it("renders properly", () => { + const { container } = render( + + + + + + ); + expect(container).toMatchSnapshot(); + }); +}); diff --git a/services/core-web/src/tests/components/common/__snapshots__/PartySelectField.spec.js.snap b/services/core-web/src/tests/components/common/__snapshots__/PartySelectField.spec.js.snap deleted file mode 100644 index ad2e766eee..0000000000 --- a/services/core-web/src/tests/components/common/__snapshots__/PartySelectField.spec.js.snap +++ /dev/null @@ -1,54 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`PartySelectField renders properly 1`] = ` - -`; diff --git a/services/core-web/src/tests/components/common/__snapshots__/PartySelectField.spec.tsx.snap b/services/core-web/src/tests/components/common/__snapshots__/PartySelectField.spec.tsx.snap new file mode 100644 index 0000000000..7ba0580a2c --- /dev/null +++ b/services/core-web/src/tests/components/common/__snapshots__/PartySelectField.spec.tsx.snap @@ -0,0 +1,21 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`PartySelectField renders properly 1`] = ` +
+
+
+ +
+ N/A +
+
+
+
+`;