Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

style([tolerant-fetch-json-additional-clients]): drop redundant parens in transformed test mocks

[._.]/ Adam Eivy982e50a5e676
diff --git a/server/services/civitaiSuggestions.test.js b/server/services/civitaiSuggestions.test.js
index 536a959b9a..9ce7b3932e 100644
--- a/server/services/civitaiSuggestions.test.js
+++ b/server/services/civitaiSuggestions.test.js
@@ -33,12 +33,12 @@ describe('getSuggestions', () => {
const fetchImpl = async (url) => {
// Curated direct fetches go through /models/<id>; search goes through /models?...
const m = url.match(/api\/v1\/models\/(\d+)$/);
- if (m) return { ok: true, status: 200, text: async () => JSON.stringify(buildModel(Number(m[1]), `Curated-${m[1]}`, 'Flux.1 D') )};
+ if (m) return { ok: true, status: 200, text: async () => JSON.stringify(buildModel(Number(m[1]), `Curated-${m[1]}`, 'Flux.1 D'))};
// Search endpoint — return a list with entries matching the requested baseModel.
const search = new URL(url);
const baseModels = search.searchParams.getAll('baseModels');
const items = baseModels.map((bm, i) => buildModel(9000 + i, `Top-${bm}-${i}`, bm));
- return { ok: true, status: 200, text: async () => JSON.stringify(({ items }) )};
+ return { ok: true, status: 200, text: async () => JSON.stringify({ items })};
};
const out = await svc.getSuggestions({ fetchImpl, limit: 5 });
expect(Array.isArray(out.curated)).toBe(true);
@@ -61,9 +61,9 @@ describe('getSuggestions', () => {
calls += 1;
// First curated call 404s; rest succeed.
if (calls === 1) return { ok: false, status: 404 };
- return { ok: true, status: 200, text: async () => JSON.stringify(buildModel(Number(m[1]), `Ok-${m[1]}`, 'Flux.1 D') )};
+ return { ok: true, status: 200, text: async () => JSON.stringify(buildModel(Number(m[1]), `Ok-${m[1]}`, 'Flux.1 D'))};
}
- return { ok: true, status: 200, text: async () => JSON.stringify(({ items: [buildModel(9999, 'Search', 'Flux.1 D')] }) )};
+ return { ok: true, status: 200, text: async () => JSON.stringify({ items: [buildModel(9999, 'Search', 'Flux.1 D')] })};
};
const out = await svc.getSuggestions({ fetchImpl });
// The first curated entry was dropped, but we should still have the others.
@@ -76,8 +76,8 @@ describe('getSuggestions', () => {
const fetchImpl = async (url) => {
calls += 1;
const m = url.match(/api\/v1\/models\/(\d+)$/);
- if (m) return { ok: true, status: 200, text: async () => JSON.stringify(buildModel(Number(m[1]), `Curated`, 'Flux.1 D') )};
- return { ok: true, status: 200, text: async () => JSON.stringify(({ items: [buildModel(1, 'Cached', 'Flux.1 D')] }) )};
+ if (m) return { ok: true, status: 200, text: async () => JSON.stringify(buildModel(Number(m[1]), `Curated`, 'Flux.1 D'))};
+ return { ok: true, status: 200, text: async () => JSON.stringify({ items: [buildModel(1, 'Cached', 'Flux.1 D')] })};
};
await svc.getSuggestions({ fetchImpl });
const callsAfterFirst = calls;
@@ -93,9 +93,9 @@ describe('getSuggestions', () => {
let fetchCalls = 0;
const fetchImpl = async (url) => {
const m = url.match(/api\/v1\/models\/(\d+)$/);
- if (m) return { ok: true, status: 200, text: async () => JSON.stringify(buildModel(Number(m[1]), `Curated`, 'Flux.1 D') )};
+ if (m) return { ok: true, status: 200, text: async () => JSON.stringify(buildModel(Number(m[1]), `Curated`, 'Flux.1 D'))};
fetchCalls += 1;
- return { ok: true, status: 200, text: async () => JSON.stringify(({ items: makeItems(24) }) )};
+ return { ok: true, status: 200, text: async () => JSON.stringify({ items: makeItems(24) })};
};
// First call uses limit=4 — cache is populated at MAX (24 entries).
@@ -117,9 +117,9 @@ describe('getSuggestions', () => {
let fetchCalls = 0;
const fetchImpl = async (url) => {
const m = url.match(/api\/v1\/models\/(\d+)$/);
- if (m) return { ok: true, status: 200, text: async () => JSON.stringify(buildModel(Number(m[1]), `Curated`, 'Flux.1 D') )};
+ if (m) return { ok: true, status: 200, text: async () => JSON.stringify(buildModel(Number(m[1]), `Curated`, 'Flux.1 D'))};
fetchCalls += 1;
- return { ok: true, status: 200, text: async () => JSON.stringify(({ items: makeItems(24) }) )};
+ return { ok: true, status: 200, text: async () => JSON.stringify({ items: makeItems(24) })};
};
// First call: limit=24 — populates cache with 24 cards.
@@ -141,8 +141,8 @@ describe('getSuggestions', () => {
const fetchImpl = async (url) => {
calls += 1;
const m = url.match(/api\/v1\/models\/(\d+)$/);
- if (m) return { ok: true, status: 200, text: async () => JSON.stringify(buildModel(Number(m[1]), `C`, 'Flux.1 D') )};
- return { ok: true, status: 200, text: async () => JSON.stringify(({ items: [] }) )};
+ if (m) return { ok: true, status: 200, text: async () => JSON.stringify(buildModel(Number(m[1]), `C`, 'Flux.1 D'))};
+ return { ok: true, status: 200, text: async () => JSON.stringify({ items: [] })};
};
await svc.getSuggestions({ fetchImpl });
const callsAfterFirst = calls;
@@ -158,7 +158,7 @@ describe('getSuggestions', () => {
return {
ok: true,
status: 200,
- text: async () => JSON.stringify(({
+ text: async () => JSON.stringify({
...buildModel(id, 'Multi', 'Flux.1 D'),
modelVersions: [
// Most recent (first) per family wins. Two flux2 versions —
@@ -171,10 +171,10 @@ describe('getSuggestions', () => {
// Unsupported base — shouldn't appear in installs
{ id: 50, baseModel: 'SDXL 1.0', files: [{ name: 's.safetensors', primary: true, sizeKB: 500 }] },
],
- })),
+ }),
};
}
- return { ok: true, status: 200, text: async () => JSON.stringify(({ items: [] }) )};
+ return { ok: true, status: 200, text: async () => JSON.stringify({ items: [] })};
};
const out = await svc.getSuggestions({ fetchImpl });
const card = out.curated[0];
@@ -198,16 +198,16 @@ describe('getSuggestions', () => {
return {
ok: true,
status: 200,
- text: async () => JSON.stringify(({
+ text: async () => JSON.stringify({
...buildModel(id, 'Multi', 'Flux.1 D'),
modelVersions: [
{ id: id * 10, baseModel: 'Flux.1 D', trainedWords: [], images: [], files: [{ name: 'a.safetensors', primary: true }] },
{ id: id * 10 + 1, baseModel: 'Flux.2', trainedWords: [], images: [], files: [{ name: 'b.safetensors', primary: true }] },
],
- })),
+ }),
};
}
- return { ok: true, status: 200, text: async () => JSON.stringify(({ items: [] }) )};
+ return { ok: true, status: 200, text: async () => JSON.stringify({ items: [] })};
};
const out = await svc.getSuggestions({ fetchImpl });
const card = out.curated[0];
diff --git a/server/services/loras.test.js b/server/services/loras.test.js
index 27a22a8a65..56513b2cce 100644
--- a/server/services/loras.test.js
+++ b/server/services/loras.test.js
@@ -220,7 +220,7 @@ describe('installFromCivitai', () => {
const fetchImpl = async (url) => {
calls.push(url);
if (url.startsWith('https://civitai.com/api/v1/models/2600698')) {
- return { ok: true, status: 200, text: async () => JSON.stringify(FAKE_MODEL )};
+ return { ok: true, status: 200, text: async () => JSON.stringify(FAKE_MODEL)};
}
if (url.startsWith('https://civitai.com/api/download/models/7')) {
// Return a Web ReadableStream so Readable.fromWeb can consume it.
@@ -250,7 +250,7 @@ describe('installFromCivitai', () => {
});
it('refuses to install non-LoRA model types', async () => {
- const fetchImpl = async () => ({ ok: true, status: 200, text: async () => JSON.stringify(({ ...FAKE_MODEL, type: 'Checkpoint' }) )});
+ const fetchImpl = async () => ({ ok: true, status: 200, text: async () => JSON.stringify({ ...FAKE_MODEL, type: 'Checkpoint' })});
await expect(
lorasService.installFromCivitai({ url: 'https://civitai.com/models/2600698' }, { fetchImpl }),
).rejects.toThrow(/not a LoRA/);
@@ -261,7 +261,7 @@ describe('installFromCivitai', () => {
// / lower-case variants are all the same family from diffusers' POV.
const fetchImpl = async (url) => {
if (url.startsWith('https://civitai.com/api/v1/models/')) {
- return { ok: true, status: 200, text: async () => JSON.stringify(({ ...FAKE_MODEL, type: 'DoRA' }) )};
+ return { ok: true, status: 200, text: async () => JSON.stringify({ ...FAKE_MODEL, type: 'DoRA' })};
}
const stream = new ReadableStream({ start(c) { c.enqueue(new Uint8Array(Buffer.from('w'))); c.close(); } });
return { ok: true, status: 200, body: stream };
@@ -275,7 +275,7 @@ describe('installFromCivitai', () => {
await fs.mkdir(tmpLoras, { recursive: true });
await fs.writeFile(join(tmpLoras, 'lora-realstagram-v7.safetensors'), 'pre-existing');
const fetchImpl = async (url) => {
- if (url.startsWith('https://civitai.com/api/v1/models/')) return { ok: true, status: 200, text: async () => JSON.stringify(FAKE_MODEL )};
+ if (url.startsWith('https://civitai.com/api/v1/models/')) return { ok: true, status: 200, text: async () => JSON.stringify(FAKE_MODEL)};
throw new Error(`should not download: ${url}`);
};
await expect(
@@ -285,7 +285,7 @@ describe('installFromCivitai', () => {
it('surfaces a friendly auth error when download is gated (no key)', async () => {
const fetchImpl = async (url) => {
- if (url.startsWith('https://civitai.com/api/v1/models/')) return { ok: true, status: 200, text: async () => JSON.stringify(FAKE_MODEL )};
+ if (url.startsWith('https://civitai.com/api/v1/models/')) return { ok: true, status: 200, text: async () => JSON.stringify(FAKE_MODEL)};
return { ok: false, status: 401, statusText: 'Unauthorized' };
};
await expect(
@@ -295,7 +295,7 @@ describe('installFromCivitai', () => {
it('surfaces a different auth error message when a key was provided but download still fails', async () => {
const fetchImpl = async (url) => {
- if (url.startsWith('https://civitai.com/api/v1/models/')) return { ok: true, status: 200, text: async () => JSON.stringify(FAKE_MODEL )};
+ if (url.startsWith('https://civitai.com/api/v1/models/')) return { ok: true, status: 200, text: async () => JSON.stringify(FAKE_MODEL)};
return { ok: false, status: 403, statusText: 'Forbidden' };
};
// Provide apiKey inline so hasApiKey=true
@@ -317,7 +317,7 @@ describe('installFromCivitai', () => {
const destFilename = 'lora-realstagram-v7.safetensors';
const fetchImpl = async (url) => {
- if (url.startsWith('https://civitai.com/api/v1/models/')) return { ok: true, status: 200, text: async () => JSON.stringify(FAKE_MODEL )};
+ if (url.startsWith('https://civitai.com/api/v1/models/')) return { ok: true, status: 200, text: async () => JSON.stringify(FAKE_MODEL)};
if (url.startsWith('https://civitai.com/api/download/models/7')) {
// Plant the dest file to simulate a concurrent install winning before
// our link() call — this is what makes link() return EEXIST.