-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
95f27b2
commit 2431487
Showing
13 changed files
with
131 additions
and
140 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
40 changes: 40 additions & 0 deletions
40
services/core-api/tests/users/resources/test_user_list_resource.py
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,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 |
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
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
26 changes: 0 additions & 26 deletions
26
services/core-web/src/tests/components/common/PartySelectField.spec.js
This file was deleted.
Oops, something went wrong.
25 changes: 25 additions & 0 deletions
25
services/core-web/src/tests/components/common/PartySelectField.spec.tsx
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,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( | ||
<ReduxWrapper initialState={initialState}> | ||
<FormWrapper name="test_party_select" isEditMode={false} onSubmit={jest.fn()}> | ||
<PartySelectField validate={[]} allowAddingParties={true} name="test" /> | ||
</FormWrapper> | ||
</ReduxWrapper> | ||
); | ||
expect(container).toMatchSnapshot(); | ||
}); | ||
}); |
54 changes: 0 additions & 54 deletions
54
services/core-web/src/tests/components/common/__snapshots__/PartySelectField.spec.js.snap
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.