Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(cat-voices): 1444 add tooltip test #1445

Merged
merged 3 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:patrol_finders/patrol_finders.dart';
Expand Down Expand Up @@ -124,4 +125,39 @@ void main() async {
);
},
);

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
Loading