From b72f881eacb1543af121b3025c35e408d012b413 Mon Sep 17 00:00:00 2001 From: shekhar-cis Date: Fri, 22 Oct 2021 14:44:02 +0530 Subject: [PATCH] added set_default_address() and open_side navbar() --- src/bitmessagekivy/tests/telenium_process.py | 11 +++ .../tests/test_myaddress_screen.py | 68 +++++++++++++++++++ 2 files changed, 79 insertions(+) diff --git a/src/bitmessagekivy/tests/telenium_process.py b/src/bitmessagekivy/tests/telenium_process.py index 37cd4c32..f9a397e8 100644 --- a/src/bitmessagekivy/tests/telenium_process.py +++ b/src/bitmessagekivy/tests/telenium_process.py @@ -114,3 +114,14 @@ class TeleniumTestProcess(TeleniumTestCase): if timeout > 0 and time() - start > timeout: raise Exception("Timeout") sleep(0.1) + + def open_side_navbar(self): + """Common method for opening Side navbar (Side Drawer)""" + # Checking the drawer is in 'closed' state + self.assertExists('//MDNavigationDrawer[@status~=\"closed\"]', timeout=5) + # This is for checking the menu button is appeared + self.assertExists('//MDActionTopAppBarButton[@icon~=\"menu\"]', timeout=5) + # this is for opening Nav drawer + self.cli.wait_click('//MDActionTopAppBarButton[@icon=\"menu\"]', timeout=5) + # checking state of Nav drawer + self.assertExists("//MDNavigationDrawer[@state~=\"open\"]", timeout=5) diff --git a/src/bitmessagekivy/tests/test_myaddress_screen.py b/src/bitmessagekivy/tests/test_myaddress_screen.py index 358953d0..cf2136f2 100644 --- a/src/bitmessagekivy/tests/test_myaddress_screen.py +++ b/src/bitmessagekivy/tests/test_myaddress_screen.py @@ -88,3 +88,71 @@ class MyAddressScreen(TeleniumTestProcess): self.cli.wait_click('//MDToolbar//MDActionTopAppBarButton[@icon=\"arrow-left\"]', timeout=2) # Checking current screen(My Address) after BACK press self.assertExists("//ScreenManager[@current=\"myaddress\"]", timeout=3) + + @skip_screen_checks + @ordered + def test_set_default_address(self): + """Selecting First Address From Drawer-Box""" + # Checking current screen + self.assertExists("//ScreenManager[@current=\"myaddress\"]", timeout=5) + # This is for checking the Side nav Bar is closed + self.open_side_navbar() + # Scrolling up + self.cli.wait_drag( + "//NavigationItem[@text=\"Settings\"]", "//NavigationItem[@text=\"Purchase\"]", 2, timeout=2) + # Checking scroll state + self.assertCheckScrollUp('//ContentNavigationDrawer//ScrollView[0]', timeout=5) + # Click to open Address Dropdown + self.cli.wait_click('//NavigationItem[0]/CustomSpinner[0]', timeout=5) + # Checking the dropdown option is exist + self.assertExists('//MySpinnerOption[1]', timeout=5) + is_open = self.cli.getattr('//NavigationItem[0]/CustomSpinner[@is_open]', 'is_open') + # Check the state of dropdown. + self.assertEqual(is_open, True) + # Selecting an address to set as a default address from dropdown. + self.cli.wait_click('//MySpinnerOption[1]', timeout=5) + # Checking the dropdown is closed + self.assertNotExists('//MySpinnerOption', timeout=5) + # Checking current screen after selecting the address + self.assertExists("//ScreenManager[@current=\"inbox\"]", timeout=5) + + @skip_screen_checks + @ordered + def test_enable_and_disable_address(self): + """Test enable and disable address from own address list""" + # checking state of Nav drawer + self.assertExists("//MDNavigationDrawer[@state~=\"open\"]", timeout=5) + # SCrolling down to click 'My address' Tab + self.cli.wait_drag("//NavigationItem[@text=\"Sent\"]", "//NavigationItem[@text=\"Inbox\"]", 2, timeout=5) + # Checking the scoll state + self.assertCheckScrollDown('//ContentNavigationDrawer//ScrollView[0]', timeout=5) + # Clicking on "My Address" Tab + self.cli.wait_click('//NavigationItem[@text=\"My addresses\"]', timeout=3) + # This is for checking the Side nav Bar is closed + self.assertExists('//MDNavigationDrawer[@status~=\"closed\"]', timeout=5) + # Checking current screen + self.assertExists("//ScreenManager[@current=\"myaddress\"]", timeout=5) + # Waiting for rendering the toggle + self.cli.wait('//MDList//Thumb[0]', timeout=5) + # Checking the toggle is rendered + self.assertExists('//MDList//Thumb[0]', timeout=5) + # Click on toggle to disable address + self.cli.wait_click('//MDList//Thumb[0]', timeout=5) + # Getting Disabled address + disabled_address = self.cli.getattr('//MDList[0]/CustomTwoLineAvatarIconListItem[1]', 'secondary_text') + # This is for checking the Side nav Bar is closed + self.open_side_navbar() + # Scrolling up + self.cli.wait_drag( + "//NavigationItem[@text=\"Settings\"]", "//NavigationItem[@text=\"Purchase\"]", 2, timeout=2) + # Checking scroll state + self.assertCheckScrollUp('//ContentNavigationDrawer//ScrollView[0]', timeout=5) + # Click to open Address Dropdown + self.cli.wait_click('//NavigationItem[0]/CustomSpinner[0]', timeout=5) + # Checking the dropdown option is rendered + self.assertExists('//MySpinnerOption', timeout=5) + is_open = self.cli.getattr('//NavigationItem[0]/CustomSpinner[@is_open]', 'is_open') + # Check the state of dropdown. + self.assertEqual(is_open, True) + # Checking the disabled address should not be in dropdown + self.assertNotExists('//MySpinnerOption[@text="{}"]'.format(disabled_address), timeout=5) \ No newline at end of file