@@ -4056,6 +4056,44 @@ def test_cancel_delete_related_confirmation(self):
40564056 self .assertEqual (Pizza .objects .count (), 1 )
40574057 self .assertEqual (Topping .objects .count (), 2 )
40584058
4059+ def test_list_editable_popups (self ):
4060+ """
4061+ list_editable foreign keys have add/change popups.
4062+ """
4063+ from selenium .webdriver .support .ui import Select
4064+ s1 = Section .objects .create (name = 'Test section' )
4065+ Article .objects .create (
4066+ title = 'foo' ,
4067+ content = '<p>Middle content</p>' ,
4068+ date = datetime .datetime (2008 , 3 , 18 , 11 , 54 , 58 ),
4069+ section = s1 ,
4070+ )
4071+ self .admin_login (username = 'super' , password = 'secret' , login_url = reverse ('admin:index' ))
4072+ self .selenium .get (self .live_server_url + reverse ('admin:admin_views_article_changelist' ))
4073+ # Change popup
4074+ self .selenium .find_element_by_id ('change_id_form-0-section' ).click ()
4075+ self .wait_for_popup ()
4076+ self .selenium .switch_to .window (self .selenium .window_handles [- 1 ])
4077+ self .wait_for_text ('#content h1' , 'Change section' )
4078+ name_input = self .selenium .find_element_by_id ('id_name' )
4079+ name_input .clear ()
4080+ name_input .send_keys ('<i>edited section</i>' )
4081+ self .selenium .find_element_by_xpath ('//input[@value="Save"]' ).click ()
4082+ self .selenium .switch_to .window (self .selenium .window_handles [0 ])
4083+ select = Select (self .selenium .find_element_by_id ('id_form-0-section' ))
4084+ self .assertEqual (select .first_selected_option .text , '<i>edited section</i>' )
4085+
4086+ # Add popup
4087+ self .selenium .find_element_by_id ('add_id_form-0-section' ).click ()
4088+ self .wait_for_popup ()
4089+ self .selenium .switch_to .window (self .selenium .window_handles [- 1 ])
4090+ self .wait_for_text ('#content h1' , 'Add section' )
4091+ self .selenium .find_element_by_id ('id_name' ).send_keys ('new section' )
4092+ self .selenium .find_element_by_xpath ('//input[@value="Save"]' ).click ()
4093+ self .selenium .switch_to .window (self .selenium .window_handles [0 ])
4094+ select = Select (self .selenium .find_element_by_id ('id_form-0-section' ))
4095+ self .assertEqual (select .first_selected_option .text , 'new section' )
4096+
40594097 def test_list_editable_raw_id_fields (self ):
40604098 parent = ParentWithUUIDPK .objects .create (title = 'test' )
40614099 parent2 = ParentWithUUIDPK .objects .create (title = 'test2' )
0 commit comments