правки по лаунчеру

This commit is contained in:
2026-07-28 20:43:53 +04:00
parent 155922a3f1
commit 0b6f7fc647
51 changed files with 3158 additions and 437 deletions
@@ -0,0 +1,84 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:moonwell_launcher/app/design_system/mw_authentication.dart';
import 'package:moonwell_launcher/app/theme/moonwell_design_system.dart';
void main() {
testWidgets('authentication placeholders use muted text color', (
tester,
) async {
await tester.pumpWidget(
MaterialApp(
theme: MoonWellTheme.create(MoonWellThemeVariant.forest),
home: Scaffold(
body: MwAuthenticationForm(
usernameController: TextEditingController(),
passwordController: TextEditingController(),
onSubmit: () {},
),
),
),
);
final fieldContext = tester.element(find.byType(TextField).first);
final hintColor = Theme.of(
fieldContext,
).inputDecorationTheme.hintStyle?.color;
expect(hintColor, const Color(0x69ECE4D0));
});
testWidgets('registration mode exposes all API registration fields', (
tester,
) async {
await tester.pumpWidget(
MaterialApp(
theme: MoonWellTheme.create(MoonWellThemeVariant.forest),
home: Scaffold(
body: SingleChildScrollView(
child: MwAuthenticationForm(
usernameController: TextEditingController(),
emailController: TextEditingController(),
passwordController: TextEditingController(),
passwordConfirmationController: TextEditingController(),
inviteCodeController: TextEditingController(),
mode: MwAuthenticationMode.registration,
termsAccepted: true,
onSubmit: () {},
),
),
),
),
);
expect(find.text('СОЗДАТЬ АККАУНТ'), findsOneWidget);
expect(find.text('EMAIL'), findsOneWidget);
expect(find.text('ПОВТОРИТЕ ПАРОЛЬ'), findsOneWidget);
expect(find.text('ИНВАЙТ-КОД (НЕОБЯЗАТЕЛЬНО)'), findsOneWidget);
expect(
find.text('Я принимаю правила сервера и пользовательское соглашение'),
findsOneWidget,
);
});
testWidgets('authentication tabs request mode changes', (tester) async {
MwAuthenticationMode? requestedMode;
await tester.pumpWidget(
MaterialApp(
theme: MoonWellTheme.create(MoonWellThemeVariant.forest),
home: Scaffold(
body: MwAuthenticationForm(
usernameController: TextEditingController(),
passwordController: TextEditingController(),
onModeChanged: (mode) => requestedMode = mode,
onSubmit: () {},
),
),
),
);
await tester.tap(find.text('РЕГИСТРАЦИЯ'));
expect(requestedMode, MwAuthenticationMode.registration);
});
}
@@ -0,0 +1,142 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:moonwell_launcher/app/design_system/mw_launcher_components.dart';
import 'package:moonwell_launcher/app/theme/moonwell_design_system.dart';
void main() {
testWidgets('game rail shows WoW and MoonWell Karts', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: MoonWellTheme.create(MoonWellThemeVariant.forest),
home: const Scaffold(
body: SizedBox(width: 240, child: MwGameRail(username: 'Sindoring')),
),
),
);
expect(find.text('MOONWELL · WOW'), findsOneWidget);
expect(find.text('OPEN BETA'), findsOneWidget);
expect(find.text('S'), findsOneWidget);
expect(find.text('MOONWELL KARTS'), findsOneWidget);
expect(find.text('В РАЗРАБОТКЕ'), findsOneWidget);
expect(find.text('SOON'), findsNothing);
expect(find.textContaining('TIDES OF ELUNE'), findsNothing);
expect(find.textContaining('PROJECT VERGE'), findsNothing);
});
testWidgets('game rail settings button invokes settings callback', (
tester,
) async {
var settingsRequested = false;
await tester.pumpWidget(
MaterialApp(
theme: MoonWellTheme.create(MoonWellThemeVariant.forest),
home: Scaffold(
body: SizedBox(
width: 240,
child: MwGameRail(onSettings: () => settingsRequested = true),
),
),
),
);
await tester.tap(find.byTooltip('Настройки'));
expect(settingsRequested, isTrue);
});
testWidgets('sync area displays realm data received from API', (
tester,
) async {
await tester.pumpWidget(
MaterialApp(
theme: MoonWellTheme.create(MoonWellThemeVariant.forest),
home: const Scaffold(
body: SizedBox(
width: 1000,
height: 150,
child: MwSyncActionArea(
state: MwSyncPresentation.ready,
status: 'Клиент готов.',
realmName: 'MoonWell',
realmOnline: true,
realmGameBuild: 12340,
onPrimary: _noop,
),
),
),
),
);
expect(find.text('MOONWELL'), findsOneWidget);
expect(find.text('ONLINE · BUILD 12340'), findsOneWidget);
});
testWidgets('news item invokes its link callback when pressed', (
tester,
) async {
var pressed = false;
await tester.pumpWidget(
MaterialApp(
theme: MoonWellTheme.create(MoonWellThemeVariant.forest),
home: Scaffold(
body: MwNewsItem(
item: MwNewsItemData(
title: 'Update 1.2',
body: 'News body',
onPressed: () => pressed = true,
),
),
),
),
);
await tester.tap(find.text('Update 1.2'));
expect(pressed, isTrue);
});
testWidgets('account affordance displays username without balance', (
tester,
) async {
await tester.pumpWidget(
MaterialApp(
theme: MoonWellTheme.create(MoonWellThemeVariant.forest),
home: Scaffold(
body: MwAccountAffordance(username: 'PLAYERONE', onLogout: _noop),
),
),
);
expect(find.text('PLAYERONE'), findsOneWidget);
expect(find.textContaining('1250'), findsNothing);
expect(find.text('P'), findsOneWidget);
await tester.tap(find.byType(PopupMenuButton<String>));
await tester.pumpAndSettle();
expect(find.text('Выйти'), findsOneWidget);
expect(find.text('Настройки'), findsNothing);
});
testWidgets('settings panel excludes logout action', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: MoonWellTheme.create(MoonWellThemeVariant.forest),
home: Scaffold(
body: MwSettingsPanel(
installationPath: r'C:\Games\MoonWell',
onChooseDirectory: _noop,
onVerify: _noop,
),
),
),
);
expect(find.text('Выбрать папку'), findsOneWidget);
expect(find.text('Проверить файлы'), findsOneWidget);
expect(find.text('Выйти'), findsNothing);
});
}
void _noop() {}
@@ -0,0 +1,75 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:moonwell_launcher/app/design_system/mw_shells.dart';
import 'package:moonwell_launcher/app/theme/moonwell_design_system.dart';
void main() {
testWidgets('brand mark fits its requested width without overflow', (
tester,
) async {
await tester.pumpWidget(
MaterialApp(
theme: MoonWellTheme.create(MoonWellThemeVariant.forest),
home: const Scaffold(body: Center(child: MwBrandMark(width: 220))),
),
);
expect(tester.takeException(), isNull);
});
testWidgets('login shell renders the key art asset', (tester) async {
await tester.binding.setSurfaceSize(const Size(1280, 720));
addTearDown(() => tester.binding.setSurfaceSize(null));
await tester.pumpWidget(
MaterialApp(
theme: MoonWellTheme.create(MoonWellThemeVariant.forest),
home: MwLoginShell(
form: const SizedBox(),
onDrag: _noop,
onDoubleTap: _noop,
onMinimize: _noop,
onMaximizeRestore: _noop,
onClose: _noop,
),
),
);
await tester.pumpAndSettle();
final image = tester.widget<Image>(find.byType(Image));
expect((image.image as AssetImage).assetName, 'assets/login_key_art.png');
expect(tester.takeException(), isNull);
});
testWidgets('launcher shell renders the main key art asset', (tester) async {
await tester.binding.setSurfaceSize(const Size(1280, 720));
addTearDown(() => tester.binding.setSurfaceSize(null));
await tester.pumpWidget(
MaterialApp(
theme: MoonWellTheme.create(MoonWellThemeVariant.forest),
home: const MwLauncherShell(
news: SizedBox(),
syncActions: SizedBox(),
statusBar: SizedBox(),
account: SizedBox(),
onDrag: _noop,
onDoubleTap: _noop,
onMinimize: _noop,
onMaximizeRestore: _noop,
onClose: _noop,
),
),
);
await tester.pumpAndSettle();
final image = tester.widget<Image>(find.byType(Image));
expect(
(image.image as AssetImage).assetName,
'assets/launcher_key_art.png',
);
expect(tester.takeException(), isNull);
});
}
void _noop() {}