mirror of
https://github.com/lichess-org/mobile.git
synced 2026-05-26 13:50:52 +00:00
Move socket and http to network folder
This commit is contained in:
+20
-9
@@ -10,17 +10,20 @@ import 'package:lichess_mobile/src/constants.dart';
|
||||
import 'package:lichess_mobile/src/model/account/account_repository.dart';
|
||||
import 'package:lichess_mobile/src/model/auth/auth_session.dart';
|
||||
import 'package:lichess_mobile/src/model/challenge/challenge_service.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/common/socket.dart';
|
||||
import 'package:lichess_mobile/src/model/correspondence/correspondence_service.dart';
|
||||
import 'package:lichess_mobile/src/model/notifications/notification_service.dart';
|
||||
import 'package:lichess_mobile/src/model/settings/board_preferences.dart';
|
||||
import 'package:lichess_mobile/src/model/settings/brightness.dart';
|
||||
import 'package:lichess_mobile/src/model/settings/general_preferences.dart';
|
||||
import 'package:lichess_mobile/src/navigation.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:lichess_mobile/src/network/socket.dart';
|
||||
import 'package:lichess_mobile/src/styles/styles.dart';
|
||||
import 'package:lichess_mobile/src/utils/connectivity.dart';
|
||||
import 'package:lichess_mobile/src/utils/screen.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
|
||||
final _logger = Logger('Application');
|
||||
|
||||
/// The main application widget.
|
||||
///
|
||||
@@ -52,9 +55,6 @@ class _AppState extends ConsumerState<Application> {
|
||||
},
|
||||
);
|
||||
|
||||
// check if session is still active and delete it if it is not
|
||||
checkSession();
|
||||
|
||||
// Start services
|
||||
ref.read(notificationServiceProvider).start();
|
||||
ref.read(challengeServiceProvider).start();
|
||||
@@ -76,6 +76,9 @@ class _AppState extends ConsumerState<Application> {
|
||||
// Perform actions once when the app comes online.
|
||||
if (current.value?.isOnline == true && !_firstTimeOnlineCheck) {
|
||||
_firstTimeOnlineCheck = true;
|
||||
// check if session is still active and delete it if it is not
|
||||
checkSession();
|
||||
|
||||
ref.read(correspondenceServiceProvider).syncGames();
|
||||
}
|
||||
|
||||
@@ -208,16 +211,24 @@ class _AppState extends ConsumerState<Application> {
|
||||
// check if session is still active
|
||||
final session = ref.read(authSessionProvider);
|
||||
if (session != null) {
|
||||
_logger.fine(
|
||||
'Found a stored session: ${session.user.id}. Checking if it is still active.',
|
||||
);
|
||||
try {
|
||||
final client = ref.read(lichessClientProvider);
|
||||
final response = await client
|
||||
.get(Uri(path: '/api/account'))
|
||||
final data = await client
|
||||
.postReadJson(
|
||||
Uri(path: '/api/token/test'),
|
||||
body: session.token,
|
||||
mapper: (json) => json,
|
||||
)
|
||||
.timeout(const Duration(seconds: 3));
|
||||
if (response.statusCode == 401) {
|
||||
if (data[session.token] == null) {
|
||||
_logger.fine('Session is not active. Deleting it.');
|
||||
await ref.read(authSessionProvider.notifier).delete();
|
||||
}
|
||||
} catch (e) {
|
||||
debugPrint('Could not check session: $e');
|
||||
_logger.warning('Could not check session: $e');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,9 +13,9 @@ import 'package:lichess_mobile/src/db/secure_storage.dart';
|
||||
import 'package:lichess_mobile/src/log.dart';
|
||||
import 'package:lichess_mobile/src/model/auth/auth_session.dart';
|
||||
import 'package:lichess_mobile/src/model/auth/session_storage.dart';
|
||||
import 'package:lichess_mobile/src/model/common/socket.dart';
|
||||
import 'package:lichess_mobile/src/model/notifications/notification_service.dart';
|
||||
import 'package:lichess_mobile/src/model/notifications/notifications.dart';
|
||||
import 'package:lichess_mobile/src/network/socket.dart';
|
||||
import 'package:lichess_mobile/src/utils/string.dart';
|
||||
import 'package:lichess_mobile/src/utils/system.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
|
||||
+1
-1
@@ -6,9 +6,9 @@ import 'package:flutter/services.dart';
|
||||
import 'package:flutter_displaymode/flutter_displaymode.dart';
|
||||
import 'package:lichess_mobile/src/binding.dart';
|
||||
import 'package:lichess_mobile/src/db/secure_storage.dart';
|
||||
import 'package:lichess_mobile/src/model/common/socket.dart';
|
||||
import 'package:lichess_mobile/src/model/settings/board_preferences.dart';
|
||||
import 'package:lichess_mobile/src/model/settings/preferences.dart';
|
||||
import 'package:lichess_mobile/src/network/socket.dart';
|
||||
import 'package:lichess_mobile/src/utils/color_palette.dart';
|
||||
import 'package:lichess_mobile/src/utils/screen.dart';
|
||||
import 'package:lichess_mobile/src/utils/string.dart';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:lichess_mobile/src/model/auth/auth_session.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:lichess_mobile/src/utils/l10n_context.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
|
||||
@@ -3,12 +3,12 @@ import 'package:fast_immutable_collections/fast_immutable_collections.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:lichess_mobile/src/model/auth/auth_session.dart';
|
||||
import 'package:lichess_mobile/src/model/common/chess.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/common/id.dart';
|
||||
import 'package:lichess_mobile/src/model/common/perf.dart';
|
||||
import 'package:lichess_mobile/src/model/common/speed.dart';
|
||||
import 'package:lichess_mobile/src/model/user/user.dart';
|
||||
import 'package:lichess_mobile/src/model/user/user_repository.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
|
||||
@@ -2,11 +2,11 @@ import 'dart:async';
|
||||
|
||||
import 'package:dartchess/dartchess.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/common/id.dart';
|
||||
import 'package:lichess_mobile/src/model/common/socket.dart';
|
||||
import 'package:lichess_mobile/src/model/game/game_repository.dart';
|
||||
import 'package:lichess_mobile/src/model/game/game_socket_events.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:lichess_mobile/src/network/socket.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
part 'server_analysis_service.g.dart';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'package:lichess_mobile/src/model/auth/auth_session.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/common/socket.dart';
|
||||
import 'package:lichess_mobile/src/model/notifications/notification_service.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:lichess_mobile/src/network/socket.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
import 'auth_repository.dart';
|
||||
|
||||
@@ -4,8 +4,8 @@ import 'package:http/http.dart' as http;
|
||||
import 'package:lichess_mobile/src/constants.dart';
|
||||
import 'package:lichess_mobile/src/model/auth/auth_session.dart';
|
||||
import 'package:lichess_mobile/src/model/auth/bearer.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/user/user.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'package:lichess_mobile/src/model/broadcast/broadcast.dart';
|
||||
import 'package:lichess_mobile/src/model/broadcast/broadcast_repository.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
part 'broadcast_providers.g.dart';
|
||||
|
||||
@@ -3,8 +3,8 @@ import 'package:deep_pick/deep_pick.dart';
|
||||
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
|
||||
import 'package:lichess_mobile/src/model/broadcast/broadcast.dart';
|
||||
import 'package:lichess_mobile/src/model/common/chess.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/common/id.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:lichess_mobile/src/utils/json.dart';
|
||||
|
||||
class BroadcastRepository {
|
||||
|
||||
@@ -6,9 +6,9 @@ import 'package:fast_immutable_collections/fast_immutable_collections.dart';
|
||||
import 'package:lichess_mobile/src/model/broadcast/broadcast.dart';
|
||||
import 'package:lichess_mobile/src/model/broadcast/broadcast_repository.dart';
|
||||
import 'package:lichess_mobile/src/model/common/chess.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/common/id.dart';
|
||||
import 'package:lichess_mobile/src/model/common/socket.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:lichess_mobile/src/network/socket.dart';
|
||||
import 'package:lichess_mobile/src/utils/json.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@ import 'package:deep_pick/deep_pick.dart';
|
||||
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:lichess_mobile/src/model/challenge/challenge.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/common/id.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
part 'challenge_repository.g.dart';
|
||||
|
||||
@@ -7,10 +7,10 @@ import 'package:flutter/widgets.dart';
|
||||
import 'package:lichess_mobile/src/model/challenge/challenge.dart';
|
||||
import 'package:lichess_mobile/src/model/challenge/challenge_repository.dart';
|
||||
import 'package:lichess_mobile/src/model/common/id.dart';
|
||||
import 'package:lichess_mobile/src/model/common/socket.dart';
|
||||
import 'package:lichess_mobile/src/model/notifications/notification_service.dart';
|
||||
import 'package:lichess_mobile/src/model/notifications/notifications.dart';
|
||||
import 'package:lichess_mobile/src/navigation.dart';
|
||||
import 'package:lichess_mobile/src/network/socket.dart';
|
||||
import 'package:lichess_mobile/src/utils/l10n_context.dart';
|
||||
import 'package:lichess_mobile/src/utils/navigation.dart';
|
||||
import 'package:lichess_mobile/src/view/game/game_screen.dart';
|
||||
|
||||
@@ -8,15 +8,15 @@ import 'package:flutter/widgets.dart';
|
||||
import 'package:lichess_mobile/src/model/account/account_repository.dart';
|
||||
import 'package:lichess_mobile/src/model/auth/auth_session.dart';
|
||||
import 'package:lichess_mobile/src/model/auth/bearer.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/common/id.dart';
|
||||
import 'package:lichess_mobile/src/model/common/socket.dart';
|
||||
import 'package:lichess_mobile/src/model/correspondence/correspondence_game_storage.dart';
|
||||
import 'package:lichess_mobile/src/model/correspondence/offline_correspondence_game.dart';
|
||||
import 'package:lichess_mobile/src/model/game/game_repository.dart';
|
||||
import 'package:lichess_mobile/src/model/game/game_socket_events.dart';
|
||||
import 'package:lichess_mobile/src/model/game/playable_game.dart';
|
||||
import 'package:lichess_mobile/src/navigation.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:lichess_mobile/src/network/socket.dart';
|
||||
import 'package:lichess_mobile/src/utils/navigation.dart';
|
||||
import 'package:lichess_mobile/src/view/game/game_screen.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
|
||||
@@ -5,8 +5,8 @@ import 'package:fast_immutable_collections/fast_immutable_collections.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:lichess_mobile/src/db/database.dart';
|
||||
import 'package:lichess_mobile/src/model/common/id.dart';
|
||||
import 'package:lichess_mobile/src/model/common/socket.dart';
|
||||
import 'package:lichess_mobile/src/model/game/game_controller.dart';
|
||||
import 'package:lichess_mobile/src/network/socket.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
import 'package:sqflite/sqflite.dart';
|
||||
|
||||
|
||||
@@ -8,11 +8,11 @@ import 'package:intl/intl.dart';
|
||||
import 'package:lichess_mobile/src/model/account/account_preferences.dart';
|
||||
import 'package:lichess_mobile/src/model/common/chess.dart';
|
||||
import 'package:lichess_mobile/src/model/common/eval.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/common/id.dart';
|
||||
import 'package:lichess_mobile/src/model/common/node.dart';
|
||||
import 'package:lichess_mobile/src/model/common/perf.dart';
|
||||
import 'package:lichess_mobile/src/model/common/speed.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
|
||||
import 'game_status.dart';
|
||||
import 'material_diff.dart';
|
||||
|
||||
@@ -13,11 +13,9 @@ import 'package:lichess_mobile/src/model/account/account_repository.dart';
|
||||
import 'package:lichess_mobile/src/model/analysis/analysis_controller.dart';
|
||||
import 'package:lichess_mobile/src/model/analysis/server_analysis_service.dart';
|
||||
import 'package:lichess_mobile/src/model/common/chess.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/common/id.dart';
|
||||
import 'package:lichess_mobile/src/model/common/service/move_feedback.dart';
|
||||
import 'package:lichess_mobile/src/model/common/service/sound_service.dart';
|
||||
import 'package:lichess_mobile/src/model/common/socket.dart';
|
||||
import 'package:lichess_mobile/src/model/common/speed.dart';
|
||||
import 'package:lichess_mobile/src/model/correspondence/correspondence_service.dart';
|
||||
import 'package:lichess_mobile/src/model/game/archived_game.dart';
|
||||
@@ -29,6 +27,8 @@ import 'package:lichess_mobile/src/model/game/game_storage.dart';
|
||||
import 'package:lichess_mobile/src/model/game/material_diff.dart';
|
||||
import 'package:lichess_mobile/src/model/game/playable_game.dart';
|
||||
import 'package:lichess_mobile/src/model/settings/board_preferences.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:lichess_mobile/src/network/socket.dart';
|
||||
import 'package:lichess_mobile/src/utils/rate_limit.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:result_extensions/result_extensions.dart';
|
||||
|
||||
@@ -6,7 +6,6 @@ import 'package:fast_immutable_collections/fast_immutable_collections.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:lichess_mobile/src/model/account/account_repository.dart';
|
||||
import 'package:lichess_mobile/src/model/auth/auth_session.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/common/id.dart';
|
||||
import 'package:lichess_mobile/src/model/game/archived_game.dart';
|
||||
import 'package:lichess_mobile/src/model/game/game_filter.dart';
|
||||
@@ -14,6 +13,7 @@ import 'package:lichess_mobile/src/model/game/game_repository.dart';
|
||||
import 'package:lichess_mobile/src/model/game/game_storage.dart';
|
||||
import 'package:lichess_mobile/src/model/user/user.dart';
|
||||
import 'package:lichess_mobile/src/model/user/user_repository_providers.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:lichess_mobile/src/utils/connectivity.dart';
|
||||
import 'package:lichess_mobile/src/utils/riverpod.dart';
|
||||
import 'package:result_extensions/result_extensions.dart';
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import 'package:dartchess/dartchess.dart';
|
||||
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/common/id.dart';
|
||||
import 'package:lichess_mobile/src/model/common/perf.dart';
|
||||
import 'package:lichess_mobile/src/model/game/archived_game.dart';
|
||||
import 'package:lichess_mobile/src/model/game/game_filter.dart';
|
||||
import 'package:lichess_mobile/src/model/game/playable_game.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
|
||||
class GameRepository {
|
||||
const GameRepository(this.client);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/common/id.dart';
|
||||
import 'package:lichess_mobile/src/model/game/archived_game.dart';
|
||||
import 'package:lichess_mobile/src/model/game/game_storage.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
import 'game_repository.dart';
|
||||
|
||||
@@ -2,9 +2,9 @@ import 'dart:convert';
|
||||
|
||||
import 'package:dartchess/dartchess.dart';
|
||||
import 'package:lichess_mobile/src/constants.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/common/id.dart';
|
||||
import 'package:lichess_mobile/src/model/settings/board_preferences.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
|
||||
|
||||
@@ -5,11 +5,11 @@ import 'package:lichess_mobile/src/binding.dart';
|
||||
import 'package:lichess_mobile/src/model/account/account_repository.dart';
|
||||
import 'package:lichess_mobile/src/model/challenge/challenge.dart';
|
||||
import 'package:lichess_mobile/src/model/challenge/challenge_repository.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/common/id.dart';
|
||||
import 'package:lichess_mobile/src/model/common/socket.dart';
|
||||
import 'package:lichess_mobile/src/model/lobby/game_seek.dart';
|
||||
import 'package:lichess_mobile/src/model/lobby/lobby_repository.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:lichess_mobile/src/network/socket.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:lichess_mobile/src/model/common/socket.dart';
|
||||
import 'package:lichess_mobile/src/network/socket.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
part 'lobby_numbers.g.dart';
|
||||
|
||||
@@ -2,9 +2,9 @@ import 'package:deep_pick/deep_pick.dart';
|
||||
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:lichess_mobile/src/model/common/chess.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/common/id.dart';
|
||||
import 'package:lichess_mobile/src/model/common/perf.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
import 'correspondence_challenge.dart';
|
||||
|
||||
@@ -8,9 +8,9 @@ import 'package:lichess_mobile/l10n/l10n.dart';
|
||||
import 'package:lichess_mobile/src/binding.dart';
|
||||
import 'package:lichess_mobile/src/model/auth/auth_session.dart';
|
||||
import 'package:lichess_mobile/src/model/challenge/challenge_service.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/correspondence/correspondence_service.dart';
|
||||
import 'package:lichess_mobile/src/model/notifications/notifications.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:lichess_mobile/src/utils/badge_service.dart';
|
||||
import 'package:lichess_mobile/src/utils/connectivity.dart';
|
||||
import 'package:lichess_mobile/src/utils/l10n.dart';
|
||||
|
||||
@@ -4,10 +4,10 @@ import 'package:dartchess/dartchess.dart';
|
||||
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:lichess_mobile/src/constants.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/common/speed.dart';
|
||||
import 'package:lichess_mobile/src/model/opening_explorer/opening_explorer.dart';
|
||||
import 'package:lichess_mobile/src/model/opening_explorer/opening_explorer_preferences.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
part 'opening_explorer_repository.g.dart';
|
||||
|
||||
@@ -3,10 +3,10 @@ import 'dart:async';
|
||||
import 'package:async/async.dart';
|
||||
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/puzzle/puzzle.dart';
|
||||
import 'package:lichess_mobile/src/model/puzzle/puzzle_providers.dart';
|
||||
import 'package:lichess_mobile/src/model/puzzle/puzzle_repository.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:lichess_mobile/src/utils/riverpod.dart';
|
||||
import 'package:result_extensions/result_extensions.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
@@ -6,7 +6,6 @@ import 'package:dartchess/dartchess.dart';
|
||||
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:lichess_mobile/src/model/common/chess.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/common/node.dart';
|
||||
import 'package:lichess_mobile/src/model/common/service/move_feedback.dart';
|
||||
import 'package:lichess_mobile/src/model/common/service/sound_service.dart';
|
||||
@@ -22,6 +21,7 @@ import 'package:lichess_mobile/src/model/puzzle/puzzle_service.dart';
|
||||
import 'package:lichess_mobile/src/model/puzzle/puzzle_session.dart';
|
||||
import 'package:lichess_mobile/src/model/puzzle/puzzle_streak.dart';
|
||||
import 'package:lichess_mobile/src/model/puzzle/puzzle_theme.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:lichess_mobile/src/utils/rate_limit.dart';
|
||||
import 'package:result_extensions/result_extensions.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
@@ -2,7 +2,6 @@ import 'dart:async';
|
||||
|
||||
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
|
||||
import 'package:lichess_mobile/src/model/auth/auth_session.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/common/id.dart';
|
||||
import 'package:lichess_mobile/src/model/puzzle/puzzle.dart';
|
||||
import 'package:lichess_mobile/src/model/puzzle/puzzle_angle.dart';
|
||||
@@ -13,6 +12,7 @@ import 'package:lichess_mobile/src/model/puzzle/puzzle_service.dart';
|
||||
import 'package:lichess_mobile/src/model/puzzle/puzzle_storage.dart';
|
||||
import 'package:lichess_mobile/src/model/puzzle/puzzle_theme.dart';
|
||||
import 'package:lichess_mobile/src/model/puzzle/storm.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
part 'puzzle_providers.g.dart';
|
||||
|
||||
@@ -8,9 +8,9 @@ import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:lichess_mobile/src/model/common/chess.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/common/id.dart';
|
||||
import 'package:lichess_mobile/src/model/common/perf.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:lichess_mobile/src/utils/json.dart';
|
||||
|
||||
import 'puzzle.dart';
|
||||
|
||||
@@ -3,9 +3,9 @@ import 'dart:math' show max;
|
||||
import 'package:async/async.dart';
|
||||
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/common/id.dart';
|
||||
import 'package:lichess_mobile/src/model/puzzle/puzzle_storage.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:result_extensions/result_extensions.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
@@ -9,9 +9,9 @@ import 'package:flutter/services.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:lichess_mobile/src/model/auth/auth_session.dart';
|
||||
import 'package:lichess_mobile/src/model/common/chess.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/common/service/move_feedback.dart';
|
||||
import 'package:lichess_mobile/src/model/common/service/sound_service.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:result_extensions/result_extensions.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@ import 'dart:async';
|
||||
|
||||
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
|
||||
import 'package:lichess_mobile/src/model/common/id.dart';
|
||||
import 'package:lichess_mobile/src/model/common/socket.dart';
|
||||
import 'package:lichess_mobile/src/model/user/user.dart';
|
||||
import 'package:lichess_mobile/src/network/socket.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
part 'online_friends.g.dart';
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/common/id.dart';
|
||||
import 'package:lichess_mobile/src/model/user/user.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
|
||||
class RelationRepository {
|
||||
const RelationRepository(this.client);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/user/user.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
import 'relation_repository.dart';
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import 'package:deep_pick/deep_pick.dart';
|
||||
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/study/study.dart';
|
||||
import 'package:lichess_mobile/src/model/study/study_filter.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
|
||||
class StudyRepository {
|
||||
StudyRepository(this.client);
|
||||
|
||||
@@ -3,9 +3,9 @@ import 'dart:async';
|
||||
import 'package:dartchess/dartchess.dart';
|
||||
import 'package:deep_pick/deep_pick.dart';
|
||||
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/common/socket.dart';
|
||||
import 'package:lichess_mobile/src/model/tv/tv_socket_events.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:lichess_mobile/src/network/socket.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
import 'featured_player.dart';
|
||||
|
||||
@@ -4,10 +4,8 @@ import 'package:dartchess/dartchess.dart';
|
||||
import 'package:deep_pick/deep_pick.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:lichess_mobile/src/model/common/chess.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/common/id.dart';
|
||||
import 'package:lichess_mobile/src/model/common/service/sound_service.dart';
|
||||
import 'package:lichess_mobile/src/model/common/socket.dart';
|
||||
import 'package:lichess_mobile/src/model/game/game.dart';
|
||||
import 'package:lichess_mobile/src/model/game/game_socket_events.dart';
|
||||
import 'package:lichess_mobile/src/model/game/game_status.dart';
|
||||
@@ -16,6 +14,8 @@ import 'package:lichess_mobile/src/model/game/playable_game.dart';
|
||||
import 'package:lichess_mobile/src/model/tv/tv_channel.dart';
|
||||
import 'package:lichess_mobile/src/model/tv/tv_repository.dart';
|
||||
import 'package:lichess_mobile/src/model/tv/tv_socket_events.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:lichess_mobile/src/network/socket.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
part 'tv_controller.freezed.dart';
|
||||
|
||||
@@ -2,9 +2,9 @@ import 'package:deep_pick/deep_pick.dart';
|
||||
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:lichess_mobile/src/model/common/chess.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/common/id.dart';
|
||||
import 'package:lichess_mobile/src/model/user/user.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
|
||||
import './tv_channel.dart';
|
||||
import './tv_game.dart';
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:deep_pick/deep_pick.dart';
|
||||
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/common/id.dart';
|
||||
import 'package:lichess_mobile/src/model/common/perf.dart';
|
||||
import 'package:lichess_mobile/src/model/user/leaderboard.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:lichess_mobile/src/utils/json.dart';
|
||||
|
||||
import 'streamer.dart';
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/common/id.dart';
|
||||
import 'package:lichess_mobile/src/model/common/perf.dart';
|
||||
import 'package:lichess_mobile/src/model/user/leaderboard.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
import 'streamer.dart';
|
||||
|
||||
@@ -146,10 +146,14 @@ class LoggingClient extends BaseClient {
|
||||
|
||||
/// Lichess HTTP client.
|
||||
///
|
||||
/// - All requests go to the lichess server, defined in [kLichessHost].
|
||||
/// - Sets the Authorization header when a token has been stored.
|
||||
/// - Sets the user-agent header with the app version, build number, and device info. If the user is logged in, it also includes the user's id.
|
||||
/// - Logs all requests and responses with status code >= 400.
|
||||
/// * All requests made with [head], [get], [post], [put], [patch], [delete] target
|
||||
/// the lichess server, defined in [kLichessHost]. It does not apply to the low-level
|
||||
/// [send] method.
|
||||
/// * Sets the Authorization header when a token has been stored.
|
||||
/// * Sets the user-agent header with the app version, build number, and device info. If the user is logged in, it also includes the user's id.
|
||||
/// * Logs all requests and responses with status code >= 400.
|
||||
/// * When a response has the 401 status, checks if the session token is still valid,
|
||||
/// and deletes the session if it's not.
|
||||
class LichessClient implements Client {
|
||||
LichessClient(this._inner, this._ref);
|
||||
|
||||
@@ -180,6 +184,10 @@ class LichessClient implements Client {
|
||||
|
||||
_logIfError(response);
|
||||
|
||||
if (response.statusCode == 401 && session != null) {
|
||||
_checkSessionToken(session);
|
||||
}
|
||||
|
||||
return response;
|
||||
} catch (e, st) {
|
||||
_logger.warning('Request to ${request.url} failed: $e', e, st);
|
||||
@@ -187,6 +195,18 @@ class LichessClient implements Client {
|
||||
}
|
||||
}
|
||||
|
||||
/// Checks if the session token is still valid, and delete session if it's not.
|
||||
Future<void> _checkSessionToken(AuthSessionState session) async {
|
||||
final data = await postReadJson(
|
||||
Uri(path: '/api/token/test'),
|
||||
mapper: (json) => json,
|
||||
).timeout(const Duration(seconds: 5));
|
||||
if (data[session.token] == null) {
|
||||
_logger.fine('Session is not active. Deleting it.');
|
||||
await _ref.read(authSessionProvider.notifier).delete();
|
||||
}
|
||||
}
|
||||
|
||||
void _logIfError(BaseResponse response) {
|
||||
if (response.request != null && response.statusCode >= 400) {
|
||||
final request = response.request!;
|
||||
@@ -11,7 +11,7 @@ import 'package:lichess_mobile/src/binding.dart';
|
||||
import 'package:lichess_mobile/src/constants.dart';
|
||||
import 'package:lichess_mobile/src/model/auth/auth_session.dart';
|
||||
import 'package:lichess_mobile/src/model/auth/bearer.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
@@ -5,7 +5,7 @@ import 'package:flutter/widgets.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:lichess_mobile/src/constants.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:lichess_mobile/src/utils/rate_limit.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
@@ -3,8 +3,8 @@ import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:lichess_mobile/src/model/account/account_repository.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/user/user.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:lichess_mobile/src/styles/styles.dart';
|
||||
import 'package:lichess_mobile/src/utils/l10n_context.dart';
|
||||
import 'package:lichess_mobile/src/view/user/countries.dart';
|
||||
|
||||
@@ -15,13 +15,13 @@ import 'package:lichess_mobile/src/model/analysis/server_analysis_service.dart';
|
||||
import 'package:lichess_mobile/src/model/auth/auth_session.dart';
|
||||
import 'package:lichess_mobile/src/model/common/chess.dart';
|
||||
import 'package:lichess_mobile/src/model/common/eval.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/common/id.dart';
|
||||
import 'package:lichess_mobile/src/model/engine/engine.dart';
|
||||
import 'package:lichess_mobile/src/model/engine/evaluation_service.dart';
|
||||
import 'package:lichess_mobile/src/model/game/game_repository_providers.dart';
|
||||
import 'package:lichess_mobile/src/model/game/game_share_service.dart';
|
||||
import 'package:lichess_mobile/src/model/settings/brightness.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:lichess_mobile/src/styles/lichess_icons.dart';
|
||||
import 'package:lichess_mobile/src/styles/styles.dart';
|
||||
import 'package:lichess_mobile/src/utils/connectivity.dart';
|
||||
|
||||
@@ -7,8 +7,8 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:lichess_mobile/src/model/broadcast/broadcast.dart';
|
||||
import 'package:lichess_mobile/src/model/broadcast/broadcast_round_controller.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/common/id.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:lichess_mobile/src/styles/styles.dart';
|
||||
import 'package:lichess_mobile/src/utils/duration.dart';
|
||||
import 'package:lichess_mobile/src/utils/lichess_assets.dart';
|
||||
|
||||
@@ -4,11 +4,11 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:lichess_mobile/src/model/analysis/analysis_controller.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/common/id.dart';
|
||||
import 'package:lichess_mobile/src/model/game/archived_game.dart';
|
||||
import 'package:lichess_mobile/src/model/game/game.dart';
|
||||
import 'package:lichess_mobile/src/model/game/game_repository_providers.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:lichess_mobile/src/utils/l10n_context.dart';
|
||||
import 'package:lichess_mobile/src/utils/navigation.dart';
|
||||
import 'package:lichess_mobile/src/view/analysis/analysis_screen.dart';
|
||||
|
||||
@@ -4,12 +4,12 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:lichess_mobile/src/model/challenge/challenge.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/common/id.dart';
|
||||
import 'package:lichess_mobile/src/model/common/time_increment.dart';
|
||||
import 'package:lichess_mobile/src/model/game/game.dart';
|
||||
import 'package:lichess_mobile/src/model/game/game_share_service.dart';
|
||||
import 'package:lichess_mobile/src/model/lobby/game_seek.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:lichess_mobile/src/utils/l10n_context.dart';
|
||||
import 'package:lichess_mobile/src/utils/share.dart';
|
||||
import 'package:lichess_mobile/src/widgets/adaptive_action_sheet.dart';
|
||||
|
||||
@@ -4,11 +4,11 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:lichess_mobile/src/model/analysis/analysis_controller.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/common/id.dart';
|
||||
import 'package:lichess_mobile/src/model/game/archived_game.dart';
|
||||
import 'package:lichess_mobile/src/model/game/game_share_service.dart';
|
||||
import 'package:lichess_mobile/src/model/game/game_status.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:lichess_mobile/src/styles/lichess_colors.dart';
|
||||
import 'package:lichess_mobile/src/styles/styles.dart';
|
||||
import 'package:lichess_mobile/src/utils/l10n_context.dart';
|
||||
|
||||
@@ -4,13 +4,13 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:lichess_mobile/src/model/account/account_repository.dart';
|
||||
import 'package:lichess_mobile/src/model/challenge/challenge.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/common/id.dart';
|
||||
import 'package:lichess_mobile/src/model/game/game_history.dart';
|
||||
import 'package:lichess_mobile/src/model/lobby/create_game_service.dart';
|
||||
import 'package:lichess_mobile/src/model/lobby/game_seek.dart';
|
||||
import 'package:lichess_mobile/src/model/lobby/game_setup_preferences.dart';
|
||||
import 'package:lichess_mobile/src/navigation.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:lichess_mobile/src/utils/l10n_context.dart';
|
||||
import 'package:lichess_mobile/src/utils/navigation.dart';
|
||||
import 'package:lichess_mobile/src/view/game/game_loading_board.dart';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:lichess_mobile/src/model/common/socket.dart';
|
||||
import 'package:lichess_mobile/src/network/socket.dart';
|
||||
import 'package:lichess_mobile/src/widgets/feedback.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
|
||||
@@ -10,13 +10,13 @@ import 'package:lichess_mobile/src/model/common/chess.dart';
|
||||
import 'package:lichess_mobile/src/model/common/game.dart';
|
||||
import 'package:lichess_mobile/src/model/common/id.dart';
|
||||
import 'package:lichess_mobile/src/model/common/perf.dart';
|
||||
import 'package:lichess_mobile/src/model/common/socket.dart';
|
||||
import 'package:lichess_mobile/src/model/common/time_increment.dart';
|
||||
import 'package:lichess_mobile/src/model/lobby/create_game_service.dart';
|
||||
import 'package:lichess_mobile/src/model/lobby/game_seek.dart';
|
||||
import 'package:lichess_mobile/src/model/lobby/game_setup_preferences.dart';
|
||||
import 'package:lichess_mobile/src/model/lobby/lobby_repository.dart';
|
||||
import 'package:lichess_mobile/src/model/user/user.dart';
|
||||
import 'package:lichess_mobile/src/network/socket.dart';
|
||||
import 'package:lichess_mobile/src/styles/styles.dart';
|
||||
import 'package:lichess_mobile/src/utils/l10n_context.dart';
|
||||
import 'package:lichess_mobile/src/utils/navigation.dart';
|
||||
|
||||
@@ -4,11 +4,11 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_linkify/flutter_linkify.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:lichess_mobile/src/model/auth/auth_session.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/common/id.dart';
|
||||
import 'package:lichess_mobile/src/model/common/perf.dart';
|
||||
import 'package:lichess_mobile/src/model/user/user.dart';
|
||||
import 'package:lichess_mobile/src/model/user/user_repository.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:lichess_mobile/src/styles/styles.dart';
|
||||
import 'package:lichess_mobile/src/utils/l10n_context.dart';
|
||||
import 'package:lichess_mobile/src/utils/navigation.dart';
|
||||
|
||||
@@ -8,7 +8,6 @@ import 'package:lichess_mobile/src/constants.dart';
|
||||
import 'package:lichess_mobile/src/model/analysis/analysis_controller.dart';
|
||||
import 'package:lichess_mobile/src/model/auth/auth_session.dart';
|
||||
import 'package:lichess_mobile/src/model/common/chess.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/common/id.dart';
|
||||
import 'package:lichess_mobile/src/model/engine/evaluation_service.dart';
|
||||
import 'package:lichess_mobile/src/model/game/game_repository_providers.dart';
|
||||
@@ -22,6 +21,7 @@ import 'package:lichess_mobile/src/model/puzzle/puzzle_service.dart';
|
||||
import 'package:lichess_mobile/src/model/puzzle/puzzle_theme.dart';
|
||||
import 'package:lichess_mobile/src/model/settings/board_preferences.dart';
|
||||
import 'package:lichess_mobile/src/navigation.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:lichess_mobile/src/utils/connectivity.dart';
|
||||
import 'package:lichess_mobile/src/utils/immersive_mode.dart';
|
||||
import 'package:lichess_mobile/src/utils/l10n_context.dart';
|
||||
|
||||
@@ -7,13 +7,13 @@ import 'package:lichess_mobile/src/constants.dart';
|
||||
import 'package:lichess_mobile/src/model/analysis/analysis_controller.dart';
|
||||
import 'package:lichess_mobile/src/model/auth/auth_session.dart';
|
||||
import 'package:lichess_mobile/src/model/common/chess.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/puzzle/puzzle_angle.dart';
|
||||
import 'package:lichess_mobile/src/model/puzzle/puzzle_controller.dart';
|
||||
import 'package:lichess_mobile/src/model/puzzle/puzzle_providers.dart';
|
||||
import 'package:lichess_mobile/src/model/puzzle/puzzle_service.dart';
|
||||
import 'package:lichess_mobile/src/model/puzzle/puzzle_streak.dart';
|
||||
import 'package:lichess_mobile/src/model/puzzle/puzzle_theme.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:lichess_mobile/src/styles/lichess_icons.dart';
|
||||
import 'package:lichess_mobile/src/styles/styles.dart';
|
||||
import 'package:lichess_mobile/src/utils/immersive_mode.dart';
|
||||
|
||||
@@ -3,11 +3,11 @@ import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_slidable/flutter_slidable.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/relation/online_friends.dart';
|
||||
import 'package:lichess_mobile/src/model/relation/relation_repository.dart';
|
||||
import 'package:lichess_mobile/src/model/relation/relation_repository_providers.dart';
|
||||
import 'package:lichess_mobile/src/model/user/user.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:lichess_mobile/src/styles/styles.dart';
|
||||
import 'package:lichess_mobile/src/utils/l10n_context.dart';
|
||||
import 'package:lichess_mobile/src/utils/navigation.dart';
|
||||
|
||||
@@ -11,12 +11,12 @@ import 'package:intl/intl.dart';
|
||||
import 'package:lichess_mobile/l10n/l10n.dart';
|
||||
import 'package:lichess_mobile/src/constants.dart';
|
||||
import 'package:lichess_mobile/src/model/auth/auth_session.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/common/perf.dart';
|
||||
import 'package:lichess_mobile/src/model/game/game_filter.dart';
|
||||
import 'package:lichess_mobile/src/model/game/game_repository.dart';
|
||||
import 'package:lichess_mobile/src/model/user/user.dart';
|
||||
import 'package:lichess_mobile/src/model/user/user_repository_providers.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:lichess_mobile/src/styles/lichess_icons.dart';
|
||||
import 'package:lichess_mobile/src/styles/styles.dart';
|
||||
import 'package:lichess_mobile/src/utils/duration.dart';
|
||||
|
||||
@@ -3,10 +3,10 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:lichess_mobile/src/model/account/account_repository.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/common/id.dart';
|
||||
import 'package:lichess_mobile/src/model/user/user.dart';
|
||||
import 'package:lichess_mobile/src/model/user/user_repository.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:lichess_mobile/src/styles/lichess_colors.dart';
|
||||
import 'package:lichess_mobile/src/styles/lichess_icons.dart';
|
||||
import 'package:lichess_mobile/src/styles/styles.dart';
|
||||
|
||||
@@ -2,10 +2,10 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:http/http.dart' show ClientException;
|
||||
import 'package:lichess_mobile/src/model/auth/auth_session.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/relation/relation_repository.dart';
|
||||
import 'package:lichess_mobile/src/model/user/user.dart';
|
||||
import 'package:lichess_mobile/src/model/user/user_repository_providers.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:lichess_mobile/src/styles/lichess_icons.dart';
|
||||
import 'package:lichess_mobile/src/styles/styles.dart';
|
||||
import 'package:lichess_mobile/src/utils/l10n_context.dart';
|
||||
|
||||
@@ -5,13 +5,13 @@ import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:lichess_mobile/src/model/broadcast/broadcast_providers.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/tv/featured_player.dart';
|
||||
import 'package:lichess_mobile/src/model/tv/tv_channel.dart';
|
||||
import 'package:lichess_mobile/src/model/tv/tv_game.dart';
|
||||
import 'package:lichess_mobile/src/model/tv/tv_repository.dart';
|
||||
import 'package:lichess_mobile/src/model/user/user_repository_providers.dart';
|
||||
import 'package:lichess_mobile/src/navigation.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:lichess_mobile/src/styles/styles.dart';
|
||||
import 'package:lichess_mobile/src/utils/l10n_context.dart';
|
||||
import 'package:lichess_mobile/src/utils/navigation.dart';
|
||||
|
||||
+56
-3
@@ -1,14 +1,19 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:http/testing.dart';
|
||||
import 'package:lichess_mobile/src/app.dart';
|
||||
import 'package:lichess_mobile/src/navigation.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
|
||||
import 'mock_server_responses.dart';
|
||||
import 'model/auth/fake_session_storage.dart';
|
||||
import 'test_helpers.dart';
|
||||
import 'test_provider_scope.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('App loads', (tester) async {
|
||||
final app = await makeProviderScope(
|
||||
final app = await makeTestProviderScope(
|
||||
tester,
|
||||
child: const Application(),
|
||||
);
|
||||
@@ -20,7 +25,7 @@ void main() {
|
||||
|
||||
testWidgets('App loads with system theme, which defaults to light',
|
||||
(tester) async {
|
||||
final app = await makeProviderScope(
|
||||
final app = await makeTestProviderScope(
|
||||
tester,
|
||||
child: const Application(),
|
||||
);
|
||||
@@ -33,8 +38,56 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
// testWidgets('App checks a stored session', (tester) async {
|
||||
// int tokenTestRequests = 0;
|
||||
// final mockClient = MockClient((request) {
|
||||
// if (request.url.path == '/api/token/test') {
|
||||
// tokenTestRequests++;
|
||||
// return mockResponse(
|
||||
// '''
|
||||
// {
|
||||
// "${fakeSession.token}": {
|
||||
// "scopes": "web:mobile",
|
||||
// "userId": "${fakeSession.user.id}"
|
||||
// }
|
||||
// }
|
||||
// ''',
|
||||
// 200,
|
||||
// );
|
||||
// } else if (request.url.path == '/api/account') {
|
||||
// return mockResponse(
|
||||
// mockApiAccountResponse(fakeSession.user.name),
|
||||
// 200,
|
||||
// );
|
||||
// }
|
||||
// return mockResponse('', 404);
|
||||
// });
|
||||
|
||||
// final app = await makeTestProviderScope(
|
||||
// tester,
|
||||
// child: const Application(),
|
||||
// userSession: fakeSession,
|
||||
// overrides: [
|
||||
// lichessClientProvider
|
||||
// .overrideWith((ref) => LichessClient(mockClient, ref)),
|
||||
// ],
|
||||
// );
|
||||
|
||||
// await tester.pumpWidget(app);
|
||||
|
||||
// expect(find.byType(MaterialApp), findsOneWidget);
|
||||
|
||||
// // wait for the session check request to complete
|
||||
// await tester.pump(const Duration(milliseconds: 100));
|
||||
|
||||
// expect(tokenTestRequests, 1);
|
||||
|
||||
// // session is still active
|
||||
// expect(find.text('Hello testUser'), findsOneWidget);
|
||||
// });
|
||||
|
||||
testWidgets('Bottom navigation', (tester) async {
|
||||
final app = await makeProviderScope(
|
||||
final app = await makeTestProviderScope(
|
||||
tester,
|
||||
child: const Application(),
|
||||
);
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
/// Mock server response for /api/account endpoint.
|
||||
String mockApiAccountResponse(String username) => '''
|
||||
{
|
||||
"id": "${username.toLowerCase()}",
|
||||
"username": "$username",
|
||||
"createdAt": 1290415680000,
|
||||
"seenAt": 1290415680000,
|
||||
"title": "GM",
|
||||
"patron": true,
|
||||
"perfs": {
|
||||
"blitz": {
|
||||
"games": 2340,
|
||||
"rating": 1681,
|
||||
"rd": 30,
|
||||
"prog": 10
|
||||
},
|
||||
"rapid": {
|
||||
"games": 2340,
|
||||
"rating": 1677,
|
||||
"rd": 30,
|
||||
"prog": 10
|
||||
},
|
||||
"classical": {
|
||||
"games": 2340,
|
||||
"rating": 1618,
|
||||
"rd": 30,
|
||||
"prog": 10
|
||||
}
|
||||
},
|
||||
"profile": {
|
||||
"country": "France",
|
||||
"location": "Lille",
|
||||
"bio": "test bio",
|
||||
"firstName": "John",
|
||||
"lastName": "Doe",
|
||||
"fideRating": 1800,
|
||||
"links": "http://test.com"
|
||||
}
|
||||
}
|
||||
''';
|
||||
@@ -2,7 +2,7 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:http/testing.dart';
|
||||
import 'package:lichess_mobile/src/model/account/account_preferences.dart';
|
||||
import 'package:lichess_mobile/src/model/account/account_repository.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
|
||||
import '../../test_container.dart';
|
||||
import '../../test_helpers.dart';
|
||||
|
||||
@@ -6,11 +6,12 @@ import 'package:lichess_mobile/src/model/auth/auth_controller.dart';
|
||||
import 'package:lichess_mobile/src/model/auth/auth_repository.dart';
|
||||
import 'package:lichess_mobile/src/model/auth/auth_session.dart';
|
||||
import 'package:lichess_mobile/src/model/auth/session_storage.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/common/id.dart';
|
||||
import 'package:lichess_mobile/src/model/user/user.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:mocktail/mocktail.dart';
|
||||
|
||||
import '../../mock_server_responses.dart';
|
||||
import '../../test_container.dart';
|
||||
import '../../test_helpers.dart';
|
||||
|
||||
@@ -22,15 +23,6 @@ class Listener<T> extends Mock {
|
||||
void call(T? previous, T value);
|
||||
}
|
||||
|
||||
final client = MockClient((request) {
|
||||
if (request.url.path == '/api/account') {
|
||||
return mockResponse(testAccountResponse, 200);
|
||||
} else if (request.method == 'DELETE' && request.url.path == '/api/token') {
|
||||
return mockResponse('ok', 200);
|
||||
}
|
||||
return mockResponse('', 404);
|
||||
});
|
||||
|
||||
void main() {
|
||||
final mockSessionStorage = MockSessionStorage();
|
||||
final mockFlutterAppAuth = MockFlutterAppAuth();
|
||||
@@ -47,6 +39,18 @@ void main() {
|
||||
const loading = AsyncLoading<void>();
|
||||
const nullData = AsyncData<void>(null);
|
||||
|
||||
final client = MockClient((request) {
|
||||
if (request.url.path == '/api/account') {
|
||||
return mockResponse(
|
||||
mockApiAccountResponse(testUserSession.user.name),
|
||||
200,
|
||||
);
|
||||
} else if (request.method == 'DELETE' && request.url.path == '/api/token') {
|
||||
return mockResponse('ok', 200);
|
||||
}
|
||||
return mockResponse('', 404);
|
||||
});
|
||||
|
||||
setUpAll(() {
|
||||
registerFallbackValue(
|
||||
AuthorizationTokenRequest(
|
||||
@@ -156,46 +160,6 @@ void main() {
|
||||
});
|
||||
}
|
||||
|
||||
const testAccountResponse = '''
|
||||
{
|
||||
"id": "test",
|
||||
"username": "test",
|
||||
"createdAt": 1290415680000,
|
||||
"seenAt": 1290415680000,
|
||||
"title": "GM",
|
||||
"patron": true,
|
||||
"perfs": {
|
||||
"blitz": {
|
||||
"games": 2340,
|
||||
"rating": 1681,
|
||||
"rd": 30,
|
||||
"prog": 10
|
||||
},
|
||||
"rapid": {
|
||||
"games": 2340,
|
||||
"rating": 1677,
|
||||
"rd": 30,
|
||||
"prog": 10
|
||||
},
|
||||
"classical": {
|
||||
"games": 2340,
|
||||
"rating": 1618,
|
||||
"rd": 30,
|
||||
"prog": 10
|
||||
}
|
||||
},
|
||||
"profile": {
|
||||
"country": "France",
|
||||
"location": "Lille",
|
||||
"bio": "test bio",
|
||||
"firstName": "John",
|
||||
"lastName": "Doe",
|
||||
"fideRating": 1800,
|
||||
"links": "http://test.com"
|
||||
}
|
||||
}
|
||||
''';
|
||||
|
||||
final signInResponse = AuthorizationTokenResponse(
|
||||
'testToken',
|
||||
null,
|
||||
|
||||
@@ -2,8 +2,8 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:http/testing.dart';
|
||||
import 'package:lichess_mobile/src/model/broadcast/broadcast.dart';
|
||||
import 'package:lichess_mobile/src/model/broadcast/broadcast_repository.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/common/id.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
|
||||
import '../../test_container.dart';
|
||||
import '../../test_helpers.dart';
|
||||
|
||||
@@ -3,8 +3,8 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:http/testing.dart';
|
||||
import 'package:lichess_mobile/src/model/challenge/challenge.dart';
|
||||
import 'package:lichess_mobile/src/model/challenge/challenge_repository.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/common/id.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
|
||||
import '../../test_container.dart';
|
||||
import '../../test_helpers.dart';
|
||||
|
||||
@@ -12,10 +12,10 @@ import 'package:lichess_mobile/src/model/notifications/notification_service.dart
|
||||
import 'package:lichess_mobile/src/model/user/user.dart';
|
||||
import 'package:mocktail/mocktail.dart';
|
||||
|
||||
import '../../network/fake_websocket_channel.dart';
|
||||
import '../../network/socket_test.dart';
|
||||
import '../../test_container.dart';
|
||||
import '../auth/fake_session_storage.dart';
|
||||
import '../common/fake_websocket_channel.dart';
|
||||
import '../common/socket_test.dart';
|
||||
|
||||
class NotificationDisplayMock extends Mock
|
||||
implements FlutterLocalNotificationsPlugin {}
|
||||
|
||||
@@ -2,10 +2,10 @@ import 'package:dartchess/dartchess.dart';
|
||||
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:http/testing.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/common/id.dart';
|
||||
import 'package:lichess_mobile/src/model/game/archived_game.dart';
|
||||
import 'package:lichess_mobile/src/model/game/game_repository.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
|
||||
import '../../test_container.dart';
|
||||
import '../../test_helpers.dart';
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:http/testing.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/common/id.dart';
|
||||
import 'package:lichess_mobile/src/model/lobby/correspondence_challenge.dart';
|
||||
import 'package:lichess_mobile/src/model/lobby/lobby_repository.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
|
||||
import '../../test_container.dart';
|
||||
import '../../test_helpers.dart';
|
||||
|
||||
@@ -5,13 +5,14 @@ import 'package:firebase_messaging/firebase_messaging.dart';
|
||||
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:http/testing.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/common/id.dart';
|
||||
import 'package:lichess_mobile/src/model/correspondence/correspondence_service.dart';
|
||||
import 'package:lichess_mobile/src/model/game/playable_game.dart';
|
||||
import 'package:lichess_mobile/src/model/notifications/notification_service.dart';
|
||||
import 'package:lichess_mobile/src/model/notifications/notifications.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:mocktail/mocktail.dart';
|
||||
|
||||
import '../../binding.dart';
|
||||
import '../../test_container.dart';
|
||||
import '../../test_helpers.dart';
|
||||
|
||||
@@ -2,10 +2,10 @@ import 'package:dartchess/dartchess.dart';
|
||||
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:http/testing.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/common/speed.dart';
|
||||
import 'package:lichess_mobile/src/model/opening_explorer/opening_explorer.dart';
|
||||
import 'package:lichess_mobile/src/model/opening_explorer/opening_explorer_repository.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
|
||||
import '../../test_container.dart';
|
||||
import '../../test_helpers.dart';
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:http/testing.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/puzzle/puzzle.dart';
|
||||
import 'package:lichess_mobile/src/model/puzzle/puzzle_repository.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
|
||||
import '../../test_container.dart';
|
||||
import '../../test_helpers.dart';
|
||||
|
||||
@@ -5,7 +5,6 @@ import 'package:fast_immutable_collections/fast_immutable_collections.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:http/testing.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/common/id.dart';
|
||||
import 'package:lichess_mobile/src/model/common/perf.dart';
|
||||
import 'package:lichess_mobile/src/model/puzzle/puzzle.dart';
|
||||
@@ -13,6 +12,7 @@ import 'package:lichess_mobile/src/model/puzzle/puzzle_angle.dart';
|
||||
import 'package:lichess_mobile/src/model/puzzle/puzzle_batch_storage.dart';
|
||||
import 'package:lichess_mobile/src/model/puzzle/puzzle_service.dart';
|
||||
import 'package:lichess_mobile/src/model/puzzle/puzzle_theme.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
|
||||
import '../../test_container.dart';
|
||||
import '../../test_helpers.dart';
|
||||
@@ -318,7 +318,7 @@ void main() {
|
||||
expect(nbReq, equals(1));
|
||||
|
||||
final data = await storage.fetch(userId: const UserId('testUserId'));
|
||||
expect(data?.solved, equals(IList(const [])));
|
||||
expect(data?.solved, equals(IList<PuzzleSolution>(const [])));
|
||||
expect(data?.unsolved[0].puzzle.id, equals(const PuzzleId('20yWT')));
|
||||
expect(next?.puzzle.puzzle.id, equals(const PuzzleId('20yWT')));
|
||||
expect(next?.glicko?.rating, equals(1834.54));
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:http/testing.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/relation/relation_repository.dart';
|
||||
import 'package:lichess_mobile/src/model/user/user.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
|
||||
import '../../test_container.dart';
|
||||
import '../../test_helpers.dart';
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:http/testing.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/common/id.dart';
|
||||
import 'package:lichess_mobile/src/model/common/perf.dart';
|
||||
import 'package:lichess_mobile/src/model/user/leaderboard.dart';
|
||||
import 'package:lichess_mobile/src/model/user/user.dart';
|
||||
import 'package:lichess_mobile/src/model/user/user_repository.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
|
||||
import '../../test_container.dart';
|
||||
import '../../test_helpers.dart';
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:async/src/stream_sink_transformer.dart';
|
||||
import 'package:lichess_mobile/src/model/common/socket.dart';
|
||||
import 'package:lichess_mobile/src/network/socket.dart';
|
||||
import 'package:stream_channel/stream_channel.dart';
|
||||
import 'package:web_socket_channel/web_socket_channel.dart';
|
||||
|
||||
@@ -2,7 +2,7 @@ import 'dart:io';
|
||||
|
||||
import 'package:device_info_plus/device_info_plus.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:lichess_mobile/src/model/common/socket.dart';
|
||||
import 'package:lichess_mobile/src/network/socket.dart';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
|
||||
import 'fake_websocket_channel.dart';
|
||||
@@ -8,10 +8,10 @@ import 'package:intl/intl.dart';
|
||||
import 'package:lichess_mobile/src/crashlytics.dart';
|
||||
import 'package:lichess_mobile/src/db/database.dart';
|
||||
import 'package:lichess_mobile/src/model/auth/auth_session.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/common/service/sound_service.dart';
|
||||
import 'package:lichess_mobile/src/model/common/socket.dart';
|
||||
import 'package:lichess_mobile/src/model/notifications/notification_service.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:lichess_mobile/src/network/socket.dart';
|
||||
import 'package:lichess_mobile/src/utils/connectivity.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:sqflite_common_ffi/sqflite_ffi.dart';
|
||||
@@ -19,8 +19,8 @@ import 'package:sqflite_common_ffi/sqflite_ffi.dart';
|
||||
import './fake_crashlytics.dart';
|
||||
import './model/common/service/fake_sound_service.dart';
|
||||
import 'binding.dart';
|
||||
import 'model/common/fake_websocket_channel.dart';
|
||||
import 'model/notifications/fake_notification_display.dart';
|
||||
import 'network/fake_websocket_channel.dart';
|
||||
import 'utils/fake_connectivity.dart';
|
||||
|
||||
/// A mock client that always returns a 200 empty response.
|
||||
|
||||
@@ -14,11 +14,11 @@ import 'package:lichess_mobile/src/db/database.dart';
|
||||
import 'package:lichess_mobile/src/model/account/account_preferences.dart';
|
||||
import 'package:lichess_mobile/src/model/auth/auth_session.dart';
|
||||
import 'package:lichess_mobile/src/model/auth/session_storage.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/common/service/sound_service.dart';
|
||||
import 'package:lichess_mobile/src/model/common/socket.dart';
|
||||
import 'package:lichess_mobile/src/model/notifications/notification_service.dart';
|
||||
import 'package:lichess_mobile/src/model/settings/board_preferences.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:lichess_mobile/src/network/socket.dart';
|
||||
import 'package:lichess_mobile/src/utils/connectivity.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:sqflite_common_ffi/sqflite_ffi.dart';
|
||||
@@ -27,8 +27,8 @@ import 'package:visibility_detector/visibility_detector.dart';
|
||||
import './fake_crashlytics.dart';
|
||||
import './model/common/service/fake_sound_service.dart';
|
||||
import 'binding.dart';
|
||||
import 'model/common/fake_websocket_channel.dart';
|
||||
import 'model/notifications/fake_notification_display.dart';
|
||||
import 'network/fake_websocket_channel.dart';
|
||||
import 'test_helpers.dart';
|
||||
import 'utils/fake_connectivity.dart';
|
||||
|
||||
@@ -45,14 +45,14 @@ final mockClient = MockClient((request) async {
|
||||
/// The [overrides] parameter can be used to override any provider in the app.
|
||||
/// The [userSession] parameter can be used to set the initial user session state.
|
||||
/// The [defaultPreferences] parameter can be used to set the initial shared preferences.
|
||||
Future<Widget> makeProviderScopeApp(
|
||||
Future<Widget> makeTestProviderScopeApp(
|
||||
WidgetTester tester, {
|
||||
required Widget home,
|
||||
List<Override>? overrides,
|
||||
AuthSessionState? userSession,
|
||||
Map<String, Object>? defaultPreferences,
|
||||
}) async {
|
||||
return makeProviderScope(
|
||||
return makeTestProviderScope(
|
||||
tester,
|
||||
child: MaterialApp(
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
@@ -79,7 +79,7 @@ Future<Widget> makeProviderScopeApp(
|
||||
/// The [overrides] parameter can be used to override any provider in the app.
|
||||
/// The [userSession] parameter can be used to set the initial user session state.
|
||||
/// The [defaultPreferences] parameter can be used to set the initial shared preferences.
|
||||
Future<Widget> makeProviderScope(
|
||||
Future<Widget> makeTestProviderScope(
|
||||
WidgetTester tester, {
|
||||
required Widget child,
|
||||
List<Override>? overrides,
|
||||
|
||||
@@ -29,7 +29,7 @@ void main() {
|
||||
|
||||
group('Analysis Screen', () {
|
||||
testWidgets('displays correct move and position', (tester) async {
|
||||
final app = await makeProviderScopeApp(
|
||||
final app = await makeTestProviderScopeApp(
|
||||
tester,
|
||||
home: AnalysisScreen(
|
||||
pgnOrId: sanMoves,
|
||||
@@ -56,7 +56,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('move backwards and forward', (tester) async {
|
||||
final app = await makeProviderScopeApp(
|
||||
final app = await makeTestProviderScopeApp(
|
||||
tester,
|
||||
home: AnalysisScreen(
|
||||
pgnOrId: sanMoves,
|
||||
|
||||
@@ -12,7 +12,7 @@ import '../../test_provider_scope.dart';
|
||||
void main() {
|
||||
group('Board Editor', () {
|
||||
testWidgets('Displays initial FEN on start', (tester) async {
|
||||
final app = await makeProviderScopeApp(
|
||||
final app = await makeTestProviderScopeApp(
|
||||
tester,
|
||||
home: const BoardEditorScreen(),
|
||||
);
|
||||
@@ -37,7 +37,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('Flip board', (tester) async {
|
||||
final app = await makeProviderScopeApp(
|
||||
final app = await makeTestProviderScopeApp(
|
||||
tester,
|
||||
home: const BoardEditorScreen(),
|
||||
);
|
||||
@@ -57,7 +57,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('Side to play and castling rights', (tester) async {
|
||||
final app = await makeProviderScopeApp(
|
||||
final app = await makeTestProviderScopeApp(
|
||||
tester,
|
||||
home: const BoardEditorScreen(),
|
||||
);
|
||||
@@ -120,7 +120,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('Castling rights ignored when rook is missing', (tester) async {
|
||||
final app = await makeProviderScopeApp(
|
||||
final app = await makeTestProviderScopeApp(
|
||||
tester,
|
||||
home: const BoardEditorScreen(),
|
||||
);
|
||||
@@ -145,7 +145,7 @@ void main() {
|
||||
|
||||
testWidgets('Possible en passant squares are calculated correctly',
|
||||
(tester) async {
|
||||
final app = await makeProviderScopeApp(
|
||||
final app = await makeTestProviderScopeApp(
|
||||
tester,
|
||||
home: const BoardEditorScreen(),
|
||||
);
|
||||
@@ -182,7 +182,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('Can drag pieces to new squares', (tester) async {
|
||||
final app = await makeProviderScopeApp(
|
||||
final app = await makeTestProviderScopeApp(
|
||||
tester,
|
||||
home: const BoardEditorScreen(),
|
||||
);
|
||||
@@ -211,7 +211,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('illegal position cannot be analyzed', (tester) async {
|
||||
final app = await makeProviderScopeApp(
|
||||
final app = await makeTestProviderScopeApp(
|
||||
tester,
|
||||
home: const BoardEditorScreen(),
|
||||
);
|
||||
@@ -231,7 +231,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('Delete pieces via bin button', (tester) async {
|
||||
final app = await makeProviderScopeApp(
|
||||
final app = await makeTestProviderScopeApp(
|
||||
tester,
|
||||
home: const BoardEditorScreen(),
|
||||
);
|
||||
@@ -273,7 +273,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('Add pieces via tap and pan', (tester) async {
|
||||
final app = await makeProviderScopeApp(
|
||||
final app = await makeTestProviderScopeApp(
|
||||
tester,
|
||||
home: const BoardEditorScreen(),
|
||||
);
|
||||
@@ -297,7 +297,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('Drag pieces onto the board', (tester) async {
|
||||
final app = await makeProviderScopeApp(
|
||||
final app = await makeTestProviderScopeApp(
|
||||
tester,
|
||||
home: const BoardEditorScreen(),
|
||||
);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:http/testing.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:lichess_mobile/src/view/broadcast/broadcasts_list_screen.dart';
|
||||
import 'package:network_image_mock/network_image_mock.dart';
|
||||
|
||||
@@ -24,7 +24,7 @@ void main() {
|
||||
'Displays broadcast tournament screen',
|
||||
variant: kPlatformVariant,
|
||||
(tester) async {
|
||||
final app = await makeProviderScopeApp(
|
||||
final app = await makeTestProviderScopeApp(
|
||||
tester,
|
||||
home: const BroadcastsListScreen(),
|
||||
overrides: [
|
||||
@@ -48,7 +48,7 @@ void main() {
|
||||
'Scroll broadcast tournament screen',
|
||||
variant: kPlatformVariant,
|
||||
(tester) async {
|
||||
final app = await makeProviderScopeApp(
|
||||
final app = await makeTestProviderScopeApp(
|
||||
tester,
|
||||
home: const BroadcastsListScreen(),
|
||||
overrides: [
|
||||
|
||||
@@ -13,7 +13,7 @@ void main() {
|
||||
group('Coordinate Training', () {
|
||||
testWidgets('Initial state when started in FindSquare mode',
|
||||
(tester) async {
|
||||
final app = await makeProviderScopeApp(
|
||||
final app = await makeTestProviderScopeApp(
|
||||
tester,
|
||||
home: const CoordinateTrainingScreen(),
|
||||
);
|
||||
@@ -52,7 +52,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('Tap wrong square', (tester) async {
|
||||
final app = await makeProviderScopeApp(
|
||||
final app = await makeTestProviderScopeApp(
|
||||
tester,
|
||||
home: const CoordinateTrainingScreen(),
|
||||
);
|
||||
@@ -101,7 +101,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('Tap correct square', (tester) async {
|
||||
final app = await makeProviderScopeApp(
|
||||
final app = await makeTestProviderScopeApp(
|
||||
tester,
|
||||
home: const CoordinateTrainingScreen(),
|
||||
);
|
||||
|
||||
@@ -4,7 +4,6 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:http/testing.dart';
|
||||
import 'package:lichess_mobile/src/model/common/chess.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/common/id.dart';
|
||||
import 'package:lichess_mobile/src/model/common/perf.dart';
|
||||
import 'package:lichess_mobile/src/model/common/speed.dart';
|
||||
@@ -12,6 +11,7 @@ import 'package:lichess_mobile/src/model/game/archived_game.dart';
|
||||
import 'package:lichess_mobile/src/model/game/game_status.dart';
|
||||
import 'package:lichess_mobile/src/model/game/player.dart';
|
||||
import 'package:lichess_mobile/src/model/user/user.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:lichess_mobile/src/view/game/archived_game_screen.dart';
|
||||
import 'package:lichess_mobile/src/view/game/game_player.dart';
|
||||
import 'package:lichess_mobile/src/widgets/bottom_bar_button.dart';
|
||||
@@ -32,7 +32,7 @@ void main() {
|
||||
testWidgets(
|
||||
'loads game data if only game id is provided',
|
||||
(tester) async {
|
||||
final app = await makeProviderScopeApp(
|
||||
final app = await makeTestProviderScopeApp(
|
||||
tester,
|
||||
home: const ArchivedGameScreen(
|
||||
gameId: GameId('qVChCOTc'),
|
||||
@@ -65,7 +65,7 @@ void main() {
|
||||
testWidgets(
|
||||
'displays game data and last fen immediately, then moves',
|
||||
(tester) async {
|
||||
final app = await makeProviderScopeApp(
|
||||
final app = await makeTestProviderScopeApp(
|
||||
tester,
|
||||
home: ArchivedGameScreen(
|
||||
gameData: gameData,
|
||||
@@ -138,7 +138,7 @@ void main() {
|
||||
);
|
||||
|
||||
testWidgets('navigate game positions', (tester) async {
|
||||
final app = await makeProviderScopeApp(
|
||||
final app = await makeTestProviderScopeApp(
|
||||
tester,
|
||||
home: ArchivedGameScreen(
|
||||
gameData: gameData,
|
||||
|
||||
@@ -7,13 +7,13 @@ import 'package:http/testing.dart';
|
||||
import 'package:lichess_mobile/src/model/analysis/analysis_controller.dart';
|
||||
import 'package:lichess_mobile/src/model/auth/auth_session.dart';
|
||||
import 'package:lichess_mobile/src/model/common/chess.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/common/id.dart';
|
||||
import 'package:lichess_mobile/src/model/opening_explorer/opening_explorer.dart';
|
||||
import 'package:lichess_mobile/src/model/opening_explorer/opening_explorer_preferences.dart';
|
||||
import 'package:lichess_mobile/src/model/settings/preferences.dart';
|
||||
import 'package:lichess_mobile/src/model/settings/preferences_storage.dart';
|
||||
import 'package:lichess_mobile/src/model/user/user.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:lichess_mobile/src/view/opening_explorer/opening_explorer_screen.dart';
|
||||
|
||||
import '../../test_helpers.dart';
|
||||
@@ -63,7 +63,7 @@ void main() {
|
||||
testWidgets(
|
||||
'master opening explorer loads',
|
||||
(WidgetTester tester) async {
|
||||
final app = await makeProviderScopeApp(
|
||||
final app = await makeTestProviderScopeApp(
|
||||
tester,
|
||||
home: const OpeningExplorerScreen(
|
||||
pgn: '',
|
||||
@@ -112,7 +112,7 @@ void main() {
|
||||
testWidgets(
|
||||
'lichess opening explorer loads',
|
||||
(WidgetTester tester) async {
|
||||
final app = await makeProviderScopeApp(
|
||||
final app = await makeTestProviderScopeApp(
|
||||
tester,
|
||||
home: const OpeningExplorerScreen(
|
||||
pgn: '',
|
||||
@@ -167,7 +167,7 @@ void main() {
|
||||
testWidgets(
|
||||
'player opening explorer loads',
|
||||
(WidgetTester tester) async {
|
||||
final app = await makeProviderScopeApp(
|
||||
final app = await makeTestProviderScopeApp(
|
||||
tester,
|
||||
home: const OpeningExplorerScreen(
|
||||
pgn: '',
|
||||
|
||||
@@ -203,7 +203,7 @@ Future<Rect> initOverTheBoardGame(
|
||||
WidgetTester tester,
|
||||
TimeIncrement timeIncrement,
|
||||
) async {
|
||||
final app = await makeProviderScopeApp(
|
||||
final app = await makeTestProviderScopeApp(
|
||||
tester,
|
||||
home: const OverTheBoardScreen(),
|
||||
);
|
||||
|
||||
@@ -6,7 +6,6 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:http/testing.dart';
|
||||
import 'package:lichess_mobile/src/model/account/account_preferences.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/common/id.dart';
|
||||
import 'package:lichess_mobile/src/model/common/perf.dart';
|
||||
import 'package:lichess_mobile/src/model/puzzle/puzzle.dart';
|
||||
@@ -14,6 +13,7 @@ import 'package:lichess_mobile/src/model/puzzle/puzzle_angle.dart';
|
||||
import 'package:lichess_mobile/src/model/puzzle/puzzle_batch_storage.dart';
|
||||
import 'package:lichess_mobile/src/model/puzzle/puzzle_storage.dart';
|
||||
import 'package:lichess_mobile/src/model/puzzle/puzzle_theme.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:lichess_mobile/src/utils/string.dart';
|
||||
import 'package:lichess_mobile/src/view/puzzle/puzzle_screen.dart';
|
||||
import 'package:lichess_mobile/src/widgets/bottom_bar_button.dart';
|
||||
@@ -47,7 +47,7 @@ void main() {
|
||||
(WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
|
||||
final app = await makeProviderScopeApp(
|
||||
final app = await makeTestProviderScopeApp(
|
||||
tester,
|
||||
home: PuzzleScreen(
|
||||
angle: const PuzzleTheme(PuzzleThemeKey.mix),
|
||||
@@ -78,7 +78,7 @@ void main() {
|
||||
'Loads puzzle directly by passing a puzzleId',
|
||||
variant: kPlatformVariant,
|
||||
(tester) async {
|
||||
final app = await makeProviderScopeApp(
|
||||
final app = await makeTestProviderScopeApp(
|
||||
tester,
|
||||
home: PuzzleScreen(
|
||||
angle: const PuzzleTheme(PuzzleThemeKey.mix),
|
||||
@@ -104,7 +104,7 @@ void main() {
|
||||
);
|
||||
|
||||
testWidgets('Loads next puzzle when no puzzleId is passed', (tester) async {
|
||||
final app = await makeProviderScopeApp(
|
||||
final app = await makeTestProviderScopeApp(
|
||||
tester,
|
||||
home: const PuzzleScreen(
|
||||
angle: PuzzleTheme(PuzzleThemeKey.mix),
|
||||
@@ -151,7 +151,7 @@ void main() {
|
||||
when(() => mockHistoryStorage.fetch(puzzleId: puzzle2.puzzle.id))
|
||||
.thenAnswer((_) async => puzzle2);
|
||||
|
||||
final app = await makeProviderScopeApp(
|
||||
final app = await makeTestProviderScopeApp(
|
||||
tester,
|
||||
home: PuzzleScreen(
|
||||
angle: const PuzzleTheme(PuzzleThemeKey.mix),
|
||||
@@ -264,7 +264,7 @@ void main() {
|
||||
when(() => mockHistoryStorage.fetch(puzzleId: puzzle2.puzzle.id))
|
||||
.thenAnswer((_) async => puzzle2);
|
||||
|
||||
final app = await makeProviderScopeApp(
|
||||
final app = await makeTestProviderScopeApp(
|
||||
tester,
|
||||
home: PuzzleScreen(
|
||||
angle: const PuzzleTheme(PuzzleThemeKey.mix),
|
||||
@@ -377,7 +377,7 @@ void main() {
|
||||
return mockResponse('', 404);
|
||||
});
|
||||
|
||||
final app = await makeProviderScopeApp(
|
||||
final app = await makeTestProviderScopeApp(
|
||||
tester,
|
||||
home: PuzzleScreen(
|
||||
angle: const PuzzleTheme(PuzzleThemeKey.mix),
|
||||
|
||||
@@ -4,11 +4,11 @@ import 'package:fast_immutable_collections/fast_immutable_collections.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:http/testing.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/common/id.dart';
|
||||
import 'package:lichess_mobile/src/model/puzzle/puzzle.dart';
|
||||
import 'package:lichess_mobile/src/model/puzzle/puzzle_providers.dart';
|
||||
import 'package:lichess_mobile/src/model/puzzle/puzzle_repository.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:lichess_mobile/src/view/puzzle/storm_screen.dart';
|
||||
|
||||
import '../../test_helpers.dart';
|
||||
@@ -28,7 +28,7 @@ void main() {
|
||||
(tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
|
||||
final app = await makeProviderScopeApp(
|
||||
final app = await makeTestProviderScopeApp(
|
||||
tester,
|
||||
home: const StormScreen(),
|
||||
overrides: [
|
||||
@@ -49,7 +49,7 @@ void main() {
|
||||
testWidgets(
|
||||
'Load puzzle and play white pieces',
|
||||
(tester) async {
|
||||
final app = await makeProviderScopeApp(
|
||||
final app = await makeTestProviderScopeApp(
|
||||
tester,
|
||||
home: const StormScreen(),
|
||||
overrides: [
|
||||
@@ -73,7 +73,7 @@ void main() {
|
||||
testWidgets(
|
||||
'Play one puzzle',
|
||||
(tester) async {
|
||||
final app = await makeProviderScopeApp(
|
||||
final app = await makeTestProviderScopeApp(
|
||||
tester,
|
||||
home: const StormScreen(),
|
||||
overrides: [
|
||||
@@ -128,7 +128,7 @@ void main() {
|
||||
);
|
||||
|
||||
testWidgets('shows end run result', (tester) async {
|
||||
final app = await makeProviderScopeApp(
|
||||
final app = await makeTestProviderScopeApp(
|
||||
tester,
|
||||
home: const StormScreen(),
|
||||
overrides: [
|
||||
@@ -173,7 +173,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('play wrong move', (tester) async {
|
||||
final app = await makeProviderScopeApp(
|
||||
final app = await makeTestProviderScopeApp(
|
||||
tester,
|
||||
home: const StormScreen(),
|
||||
overrides: [
|
||||
|
||||
@@ -4,7 +4,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:http/testing.dart';
|
||||
import 'package:lichess_mobile/src/db/database.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:lichess_mobile/src/view/settings/settings_tab_screen.dart';
|
||||
import 'package:lichess_mobile/src/widgets/list.dart';
|
||||
|
||||
@@ -26,7 +26,7 @@ void main() {
|
||||
(WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
|
||||
final app = await makeProviderScopeApp(
|
||||
final app = await makeTestProviderScopeApp(
|
||||
tester,
|
||||
home: const SettingsTabScreen(),
|
||||
);
|
||||
@@ -46,7 +46,7 @@ void main() {
|
||||
testWidgets(
|
||||
"don't show signOut if no session",
|
||||
(WidgetTester tester) async {
|
||||
final app = await makeProviderScopeApp(
|
||||
final app = await makeTestProviderScopeApp(
|
||||
tester,
|
||||
home: const SettingsTabScreen(),
|
||||
);
|
||||
@@ -61,7 +61,7 @@ void main() {
|
||||
testWidgets(
|
||||
'signout',
|
||||
(WidgetTester tester) async {
|
||||
final app = await makeProviderScopeApp(
|
||||
final app = await makeTestProviderScopeApp(
|
||||
tester,
|
||||
home: const SettingsTabScreen(),
|
||||
userSession: fakeSession,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:http/testing.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:lichess_mobile/src/view/user/leaderboard_screen.dart';
|
||||
|
||||
import '../../test_helpers.dart';
|
||||
@@ -21,7 +21,7 @@ void main() {
|
||||
(WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
|
||||
final app = await makeProviderScopeApp(
|
||||
final app = await makeTestProviderScopeApp(
|
||||
tester,
|
||||
overrides: [
|
||||
lichessClientProvider
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:http/testing.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:lichess_mobile/src/view/user/leaderboard_screen.dart';
|
||||
import 'package:lichess_mobile/src/view/user/leaderboard_widget.dart';
|
||||
|
||||
@@ -21,7 +21,7 @@ void main() {
|
||||
'accessibility and basic info showing test',
|
||||
(WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
final app = await makeProviderScopeApp(
|
||||
final app = await makeTestProviderScopeApp(
|
||||
tester,
|
||||
home: Column(children: [LeaderboardWidget()]),
|
||||
overrides: [
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:http/testing.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/common/perf.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:lichess_mobile/src/view/user/perf_stats_screen.dart';
|
||||
import 'package:lichess_mobile/src/widgets/platform.dart';
|
||||
|
||||
@@ -27,7 +27,7 @@ void main() {
|
||||
(WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
|
||||
final app = await makeProviderScopeApp(
|
||||
final app = await makeTestProviderScopeApp(
|
||||
tester,
|
||||
home: PerfStatsScreen(
|
||||
user: fakeUser,
|
||||
@@ -59,7 +59,7 @@ void main() {
|
||||
testWidgets(
|
||||
'screen loads, required stats are shown',
|
||||
(WidgetTester tester) async {
|
||||
final app = await makeProviderScopeApp(
|
||||
final app = await makeTestProviderScopeApp(
|
||||
tester,
|
||||
home: PerfStatsScreen(
|
||||
user: fakeUser,
|
||||
|
||||
@@ -3,7 +3,7 @@ import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:http/testing.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:lichess_mobile/src/view/user/search_screen.dart';
|
||||
import 'package:lichess_mobile/src/widgets/user_list_tile.dart';
|
||||
|
||||
@@ -25,7 +25,7 @@ void main() {
|
||||
testWidgets(
|
||||
'should see search results',
|
||||
(WidgetTester tester) async {
|
||||
final app = await makeProviderScopeApp(
|
||||
final app = await makeTestProviderScopeApp(
|
||||
tester,
|
||||
home: const SearchScreen(),
|
||||
overrides: [
|
||||
@@ -66,7 +66,7 @@ void main() {
|
||||
testWidgets(
|
||||
'should see "no result" when search finds nothing',
|
||||
(WidgetTester tester) async {
|
||||
final app = await makeProviderScopeApp(
|
||||
final app = await makeTestProviderScopeApp(
|
||||
tester,
|
||||
home: const SearchScreen(),
|
||||
overrides: [
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:http/testing.dart';
|
||||
import 'package:lichess_mobile/src/model/common/http.dart';
|
||||
import 'package:lichess_mobile/src/model/common/id.dart';
|
||||
import 'package:lichess_mobile/src/model/user/user.dart';
|
||||
import 'package:lichess_mobile/src/network/http.dart';
|
||||
import 'package:lichess_mobile/src/view/user/user_screen.dart';
|
||||
|
||||
import '../../model/user/user_repository_test.dart';
|
||||
@@ -38,7 +38,7 @@ void main() {
|
||||
testWidgets(
|
||||
'should see activity and recent games',
|
||||
(WidgetTester tester) async {
|
||||
final app = await makeProviderScopeApp(
|
||||
final app = await makeTestProviderScopeApp(
|
||||
tester,
|
||||
home: const UserScreen(user: testUser),
|
||||
overrides: [
|
||||
|
||||
Reference in New Issue
Block a user