Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1945: Unit test card search params #1947

Open
wants to merge 2 commits into
base: 1799-card-generator-refactoring
Choose a base branch
from

Conversation

f1sh1918
Copy link
Contributor

@f1sh1918 f1sh1918 commented Feb 26, 2025

Short Description

Add unit tests for correctly initializing cards with searchParams.

Proposed Changes

  • add a unit test for each project to ensure that cards will be initialized correctly with all possible search params

Side Effects

  • none

Testing

N/A

Resolved Issues

Fixes: #1945

@f1sh1918 f1sh1918 force-pushed the 1945-unit-test-card-search-params branch from affc752 to aea1fc0 Compare February 26, 2025 16:02
@f1sh1918 f1sh1918 marked this pull request as ready for review February 26, 2025 16:04
Copy link
Member

@steffenkleinle steffenkleinle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, I like it 👍 You want to add the same tests for useSelfServiceCardGenerator? Also, there is no test yet for initializing applicationIdToMarkAsProcessed if you feel motivated.

@f1sh1918
Copy link
Contributor Author

applicationIdToMarkAsProcessed

I moved the test for koblenz to the selfService hook. Not sure if we need both tests, since normal card creation is disabled for koblenz.

I dunno how i should test this applicationId since it will not be set in the cards object.

@f1sh1918 f1sh1918 force-pushed the 1945-unit-test-card-search-params branch from 12ef720 to 9b1ff72 Compare February 28, 2025 10:35
Comment on lines +33 to +49
const wrapper = ({ children, initialRoutes }: { children: ReactNode; initialRoutes?: string[] }) => (
<MemoryRouter initialEntries={initialRoutes}>
<AppToasterProvider>
<MockedProvider mocks={mocks} addTypename={false}>
<ProjectConfigProvider projectConfig={koblenzConfig}>{children}</ProjectConfigProvider>
</MockedProvider>
</AppToasterProvider>
</MemoryRouter>
)

const withCustomWrapper =
(initialRoute: string) =>
({ children }: { children: ReactNode }) =>
wrapper({
children,
initialRoutes: [initialRoute],
})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙃 I guess we should make this reusable at some point to a shared testing file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes feel free to add a task for this

@steffenkleinle
Copy link
Member

I dunno how i should test this applicationId since it will not be set in the cards object.

You could mock the mutation and ensure that it was called with the application id from the query params.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants