test(routes): drive the forwarding fallback case from data and cover re-export merges

Replace the boolean-switched forwarding fallback case with table rows instead
of branching inside the test, and assert that barrel re-export facts survive
worker sub-batch merges.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Gergo Magyar 2026-10-19 06:56:00 +00:00
parent 205787b2ca
commit 47d09da4ac
2 changed files with 29 additions and 12 deletions

View file

@ -179,18 +179,17 @@ describe('fetch wrapper forwarding propagation', () => {
expect(index.isWrapperCall(call({ kind: 'binding', bindingId: 'outer' }))).toBe(false);
});
it.each([false, true])(
'uses the same unique fallback for forwarding, duplicate=%s',
(duplicate) => {
const defs = [
definition('carrier', { functionName: 'send', forwardsUrl: true }),
definition('outer', { forwardsTo: [{ callee: 'send', target: { kind: 'unresolved' } }] }),
];
if (duplicate) defs.push(definition('other', { functionName: 'send' }));
const index = buildFetchWrapperIndex(defs);
expect(index.isWrapperCall(call({ kind: 'binding', bindingId: 'outer' }))).toBe(!duplicate);
},
);
it.each([
['a unique carrier', [], true],
['a same-named collision', [definition('other', { functionName: 'send' })], false],
])('uses the same unique fallback for forwarding with %s', (_shape, collisions, expected) => {
const index = buildFetchWrapperIndex([
definition('carrier', { functionName: 'send', forwardsUrl: true }),
definition('outer', { forwardsTo: [{ callee: 'send', target: { kind: 'unresolved' } }] }),
...collisions,
]);
expect(index.isWrapperCall(call({ kind: 'binding', bindingId: 'outer' }))).toBe(expected);
});
it('propagates imported identity and configured overrides through forwarding', () => {
const index = buildFetchWrapperIndex(

View file

@ -79,6 +79,24 @@ describe('mergeResult', () => {
expect(target.fetchCalls).toEqual([]);
});
it('retains barrel re-export facts across sub-batches', () => {
const target = emptyResult();
const named = {
filePath: 'index.ts',
exportedName: 'request',
from: { specifier: './request', importedName: 'request' },
};
const star = {
filePath: 'index.ts',
exportedName: '*',
from: { specifier: './star', importedName: '*' },
};
mergeResult(target, { ...emptyResult(), fetchWrapperReexports: [named] });
mergeResult(target, emptyResult());
mergeResult(target, { ...emptyResult(), fetchWrapperReexports: [star] });
expect(target.fetchWrapperReexports).toEqual([named, star]);
});
it('sums every CFG skip bucket by language across worker sub-batches', () => {
const target = emptyResult();
const first = {