feat(web): add groups page with RouteManager and route handler proxies

Implements the Groups & Routes admin page with a client-side RouteManager
component (add/delete sync routes via fetch), server-side groups page that
pre-fetches groups/routes from the API, and Next.js Route Handler proxies
for /api/routes (GET, POST) and /api/routes/[id] (DELETE). Adds a custom
jest environment that polyfills Node 18+ native fetch into the jsdom sandbox
so tests can use jest.spyOn(global, 'fetch').

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-28 01:37:13 +05:30
parent 71e2b0681c
commit 1389a65e18
8 changed files with 300 additions and 1 deletions
+22
View File
@@ -0,0 +1,22 @@
/**
* Custom Jest environment that extends jest-environment-jsdom and polyfills
* the Fetch API (fetch, Request, Response, Headers) from Node 18+'s native
* implementation. This lets tests spy on `global.fetch` with jest.spyOn.
*/
const JSDOMEnvironment = require('jest-environment-jsdom').default;
class CustomJSDOMEnvironment extends JSDOMEnvironment {
async setup() {
await super.setup();
// Node 18+ exposes fetch on globalThis; copy it into the jsdom sandbox.
if (typeof globalThis.fetch === 'function') {
this.global.fetch = globalThis.fetch.bind(globalThis);
this.global.Request = globalThis.Request;
this.global.Response = globalThis.Response;
this.global.Headers = globalThis.Headers;
}
}
}
module.exports = CustomJSDOMEnvironment;