test: aggiungi test parsing JSON e widget test del dialog

parseTagName: v-prefix, body senza prefisso, JSON malformato, tag_name
assente, body vuoto. Widget test del dialog: titolo, versione nel testo,
pulsanti Più tardi e Scarica, chiusura dialog, chiamata MethodChannel
verificata con mock. 130/130 test passati.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-04 16:28:21 +02:00
parent 3da8ccc4d3
commit b391199bce
2 changed files with 104 additions and 0 deletions
@@ -2,6 +2,28 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:biteplan/shared/services/update_service.dart';
void main() {
group('UpdateService.parseTagName', () {
test('strips v prefix from tag_name', () {
expect(UpdateService.parseTagName('{"tag_name":"v2.1.0"}'), '2.1.0');
});
test('works without v prefix', () {
expect(UpdateService.parseTagName('{"tag_name":"2.1.0"}'), '2.1.0');
});
test('returns null for malformed JSON', () {
expect(UpdateService.parseTagName('not json'), isNull);
});
test('returns null when tag_name is missing', () {
expect(UpdateService.parseTagName('{"message":"Not Found"}'), isNull);
});
test('returns null for empty body', () {
expect(UpdateService.parseTagName(''), isNull);
});
});
group('UpdateService.parseVersion', () {
test('parses standard semver', () {
expect(UpdateService.parseVersion('2.1.3'), [2, 1, 3]);