Skip to content

chore:(public) added tests for listing add#6091

Open
millord wants to merge 3 commits into
mainfrom
4567/partners/src/pages/listings/add
Open

chore:(public) added tests for listing add#6091
millord wants to merge 3 commits into
mainfrom
4567/partners/src/pages/listings/add

Conversation

@millord

@millord millord commented Mar 20, 2026

Copy link
Copy Markdown
Collaborator

This PR addresses #(insert-number-here)

  • Addresses the issue in full
  • Addresses only certain aspects of the issue

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.tsx

Author Checklist:

  • Added QA notes to the issue with applicable URLs
  • Reviewed in a desktop view
  • Reviewed in a mobile view
  • Reviewed considering accessibility
  • Added tests covering the changes
  • Made corresponding changes to the documentation
  • Ran yarn generate:client and/or created a migration when required

Review Process:

  • Read and understand the issue
  • Ensure the author has added QA notes
  • Review the code itself from a style point of view
  • Pull the changes down locally and test that the acceptance criteria is met
  • Either (1) explicitly ask a clarifying question, (2) request changes, or (3) approve the PR, even if there are very small remaining changes, if you don't need to re-review after the updates

@netlify

netlify Bot commented Mar 20, 2026

Copy link
Copy Markdown

Deploy Preview for partners-bloom-dev ready!

Name Link
🔨 Latest commit 21bde09
🔍 Latest deploy log https://app.netlify.com/projects/partners-bloom-dev/deploys/69bdaf2d6b5600000845bd7a
😎 Deploy Preview https://deploy-preview-6091--partners-bloom-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Mar 20, 2026

Copy link
Copy Markdown

Deploy Preview for bloom-angelopolis canceled.

Name Link
🔨 Latest commit 21bde09
🔍 Latest deploy log https://app.netlify.com/projects/bloom-angelopolis/deploys/69bdaf2de27e530008c98a5d

@netlify

netlify Bot commented Mar 20, 2026

Copy link
Copy Markdown

Deploy Preview for partners-bloom-msq2 ready!

Name Link
🔨 Latest commit 21bde09
🔍 Latest deploy log https://app.netlify.com/projects/partners-bloom-msq2/deploys/69bdaf2dd23b460008883d33
😎 Deploy Preview https://deploy-preview-6091--partners-bloom-msq2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Mar 20, 2026

Copy link
Copy Markdown

Deploy Preview for bloom-public-seeds ready!

Name Link
🔨 Latest commit 21bde09
🔍 Latest deploy log https://app.netlify.com/projects/bloom-public-seeds/deploys/69bdaf2d18c9d80008185808
😎 Deploy Preview https://deploy-preview-6091--bloom-public-seeds.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Mar 20, 2026

Copy link
Copy Markdown

Deploy Preview for bloom-exygy-dev ready!

Name Link
🔨 Latest commit 21bde09
🔍 Latest deploy log https://app.netlify.com/projects/bloom-exygy-dev/deploys/69bdaf2c915dee00089ad626
😎 Deploy Preview https://deploy-preview-6091--bloom-exygy-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@millord millord marked this pull request as ready for review March 20, 2026 20:49
@millord millord added the 1 review needed Requires 1 more review before ready to merge label Mar 20, 2026
@emilyjablonski emilyjablonski requested a review from Copilot May 15, 2026 18:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 nonRegulated query rendering.
Comments suppressed due to low confidence (3)

sites/partners/tests/pages/listings/add.test.tsx:124

  • This negative assertion runs immediately after render, before AuthProvider has finished loading the mocked profile. At that point ListingGuard renders null for 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 nonRegulated behavior: the mocked jurisdiction from user has no enableNonRegulatedListings feature 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's RequireLogin gate or a preloaded AuthContext profile), ListingGuard sees profile as undefined on the initial render and redirects to /unauthorized before this happy-path assertion eventually passes. Seed the auth context or wrap the page the same way as _app so 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 }))
}),
Comment on lines +66 to +67
await new Promise((resolve) => setTimeout(resolve, 100))
expect(replaceMock).toHaveBeenCalledWith("/")
@netlify

netlify Bot commented Jun 2, 2026

Copy link
Copy Markdown

Deploy Preview for bloom-exygy-dev ready!

Name Link
🔨 Latest commit 95984a0
🔍 Latest deploy log https://app.netlify.com/projects/bloom-exygy-dev/deploys/6a2b2392ea6124000815afd7
😎 Deploy Preview https://deploy-preview-6091--bloom-exygy-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Jun 2, 2026

Copy link
Copy Markdown

Deploy Preview for bloom-angelopolis canceled.

Name Link
🔨 Latest commit 95984a0
🔍 Latest deploy log https://app.netlify.com/projects/bloom-angelopolis/deploys/6a2b2392ea6124000815afdd

@netlify

netlify Bot commented Jun 2, 2026

Copy link
Copy Markdown

Deploy Preview for partners-bloom-dev ready!

Name Link
🔨 Latest commit 95984a0
🔍 Latest deploy log https://app.netlify.com/projects/partners-bloom-dev/deploys/6a2b2392a3146900085937c6
😎 Deploy Preview https://deploy-preview-6091--partners-bloom-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Jun 2, 2026

Copy link
Copy Markdown

Deploy Preview for bloom-public-seeds ready!

Name Link
🔨 Latest commit 95984a0
🔍 Latest deploy log https://app.netlify.com/projects/bloom-public-seeds/deploys/6a2b23921961a900088524fb
😎 Deploy Preview https://deploy-preview-6091--bloom-public-seeds.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

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

Labels

1 review needed Requires 1 more review before ready to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants