Skip to content

Commit 5729933

Browse files
committed
Selenium regression test for #20886 (sharing private histories)
1 parent 425ddc9 commit 5729933

File tree

6 files changed

+74
-5
lines changed

6 files changed

+74
-5
lines changed

client/src/components/History/HistoryAccessibility.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function openSharingTab() {
4444
<BreadcrumbHeading :items="breadcrumbItems" />
4545

4646
<BTabs class="mt-3">
47-
<BTab :lazy="historyPrivacyChanged" @click="openSharingTab">
47+
<BTab id="history-sharing-tab" :lazy="historyPrivacyChanged" @click="openSharingTab">
4848
<template v-slot:title>
4949
<FontAwesomeIcon :icon="faShareAlt" class="mr-1" />
5050
{{ localize("Share or Publish") }}
@@ -68,7 +68,7 @@ function openSharingTab() {
6868
</PortletSection>
6969
</BTab>
7070

71-
<BTab :lazy="historyPrivacyChanged" @click="historyPrivacyChanged = false">
71+
<BTab id="history-permissions-tab" :lazy="historyPrivacyChanged" @click="historyPrivacyChanged = false">
7272
<template v-slot:title>
7373
<FontAwesomeIcon :icon="faUserLock" class="mr-1" />
7474
{{ localize("Set Permissions") }}
@@ -77,7 +77,7 @@ function openSharingTab() {
7777
<HistoryDatasetPermissions :history-id="props.historyId" no-redirect />
7878
</BTab>
7979

80-
<BTab>
80+
<BTab id="history-make-private-tab">
8181
<template v-slot:title>
8282
<FontAwesomeIcon :icon="faLock" class="mr-1" />
8383
{{ localize("Make Private") }}

client/src/components/History/HistoryMakePrivate.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,12 @@ async function makeHistoryPrivate() {
5656
re-shared or published. Are you sure you want to do this?
5757
</p>
5858

59-
<AsyncButton :icon="faLock" :disabled="!history" variant="primary" :action="makeHistoryPrivate">
59+
<AsyncButton
60+
data-description="history make private"
61+
:icon="faLock"
62+
:disabled="!history"
63+
variant="primary"
64+
:action="makeHistoryPrivate">
6065
{{ localize("Make History Private") }}
6166
</AsyncButton>
6267
</PortletSection>

client/src/components/Sharing/UserSharing.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ defineExpose({
225225
no-close-on-backdrop
226226
scrollable
227227
dialog-class="user-sharing-modal"
228+
data-description="sharing permissions change required"
228229
@ok="onUpdatePermissions"
229230
@cancel="onCancel"
230231
@close="onCancel">
@@ -250,7 +251,7 @@ defineExpose({
250251
header-bg-variant="primary"
251252
header-text-variant="white"
252253
class="mb-4">
253-
<BFormSelect v-model="selectedSharingOption">
254+
<BFormSelect v-model="selectedSharingOption" data-description="sharing permissions change required how">
254255
<BFormSelectOption value="make_public"> Make datasets public </BFormSelectOption>
255256
<BFormSelectOption value="make_accessible_to_shared">
256257
Make datasets private to me and users this {{ modelClass }} is shared with

client/src/utils/navigation/navigation.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,12 @@ histories:
513513
share_with_input: '.share_with_view input'
514514
make_accessible: '.make-accessible label'
515515
make_publishable: '.make-publishable label'
516+
tab_make_private: '[aria-controls="history-make-private-tab"]'
517+
make_private: '[data-description="history make private"]'
518+
permissions_change_required: '[data-description="sharing permissions change required"]'
519+
permissions_change_required_how: '[data-description="sharing permissions change required how"]'
520+
permissions_change_required_ok: '[data-description="sharing permissions change required"] .btn-primary'
521+
516522
labels:
517523
unshare: 'Unshare'
518524

lib/galaxy/selenium/navigates_galaxy.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,12 @@ def go_to_workflow_export(self, workflow_id: str) -> None:
335335
def go_to_history_sharing(self, history_id: str) -> None:
336336
self.driver.get(self.build_url(f"histories/sharing?id={history_id}"))
337337

338+
def make_history_private(self):
339+
self.click_history_option_sharing()
340+
sharing = self.components.histories.sharing
341+
sharing.tab_make_private.wait_for_and_click()
342+
sharing.make_private.wait_for_and_click()
343+
338344
def go_to_import_zip(self) -> None:
339345
self.driver.get(self.build_url("import/zip"))
340346
self.components.masthead._.wait_for_visible()

lib/galaxy_test/selenium/test_history_sharing.py

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

0 commit comments

Comments
 (0)