Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/pages/people/tabs/Wanted.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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<BountyType[]>([]);
const [loading, setIsLoading] = useState<boolean>(false);
const [page, setPage] = useState(1);
Expand Down Expand Up @@ -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}`);
}}
>
<WantedView {...w.body} person={person} />
Expand Down
6 changes: 5 additions & 1 deletion src/people/widgetViews/UserTicketsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
8 changes: 8 additions & 0 deletions src/people/widgetViews/__tests__/UserTicketsView.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) => <div>{text}</div>
}));

/**
* @jest-environment jsdom
*/
Expand Down