fix(desktop): i18n ErrorBoundary fallback strings#59
Merged
Conversation
Contributor
There was a problem hiding this comment.
Findings
- [Minor] Missing regression test for localized ErrorBoundary fallback copy — this PR replaces hardcoded fallback text with i18n keys, but no Vitest coverage was added to lock this behavior. Without a test, hardcoded strings or missing keys can regress silently. Evidence:
apps/desktop/src/renderer/src/components/ErrorBoundary.tsx:107,apps/desktop/src/renderer/src/components/ErrorBoundary.tsx:113,packages/i18n/src/locales/en.json:375,packages/i18n/src/locales/zh-CN.json:374.
Suggested fix:// apps/desktop/src/renderer/src/components/ErrorBoundary.test.tsx it('renders localized fallback copy when child throws', () => { const Boom = () => { throw new Error('boom'); }; render( <I18nProvider locale="en"> <ErrorBoundary scope="Preview"> <Boom /> </ErrorBoundary> </I18nProvider> ); expect(screen.getByText('Preview crashed')).toBeInTheDocument(); expect(screen.getByRole('button', { name: 'Reload' })).toBeInTheDocument(); expect(screen.getByRole('button', { name: 'Copy stack' })).toBeInTheDocument(); });
Summary
- Review mode: initial
- 1 issue found (test coverage gap for this behavior change).
- Context limit:
docs/VISION.mdanddocs/PRINCIPLES.mdwere not found in repo/docs.
Testing
- Not run (automation)
open-codesign Bot
| onReset, | ||
| onCopyStack, | ||
| }: ErrorBoundaryFallbackProps): ReactNode { | ||
| const t = useT(); |
Contributor
There was a problem hiding this comment.
[Minor] Please add a Vitest regression test for this fallback path now that copy is i18n-driven. This guards against accidental reintroduction of hardcoded strings and missing locale keys for the error UI.
Suggested fix:
it('renders localized fallback copy when child throws', () => {
const Boom = () => {
throw new Error('boom');
};
render(
<I18nProvider locale="en">
<ErrorBoundary scope="Preview">
<Boom />
</ErrorBoundary>
</I18nProvider>
);
expect(screen.getByText('Preview crashed')).toBeInTheDocument();
expect(screen.getByRole('button', { name: 'Reload' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: 'Copy stack' })).toBeInTheDocument();
});
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ErrorBoundary fallback UI shipped hardcoded English ('crashed', 'Reload', 'Copy stack', body, '(no stack)') that bypassed the i18n layer — same pattern codex flagged on PRs #35, #47, #48, #49. Adds errorBoundary.* keys (en + zh-CN) and routes the fallback render through useT() via a function child component (since ErrorBoundary is class-based).