Skip to content

Commit b744384

Browse files
authored
Merge pull request #21040 from jmchilton/25_1_selenium_3
Selenium test for #20886 (sharing private histories)
2 parents 17aa2bc + 5729933 commit b744384

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
@@ -533,6 +533,12 @@ histories:
533533
share_with_input: '.share_with_view input'
534534
make_accessible: '.make-accessible label'
535535
make_publishable: '.make-publishable label'
536+
tab_make_private: '[aria-controls="history-make-private-tab"]'
537+
make_private: '[data-description="history make private"]'
538+
permissions_change_required: '[data-description="sharing permissions change required"]'
539+
permissions_change_required_how: '[data-description="sharing permissions change required how"]'
540+
permissions_change_required_ok: '[data-description="sharing permissions change required"] .btn-primary'
541+
536542
labels:
537543
unshare: 'Unshare'
538544

lib/galaxy/selenium/navigates_galaxy.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,12 @@ def go_to_workflow_export(self, workflow_id: str) -> None:
381381
def go_to_history_sharing(self, history_id: str) -> None:
382382
self.navigate_to(self.build_url(f"histories/sharing?id={history_id}"))
383383

384+
def make_history_private(self):
385+
self.click_history_option_sharing()
386+
sharing = self.components.histories.sharing
387+
sharing.tab_make_private.wait_for_and_click()
388+
sharing.make_private.wait_for_and_click()
389+
384390
def go_to_import_zip(self) -> None:
385391
self.navigate_to(self.build_url("import/zip"))
386392
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
@@ -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

Comments
 (0)