TEST: add cloud DTO and entitlement architecture contracts
This commit is contained in:
parent
b0d1ed1d24
commit
5e13892dda
|
|
@ -0,0 +1,64 @@
|
|||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:motorsignal/services/cloud/cloud_models.dart';
|
||||
import 'package:motorsignal/services/entitlements/entitlement_state.dart';
|
||||
|
||||
void main() {
|
||||
group('Cloud architecture contracts', () {
|
||||
test('profile DTO preserves stable identity', () {
|
||||
final now = DateTime.utc(2026, 9, 1);
|
||||
final profile = CloudUserProfile(
|
||||
id: 'firebase-user-1',
|
||||
displayName: 'Rider',
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
);
|
||||
|
||||
final json = profile.toJson();
|
||||
expect(json['id'], 'firebase-user-1');
|
||||
expect(json['displayName'], 'Rider');
|
||||
expect(json['createdAt'], now.toIso8601String());
|
||||
});
|
||||
|
||||
test('motorcycle DTO keeps owner separate from display identity', () {
|
||||
final now = DateTime.utc(2026, 9, 1);
|
||||
final motorcycle = CloudMotorcycle(
|
||||
id: '42',
|
||||
ownerId: 'firebase-user-1',
|
||||
year: 2001,
|
||||
makeId: 'yamaha',
|
||||
makeName: 'Yamaha',
|
||||
modelId: 'yzf-r6',
|
||||
modelName: 'YZF-R6',
|
||||
isDefault: true,
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
);
|
||||
|
||||
expect(motorcycle.toJson()['id'], '42');
|
||||
expect(motorcycle.toJson()['ownerId'], 'firebase-user-1');
|
||||
expect(motorcycle.toJson()['year'], 2001);
|
||||
});
|
||||
|
||||
test('free entitlement exposes core capabilities but not premium capabilities', () {
|
||||
const state = EntitlementState();
|
||||
expect(state.canCloudBackup, isTrue);
|
||||
expect(state.canAdvancedTelemetry, isFalse);
|
||||
expect(state.canExportCsv, isFalse);
|
||||
expect(state.canPlanTrips, isFalse);
|
||||
});
|
||||
|
||||
test('lifetime entitlement exposes the complete Pro capability surface', () {
|
||||
const state = EntitlementState(
|
||||
plan: MotorSignalPlan.proLifetime,
|
||||
status: MotorSignalEntitlementStatus.proLifetime,
|
||||
);
|
||||
expect(state.isPro, isTrue);
|
||||
expect(state.canUnlimitedCloudHistory, isTrue);
|
||||
expect(state.canAdvancedAcceleration, isTrue);
|
||||
expect(state.canAdvancedBraking, isTrue);
|
||||
expect(state.canAdvancedLean, isTrue);
|
||||
expect(state.canExportPdf, isTrue);
|
||||
expect(state.canCreateGroupRides, isTrue);
|
||||
});
|
||||
});
|
||||
}
|
||||
Loading…
Reference in New Issue