Files
cutdex/test/name_dialog_test.dart
T
lingjhf 27e77fff39 feat: initial Cutdex application
Add the Flutter video editing application with project management, media
import, timeline editing, preview, AI assistance, diagnostics and settings.

Include shared UI and native host packages, platform runners, application
tests and release tooling.

Provide usage and contribution guides, the MIT license and third-party
notices. Exclude local credentials, build outputs and validation data.
2026-10-05 23:36:23 +08:00

71 lines
2.3 KiB
Dart

import 'package:cutdex/app/editor_theme.dart';
import 'package:cutdex/l10n/app_localizations.dart';
import 'package:cutdex_ui/theme.dart';
import 'package:cutdex/features/projects/widgets/name_dialog.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('rename chat uses the same dialog and compact input', (
tester,
) async {
await tester.pumpWidget(
MaterialApp(
theme: EditorTheme.penDark,
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
locale: const Locale('zh'),
home: Scaffold(
body: Builder(
builder: (context) => TextButton(
onPressed: () => askName(
context,
title: '重命名聊天',
description: '保持简短且易于识别',
label: '名称',
initialValue: '实现图片页面并添加跳转',
submitLabel: '保存',
),
child: const Text('Open'),
),
),
),
),
);
await tester.tap(find.text('Open'));
await tester.pumpAndSettle();
final frame = tester.getRect(find.byKey(const Key('app-dialog-frame')));
final field = tester.getRect(find.byType(TextFormField));
final save = tester.getRect(find.widgetWithText(FilledButton, '保存'));
expect(frame.width, 420);
expect(find.text('重命名聊天'), findsOneWidget);
expect(find.text('保持简短且易于识别'), findsOneWidget);
expect(field.left - frame.left, AppSpacing.large);
expect(frame.right - field.right, AppSpacing.large);
expect(field.height, 36);
expect(save.top - field.bottom, AppSpacing.compact);
expect(
tester
.widget<EditableText>(
find.descendant(
of: find.byType(TextFormField),
matching: find.byType(EditableText),
),
)
.style
.fontSize,
14,
);
expect(
(Theme.of(tester.element(find.byType(TextFormField)))
.inputDecorationTheme
.focusedBorder!
as OutlineInputBorder)
.borderSide
.color,
const Color(0xFF6084AF),
);
});
}