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): integration tests cleanup #1428

Merged
merged 3 commits into from
Dec 23, 2024
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
34 changes: 11 additions & 23 deletions catalyst_voices/apps/voices/integration_test/app_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,12 @@ void main() async {
await $(OverallSpacesPage.guestShortcutBtn)
.tap(settleTimeout: const Duration(seconds: 10));
await $(AppBarPage.spacesDrawerButton).waitUntilVisible().tap();
SpacesDrawerPage.guestLooksAsExpected($);
SpacesDrawerPage.commonElementsLookAsExpected($);

// iterate thru spaces by clicking on spaces icons directly
for (final space in Space.values) {
await $(SpacesDrawerPage.chooserItem(space)).tap();
expect(
$(SpacesDrawerPage.chooserIcon(space)),
findsOneWidget,
);
final children = find.descendant(
of: $(SpacesDrawerPage.guestMenuItems),
matching: find.byWidgetPredicate((widget) => true),
);
expect($(children), findsAtLeast(1));
await SpacesDrawerPage.guestLooksAsExpected($, space);
}
SelectorUtils.isDisabled($, $(SpacesDrawerPage.chooserNextBtn));
},
Expand All @@ -75,25 +67,17 @@ void main() async {
await $(AppBarPage.spacesDrawerButton).waitUntilVisible().tap();

// iterate thru spaces by clicking next
for (var i = 0; i < Space.values.length; i++) {
for (final space in Space.values) {
await SpacesDrawerPage.guestLooksAsExpected($, space);
await $(SpacesDrawerPage.chooserNextBtn).tap();
final children = find.descendant(
of: $(SpacesDrawerPage.guestMenuItems),
matching: find.byWidgetPredicate((widget) => true),
);
expect($(children), findsAtLeast(1));
SelectorUtils.isEnabled($, $(SpacesDrawerPage.chooserPrevBtn));
}
SelectorUtils.isDisabled($, $(SpacesDrawerPage.chooserNextBtn));

// iterate thru spaces by clicking previous
for (var i = 0; i < Space.values.length; i++) {
for (final space in Space.values.reversed) {
await SpacesDrawerPage.guestLooksAsExpected($, space);
await $(SpacesDrawerPage.chooserPrevBtn).tap();
final children = find.descendant(
of: $(SpacesDrawerPage.guestMenuItems),
matching: find.byWidgetPredicate((widget) => true),
);
expect($(children), findsAtLeast(1));
SelectorUtils.isEnabled($, $(SpacesDrawerPage.chooserNextBtn));
}
SelectorUtils.isDisabled($, $(SpacesDrawerPage.chooserPrevBtn));
Expand All @@ -107,7 +91,11 @@ void main() async {
await $(OverallSpacesPage.userShortcutBtn)
.tap(settleTimeout: const Duration(seconds: 10));
await $(AppBarPage.spacesDrawerButton).waitUntilVisible().tap();
await SpacesDrawerPage.userLooksAsExpected($);
SpacesDrawerPage.commonElementsLookAsExpected($);
for (final space in Space.values) {
await $(SpacesDrawerPage.chooserItem(space)).tap();
await SpacesDrawerPage.userLooksAsExpected($, space);
}
},
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:patrol_finders/patrol_finders.dart';

import '../utils/selector_utils.dart';

class SpacesDrawerPage {
static const closeBtn = Key('MenuCloseButton');
static const guestMenuItems = Key('GuestMenuItems');
Expand Down Expand Up @@ -40,39 +38,43 @@ class SpacesDrawerPage {
return Key('Header.${space.name}');
}

static void guestLooksAsExpected(PatrolTester $) {
static void commonElementsLookAsExpected(PatrolTester $) {
expect($(closeBtn), findsOneWidget);
expect($(allSpacesBtn), findsOneWidget);
expect($(chooserPrevBtn), findsOneWidget);
SelectorUtils.isDisabled($, $(chooserPrevBtn));
expect($(chooserNextBtn), findsOneWidget);
expect($(chooserItemContainer), findsExactly(5));
}

static Future<void> guestLooksAsExpected(PatrolTester $, Space space) async {
expect(
$(chooserIcon(Space.discovery)),
$(SpacesDrawerPage.chooserIcon(space)),
findsOneWidget,
);
final children = find.descendant(
of: $(guestMenuItems),
matching: find.byWidgetPredicate((widget) => true),
);
expect($(children), findsAtLeast(1));
}

static Future<void> userLooksAsExpected(PatrolTester $) async {
for (final space in Space.values) {
await $(SpacesDrawerPage.chooserItem(space)).tap();
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 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;
}
}

Expand Down
Loading