feat: more easter eggs + version checking
This commit is contained in:
@@ -88,5 +88,44 @@ void main() {
|
||||
throwsA(isA<UnauthorizedException>()),
|
||||
);
|
||||
});
|
||||
|
||||
test('sends the app version', () async {
|
||||
late http.Request sent;
|
||||
final client = KoolTapApiClient(
|
||||
client: MockClient((request) async {
|
||||
sent = request;
|
||||
return http.Response('{}', 200);
|
||||
}),
|
||||
baseUrl: 'https://api.test',
|
||||
appVersion: '1.4.0',
|
||||
);
|
||||
|
||||
await client.sync(
|
||||
token: 'token',
|
||||
request: const SyncRequest(deviceId: 'device', openTabs: []),
|
||||
);
|
||||
|
||||
expect(sent.headers['X-App-Version'], '1.4.0');
|
||||
});
|
||||
|
||||
test('treats a 426 as an app that must be updated', () async {
|
||||
final client = _clientReturning(
|
||||
_error(426, 'app_update_required', 'Update the app to version 1.4.0'),
|
||||
);
|
||||
|
||||
await expectLater(
|
||||
client.sync(
|
||||
token: 'token',
|
||||
request: const SyncRequest(deviceId: 'device', openTabs: []),
|
||||
),
|
||||
throwsA(
|
||||
isA<UpdateRequiredException>().having(
|
||||
(e) => e.message,
|
||||
'message',
|
||||
'Update the app to version 1.4.0',
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -243,6 +243,22 @@ void main() {
|
||||
expect(await service.isConfigured, false);
|
||||
});
|
||||
|
||||
test('stops syncing but keeps the token when the app is too old', () async {
|
||||
server.syncResponse = http.Response(
|
||||
jsonEncode({
|
||||
'error': {'code': 'app_update_required', 'message': 'Update'},
|
||||
}),
|
||||
426,
|
||||
);
|
||||
|
||||
await service.sync();
|
||||
await pumpEventQueue();
|
||||
|
||||
expect(eventTypes(), [RemoteSyncEventType.updateRequired]);
|
||||
expect(events.single.message, 'Update');
|
||||
expect(await service.isConfigured, true);
|
||||
});
|
||||
|
||||
test('creates planned tabs that are not open yet, once', () async {
|
||||
await barTabService.createTab(customerName: 'Alice');
|
||||
server.respondWith({
|
||||
|
||||
Reference in New Issue
Block a user