Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

test(forge-gallery): cover the community feed boundary added with the gallery fix

nirholas5c1b295bc2f9
diff --git a/tests/api/forge-gallery-community.test.js b/tests/api/forge-gallery-community.test.js
index 63c3e7dad..b959c669f 100644
--- a/tests/api/forge-gallery-community.test.js
+++ b/tests/api/forge-gallery-community.test.js
@@ -125,6 +125,35 @@ describe('GET /api/forge-gallery?scope=community', () => {
expect(res.getHeader('cache-control')).toMatch(/s-maxage=\d+/);
});
+ // Regression: the anonymous copy is edge-cached for 60s (+300s stale) under the
+ // bare URL. Without a Vary on the header the body actually depends on, the edge
+ // served that copy to browsers that DID send x-forge-client, so every card came
+ // back voted=false for a voter who had already liked it. Observed live against
+ // three.ws before the fix.
+ it('varies the community feed on x-forge-client so the edge cannot serve the anonymous copy to a voter', async () => {
+ const res = mkRes();
+ await handler(mkReq('/api/forge-gallery?scope=community'), res);
+ expect(String(res.getHeader('vary') || '').toLowerCase()).toContain('x-forge-client');
+ });
+
+ it('varies on x-forge-client for the per-voter read too', async () => {
+ const res = mkRes();
+ await handler(mkReq('/api/forge-gallery?scope=community', { 'x-forge-client': 'browser-9' }), res);
+ expect(String(res.getHeader('vary') || '').toLowerCase()).toContain('x-forge-client');
+ });
+
+ // varyOn merges rather than replaces, so an Origin-varying CORS response keeps
+ // its own field. Dropping it would let a shared cache hand one origin's CORS
+ // headers to another.
+ it('keeps an existing Vary field when adding its own', async () => {
+ const res = mkRes();
+ res.setHeader('vary', 'origin');
+ await handler(mkReq('/api/forge-gallery?scope=community'), res);
+ const vary = String(res.getHeader('vary') || '').toLowerCase();
+ expect(vary).toContain('origin');
+ expect(vary).toContain('x-forge-client');
+ });
+
it('answers enabled:false when the deployment has no durable store', async () => {
storeEnabledMock.mockReturnValue(false);
const res = mkRes();