fix: avoid pending post cleanup crash

This commit is contained in:
Tommaso Casaburi
2026-07-04 23:13:49 +07:00
parent dad43a0830
commit 5111954081
2 changed files with 19 additions and 1 deletions
@@ -133,6 +133,22 @@ describe('PendingPost', () => {
expect(testState.navigateMock).not.toHaveBeenCalledWith('/not-found', { replace: true });
});
it('does not register the scroll helper return value as an effect cleanup', async () => {
scrollToMock.mockReturnValueOnce({});
testState.accountCommentIndex = '0';
testState.accountComments = [{}];
testState.post = {
communityAddress: 'music-posting.eth',
};
await renderPendingPost();
expect(() => {
act(() => root.unmount());
}).not.toThrow();
root = createRoot(container);
});
it('passes normalized numeric-string pending indices to the account comment lookup', async () => {
testState.accountCommentIndex = '01';
testState.accountComments = [{}, {}];
+3 -1
View File
@@ -61,7 +61,9 @@ const PendingPost = () => {
const isRetryingThisPendingPost = retryingAccountCommentIndex !== null && retryingAccountCommentIndex === normalizedAccountCommentIndex;
const lastPendingBoardRef = useRef<{ accountCommentIndex: number; boardPath: string } | null>(null);
useEffect(() => window.scrollTo(0, 0), []);
useEffect(() => {
window.scrollTo(0, 0);
}, []);
useEffect(() => {
if (typeof normalizedAccountCommentIndex === 'number' && pendingBoardPath) {