@@ -147,3 +147,54 @@ def test_share_history_login_redirect(self):
147147 self .fill_login_and_submit (user_email )
148148 self .wait_for_logged_in ()
149149 self .wait_for_selector (".make-accessible" )
150+
151+
152+ class TestPrivateHistorySharingRequiresPermissionChanges (SeleniumTestCase ):
153+ """Test that sharing private histories requires permission changes.
154+
155+ Includes regression test for PR #20886: When sharing a history containing private datasets
156+ with another user, the default option should be "Make datasets private to
157+ me and users this history is shared with" rather than "Make datasets public".
158+ """
159+
160+ @selenium_test
161+ def test_sharing_private_history_default_permission (self ):
162+ # Create two test users - one to own the history, one to share with
163+ user1_email = self ._get_random_email ()
164+ user2_email = self ._get_random_email ()
165+
166+ # Register first user and create a private history with data
167+ self .register (user1_email )
168+ self .make_history_private ()
169+ self .perform_upload_of_pasted_content ("hello world" )
170+ self .wait_for_history ()
171+
172+ # Register second user (must exist to share with)
173+ self .logout_if_needed ()
174+ self .register (user2_email )
175+ self .logout_if_needed ()
176+
177+ # Login as first user and initiate sharing
178+ self .submit_login (user1_email )
179+ self .home ()
180+ self .click_history_option_sharing ()
181+
182+ # Share with the second user - this triggers the permission dialog
183+ sharing = self .components .histories .sharing
184+ self .share_with_user (sharing , user_email = user2_email )
185+
186+ # Verify the permission change required dialog appears
187+ self .screenshot ("history_private_sharing_permissions_dialog" )
188+ self .components .histories .sharing .permissions_change_required .wait_for_visible ()
189+
190+ # Verify the default selected option is 'make_accessible_to_shared'
191+ element = self .components .histories .sharing .permissions_change_required_how .wait_for_visible ()
192+ default_value = element .get_attribute ("value" )
193+ assert default_value == "make_accessible_to_shared" , (
194+ f"Expected default permission option to be 'make_accessible_to_shared' "
195+ f"(private to shared users), but got '{ default_value } '"
196+ )
197+
198+ # Confirm the permission change to complete sharing
199+ self .components .histories .sharing .permissions_change_required_ok .wait_for_and_click ()
200+ self .screenshot ("history_private_sharing_permissions_confirmed" )
0 commit comments