Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
feat: add link menu test
Lucas.Xu126245775586
diff --git a/frontend/app_flowy/packages/appflowy_editor/lib/src/render/link_menu/link_menu.dart b/frontend/app_flowy/packages/appflowy_editor/lib/src/render/link_menu/link_menu.dartindex 3a519ed70f..2c4ba2b975 100644--- a/frontend/app_flowy/packages/appflowy_editor/lib/src/render/link_menu/link_menu.dart+++ b/frontend/app_flowy/packages/appflowy_editor/lib/src/render/link_menu/link_menu.dart@@ -40,24 +40,25 @@ class _LinkMenuState extends State<LinkMenu> {@overrideWidget build(BuildContext context) {- return Container(- decoration: BoxDecoration(- color: Colors.white,- boxShadow: [- BoxShadow(- blurRadius: 5,- spreadRadius: 1,- color: Colors.black.withOpacity(0.1),- ),- ],- borderRadius: BorderRadius.circular(6.0),- ),- child: SizedBox(- width: 350,+ return SizedBox(+ width: 350,+ child: Container(+ decoration: BoxDecoration(+ color: Colors.white,+ boxShadow: [+ BoxShadow(+ blurRadius: 5,+ spreadRadius: 1,+ color: Colors.black.withOpacity(0.1),+ ),+ ],+ borderRadius: BorderRadius.circular(6.0),+ ),child: Padding(padding: const EdgeInsets.all(20.0),child: Column(crossAxisAlignment: CrossAxisAlignment.start,+ mainAxisSize: MainAxisSize.min,children: [_buildHeader(),const SizedBox(height: 16.0),diff --git a/frontend/app_flowy/packages/appflowy_editor/lib/src/render/toolbar/toolbar_item.dart b/frontend/app_flowy/packages/appflowy_editor/lib/src/render/toolbar/toolbar_item.dartindex e20ebb798d..41283e6b6a 100644--- a/frontend/app_flowy/packages/appflowy_editor/lib/src/render/toolbar/toolbar_item.dart+++ b/frontend/app_flowy/packages/appflowy_editor/lib/src/render/toolbar/toolbar_item.dart@@ -181,11 +181,9 @@ void _showLinkMenu(EditorState editorState, BuildContext context) {final length = (selection.start.offset - selection.end.offset).abs();final node = editorState.service.selectionService.currentSelectedNodes.firstas TextNode;- final String linkText;+ String? linkText;if (node.allSatisfyLinkInSelection(selection)) {linkText = node.getAttributeInSelection(selection, StyleKey.href);- } else {- linkText = '';}_linkMenuOverlay = OverlayEntry(builder: (context) {return Positioned(diff --git a/frontend/app_flowy/packages/appflowy_editor/test/render/link_menu/link_menu_test.dart b/frontend/app_flowy/packages/appflowy_editor/test/render/link_menu/link_menu_test.dartnew file mode 100644index 0000000000..7b4541033b--- /dev/null+++ b/frontend/app_flowy/packages/appflowy_editor/test/render/link_menu/link_menu_test.dart@@ -0,0 +1,41 @@+import 'package:appflowy_editor/src/render/link_menu/link_menu.dart';+import 'package:flutter/material.dart';+import 'package:flutter_test/flutter_test.dart';++void main() async {+ setUpAll(() {+ TestWidgetsFlutterBinding.ensureInitialized();+ });++ group('link_menu.dart', () {+ testWidgets('test empty link menu actions', (tester) async {+ const link = 'appflowy.io';+ var submittedText = '';+ final linkMenu = LinkMenu(+ onCopyLink: () {},+ onRemoveLink: () {},+ onSubmitted: (text) {+ submittedText = text;+ },+ );+ await tester.pumpWidget(+ MaterialApp(+ home: Material(+ child: linkMenu,+ ),+ ),+ );++ expect(find.byType(TextButton), findsNothing);+ expect(find.byType(TextField), findsOneWidget);++ await tester.tap(find.byType(TextField));+ await tester.enterText(find.byType(TextField), link);+ await tester.pumpAndSettle();+ await tester.testTextInput.receiveAction(TextInputAction.done);+ await tester.pumpAndSettle();++ expect(submittedText, link);+ });+ });+}