From bd0cab179bc368497192aadd51dbe46c74b09a7a Mon Sep 17 00:00:00 2001
From: shekhar-cis <shekhar.c@cisinlabs.com>
Date: Wed, 13 Oct 2021 15:54:53 +0530
Subject: [PATCH] Update Myaddress test

---
 .../tests/test_create_random_address.py       | 10 +++-
 .../tests/test_myaddress_screen.py            | 49 +++----------------
 2 files changed, 16 insertions(+), 43 deletions(-)

diff --git a/src/bitmessagekivy/tests/test_create_random_address.py b/src/bitmessagekivy/tests/test_create_random_address.py
index 2f6c1fe7..8429925b 100644
--- a/src/bitmessagekivy/tests/test_create_random_address.py
+++ b/src/bitmessagekivy/tests/test_create_random_address.py
@@ -39,16 +39,22 @@ class CreateRandomAddress(TeleniumTestProcess):
     @ordered
     def test_generate_random_address_label(self):
         """Creating New Adress For New User."""
+        # Checking the Button is rendered
+        self.assertExists(
+            '//RandomBoxlayout/BoxLayout[0]/AnchorLayout[1]/MDTextField[@hint_text=\"Label\"]', timeout=2)
         # Click on Label Text Field to give address Label
-        self.cli.wait_click('//RandomBoxlayout/BoxLayout[0]/AnchorLayout[1]/MDTextField[0]', timeout=2)
+        self.cli.wait_click(
+            '//RandomBoxlayout/BoxLayout[0]/AnchorLayout[1]/MDTextField[@hint_text=\"Label\"]', timeout=2)
         # Enter a Label Randomly
         random_label = ""
         for _ in range(10):
             random_label += choice(ascii_lowercase)
             self.cli.setattr('//RandomBoxlayout//AnchorLayout[1]/MDTextField[0]', "text", random_label)
             self.cli.sleep(0.1)
+        # Checking the Button is rendered
+        self.assertExists('//RandomBoxlayout//MDFillRoundFlatIconButton[@text=\"Proceed Next\"]', timeout=3)
         # Click on Proceed Next button to generate random Address
-        self.cli.wait_click('//RandomBoxlayout//MDFillRoundFlatIconButton[0]', timeout=2)
+        self.cli.wait_click('//RandomBoxlayout//MDFillRoundFlatIconButton[@text=\"Proceed Next\"]', timeout=3)
         # Checking "My Address" Screen after creating a address
         self.assertExists("//ScreenManager[@current=\"myaddress\"]", timeout=5)
         # Checking the new address is created
diff --git a/src/bitmessagekivy/tests/test_myaddress_screen.py b/src/bitmessagekivy/tests/test_myaddress_screen.py
index 1eeee08f..358953d0 100644
--- a/src/bitmessagekivy/tests/test_myaddress_screen.py
+++ b/src/bitmessagekivy/tests/test_myaddress_screen.py
@@ -20,13 +20,7 @@ class MyAddressScreen(TeleniumTestProcess):
         # This is for checking Current screen
         self.assert_wait_no_except('//ScreenManager[@current]', timeout=15, value='inbox')
         # This is for checking the Side nav Bar is closed
-        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)
+        self.open_side_navbar()
         # this is for scrolling Nav drawer
         self.drag("//NavigationItem[@text=\"Sent\"]", "//NavigationItem[@text=\"Inbox\"]")
         # assert for checking scroll function
@@ -58,15 +52,17 @@ class MyAddressScreen(TeleniumTestProcess):
         # ADD SUBJECT
         self.cli.setattr('//DropDownWidget/ScrollView[0]//MyMDTextField[0]', 'text', self.subject)
         # Checking Subject Field is Entered
-        self.assertExists('//DropDownWidget/ScrollView[0]//MyMDTextField[@text=\"{}\"]'.format(self.subject), timeout=5)
+        self.assertExists(
+            '//DropDownWidget/ScrollView[0]//MyMDTextField[@text=\"{}\"]'.format(self.subject), timeout=5)
         # ADD MESSAGE BODY
         self.cli.setattr(
             '//DropDownWidget/ScrollView[0]//ScrollView[0]/MDTextField[0]', 'text',
             self.body)
         # Checking Message body is Entered
-        self.assertExists('//DropDownWidget/ScrollView[0]//ScrollView[0]/MDTextField[@text=\"{}\"]'.format(self.body), timeout=5)
-        # Click on Send Icon
-        self.cli.wait_click('//MDActionTopAppBarButton[@icon=\"send\"]', timeout=5)
+        self.assertExists(
+            '//DropDownWidget/ScrollView[0]//ScrollView[0]/MDTextField[@text=\"{}\"]'.format(self.body), timeout=5)
+        # Click on BACK button
+        self.cli.wait_click('//MDToolbar//MDActionTopAppBarButton[@icon=\"arrow-left\"]', timeout=2)
         # Check for redirected screen (Inbox Screen)
         self.assertExists("//ScreenManager[@current=\"inbox\"]", timeout=7)
 
@@ -75,10 +71,7 @@ class MyAddressScreen(TeleniumTestProcess):
     def test_show_qrcode(self):
         """Show the Qr code of selected address"""
         # This is for checking the Side nav Bar is closed
-        self.assertExists('//MDNavigationDrawer[@status~=\"closed\"]', timeout=5)
-        self.cli.wait_click('//MDActionTopAppBarButton[@icon=\"menu\"]', timeout=3)
-        # checking state of Nav drawer
-        self.assertExists("//MDNavigationDrawer[@state~=\"open\"]", timeout=2)
+        self.open_side_navbar()
         # Clicking on Sent Tab
         self.cli.wait_click('//NavigationItem[@text=\"My addresses\"]', timeout=3)
         # Checking current screen
@@ -95,29 +88,3 @@ 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_sent_box(self):
-        """
-            Checking Message in Sent Screen after sending a Message.
-        """
-        # Checking current screen
-        self.assertExists("//ScreenManager[@current=\"myaddress\"]", timeout=3)
-        # this is for opening Nav drawer
-        self.cli.wait_click('//MDActionTopAppBarButton[@icon=\"menu\"]', timeout=3)
-        # checking state of Nav drawer
-        self.assertExists("//MDNavigationDrawer[@state~=\"open\"]", timeout=2)
-        # this is for scrolling Nav drawer
-        self.drag("//NavigationItem[@text=\"Purchase\"]", "//NavigationItem[@text=\"My addresses\"]")
-        # assert for checking scroll function
-        self.assertCheckScrollUp('//ContentNavigationDrawer//ScrollView[0]', timeout=3)
-        # Clicking on Sent Tab
-        self.cli.wait_click('//NavigationItem[@text=\"Sent\"]', timeout=3)
-        # Checking current screen; Sent
-        self.assertExists("//ScreenManager[@current=\"sent\"]", timeout=3)
-        # Checking the message is rendered in sent box screen
-        self.assertExists('//SwipeToDeleteItem', timeout=5)
-        # Checking messages count in sent box
-        total_sent_msgs = len(self.cli.select("//SwipeToDeleteItem"))
-        self.assertEqual(total_sent_msgs, 1)