Adds a server-shared Vitest project with isolate disabled and moves every
server test into it by default. Files that mock or reset modules opt out
with a header marker and stay in the isolated project.
Restores env values that leaked between files: the test URL is reset after
each file, and tests that mutate env restore the previous value. The test
server no longer closes the shared sequelize pool.
* Reduce server memory usage and add container memory best practices
Profiling a full-service boot showed ~300MB RSS per service process, much
of it client-only dependencies pulled into the server module graph, and no
heap limits applied in containers:
- Import date-fns locales individually rather than via the locale index,
which loaded all ~90 locales into every process
- Load @sentry/react dynamically in insertFiles so the browser Sentry SDK
stays out of the server-side editor graph
- Replace class-validator isHexColor with the existing validateColorHex
in the Highlight mark
- Extract icon names into a standalone IconNames module so server-side
schema validation no longer imports Font Awesome icon packs, with a
test to keep it in sync with IconLibrary
- Require S3Storage lazily so the AWS SDK and native CRT binding are only
loaded when S3 file storage is configured
- Default each forked service process to a V8 heap limit derived from the
cgroup memory constraint, preventing several processes from together
committing more memory than the container allows
- Cap glibc malloc arenas in the Docker image to reduce resident memory
fragmentation in multi-threaded processes
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016YMX5ReGHyxrR4ZE5ZbaXa
* Require both file storage backends lazily for consistency
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016YMX5ReGHyxrR4ZE5ZbaXa
* Load AWS SDK via dynamic imports compatible with test environment
Requiring the storage TypeScript modules lazily broke under Vitest, which
cannot resolve require() of source files and does not apply vi.mock to
bare requires. Move the laziness into S3Storage instead: the module is
imported statically, and the AWS SDK packages are loaded with dynamic
imports on first use, including deferred creation of the S3 client.
Also address review feedback: handle rejection of the dynamic Sentry
import, and warn when the minimum per-process heap limit exceeds the
memory budget of the container.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016YMX5ReGHyxrR4ZE5ZbaXa
* Consolidate S3 SDK loading into a single lazy accessor
The commands are loaded together with the client in getS3() rather than
as separate dynamic imports per method. The global S3Client test mock is
now a class, as a mock function is not constructable when reached through
a dynamic import.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016YMX5ReGHyxrR4ZE5ZbaXa
---------
Co-authored-by: Claude <noreply@anthropic.com>
* fix(test): restore plugin loading under Vite 8
Vite 8 dropped support for extglob negation (`!(...)`) in glob patterns,
so the test setup's plugin glob matched zero files and no plugin routes
were registered, causing every plugin API test to 404. Use Vite's
array-with-negative-patterns syntax to exclude test and schema files.
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
* wip
* Remove obsolete snapshots
* simplify
* chore(test): Convert mocks to TypeScript and tighten fetch mock types
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* Remove unneccessary patches
* Migrate to msw instead of custom fetch mock
* Address PR review comments
- Split chained vi.useFakeTimers().setSystemTime() into separate calls.
- Switch test setup to dynamic imports so EventEmitter.defaultMaxListeners
assignment runs before module init (static imports were hoisted above it).
- Drop redundant NODE_ENV guard in monkeyPatchSequelizeErrorsForJest; its
sole caller already gates on env.isTest.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
* chore(test): drop no-op per-test Redis flushall
The afterEach created a fresh ioredis-mock client and flushed it, which
doesn't clear state held by clients elsewhere in the test. Removing the
hook saves a few ms across thousands of test cases.
* Cache Jest transform cache
* chore: Update modelcontextprotocol
* fix: Restore native Web API classes after jest-fetch-mock setup
jest-fetch-mock replaces globalThis.Response with a cross-fetch polyfill
that doesn't support Web Streams (ReadableStream bodies become Buffers).
The MCP SDK's @hono/node-server adapter calls response.body.getReader()
which fails with the polyfilled Response. Since dontMock() is already
called, preserving the native classes is the correct behavior.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
* fix: public env vars using decorator
* fix: relocate
* fix: use env.public
* fix: register public env vars across plugins
* fix: test
* fix: tsc
* fix: mark remaining ones as public
* fix: move oidc ones to plugin
* fix: prevent overwrite
* fix: review
* chore: refactor server test setup
* Close dangling redis connections instead of mocking rate limiter
specific modules
* Segregate pre and post env test setup
* fix: remove mock file
Fixes#3412
Previously the only way to restrict the domains for a Team were with the ALLOWED_DOMAINS environment variable for self hosted instances.
This PR migrates this to be a database backed setting on the Team object. This is done through the creation of a TeamDomain model that is associated with the Team and contains the domain name
This settings is updated on the Security Tab. Here domains can be added or removed from the Team.
On the server side, we take the code paths that previously were using ALLOWED_DOMAINS and switched them to use the Team allowed domains instead
This PR moves the entire project to Typescript. Due to the ~1000 ignores this will lead to a messy codebase for a while, but the churn is worth it – all of those ignore comments are places that were never type-safe previously.
closes#1282