import 'dart:io'; import 'package:path/path.dart' as p; import 'package:test/test.dart'; import '../../tool/src/release/apps.dart'; import '../../tool/src/release/version.dart'; import '../../tool/src/release/whats_new.dart'; import 'fixtures.dart'; void main() { test('the drafts list the features, then the fixes, without types, scopes ' 'and closing references, as sentences; German marked to translate', () { final drafts = draftWhatsNew(const [ Commit(hash: 'a', subject: 'fix(sync): no lost rating'), Commit(hash: 'b', subject: 'docs: why'), Commit( hash: 'c', subject: 'feat(train): tabs folding into the title (ADR 0030, D60)', ), Commit(hash: 'd', subject: 'perf!: faster library.'), Commit(hash: 'e', subject: 'chore(release): notes-v0.18.0'), ], first: false); expect(drafts['en'], ''' - Tabs folding into the title. - No lost rating. - Faster library. '''); expect(drafts['de'], ''' - TRANSLATE: Tabs folding into the title. - TRANSLATE: No lost rating. - TRANSLATE: Faster library. '''); }); test('the first release says so', () { expect( draftWhatsNew(const [], first: true)['en'], '- The first release.\n', ); }); test("a text's changes are its lines starting with '- '", () { expect(whatsNewChanges('- One\n\n - Two \n'), ['One', 'Two']); expect(whatsNewList('- One\n\n - Two \n'), '- One\n- Two'); }); group('problems', () { test('none in an edited text', () { expect(whatsNewProblems('x', '- One.\n- Two.\n'), isEmpty); }); test('a text listing nothing', () { expect(whatsNewProblems('x', '\n'), ['x lists no change.']); }); test('a line not starting with a dash', () { expect(whatsNewProblems('x', '- One.\nTwo.\n'), [ "x, line 2: doesn't start with '- '.", ]); }); test('a line still to be translated', () { expect(whatsNewProblems('x', '- TRANSLATE: One.\n'), [ 'x is still to be translated (TRANSLATE:).', ]); }); test("more than F-Droid's 500 characters", () { expect(whatsNewProblems('x', '- ${'a' * 499}\n'), [ "x has 501 characters, more than F-Droid's 500.", ]); }); }); test("the files are the app's, F-Droid's changelog its listing's", () { expect( whatsNewFile(testApp, const Version(0, 19, 0), 'de'), 'apps/notes/halkyon_notes_flutter/assets/whats_new/0.19.0.de.txt', ); expect( fdroidChangelogFile(testApp, 23, 'en'), 'app.halkyon.notes/en-US/changelogs/23.txt', ); expect( fdroidChangelogFile(testApp, 23, 'de'), 'app.halkyon.notes/de/changelogs/23.txt', ); }); // The texts every app bundles, as a release would take them. for (final app in releasedApps.values) { test("${app.name}'s texts of what's new are each release's in every " 'language, and as a release takes them', () { final folder = Directory(app.whatsNewDirectory); final byVersion = >{}; for (final file in folder.listSync().whereType()) { final name = p.basename(file.path); final match = whatsNewName.firstMatch(name); expect(match, isNotNull, reason: '$name: ..txt'); (byVersion[match![1]!] ??= {}).add(match[2]!); expect(whatsNewProblems(name, file.readAsStringSync()), isEmpty); } expect(byVersion, isNotEmpty); for (final MapEntry(key: version, value: languages) in byVersion.entries) { expect(languages, whatsNewLanguages.toSet(), reason: version); } }); } }