@1agh/maude 0.58.0 → 0.58.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apps/studio/.ai/cache/_stats.json +1 -1
- package/apps/studio/acp/bridge.ts +165 -15
- package/apps/studio/artboard-hug-commit.ts +30 -0
- package/apps/studio/client/app.jsx +107 -33
- package/apps/studio/client/panels/ChatPanel.jsx +25 -2
- package/apps/studio/client/panels/timeline-media-cache.js +38 -2
- package/apps/studio/client/styles/6-acp-chat.css +12 -0
- package/apps/studio/clip-ops.ts +84 -35
- package/apps/studio/dist/client.bundle.js +899 -899
- package/apps/studio/dist/styles.css +1 -1
- package/apps/studio/sync/canvas-path.ts +329 -0
- package/apps/studio/sync/codec.ts +42 -0
- package/apps/studio/sync/index.ts +490 -17
- package/apps/studio/sync/projection.ts +11 -1
- package/apps/studio/sync/remote-docs.ts +122 -15
- package/apps/studio/test/acp-bridge-lifetime.test.ts +106 -0
- package/apps/studio/test/artboard-hug-commit.test.ts +36 -0
- package/apps/studio/test/clip-ops.test.ts +84 -2
- package/apps/studio/test/comment-relay-origin-gate.test.ts +117 -0
- package/apps/studio/test/comments-fs-rebroadcast.test.ts +155 -0
- package/apps/studio/test/fixtures/mock-acp-agent-wedged.mjs +37 -0
- package/apps/studio/test/sync-canvas-path.test.ts +200 -0
- package/apps/studio/test/sync-path-pull.test.ts +402 -0
- package/apps/studio/test/sync-remote-docs.test.ts +55 -3
- package/apps/studio/test/sync-runtime.test.ts +118 -0
- package/apps/studio/test/timeline-media-cache.test.ts +41 -0
- package/apps/studio/whats-new.json +9 -0
- package/package.json +8 -8
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
// Issue #74 — `_comments/<slug>.json` written DIRECTLY on disk must reach
|
|
2
|
+
// already-open shells over WS.
|
|
3
|
+
//
|
|
4
|
+
// This pins EXISTING behaviour rather than covering a fix. `/design:edit`
|
|
5
|
+
// resolves comments with a plain jq-rewrite of the comments file (edit.md §3's
|
|
6
|
+
// documented recipe), which bypasses api.commentsPatch and so never fires the
|
|
7
|
+
// `onCommentsChanged` re-broadcast in server.ts. The broadcast happens anyway,
|
|
8
|
+
// from collab/index.ts's `fs:any` re-seed ("the sidebar still needs the
|
|
9
|
+
// 'comments' bus emit, so keep that unconditionally") — a non-obvious owner
|
|
10
|
+
// that a reader of server.ts alone would conclude was missing.
|
|
11
|
+
//
|
|
12
|
+
// It is worth locking down because the chat panel's "Implement N comments"
|
|
13
|
+
// quick action (issue #74) is built on it: the agent resolves comments by
|
|
14
|
+
// direct write, and if that stopped reaching open shells the button would keep
|
|
15
|
+
// counting comments that are already done, with nothing else failing.
|
|
16
|
+
|
|
17
|
+
import { describe, expect, test } from 'bun:test';
|
|
18
|
+
import { mkdirSync, writeFileSync } from 'node:fs';
|
|
19
|
+
import { join } from 'node:path';
|
|
20
|
+
|
|
21
|
+
import { bootServer, killProc, makeSandbox, nextPort } from './_helpers.ts';
|
|
22
|
+
|
|
23
|
+
const FILE = '.design/ui/Foo.tsx';
|
|
24
|
+
const SLUG = 'ui-foo';
|
|
25
|
+
|
|
26
|
+
async function openWs(port: number): Promise<WebSocket> {
|
|
27
|
+
const ws = new WebSocket(`ws://localhost:${port}/_ws`);
|
|
28
|
+
await new Promise<void>((resolve, reject) => {
|
|
29
|
+
const t = setTimeout(() => reject(new Error('ws open timeout')), 2000);
|
|
30
|
+
ws.addEventListener('open', () => {
|
|
31
|
+
clearTimeout(t);
|
|
32
|
+
resolve();
|
|
33
|
+
});
|
|
34
|
+
ws.addEventListener('error', (e) => {
|
|
35
|
+
clearTimeout(t);
|
|
36
|
+
reject(e);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
return ws;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Resolve on the first `comments` frame for `file`, or null after `ms`. */
|
|
43
|
+
function nextCommentsFrame(
|
|
44
|
+
ws: WebSocket,
|
|
45
|
+
file: string,
|
|
46
|
+
ms = 5000
|
|
47
|
+
): Promise<{ file: string; comments: Array<{ id: string; status: string }> } | null> {
|
|
48
|
+
return new Promise((resolve) => {
|
|
49
|
+
const done = (v: never | null) => {
|
|
50
|
+
clearTimeout(timer);
|
|
51
|
+
ws.removeEventListener('message', onMsg);
|
|
52
|
+
resolve(v);
|
|
53
|
+
};
|
|
54
|
+
const timer = setTimeout(() => done(null), ms);
|
|
55
|
+
const onMsg = (ev: MessageEvent) => {
|
|
56
|
+
try {
|
|
57
|
+
const m = JSON.parse(String(ev.data));
|
|
58
|
+
if (m && m.type === 'comments' && m.file === file) done(m);
|
|
59
|
+
} catch {
|
|
60
|
+
/* non-JSON frame — ignore */
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
ws.addEventListener('message', onMsg);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function seedCanvas(designRoot: string) {
|
|
68
|
+
mkdirSync(join(designRoot, 'ui'), { recursive: true });
|
|
69
|
+
writeFileSync(join(designRoot, 'ui', 'Foo.tsx'), 'export default function P(){return <main/>}\n');
|
|
70
|
+
mkdirSync(join(designRoot, '_comments'), { recursive: true });
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function commentsJson(status: 'open' | 'resolved') {
|
|
74
|
+
return JSON.stringify(
|
|
75
|
+
[
|
|
76
|
+
{
|
|
77
|
+
id: 'c_one',
|
|
78
|
+
file: FILE,
|
|
79
|
+
selector: 'main',
|
|
80
|
+
dom_path: ['main'],
|
|
81
|
+
tag: 'main',
|
|
82
|
+
classes: '',
|
|
83
|
+
bounds: null,
|
|
84
|
+
html_excerpt: '',
|
|
85
|
+
text: 'tighten the padding',
|
|
86
|
+
status,
|
|
87
|
+
created: '2026-01-01T00:00:00.000Z',
|
|
88
|
+
resolved_at: status === 'resolved' ? '2026-01-02T00:00:00.000Z' : null,
|
|
89
|
+
author: 'Test User',
|
|
90
|
+
thread: [],
|
|
91
|
+
mentions: [],
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
null,
|
|
95
|
+
2
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
describe('issue #74 — comments file-watch re-broadcast', () => {
|
|
100
|
+
test('a direct resolve-write broadcasts the updated list to open shells', async () => {
|
|
101
|
+
const { root, designRoot } = makeSandbox();
|
|
102
|
+
const port = nextPort();
|
|
103
|
+
const proc = await bootServer(root, port);
|
|
104
|
+
try {
|
|
105
|
+
seedCanvas(designRoot);
|
|
106
|
+
const commentsFile = join(designRoot, '_comments', `${SLUG}.json`);
|
|
107
|
+
writeFileSync(commentsFile, commentsJson('open'));
|
|
108
|
+
|
|
109
|
+
const ws = await openWs(port);
|
|
110
|
+
// Clear the fs-watch per-path debounce window (50 ms) so the resolve
|
|
111
|
+
// write below is seen as its own event rather than folded into the seed.
|
|
112
|
+
await Bun.sleep(150);
|
|
113
|
+
|
|
114
|
+
const frame = nextCommentsFrame(ws, FILE);
|
|
115
|
+
// Exactly what edit.md §3's resolve recipe does: rewrite the file in
|
|
116
|
+
// place, never touching the API.
|
|
117
|
+
writeFileSync(commentsFile, commentsJson('resolved'));
|
|
118
|
+
|
|
119
|
+
const got = await frame;
|
|
120
|
+
ws.close();
|
|
121
|
+
|
|
122
|
+
expect(got).not.toBeNull();
|
|
123
|
+
expect(got!.comments).toHaveLength(1);
|
|
124
|
+
expect(got!.comments[0]!.id).toBe('c_one');
|
|
125
|
+
expect(got!.comments[0]!.status).toBe('resolved');
|
|
126
|
+
} finally {
|
|
127
|
+
await killProc(proc);
|
|
128
|
+
}
|
|
129
|
+
}, 20000);
|
|
130
|
+
|
|
131
|
+
test('a comments file for an unknown slug is ignored, not fatal', async () => {
|
|
132
|
+
const { root, designRoot } = makeSandbox();
|
|
133
|
+
const port = nextPort();
|
|
134
|
+
const proc = await bootServer(root, port);
|
|
135
|
+
try {
|
|
136
|
+
seedCanvas(designRoot);
|
|
137
|
+
const ws = await openWs(port);
|
|
138
|
+
await Bun.sleep(150);
|
|
139
|
+
|
|
140
|
+
// No canvas resolves to this slug — the handler must bail quietly and
|
|
141
|
+
// leave the server healthy.
|
|
142
|
+
writeFileSync(
|
|
143
|
+
join(designRoot, '_comments', 'ui-does-not-exist.json'),
|
|
144
|
+
JSON.stringify([], null, 2)
|
|
145
|
+
);
|
|
146
|
+
await Bun.sleep(400);
|
|
147
|
+
ws.close();
|
|
148
|
+
|
|
149
|
+
const health = await fetch(`http://localhost:${port}/_health`);
|
|
150
|
+
expect(health.ok).toBe(true);
|
|
151
|
+
} finally {
|
|
152
|
+
await killProc(proc);
|
|
153
|
+
}
|
|
154
|
+
}, 20000);
|
|
155
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
// A mock ACP agent that WEDGES on the FIRST turn only (issue-82): its
|
|
3
|
+
// `session/prompt` handler never resolves for call #1 — simulating a
|
|
4
|
+
// `claude` subprocess that has hung — and it never implements
|
|
5
|
+
// `session/cancel` at all, so a bridge that only sends the cooperative ACP
|
|
6
|
+
// `session/cancel` request and trusts it will hang forever, exactly like the
|
|
7
|
+
// reported "I clicked STOP and nothing happened" bug.
|
|
8
|
+
//
|
|
9
|
+
// Every call AFTER the first resolves normally and quickly — this lets a
|
|
10
|
+
// test start a second, overlapping `prompt()` on the same bridge/chat (the
|
|
11
|
+
// ethical-hacker's "no reentrancy guard" finding) and confirm that turn's
|
|
12
|
+
// ordinary completion doesn't blind `cancel()` to the still-wedged first one.
|
|
13
|
+
|
|
14
|
+
import { Readable, Writable } from 'node:stream';
|
|
15
|
+
|
|
16
|
+
import * as acp from '@agentclientprotocol/sdk';
|
|
17
|
+
|
|
18
|
+
const stream = acp.ndJsonStream(Writable.toWeb(process.stdout), Readable.toWeb(process.stdin));
|
|
19
|
+
|
|
20
|
+
let promptCalls = 0;
|
|
21
|
+
|
|
22
|
+
acp
|
|
23
|
+
.agent({ name: 'mock-acp-agent-wedged' })
|
|
24
|
+
.onRequest('initialize', () => ({
|
|
25
|
+
protocolVersion: acp.PROTOCOL_VERSION,
|
|
26
|
+
agentCapabilities: { loadSession: false },
|
|
27
|
+
}))
|
|
28
|
+
.onRequest('session/new', () => ({ sessionId: 'mock-wedged-session' }))
|
|
29
|
+
.onRequest('session/prompt', () => {
|
|
30
|
+
promptCalls += 1;
|
|
31
|
+
if (promptCalls === 1) return new Promise(() => {}); // never resolves, never rejects
|
|
32
|
+
return Promise.resolve({ stopReason: 'end_turn' });
|
|
33
|
+
})
|
|
34
|
+
// Deliberately NO `session/cancel` handler — an agent that never
|
|
35
|
+
// implemented turn-cancellation at all, the other real-world shape of
|
|
36
|
+
// "Stop does nothing".
|
|
37
|
+
.connect(stream);
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
// The traversal corpus, and the rule that makes the whole thing safe.
|
|
2
|
+
//
|
|
3
|
+
// `syncMeta.path` is hub-supplied input that chooses a DIRECTORY. Every case
|
|
4
|
+
// below is a way a path could try to be something other than "a canvas in this
|
|
5
|
+
// project", plus the one rule that closes the class rather than the instance:
|
|
6
|
+
// the path must slug back to the document carrying it.
|
|
7
|
+
|
|
8
|
+
import { describe, expect, it } from 'bun:test';
|
|
9
|
+
|
|
10
|
+
import { canvasSlugFromRel } from '../canvas-slug.ts';
|
|
11
|
+
import {
|
|
12
|
+
fallbackCanvasPath,
|
|
13
|
+
MAX_CANVAS_PATH_LEN,
|
|
14
|
+
resolveCanvasBodyRel,
|
|
15
|
+
validateCanvasPath,
|
|
16
|
+
} from '../sync/canvas-path.ts';
|
|
17
|
+
|
|
18
|
+
const GROUPS = [{ path: 'system' }, { path: 'ui' }];
|
|
19
|
+
|
|
20
|
+
/** Validate a path AGAINST THE SLUG IT WOULD REALLY CARRY, so a rejection is
|
|
21
|
+
* attributable to the rule under test and not to rule 7 firing first. */
|
|
22
|
+
function check(path: unknown, slug: string) {
|
|
23
|
+
return validateCanvasPath({ path, slug, designRel: '.design', canvasGroups: GROUPS });
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
describe('validateCanvasPath — what it accepts', () => {
|
|
27
|
+
it('accepts a genuinely nested canvas', () => {
|
|
28
|
+
const v = check('ui/2026/social/summer-camp.tsx', 'ui-2026-social-summer-camp');
|
|
29
|
+
expect(v).toEqual({ ok: true, rel: 'ui/2026/social/summer-camp.tsx' });
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('accepts a canvas directly in a group', () => {
|
|
33
|
+
expect(check('ui/Card.tsx', 'ui-card').ok).toBe(true);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('accepts the design-system group', () => {
|
|
37
|
+
expect(check('system/preview/logo.tsx', 'system-preview-logo').ok).toBe(true);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('accepts a filename with a space — they exist and they sync today', () => {
|
|
41
|
+
// The slug transform maps whitespace to `_`, so `Kanban App.tsx` is a real
|
|
42
|
+
// canvas with a real document. Refusing it here would silently relocate a
|
|
43
|
+
// file that works today.
|
|
44
|
+
expect(check('ui/Kanban App.tsx', 'ui-kanban_app').ok).toBe(true);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('is case-insensitive about the slug, like the slug transform', () => {
|
|
48
|
+
expect(check('ui/Card.tsx', 'UI-CARD').ok).toBe(true);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
describe('validateCanvasPath — the traversal corpus', () => {
|
|
53
|
+
const corpus: Array<[string, unknown, string]> = [
|
|
54
|
+
['parent traversal', '../../etc/passwd.tsx', 'anything'],
|
|
55
|
+
['traversal inside a group', 'ui/../../../tmp/x.tsx', 'anything'],
|
|
56
|
+
['a bare dot component', 'ui/./Card.tsx', 'ui-card'],
|
|
57
|
+
['absolute posix', '/etc/cron.d/x.tsx', 'anything'],
|
|
58
|
+
['windows drive', 'C:\\Windows\\x.tsx', 'anything'],
|
|
59
|
+
['UNC share', '\\\\host\\share\\x.tsx', 'anything'],
|
|
60
|
+
['a backslash smuggling a separator', 'ui\\..\\..\\x.tsx', 'anything'],
|
|
61
|
+
['an empty component', 'ui//Card.tsx', 'ui-card'],
|
|
62
|
+
['a trailing slash', 'ui/Card.tsx/', 'ui-card'],
|
|
63
|
+
['a NUL byte', 'ui/Card.tsx\u0000.png', 'ui-card'],
|
|
64
|
+
['a newline', 'ui/Ca\nrd.tsx', 'ui-card'],
|
|
65
|
+
['percent-encoded traversal', 'ui/%2e%2e/%2e%2e/x.tsx', 'anything'],
|
|
66
|
+
['a unicode dot lookalike as a component', 'ui/\u2024\u2024/x.tsx', 'anything'],
|
|
67
|
+
['a bidi override in a component', 'ui/Ca\u202erd.tsx', 'ui-card'],
|
|
68
|
+
['not a .tsx', 'ui/Card.html', 'ui-card'],
|
|
69
|
+
['no extension at all', 'ui/Card', 'ui-card'],
|
|
70
|
+
['an extra extension', 'ui/Card.tsx.png', 'ui-card'],
|
|
71
|
+
['a dotfile', 'ui/.env.tsx', 'anything'],
|
|
72
|
+
['at the design root, in no group', 'ui-card.tsx', 'ui-card'],
|
|
73
|
+
['outside every declared group', 'assets/Card.tsx', 'assets-card'],
|
|
74
|
+
['not a string', 42, 'anything'],
|
|
75
|
+
['an object', { toString: () => 'ui/Card.tsx' }, 'ui-card'],
|
|
76
|
+
['the empty string', '', 'anything'],
|
|
77
|
+
];
|
|
78
|
+
|
|
79
|
+
for (const [label, path, slug] of corpus) {
|
|
80
|
+
it(`refuses ${label}`, () => {
|
|
81
|
+
const v = validateCanvasPath({ path, slug, designRel: '.design', canvasGroups: GROUPS });
|
|
82
|
+
expect(v.ok).toBe(false);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
it('refuses a path longer than the cap', () => {
|
|
87
|
+
const long = `ui/${'a'.repeat(MAX_CANVAS_PATH_LEN)}.tsx`;
|
|
88
|
+
expect(validateCanvasPath({ path: long, slug: 'x', canvasGroups: GROUPS }).ok).toBe(false);
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
describe('rule 7 — a path that points elsewhere no longer addresses this document', () => {
|
|
93
|
+
it('refuses a well-formed path belonging to a DIFFERENT canvas', () => {
|
|
94
|
+
// The one that matters. Every rule above refuses a MALFORMED path; this
|
|
95
|
+
// refuses a perfectly legal one that simply is not this document's. Without
|
|
96
|
+
// it, any peer could overwrite any other canvas in the project by pushing a
|
|
97
|
+
// body under its own document name and someone else's path.
|
|
98
|
+
const v = check('ui/secrets/credentials.tsx', 'ui-card');
|
|
99
|
+
expect(v.ok).toBe(false);
|
|
100
|
+
if (!v.ok) expect(v.reason).toContain('slugs to');
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('refuses a path that only differs in a folder boundary', () => {
|
|
104
|
+
// `ui/a-b.tsx` and `ui/a/b.tsx` slug identically (`ui-a-b`) — so this pair
|
|
105
|
+
// is ACCEPTED by rule 7 on purpose: the collision is the slug's, it predates
|
|
106
|
+
// this feature, and `admitCanvases` already refuses to sync both files.
|
|
107
|
+
expect(check('ui/a/b.tsx', 'ui-a-b').ok).toBe(true);
|
|
108
|
+
expect(check('ui/a-b.tsx', 'ui-a-b').ok).toBe(true);
|
|
109
|
+
// What is NOT accepted is a path whose slug simply differs.
|
|
110
|
+
expect(check('ui/a/c.tsx', 'ui-a-b').ok).toBe(false);
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
describe('fallbackCanvasPath — visible, and still the same document', () => {
|
|
115
|
+
it('places an un-pathed canvas inside the group its slug came from', () => {
|
|
116
|
+
expect(fallbackCanvasPath('ui-legacy', GROUPS)).toBe('ui/legacy.tsx');
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it('the result slugs BACK to the document — a fallback must not fork it', () => {
|
|
120
|
+
// The property, not the string. `ui/ui-legacy.tsx` would be visible and
|
|
121
|
+
// would slug to `ui-ui-legacy`: a second document syncing the same bytes,
|
|
122
|
+
// with the original orphaned on the hub.
|
|
123
|
+
for (const slug of ['ui-legacy', 'ui-2026-social-summer-camp', 'system-preview-logo']) {
|
|
124
|
+
expect(canvasSlugFromRel(fallbackCanvasPath(slug, GROUPS), '.design')).toBe(slug);
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it('picks the group the slug actually came from, not the first one', () => {
|
|
129
|
+
const groups = [{ path: 'ui' }, { path: 'screens' }];
|
|
130
|
+
expect(fallbackCanvasPath('screens-x', groups)).toBe('screens/x.tsx');
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it('prefers the LONGEST matching group over declaration order', () => {
|
|
134
|
+
const groups = [{ path: 'ui' }, { path: 'ui/social' }];
|
|
135
|
+
expect(fallbackCanvasPath('ui-social-x', groups)).toBe('ui/social/x.tsx');
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it('keeps the design root when no declared group matches the slug', () => {
|
|
139
|
+
// Today's behaviour, deliberately: it is invisible, but it is the SAME
|
|
140
|
+
// document. A canvas that was outside every group at its author cannot be
|
|
141
|
+
// placed inside one without renaming it — which is what a path is for.
|
|
142
|
+
expect(fallbackCanvasPath('welcome', GROUPS)).toBe('welcome.tsx');
|
|
143
|
+
expect(fallbackCanvasPath('x', [])).toBe('x.tsx');
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
it('drops a group path that escapes the design root', () => {
|
|
147
|
+
expect(fallbackCanvasPath('etc-x', [{ path: '../../etc' }])).toBe('etc-x.tsx');
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
it('never produces a separator, a dotfile or a `..` from the slug', () => {
|
|
151
|
+
// The slug is charset-constrained upstream (`slugFromDocName`), so this is
|
|
152
|
+
// the second line rather than the first — but it is the line that stands
|
|
153
|
+
// between a bad slug and a directory of the sender's choosing.
|
|
154
|
+
for (const hostile of ['../../evil', '/etc/passwd', '..', '.', 'a\\b', '']) {
|
|
155
|
+
const rel = fallbackCanvasPath(hostile, GROUPS);
|
|
156
|
+
expect(rel).not.toContain('/');
|
|
157
|
+
expect(rel).not.toContain('\\');
|
|
158
|
+
expect(rel).not.toContain('..');
|
|
159
|
+
expect(rel.startsWith('.')).toBe(false);
|
|
160
|
+
expect(rel.endsWith('.tsx')).toBe(true);
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
describe('resolveCanvasBodyRel — one answer for "what does a refused path do"', () => {
|
|
166
|
+
it('uses the path when it validates', () => {
|
|
167
|
+
expect(
|
|
168
|
+
resolveCanvasBodyRel({
|
|
169
|
+
path: 'ui/2026/social/summer-camp.tsx',
|
|
170
|
+
slug: 'ui-2026-social-summer-camp',
|
|
171
|
+
designRel: '.design',
|
|
172
|
+
canvasGroups: GROUPS,
|
|
173
|
+
})
|
|
174
|
+
).toEqual({ rel: 'ui/2026/social/summer-camp.tsx', fromPath: true });
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
it('falls back — never throws the canvas away — and says why', () => {
|
|
178
|
+
const reasons: string[] = [];
|
|
179
|
+
const out = resolveCanvasBodyRel({
|
|
180
|
+
path: '../../etc/passwd.tsx',
|
|
181
|
+
slug: 'ui-card',
|
|
182
|
+
canvasGroups: GROUPS,
|
|
183
|
+
onRefused: (r) => reasons.push(r),
|
|
184
|
+
});
|
|
185
|
+
expect(out).toEqual({ rel: 'ui/card.tsx', fromPath: false });
|
|
186
|
+
expect(reasons.length).toBe(1);
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
it('an ABSENT path is not a refusal — an older peer omits it', () => {
|
|
190
|
+
const reasons: string[] = [];
|
|
191
|
+
const out = resolveCanvasBodyRel({
|
|
192
|
+
path: undefined,
|
|
193
|
+
slug: 'ui-card',
|
|
194
|
+
canvasGroups: GROUPS,
|
|
195
|
+
onRefused: (r) => reasons.push(r),
|
|
196
|
+
});
|
|
197
|
+
expect(out).toEqual({ rel: 'ui/card.tsx', fromPath: false });
|
|
198
|
+
expect(reasons).toEqual([]);
|
|
199
|
+
});
|
|
200
|
+
});
|