@@ -19,6 +19,8 @@ def setUp(self):
1919 self .app = MemberApp (token = self .token , original_repo = self .repo )
2020 self .app .social_container = MagicMock ()
2121 self .app .alias_container = MagicMock ()
22+ self .app .list_container = MagicMock ()
23+ self .app .form_container = MagicMock ()
2224 # Manually initialize attributes normally set in on_mount
2325 self .app .social_entries = []
2426 self .app .alias_entries = []
@@ -87,6 +89,41 @@ def stub_add_social_entry():
8789 self .app .add_social_entry ()
8890 self .assertEqual (len (self .app .social_entries ), initial_count + 1 )
8991
92+ def test_add_list_button_clears_form (self ):
93+ """Test that clicking the 'Añadir' button on the list screen clears the form and prepares for a new entry."""
94+ # Fill form fields
95+ self .app .name_input .value = "Filled Name"
96+ self .app .email_input .value = "filled@email.com"
97+ self .app .city_input .value = "Filled City"
98+ self .app .homepage_input .value = "https://filled-homepage.com"
99+ self .app .about_me_area .text = "Filled About me"
100+ self .app .who_area .text = "Filled Who am I"
101+ self .app .python_area .text = "Filled Python stuff"
102+ self .app .contributions_area .text = "Filled Contributions"
103+ self .app .availability_area .text = "Filled Available"
104+ # Add social and alias entries
105+ self .app .social_entries = [self .StubSocialEntry ()]
106+ self .app .alias_entries = [self .StubAliasEntry ()]
107+ # Simulate pressing the 'Añadir' button on the list screen
108+ class DummyButton :
109+ id = "add_list"
110+ class DummyEvent :
111+ button = DummyButton ()
112+ self .app .on_button_pressed (DummyEvent ())
113+ # After pressing, form should be cleared and current_file should be None
114+ self .assertEqual (self .app .name_input .value , "" )
115+ self .assertEqual (self .app .email_input .value , "" )
116+ self .assertEqual (self .app .city_input .value , "" )
117+ self .assertEqual (self .app .homepage_input .value , "" )
118+ self .assertEqual (self .app .about_me_area .text , "Sobre mí" )
119+ self .assertEqual (self .app .who_area .text , "¿Quién eres y a qué te dedicas?" )
120+ self .assertEqual (self .app .python_area .text , "¿Cómo programas en Python?" )
121+ self .assertEqual (self .app .contributions_area .text , "¿Tienes algún aporte a la comunidad de Python?" )
122+ self .assertEqual (self .app .availability_area .text , "¿Estás disponible para hacer mentoring, consultorías, charlas?" )
123+ self .assertEqual (len (self .app .social_entries ), 0 )
124+ self .assertEqual (len (self .app .alias_entries ), 0 )
125+ self .assertIsNone (self .app .current_file )
126+
90127 def test_add_alias_entry (self ):
91128 # Patch add_alias_entry to use stub
92129 self .app .alias_entries = []
0 commit comments