feat(app): phone onboarding (server, then password) kept across launches; a known server opens straight into the app; a refused session asks for the password
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/application/app_session.dart';
|
||||
|
||||
void main() {
|
||||
test('a known server opens the app instead of the connection screen', () {
|
||||
final fresh = AppSession(endpoint: null);
|
||||
final known = AppSession(endpoint: null, knownServer: true);
|
||||
addTearDown(fresh.dispose);
|
||||
addTearDown(known.dispose);
|
||||
expect(fresh.everConnected, isFalse);
|
||||
expect(known.everConnected, isTrue);
|
||||
});
|
||||
}
|
||||
@@ -26,29 +26,25 @@ class _TestSettingsStore implements SettingsStore {
|
||||
void main() {
|
||||
const nativeBase = 'http://127.0.0.1:8096/';
|
||||
|
||||
test(
|
||||
'uses saved endpoint natively only when build configuration is blank',
|
||||
() async {
|
||||
final store = _TestSettingsStore('wss://saved.example.test');
|
||||
final saved = await resolveLaunchServer(
|
||||
base: Uri.parse(nativeBase),
|
||||
configured: '',
|
||||
web: false,
|
||||
settingsStore: store,
|
||||
);
|
||||
expect(saved.uri, Uri.parse('wss://saved.example.test/connect'));
|
||||
expect(store.loads, 1);
|
||||
test('a saved endpoint wins over the build default on a phone', () async {
|
||||
final store = _TestSettingsStore('wss://saved.example.test');
|
||||
final saved = await resolveLaunchServer(
|
||||
base: Uri.parse(nativeBase),
|
||||
configured: 'ws://build.example.test',
|
||||
web: false,
|
||||
settingsStore: store,
|
||||
);
|
||||
expect(saved.uri, Uri.parse('wss://saved.example.test/connect'));
|
||||
|
||||
final configured = await resolveLaunchServer(
|
||||
base: Uri.parse(nativeBase),
|
||||
configured: 'ws://build.example.test',
|
||||
web: false,
|
||||
settingsStore: store,
|
||||
);
|
||||
expect(configured.uri, Uri.parse('ws://build.example.test/connect'));
|
||||
expect(store.loads, 1);
|
||||
},
|
||||
);
|
||||
// Nothing saved yet: the build default stands (and pre-fills onboarding).
|
||||
final fallback = await resolveLaunchServer(
|
||||
base: Uri.parse(nativeBase),
|
||||
configured: 'ws://build.example.test',
|
||||
web: false,
|
||||
settingsStore: _TestSettingsStore(''),
|
||||
);
|
||||
expect(fallback.uri, Uri.parse('ws://build.example.test/connect'));
|
||||
});
|
||||
|
||||
test(
|
||||
'blank or failed settings load leaves native configuration required',
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/application/pipelines_root.dart';
|
||||
import 'package:pipelines_app/application/server_endpoint.dart';
|
||||
import 'package:pipelines_app/core/session/server_session.dart';
|
||||
import 'package:pipelines_app/features/onboarding/onboarding_flow.dart';
|
||||
import 'package:pipelines_app/features/settings/settings_store.dart';
|
||||
|
||||
class _Store implements SettingsStore {
|
||||
@override
|
||||
Future<SettingsValues> load() async => const SettingsValues();
|
||||
|
||||
@override
|
||||
Future<bool> saveServerUrl(String value) async => true;
|
||||
|
||||
@override
|
||||
Future<bool> saveWorkspace(String value) async => true;
|
||||
}
|
||||
|
||||
ServerEndpoint _server(String url) => ServerEndpoint.resolve(
|
||||
base: Uri.parse('file:///'),
|
||||
web: false,
|
||||
configured: url,
|
||||
);
|
||||
|
||||
void main() {
|
||||
testWidgets(
|
||||
'a first launch starts at the server, pre-filled from the build',
|
||||
(tester) async {
|
||||
await tester.pumpWidget(
|
||||
PipelinesRoot(
|
||||
server: _server(''),
|
||||
buildDefault: 'wss://build.example/connect',
|
||||
check: (_) async => SessionState.signedOut,
|
||||
settingsStore: _Store(),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(OnboardingFlow), findsOneWidget);
|
||||
expect(find.byKey(const Key('onboarding-server')), findsOneWidget);
|
||||
expect(find.text('wss://build.example/connect'), findsOneWidget);
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('a kept session the server refuses asks for the password', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(
|
||||
PipelinesRoot(
|
||||
server: _server('wss://home.example/connect'),
|
||||
// A saved server with no kept session goes to onboarding directly.
|
||||
signedIn: false,
|
||||
check: (_) async => SessionState.signedOut,
|
||||
settingsStore: _Store(),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('onboarding-server')), findsOneWidget);
|
||||
expect(find.text('wss://home.example/connect'), findsOneWidget);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user