generated from ttipo/project-base
fix(flutter): 대구 밖 현재 위치는 대구 도심으로 대신하고 안내함
현재 위치를 그대로 쓰면 대구 밖(서울 등)에서는 모든 칸이 "근처에 아직 없어요"로 비었다(2026-11-04 회귀 점검). 서비스 지역(대구, 군위 포함 — 백엔드 geo.ts 와 같은 영역) 밖이면 대구 도심을 기준으로 쓰고, 홈에서 "아직 대구 지역만 볼 수 있어요"를 한 번 알린다. 위치를 받지 못해 대신하는 경우도 지금까지는 기준만 조용히 바뀌었는데, 같은 방식으로 알린다. 대신한 이유는 BasePoint.fallback 에 남는다. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit was merged in pull request #7.
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:wandergo/features/location/domain/base_location.dart';
|
||||
|
||||
void main() {
|
||||
group('isInServiceArea', () {
|
||||
test('대구 동네·군위군·경산 경계는 서비스 지역 안이다', () {
|
||||
for (final n in Neighborhood.values) {
|
||||
expect(isInServiceArea(n.point), isTrue, reason: n.name);
|
||||
}
|
||||
expect(isInServiceArea((lat: 36.2427, lng: 128.5728)), isTrue); // 군위군청
|
||||
expect(isInServiceArea((lat: 35.8251, lng: 128.7415)), isTrue); // 경산시청
|
||||
});
|
||||
|
||||
test('서울·부산·포항은 서비스 지역 밖이다', () {
|
||||
expect(isInServiceArea((lat: 37.5663, lng: 126.9779)), isFalse);
|
||||
expect(isInServiceArea((lat: 35.1796, lng: 129.0756)), isFalse);
|
||||
expect(isInServiceArea((lat: 36.0190, lng: 129.3435)), isFalse);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -179,16 +179,21 @@ class _FakePlaceRepository implements PlaceRepository {
|
||||
}
|
||||
|
||||
class _FakeLocationService implements LocationService {
|
||||
const _FakeLocationService({this.granted = true});
|
||||
const _FakeLocationService({
|
||||
this.granted = true,
|
||||
this.point = (lat: 35.85, lng: 128.6),
|
||||
});
|
||||
|
||||
final bool granted;
|
||||
|
||||
/// 권한이 있을 때 돌려줄 현재 위치(기본은 대구 수성구)
|
||||
final GeoPoint point;
|
||||
|
||||
@override
|
||||
Future<bool> requestPermission() async => granted;
|
||||
|
||||
@override
|
||||
Future<GeoPoint?> currentPoint() async =>
|
||||
granted ? (lat: 35.85, lng: 128.6) : null;
|
||||
Future<GeoPoint?> currentPoint() async => granted ? point : null;
|
||||
}
|
||||
|
||||
Future<_FakeEventRepository> _pumpApp(
|
||||
@@ -197,6 +202,7 @@ Future<_FakeEventRepository> _pumpApp(
|
||||
_FakeEventRepository? repo,
|
||||
_FakePlaceRepository? places,
|
||||
bool locationGranted = true,
|
||||
GeoPoint currentPoint = (lat: 35.85, lng: 128.6),
|
||||
}) async {
|
||||
SharedPreferences.setMockInitialValues({'app_locale': 'ko', ...prefs});
|
||||
final preferences = await SharedPreferences.getInstance();
|
||||
@@ -210,7 +216,7 @@ Future<_FakeEventRepository> _pumpApp(
|
||||
places ?? _FakePlaceRepository(),
|
||||
),
|
||||
locationServiceProvider.overrideWithValue(
|
||||
_FakeLocationService(granted: locationGranted),
|
||||
_FakeLocationService(granted: locationGranted, point: currentPoint),
|
||||
),
|
||||
clockProvider.overrideWithValue(() => _now),
|
||||
],
|
||||
@@ -475,4 +481,28 @@ void main() {
|
||||
);
|
||||
semantics.dispose();
|
||||
});
|
||||
|
||||
// 2026-11-04 회귀 점검: 대구 밖 좌표를 그대로 써서 모든 칸이 "근처에 아직 없어요"로 비었다
|
||||
testWidgets('대구 밖에서 현재 위치를 고르면 대구 도심을 기준으로 보이고 안내한다', (tester) async {
|
||||
final events = await _pumpApp(
|
||||
tester,
|
||||
prefs: {'onboarding_done': true, 'base_location': 'current'},
|
||||
currentPoint: (lat: 37.5663, lng: 126.9779), // 서울시청
|
||||
);
|
||||
|
||||
expect(find.text('아직 대구 지역만 볼 수 있어요. 대구 도심을 기준으로 보여 드려요.'), findsOneWidget);
|
||||
expect(find.text('대구 도심'), findsOneWidget);
|
||||
expect(events.calls.last.near, Neighborhood.downtown.point);
|
||||
});
|
||||
|
||||
testWidgets('현재 위치를 받지 못하면 대구 도심을 기준으로 보이고 안내한다', (tester) async {
|
||||
final events = await _pumpApp(
|
||||
tester,
|
||||
prefs: {'onboarding_done': true, 'base_location': 'current'},
|
||||
locationGranted: false,
|
||||
);
|
||||
|
||||
expect(find.text('현재 위치를 가져오지 못해 대구 도심을 기준으로 보여 드려요.'), findsOneWidget);
|
||||
expect(events.calls.last.near, Neighborhood.downtown.point);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user