chore:(public) added tests for listing add#6091
Conversation
✅ Deploy Preview for partners-bloom-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for bloom-angelopolis canceled.
|
✅ Deploy Preview for partners-bloom-msq2 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for bloom-public-seeds ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for bloom-exygy-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Pull request overview
Adds a new Jest/RTL test suite for the Partners “add listing” page to validate basic routing, authorization, and page rendering behavior.
Changes:
- Adds MSW-backed tests for
/listings/add. - Covers missing jurisdiction redirects, admin/jurisdictional admin access, partner denial, tabs, breadcrumbs, and
nonRegulatedquery rendering.
Comments suppressed due to low confidence (3)
sites/partners/tests/pages/listings/add.test.tsx:124
- This negative assertion runs immediately after
render, beforeAuthProviderhas finished loading the mocked profile. At that pointListingGuardrendersnullfor every user, so the test would pass even if a partner were incorrectly allowed once the async profile request resolves; wait for the profile/redirect state before asserting the page stays hidden.
const { queryByRole } = render(<NewListing />)
expect(queryByRole("heading", { name: "New listing" })).not.toBeInTheDocument()
sites/partners/tests/pages/listings/add.test.tsx:163
- This test does not actually exercise the
nonRegulatedbehavior: the mocked jurisdiction fromuserhas noenableNonRegulatedListingsfeature flag, and the assertions only check the same heading as the default render test. If the query param stopped setting the listing type, this test would still pass; enable the feature flag in the mock and assert the non-regulated state in the form.
it("should render the page with nonRegulated query param", async () => {
mockRouter({ jurisdictionId: JURISDICTION_ID, nonRegulated: "true" })
document.cookie = "access-token-available=True"
sites/partners/tests/pages/listings/add.test.tsx:82
- Because the test render wrapper only provides
AuthProvider(not the app'sRequireLogingate or a preloadedAuthContextprofile),ListingGuardseesprofileas undefined on the initial render and redirects to/unauthorizedbefore this happy-path assertion eventually passes. Seed the auth context or wrap the page the same way as_appso these tests verify the page renders without triggering an unauthorized redirect.
const { findByRole, getAllByText } = render(<NewListing />)
expect(await findByRole("heading", { name: "New listing" })).toBeInTheDocument()
| }), | ||
| rest.get("http://localhost/api/adapter/properties", (_req, res, ctx) => { | ||
| return res(ctx.json({ items: [], totalItems: 0, totalPages: 0 })) | ||
| }), |
| await new Promise((resolve) => setTimeout(resolve, 100)) | ||
| expect(replaceMock).toHaveBeenCalledWith("/") |
✅ Deploy Preview for bloom-exygy-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for bloom-angelopolis canceled.
|
✅ Deploy Preview for partners-bloom-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for bloom-public-seeds ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
This PR addresses #(insert-number-here)
Description
The purpose of this ticket is to add integration test to this file partners/src/pages/listings/add
How Can This Be Tested/Reviewed?
yarn test:unit __tests__/pages/listings/add.test.tsxAuthor Checklist:
yarn generate:clientand/or created a migration when requiredReview Process: