fixed drone status menue grid view bug. fields are shown again

This commit is contained in:
Constantin Leue
2026-08-05 21:11:28 +02:00
parent 4982341203
commit c7e4e5bf63
4 changed files with 150 additions and 16 deletions
@@ -0,0 +1,84 @@
import 'dart:io';
import 'package:drift/native.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:sqlite3/sqlite3.dart' as sqlite3;
import 'package:dmc_app/services/database/app_database.dart';
import 'package:dmc_app/services/database/drone_profile_repository.dart';
/// Reproduziert das Upgrade eines echten, bereits laufenden Geraets (Schema
/// v7, DroneProfiles ohne die neuen Ampel-Schwellwert-Spalten) auf das
/// aktuelle Schema (v8): baut die v7-Tabellenstruktur samt einer
/// Bestandszeile roh per sqlite3 auf (wie auf einem Geraet, das die App vor
/// diesem Update installiert hatte), oeffnet die Datei dann ganz normal ueber
/// AppDatabase und prueft, dass die Migration ohne Exception durchlaeuft und
/// die neuen Spalten mit den erwarteten Default-Werten befuellt werden.
void main() {
test('Upgrade von Schema v7 auf v8 befuellt neue Spalten mit Defaults', () async {
final dir = await Directory.systemTemp.createTemp('dmc_migration_test');
final file = File('${dir.path}/test.sqlite');
final raw = sqlite3.sqlite3.open(file.path);
raw.execute('''
CREATE TABLE missions (
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
location TEXT,
created_at INTEGER NOT NULL,
updated_at INTEGER NOT NULL,
waypoints_json TEXT NOT NULL,
is_dirty INTEGER NOT NULL DEFAULT 1,
server_id TEXT,
terrain_profile_json TEXT
);
CREATE TABLE drone_profiles (
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
min_speed REAL NOT NULL,
cruise_speed REAL NOT NULL,
max_speed REAL NOT NULL,
min_turn_radius REAL NOT NULL,
loiter_radius REAL NOT NULL,
catch_radius REAL NOT NULL,
max_climb_rate REAL NOT NULL,
max_descent_rate REAL NOT NULL,
max_range_m REAL NOT NULL,
max_endurance_min REAL NOT NULL,
max_altitude_m REAL NOT NULL
);
CREATE TABLE app_settings_table (
id INTEGER NOT NULL PRIMARY KEY,
active_drone_profile_id INTEGER,
current_mission_id INTEGER,
connection_device_address TEXT,
connection_auto_connect INTEGER NOT NULL DEFAULT 1,
connection_type TEXT NOT NULL DEFAULT 'wifi',
connection_wifi_host TEXT,
connection_wifi_port INTEGER NOT NULL DEFAULT 14550,
connection_wifi_ssid_prefix TEXT NOT NULL DEFAULT 'mLRS-',
connection_wifi_last_ssid TEXT
);
INSERT INTO drone_profiles (
id, name, min_speed, cruise_speed, max_speed, min_turn_radius,
loiter_radius, catch_radius, max_climb_rate, max_descent_rate,
max_range_m, max_endurance_min, max_altitude_m
) VALUES (
1, 'T1 Ranger', 13, 15, 25, 35, 100, 60, 5, 6, 15000, 45, 2000
);
PRAGMA user_version = 7;
''');
raw.close();
final db = AppDatabase.forTesting(NativeDatabase(file));
final repo = DroneProfileRepository(db);
final all = await repo.loadAll();
expect(all, hasLength(1));
expect(all.first.name, 'T1 Ranger');
expect(all.first.gpsSatGreenMin, 8.0);
expect(all.first.batteryVoltageRedMinV, 19.2);
await db.close();
await dir.delete(recursive: true);
});
}