test: pin the rename re-checks and the refused-registry answers (release review)

The rename's checks inside mutateLinkedCases and the refused-registry
branches of rename and clone had no test: removing them left every
case route test green. A hook right after the folder move lands a link,
an unlink, a re-pointed entry or a torn file between the route's first
check and its registry write. Each new test fails when its check is
removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Codeman maintainer committed 2026-11-06 02:27:39 +01:00
1 parent 5929584ea4
commit 2ec739fd3a
2 files changed
+95 -1

No files matched your search

+15 -1
View File
@@ -20,7 +20,7 @@ import {
writeFileSync,
} from 'node:fs';
import { homedir, tmpdir } from 'node:os';
import { join } from 'node:path';
import { dirname, join } from 'node:path';
import { createRouteTestHarness } from './_route-test-utils.js';
import { registerCaseRoutes } from '../../src/web/routes/case-routes.js';
import { dataPath } from '../../src/config/instance.js';
@@ -178,6 +178,20 @@ describe.skipIf(!isGitAvailable())('POST /api/cases/clone with a custom folder',
expect(Object.keys(linked())).toEqual(['twin']);
});
it('a registry that is not a JSON object is a 409 that keeps the folder, names it and leaves the file alone', async () => {
const { app } = await createRouteTestHarness(registerCaseRoutes);
const target = join(workDir, 'refused');
mkdirSync(dirname(LINKED()), { recursive: true });
writeFileSync(LINKED(), '[]');
const res = await clone(app, { name: 'refused', repository: origin, path: target });
expect(res.statusCode).toBe(409);
expect(res.json().errorCode).toBe('CONFLICT');
expect(res.json().error).toContain(target);
expect(res.json().error).toContain('Use Link Existing');
expect(existsSync(join(target, 'README.md'))).toBe(true);
expect(readFileSync(LINKED(), 'utf8')).toBe('[]');
});
it('a direct clone whose git-slot wait times out leaves what was written into the folder meanwhile', async () => {
const target = join(workDir, 'queued');
mkdirSync(target);