import 'package:flutter_test/flutter_test.dart'; import 'package:chain_studio_flow_editor/src/flow_project.dart'; void main() { group('parseFlowProject', () { test('reads a bare top-level project key', () { const yaml = 'name: demo\nproject: client-a\nsteps: []\n'; expect(parseFlowProject(yaml), 'client-a'); }); test('strips quotes and normalizes casing/spaces', () { expect(parseFlowProject('project: "Client A"'), 'client-a'); // Non-[a-z0-9] that isn't a separator is dropped without a // dash — matches the hub's normalize_project_slug. expect(parseFlowProject("project: 'Recl∆Im'"), 'reclim'); }); test('returns empty when no top-level project is declared', () { const yaml = 'name: demo\ninputs:\n topic: text\nsteps: []\n'; expect(parseFlowProject(yaml), ''); }); test('ignores an indented project inside a step with-block', () { const yaml = 'name: demo\nsteps:\n - id: s\n use: x@^0\n with:\n project: not-this\n'; expect(parseFlowProject(yaml), ''); }); test('a top-level project still wins over a later nested one', () { const yaml = 'project: top\nsteps:\n - id: s\n with:\n project: nested\n'; expect(parseFlowProject(yaml), 'top'); }); }); group('normalizeProjectSlug', () { test('collapses separators and trims trailing dashes', () { expect(normalizeProjectSlug('Projekt Alpha__'), 'projekt-alpha'); expect(normalizeProjectSlug('a - b - c'), 'a-b-c'); }); test('empty stays empty', () { expect(normalizeProjectSlug(' '), ''); }); }); }