Files
actual/packages/desktop-client/src/setupTests.ts
3a894b1bf6 [AI] Reduce dependencies (lodash, ua-parser-js, memoize-one, promise-retry, resize-observer polyfill) (#8278)
* [AI] Reduce dependencies (lodash, ua-parser-js, memoize-one, promise-retry, resize-observer polyfill)

Remove or replace several low-usage / native-coverable dependencies to shrink
the dependency surface and transitive deps:

- lodash -> es-toolkit (es-toolkit/compat) for the 5 functions in use
  (debounce, keyBy, isMatch, isEqual, uniqueId)
- ua-parser-js -> inline UA regex checks in loot-core shared/platform
- memoize-one -> small local memoizeOne helper in loot-core shared
- promise-retry -> small local retry helper (loot-core shared + a local copy
  in desktop-electron, which loads compiled JS at runtime)
- @juggle/resize-observer polyfill removed; native ResizeObserver is supported
  by all current targets

uuid was intentionally left untouched: crypto.randomUUID is only available in
secure contexts, which would break self-hosted instances served over plain HTTP
(including loot-core code running in the browser web worker).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JdZrw7VVwyF6VJgb34U9Qo

* [AI] Use es-toolkit main entry for keyBy in report spreadsheets

The two report spreadsheet files only used keyBy from es-toolkit/compat. Switch
them to the lighter main es-toolkit entry (which takes a key function instead of
a string), so these chunks no longer pull in the compat layer. Runtime behavior
is identical.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JdZrw7VVwyF6VJgb34U9Qo

* [AI] Rename release note to slug and reword for readability

Rename the dependency-reduction release note from the guessed PR number to a
descriptive slug, and reword the body to read clearly as changelog content.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JdZrw7VVwyF6VJgb34U9Qo

* [AI] Shorten release note wording

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JdZrw7VVwyF6VJgb34U9Qo

* [AI] Harden retry helper against sync throws; simplify memoizeOne typing

- retry: run fn inside a promise chain so synchronous throws (and synchronous
  retry() calls) are routed through the rejection handler instead of escaping
  uncaught. Applied to both loot-core and desktop-electron copies.
- memoizeOne: use separate Args/Result generics and drop the `as T` cast.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JdZrw7VVwyF6VJgb34U9Qo

* [AI] Update yarn.lock after merge and install

Co-authored-by: Matiss Janis Aboltins <MatissJanis@users.noreply.github.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Matiss Janis Aboltins <MatissJanis@users.noreply.github.com>
2026-06-21 20:06:15 +00:00

41 lines
876 B
TypeScript

import '@testing-library/jest-dom';
import type { ReactNode } from 'react';
import { resetTestProviders } from './mocks';
global.IS_TESTING = true;
global.Actual = {} as typeof global.Actual;
type Size = { height: number; width: number };
type AutoSizerProps = {
renderProp?: (size: Size) => ReactNode;
children?: (size: Size) => ReactNode;
};
vi.mock('react-virtualized-auto-sizer', () => {
const AutoSizer = (props: AutoSizerProps) => {
const render = props.renderProp ?? props.children;
return render ? render({ height: 1000, width: 600 }) : null;
};
return {
AutoSizer,
default: AutoSizer,
};
});
global.Date.now = () => 123456789;
global.__resetWorld = () => {
resetTestProviders();
};
process.on('unhandledRejection', (reason: unknown) => {
console.error('REJECTION', reason);
});
afterEach(() => {
global.__resetWorld();
});