mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix(mod queue): keep error details out of visible text
This commit is contained in:
@@ -421,10 +421,25 @@ describe('CommentContent', () => {
|
||||
});
|
||||
|
||||
const errorDisplay = container.querySelector('[data-testid="error-display"]');
|
||||
expect(errorDisplay?.textContent).toBe('Error');
|
||||
expect(errorDisplay?.getAttribute('data-display-message')).toBe('Error');
|
||||
expect(errorDisplay?.textContent).toBe('spam blocker server error');
|
||||
expect(errorDisplay?.getAttribute('data-display-message')).toBe('spam blocker server error');
|
||||
expect(errorDisplay?.getAttribute('data-inline')).toBe('true');
|
||||
expect(errorDisplay?.getAttribute('data-show-immediately')).toBe('true');
|
||||
expect(container.querySelector('[data-testid="loading-ellipsis"]')).toBeNull();
|
||||
});
|
||||
|
||||
it('falls back to a short label for failed unpublished comments without a message', async () => {
|
||||
testState.stateString = 'Failed';
|
||||
await renderContent({
|
||||
content: 'still pending',
|
||||
errors: [{ details: { provider: 'gateway', reason: 'timeout' } }],
|
||||
postCid: 'post-2',
|
||||
state: 'failed',
|
||||
});
|
||||
|
||||
const errorDisplay = container.querySelector('[data-testid="error-display"]');
|
||||
expect(errorDisplay?.textContent).toBe('Error');
|
||||
expect(errorDisplay?.getAttribute('data-display-message')).toBe('Error');
|
||||
expect(container.textContent).not.toContain('provider: gateway');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -18,6 +18,7 @@ import Tooltip from '../../components/tooltip';
|
||||
import styles from '../../views/post/post.module.css';
|
||||
import capitalize from 'lodash/capitalize';
|
||||
import { getCommentCommunityAddress, withResolvedCommentCommunityAddress } from '../../lib/utils/comment-utils';
|
||||
import { formatErrorMessageForDisplay } from '../../lib/utils/error-utils';
|
||||
|
||||
const QuotedCidLink = ({ cid, postCid }: { cid: string; postCid: string }) => {
|
||||
const quotedNumber = usePostNumberStore((state) => state.cidToNumber[cid]);
|
||||
@@ -131,12 +132,13 @@ const CommentContent = ({ comment: post, prependContent }: { comment: Comment; p
|
||||
const stateString = useStateString(resolvedPost);
|
||||
const hasFailedState = state === 'failed';
|
||||
const failedError = getFailedCommentError(resolvedPost);
|
||||
const failedErrorMessage = formatErrorMessageForDisplay(failedError);
|
||||
const shouldShowUnpublishedStateDetails = !cid && (!hasFailedState || Boolean(failedError));
|
||||
|
||||
const loadingString = (
|
||||
<div className={styles.stateString}>
|
||||
{failedError ? (
|
||||
<ErrorDisplay error={failedError} displayMessage={capitalize(t('error'))} inline={true} showImmediately={true} />
|
||||
<ErrorDisplay error={failedError} displayMessage={failedErrorMessage ?? capitalize(t('error'))} inline={true} showImmediately={true} />
|
||||
) : !hasFailedState ? (
|
||||
<LoadingEllipsis string={stateString || t('loading')} />
|
||||
) : (
|
||||
|
||||
Reference in New Issue
Block a user