Skip to content

Commit

Permalink
test(cat-voices): 1444 add tooltip test
Browse files Browse the repository at this point in the history
  • Loading branch information
emiride committed Dec 31, 2024
1 parent 7ef9ad9 commit ac15052
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 50 deletions.
36 changes: 36 additions & 0 deletions catalyst_voices/apps/voices/integration_test/app_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:catalyst_voices/app/view/app.dart';
import 'package:catalyst_voices/configs/bootstrap.dart';
import 'package:catalyst_voices/routes/routes.dart';
import 'package:catalyst_voices_models/catalyst_voices_models.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:go_router/go_router.dart';
import 'package:integration_test/integration_test.dart';
Expand Down Expand Up @@ -122,4 +123,39 @@ void main() async {
expect($(OverallSpacesPage.spacesListView), findsOneWidget);
},
);

patrolWidgetTest(
'Drawer tooltip - check tooltip text',
(PatrolTester $) async {
final spaceToTooltipText = <Space, String>{
Space.discovery: 'Discovery space',
Space.workspace: 'Workspace',
Space.voting: 'Voting space',
Space.fundedProjects: 'Funded project space',
Space.treasury: 'Treasury space',
};
await $.pumpWidgetAndSettle(App(routerConfig: router));
await $(OverallSpacesPage.userShortcutBtn)
.tap(settleTimeout: const Duration(seconds: 10));
await $(AppBarPage.spacesDrawerButton).waitUntilVisible().tap();
for (final space in Space.values) {
await $(SpacesDrawerPage.chooserItem(space)).tap();
await $(SpacesDrawerPage.chooserIcon(space)).longPress();
await Future<void>.delayed(const Duration(seconds: 1));
final expectedText = spaceToTooltipText[space];
final chooserItem = find.byKey(SpacesDrawerPage.chooserItem(space));
final tooltipElement = find.descendant(
of: chooserItem,
matching: find.byKey(SpacesDrawerPage.tooltipElement),
);
final tooltipTextElement = find.descendant(
of: tooltipElement,
matching: find.byType(Text),
);

final tooltipText = $(tooltipTextElement).text;
expect(tooltipText, expectedText);
}
},
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,14 @@ class SpacesDrawerPage {
static const userFeedbackTile = Key('FeedbackTile');
static const userDocumentationTile = Key('DocumentationTile');
static const userDrawerMenuItem = Key('UserDrawerMenuItem');

static Key chooserItem(Space space) {
return Key('DrawerChooser$space');
}

static Key userHeader(Space space) {
return Key('SpaceHeader.${space.name}');
}
static const tooltipElement = Key('Tooltip');

static Key chooserIcon(Space space) {
return Key('DrawerChooser${space}AvatarKey');
}

static Key userMenuContainer(Space space) {
return Key('Drawer${space}MenuKey');
}

static Key userSectionHeader(Space space) {
return Key('Header.${space.name}');
static Key chooserItem(Space space) {
return Key('DrawerChooser$space');
}

static void commonElementsLookAsExpected(PatrolTester $) {
Expand All @@ -58,26 +47,6 @@ class SpacesDrawerPage {
expect($(children), findsAtLeast(1));
}

static Future<void> userLooksAsExpected(PatrolTester $, Space space) async {
switch (space) {
case Space.discovery:
userDiscoveryLooksAsExpected($);
break;
case Space.workspace:
userWorkspaceLooksAsExpected($);
break;
case Space.voting:
userVotingLooksAsExpected($);
break;
case Space.fundedProjects:
userFundedProjectsLooksAsExpected($);
break;
case Space.treasury:
userTreasuryLooksAsExpected($);
break;
}
}

static void userDiscoveryLooksAsExpected(PatrolTester $) {
expect(
$(userMenuContainer(Space.discovery)).$(userHeader(Space.discovery)),
Expand All @@ -101,18 +70,56 @@ class SpacesDrawerPage {
);
}

static void userWorkspaceLooksAsExpected(PatrolTester $) {
static void userFundedProjectsLooksAsExpected(PatrolTester $) {
expect(
$(userMenuContainer(Space.workspace)).$(userHeader(Space.workspace)),
$(userMenuContainer(Space.fundedProjects)),
findsOneWidget,
);
}

static Key userHeader(Space space) {
return Key('SpaceHeader.${space.name}');
}

static Future<void> userLooksAsExpected(PatrolTester $, Space space) async {
switch (space) {
case Space.discovery:
userDiscoveryLooksAsExpected($);
break;
case Space.workspace:
userWorkspaceLooksAsExpected($);
break;
case Space.voting:
userVotingLooksAsExpected($);
break;
case Space.fundedProjects:
userFundedProjectsLooksAsExpected($);
break;
case Space.treasury:
userTreasuryLooksAsExpected($);
break;
}
}

static Key userMenuContainer(Space space) {
return Key('Drawer${space}MenuKey');
}

static Key userSectionHeader(Space space) {
return Key('Header.${space.name}');
}

static void userTreasuryLooksAsExpected(PatrolTester $) {
expect(
$(userMenuContainer(Space.treasury)).$(userHeader(Space.treasury)),
findsOneWidget,
);
expect(
$(userMenuContainer(Space.workspace))
.$(userSectionHeader(Space.workspace)),
$(userMenuContainer(Space.treasury)).$(userSectionHeader(Space.treasury)),
findsOneWidget,
);
final children = find.descendant(
of: $(userMenuContainer(Space.workspace)),
of: $(userMenuContainer(Space.treasury)),
matching: $(userDrawerMenuItem),
);
expect($(children), findsAtLeast(1));
Expand All @@ -134,24 +141,18 @@ class SpacesDrawerPage {
expect($(children), findsAtLeast(1));
}

static void userFundedProjectsLooksAsExpected(PatrolTester $) {
expect(
$(userMenuContainer(Space.fundedProjects)),
findsOneWidget,
);
}

static void userTreasuryLooksAsExpected(PatrolTester $) {
static void userWorkspaceLooksAsExpected(PatrolTester $) {
expect(
$(userMenuContainer(Space.treasury)).$(userHeader(Space.treasury)),
$(userMenuContainer(Space.workspace)).$(userHeader(Space.workspace)),
findsOneWidget,
);
expect(
$(userMenuContainer(Space.treasury)).$(userSectionHeader(Space.treasury)),
$(userMenuContainer(Space.workspace))
.$(userSectionHeader(Space.workspace)),
findsOneWidget,
);
final children = find.descendant(
of: $(userMenuContainer(Space.treasury)),
of: $(userMenuContainer(Space.workspace)),
matching: $(userDrawerMenuItem),
);
expect($(children), findsAtLeast(1));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class VoicesPlainTooltip extends StatelessWidget {
);

return Tooltip(
key: const Key('Tooltip'),
richMessage: WidgetSpan(
child: ConstrainedBox(
key: const ValueKey('VoicesPlainTooltipContentKey'),
Expand Down

0 comments on commit ac15052

Please sign in to comment.