test(dart): add integration tests for await and widget-tree call patterns

This commit is contained in:
arkh 2026-04-13 11:28:08 +03:00
parent ec5cc623fb
commit 8490e99732
5 changed files with 97 additions and 0 deletions

View file

@ -0,0 +1,6 @@
import 'service.dart';
Future<void> run() async {
final user = await fetchUser();
await processData(user);
}

View file

@ -0,0 +1,5 @@
Future<String> fetchUser() async {
return 'user';
}
Future<void> processData(String data) async {}

View file

@ -0,0 +1,10 @@
import 'builders.dart';
// Named argument call: child: buildHeader()
// List literal calls: children: [buildBody(), buildFooter()]
dynamic buildPage() {
return Column(
child: buildHeader(),
children: [buildBody(), buildFooter()],
);
}

View file

@ -0,0 +1,3 @@
dynamic buildHeader() => null;
dynamic buildBody() => null;
dynamic buildFooter() => null;

View file

@ -512,3 +512,76 @@ describe.skipIf(!dartAvailable)(
});
},
);
// ---------------------------------------------------------------------------
// await call patterns: await fetchUser(), await processData()
// ---------------------------------------------------------------------------
describe.skipIf(!dartAvailable)('Dart await call resolution', () => {
let result: PipelineResult;
beforeAll(async () => {
result = await runPipelineFromRepo(
path.join(FIXTURES, 'dart-await-calls'),
() => {},
);
}, 60000);
it('detects fetchUser and processData as functions', () => {
const fns = getNodesByLabel(result, 'Function');
expect(fns).toContain('fetchUser');
expect(fns).toContain('processData');
});
it('resolves run → fetchUser via await direct call', () => {
const calls = getRelationships(result, 'CALLS');
const edge = calls.find((c) => c.source === 'run' && c.target === 'fetchUser');
expect(edge).toBeDefined();
});
it('resolves run → processData via await direct call', () => {
const calls = getRelationships(result, 'CALLS');
const edge = calls.find((c) => c.source === 'run' && c.target === 'processData');
expect(edge).toBeDefined();
});
});
// ---------------------------------------------------------------------------
// Widget-tree call patterns: named argument and list literal
// ---------------------------------------------------------------------------
describe.skipIf(!dartAvailable)('Dart widget-tree call resolution', () => {
let result: PipelineResult;
beforeAll(async () => {
result = await runPipelineFromRepo(
path.join(FIXTURES, 'dart-widget-tree-calls'),
() => {},
);
}, 60000);
it('detects buildHeader, buildBody, buildFooter as functions', () => {
const fns = getNodesByLabel(result, 'Function');
expect(fns).toContain('buildHeader');
expect(fns).toContain('buildBody');
expect(fns).toContain('buildFooter');
});
it('resolves buildPage → buildHeader via named argument call', () => {
const calls = getRelationships(result, 'CALLS');
const edge = calls.find((c) => c.source === 'buildPage' && c.target === 'buildHeader');
expect(edge).toBeDefined();
});
it('resolves buildPage → buildBody via list literal call', () => {
const calls = getRelationships(result, 'CALLS');
const edge = calls.find((c) => c.source === 'buildPage' && c.target === 'buildBody');
expect(edge).toBeDefined();
});
it('resolves buildPage → buildFooter via list literal call', () => {
const calls = getRelationships(result, 'CALLS');
const edge = calls.find((c) => c.source === 'buildPage' && c.target === 'buildFooter');
expect(edge).toBeDefined();
});
});