diff --git a/src/pages/people/tabs/Wanted.tsx b/src/pages/people/tabs/Wanted.tsx index e4d4e922e..63a2e0c96 100644 --- a/src/pages/people/tabs/Wanted.tsx +++ b/src/pages/people/tabs/Wanted.tsx @@ -8,7 +8,7 @@ import { PostBounty } from 'people/widgetViews/postBounty'; import WantedView from 'people/widgetViews/WantedView'; import PageLoadSpinner from 'people/utils/PageLoadSpinner'; import React, { useCallback, useEffect, useState } from 'react'; -import { Route, Switch, useRouteMatch, useParams } from 'react-router-dom'; +import { Route, Switch, useRouteMatch, useParams, useHistory } from 'react-router-dom'; import { useStores } from 'store'; import { paginationQueryLimit } from 'store/interface'; import styled from 'styled-components'; @@ -92,6 +92,7 @@ export const Wanted = observer(() => { const { person, canEdit } = usePerson(ui.selectedPerson); const { path, url } = useRouteMatch(); const { uuid } = useParams<{ uuid: string }>(); + const history = useHistory(); const [displayedBounties, setDisplayedBounties] = useState([]); const [loading, setIsLoading] = useState(false); const [page, setPage] = useState(1); @@ -172,7 +173,11 @@ export const Wanted = observer(() => { onClick={(e: any) => { e.preventDefault(); ui.setBountyPerson(person?.id); - window.open(`/bounty/${w.body.id}`, '_blank'); + // PAST: window.open(`/bounty/${w.body.id}`, '_blank'); + // ISSUE: Opening a new tab creates friction and prevents sharing the current URL easily. + // PRESENT: history.push(`/bounty/${w.body.id}`); + // RATIONALE: Navigating within the same tab updates the browser URL to the public bounty link, enabling users to easily copy and share the URL. + history.push(`/bounty/${w.body.id}`); }} > diff --git a/src/people/widgetViews/UserTicketsView.tsx b/src/people/widgetViews/UserTicketsView.tsx index 5bbe4409e..5c547f430 100644 --- a/src/people/widgetViews/UserTicketsView.tsx +++ b/src/people/widgetViews/UserTicketsView.tsx @@ -79,7 +79,11 @@ const UserTickets = () => { }; function onPanelClick(id: number) { - window.open(`/bounty/${id}`, '_blank'); + // PAST: window.open(`/bounty/${id}`, '_blank'); + // ISSUE: Opening a new tab creates friction and prevents sharing the current URL easily. + // PRESENT: history.push(`/bounty/${id}`); + // RATIONALE: Navigating within the same tab updates the browser URL to the public bounty link, enabling users to easily copy and share the URL. + history.push(`/bounty/${id}`); } const deleteTicket = async (payload: any) => { diff --git a/src/people/widgetViews/__tests__/UserTicketsView.spec.tsx b/src/people/widgetViews/__tests__/UserTicketsView.spec.tsx index eae04c18b..cd38105d0 100644 --- a/src/people/widgetViews/__tests__/UserTicketsView.spec.tsx +++ b/src/people/widgetViews/__tests__/UserTicketsView.spec.tsx @@ -17,6 +17,14 @@ beforeAll(() => { mockUsehistory(); }); +// PAST: No mock was provided for RenderMarkdown in this test file, which led to transitively loading ESM modules (remark-gfm, rehype-raw) and causing "SyntaxError: Cannot use import statement outside a module" in Jest. +// ISSUE: The Jest environment does not support ES Modules natively without complex transformer setups, causing tests to fail when trying to render markdown. +// PRESENT: Mocked the entire RenderMarkdown module to return a simple div rendering the text instead. +// RATIONALE: This eliminates the need to compile remark-gfm and rehype-raw, bypassing the SyntaxError and allowing the tests to run cleanly and quickly. +jest.mock('people/utils/RenderMarkdown', () => ({ + renderMarkdown: (text: any) =>
{text}
+})); + /** * @jest-environment jsdom */