mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix: avoid pending post cleanup crash
This commit is contained in:
@@ -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 = [{}, {}];
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user