From 4bd67f8f2cc1e772ee54941daac9578dd51c7d83 Mon Sep 17 00:00:00 2001 From: januszjanus Date: Mon, 23 Dec 2024 11:41:15 +0100 Subject: [PATCH 1/3] cleanup --- .../voices/integration_test/app_test.dart | 28 ++++--------------- .../pageobject/spaces_drawer_page.dart | 14 +++++++--- 2 files changed, 16 insertions(+), 26 deletions(-) diff --git a/catalyst_voices/apps/voices/integration_test/app_test.dart b/catalyst_voices/apps/voices/integration_test/app_test.dart index 2f4adf8805c..89191d7e6d1 100644 --- a/catalyst_voices/apps/voices/integration_test/app_test.dart +++ b/catalyst_voices/apps/voices/integration_test/app_test.dart @@ -47,20 +47,12 @@ void main() async { await $(OverallSpacesPage.guestShortcutBtn) .tap(settleTimeout: const Duration(seconds: 10)); await $(AppBarPage.spacesDrawerButton).waitUntilVisible().tap(); - SpacesDrawerPage.guestLooksAsExpected($); + SpacesDrawerPage.guestDrawerMainElementsLooksAsExpected($); // 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)); }, @@ -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)); diff --git a/catalyst_voices/apps/voices/integration_test/pageobject/spaces_drawer_page.dart b/catalyst_voices/apps/voices/integration_test/pageobject/spaces_drawer_page.dart index 2b0ab1e65e7..852c8450174 100644 --- a/catalyst_voices/apps/voices/integration_test/pageobject/spaces_drawer_page.dart +++ b/catalyst_voices/apps/voices/integration_test/pageobject/spaces_drawer_page.dart @@ -5,7 +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'); @@ -40,17 +39,24 @@ class SpacesDrawerPage { return Key('Header.${space.name}'); } - static void guestLooksAsExpected(PatrolTester $) { + static void guestDrawerMainElementsLooksAsExpected(PatrolTester $) { expect($(closeBtn), findsOneWidget); expect($(allSpacesBtn), findsOneWidget); expect($(chooserPrevBtn), findsOneWidget); - SelectorUtils.isDisabled($, $(chooserPrevBtn)); expect($(chooserNextBtn), findsOneWidget); expect($(chooserItemContainer), findsExactly(5)); + } + + static Future guestLooksAsExpected(PatrolTester $, Space space) async { expect( - $(chooserIcon(Space.discovery)), + $(SpacesDrawerPage.chooserIcon(space)), findsOneWidget, ); + final children = find.descendant( + of: $(SpacesDrawerPage.guestMenuItems), + matching: find.byWidgetPredicate((widget) => true), + ); + expect($(children), findsAtLeast(1)); } static Future userLooksAsExpected(PatrolTester $) async { From f3adc69c55f7ce2535bb8074ab613eab420b49ac Mon Sep 17 00:00:00 2001 From: januszjanus Date: Mon, 23 Dec 2024 11:46:45 +0100 Subject: [PATCH 2/3] cleanup --- catalyst_voices/apps/voices/integration_test/app_test.dart | 3 ++- .../voices/integration_test/pageobject/spaces_drawer_page.dart | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/catalyst_voices/apps/voices/integration_test/app_test.dart b/catalyst_voices/apps/voices/integration_test/app_test.dart index 89191d7e6d1..3e1b0bcc19b 100644 --- a/catalyst_voices/apps/voices/integration_test/app_test.dart +++ b/catalyst_voices/apps/voices/integration_test/app_test.dart @@ -47,7 +47,7 @@ void main() async { await $(OverallSpacesPage.guestShortcutBtn) .tap(settleTimeout: const Duration(seconds: 10)); await $(AppBarPage.spacesDrawerButton).waitUntilVisible().tap(); - SpacesDrawerPage.guestDrawerMainElementsLooksAsExpected($); + SpacesDrawerPage.guestCommonElementsLookAsExpected($); // iterate thru spaces by clicking on spaces icons directly for (final space in Space.values) { @@ -91,6 +91,7 @@ void main() async { await $(OverallSpacesPage.userShortcutBtn) .tap(settleTimeout: const Duration(seconds: 10)); await $(AppBarPage.spacesDrawerButton).waitUntilVisible().tap(); + SpacesDrawerPage.guestCommonElementsLookAsExpected($); await SpacesDrawerPage.userLooksAsExpected($); }, ); diff --git a/catalyst_voices/apps/voices/integration_test/pageobject/spaces_drawer_page.dart b/catalyst_voices/apps/voices/integration_test/pageobject/spaces_drawer_page.dart index 852c8450174..1e446527031 100644 --- a/catalyst_voices/apps/voices/integration_test/pageobject/spaces_drawer_page.dart +++ b/catalyst_voices/apps/voices/integration_test/pageobject/spaces_drawer_page.dart @@ -39,7 +39,7 @@ class SpacesDrawerPage { return Key('Header.${space.name}'); } - static void guestDrawerMainElementsLooksAsExpected(PatrolTester $) { + static void guestCommonElementsLookAsExpected(PatrolTester $) { expect($(closeBtn), findsOneWidget); expect($(allSpacesBtn), findsOneWidget); expect($(chooserPrevBtn), findsOneWidget); From e86ca365a7313cfa6296bc9bb319eaa2ba2ad359 Mon Sep 17 00:00:00 2001 From: januszjanus Date: Mon, 23 Dec 2024 11:58:24 +0100 Subject: [PATCH 3/3] cleanup --- .../voices/integration_test/app_test.dart | 9 ++-- .../pageobject/spaces_drawer_page.dart | 42 +++++++++---------- 2 files changed, 25 insertions(+), 26 deletions(-) diff --git a/catalyst_voices/apps/voices/integration_test/app_test.dart b/catalyst_voices/apps/voices/integration_test/app_test.dart index 3e1b0bcc19b..487c720b0cf 100644 --- a/catalyst_voices/apps/voices/integration_test/app_test.dart +++ b/catalyst_voices/apps/voices/integration_test/app_test.dart @@ -47,7 +47,7 @@ void main() async { await $(OverallSpacesPage.guestShortcutBtn) .tap(settleTimeout: const Duration(seconds: 10)); await $(AppBarPage.spacesDrawerButton).waitUntilVisible().tap(); - SpacesDrawerPage.guestCommonElementsLookAsExpected($); + SpacesDrawerPage.commonElementsLookAsExpected($); // iterate thru spaces by clicking on spaces icons directly for (final space in Space.values) { @@ -91,8 +91,11 @@ void main() async { await $(OverallSpacesPage.userShortcutBtn) .tap(settleTimeout: const Duration(seconds: 10)); await $(AppBarPage.spacesDrawerButton).waitUntilVisible().tap(); - SpacesDrawerPage.guestCommonElementsLookAsExpected($); - await SpacesDrawerPage.userLooksAsExpected($); + SpacesDrawerPage.commonElementsLookAsExpected($); + for (final space in Space.values) { + await $(SpacesDrawerPage.chooserItem(space)).tap(); + await SpacesDrawerPage.userLooksAsExpected($, space); + } }, ); diff --git a/catalyst_voices/apps/voices/integration_test/pageobject/spaces_drawer_page.dart b/catalyst_voices/apps/voices/integration_test/pageobject/spaces_drawer_page.dart index 1e446527031..056d611b171 100644 --- a/catalyst_voices/apps/voices/integration_test/pageobject/spaces_drawer_page.dart +++ b/catalyst_voices/apps/voices/integration_test/pageobject/spaces_drawer_page.dart @@ -5,7 +5,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:patrol_finders/patrol_finders.dart'; - class SpacesDrawerPage { static const closeBtn = Key('MenuCloseButton'); static const guestMenuItems = Key('GuestMenuItems'); @@ -39,7 +38,7 @@ class SpacesDrawerPage { return Key('Header.${space.name}'); } - static void guestCommonElementsLookAsExpected(PatrolTester $) { + static void commonElementsLookAsExpected(PatrolTester $) { expect($(closeBtn), findsOneWidget); expect($(allSpacesBtn), findsOneWidget); expect($(chooserPrevBtn), findsOneWidget); @@ -53,32 +52,29 @@ class SpacesDrawerPage { findsOneWidget, ); final children = find.descendant( - of: $(SpacesDrawerPage.guestMenuItems), + of: $(guestMenuItems), matching: find.byWidgetPredicate((widget) => true), ); expect($(children), findsAtLeast(1)); } - static Future 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 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; } }