fix(relativeTime): guard against Invalid Date producing NaN strings
Some checks failed
CI / Unit & Component Tests (pull_request) Failing after 2m36s
CI / OCR Service Tests (pull_request) Successful in 28s
CI / Backend Unit Tests (pull_request) Failing after 2m53s
CI / OCR Service Tests (push) Has been cancelled
CI / Backend Unit Tests (push) Has been cancelled
CI / Unit & Component Tests (push) Has started running
Some checks failed
CI / Unit & Component Tests (pull_request) Failing after 2m36s
CI / OCR Service Tests (pull_request) Successful in 28s
CI / Backend Unit Tests (pull_request) Failing after 2m53s
CI / OCR Service Tests (push) Has been cancelled
CI / Backend Unit Tests (push) Has been cancelled
CI / Unit & Component Tests (push) Has started running
If a row ever receives a malformed uploadedAt (e.g. manual SQL migration, backend regression), the helper now falls back to "vor 0 Minute(n)" rather than rendering "vor NaN Tag(en)" to the user. Addresses Nora's review suggestion. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit was merged in pull request #298.
This commit is contained in:
@@ -31,4 +31,11 @@ describe('relativeTimeDe', () => {
|
||||
expect(relativeTimeDe(NOW, NOW)).toMatch(/0/);
|
||||
expect(relativeTimeDe(NOW, NOW)).toMatch(/Minute/i);
|
||||
});
|
||||
|
||||
it('falls back to 0 minutes when the input Date is invalid', () => {
|
||||
const invalid = new Date('not-a-real-date');
|
||||
// Never crash the UI if the backend ever ships a malformed uploadedAt.
|
||||
expect(relativeTimeDe(invalid, NOW)).toMatch(/0/);
|
||||
expect(relativeTimeDe(invalid, NOW)).toMatch(/Minute/i);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user