Skip to content

Commit

Permalink
add selenium and unit test for published histories username filter
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedhamidawan committed Sep 6, 2023
1 parent 57b4206 commit c6f1998
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 2 deletions.
7 changes: 6 additions & 1 deletion client/src/components/History/HistoryPublishedList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,12 @@ watch([filterText, sortBy, sortDesc], async () => {
</router-link>
</template>
<template v-slot:cell(username)="row">
<a href="#" @click="setFilter('user', row.item.username)">{{ row.item.username }}</a>
<a
href="#"
class="published-histories-username-link"
@click="setFilter('user', row.item.username)"
>{{ row.item.username }}</a
>
</template>
<template v-slot:cell(tags)="row">
<StatelessTags
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/managers/histories.py
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,7 @@ def _add_parsers(self):
}
)
self.fn_filter_parsers.update(
{"username": {"op": {"eq": self.username_eq, "contains": self.username_contains,},},}
{"username": {"op": {"eq": self.username_eq, "contains": self.username_contains, }, }, }
)

def username_eq(self, item, val: str) -> bool:
Expand Down
23 changes: 23 additions & 0 deletions lib/galaxy_test/selenium/test_histories_published.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,29 @@ def test_published_histories_tag_click(self):

self.assert_histories_present([self.history3_name, self.history1_name])

@selenium_test
def test_published_histories_username_click(self):
self._login()
self.navigate_to_published_histories()
self.sleep_for(self.wait_types.UX_RENDER)
present_histories = self.get_present_histories()
clicked = False
for row in present_histories:
his = row.find_elements(By.TAG_NAME, "td")[0]
if self.history2_name in his.text:
row.find_elements(By.TAG_NAME, "td")[2].find_elements(
By.CSS_SELECTOR, ".published-histories-username-link"
)[0].click()
clicked = True
break

assert clicked
text = self.components.published_histories.search_input.wait_for_value()
if "test2" not in text:
raise AssertionError("Failed to update search filter with username on username click")

self.assert_histories_present([self.history2_name])

@selenium_test
def test_published_histories_search_standard(self):
self._login()
Expand Down
47 changes: 47 additions & 0 deletions test/unit/app/managers/test_HistoryManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -795,10 +795,57 @@ def test_orm_filter_parsing(self):

def test_fn_filter_parsing(self):
user2 = self.user_manager.create(**user2_data)
user3 = self.user_manager.create(**user3_data)
history1 = self.history_manager.create(name="history1", user=user2)
history2 = self.history_manager.create(name="history2", user=user2)
history3 = self.history_manager.create(name="history3", user=user2)
history4 = self.history_manager.create(name="history4", user=user3)

# test username eq filter
filters_2 = self.filter_parser.parse_filters(
[
("username", "eq", "user2"),
]
)
filters_3 = self.filter_parser.parse_filters(
[
("username", "eq", "user3"),
]
)
username_filter_2 = filters_2[0].filter
username_filter_3 = filters_3[0].filter

assert username_filter_2(history1)
assert username_filter_2(history2)
assert username_filter_2(history3)
assert not username_filter_2(history4)
assert not username_filter_3(history1)
assert not username_filter_3(history2)
assert not username_filter_3(history3)
assert username_filter_3(history4)

assert self.history_manager.list(filters=filters_2) == [history1, history2, history3]
assert self.history_manager.list(filters=filters_3) == [history4]

# test username contains filter
filters = self.filter_parser.parse_filters(
[
("username", "contains", "user"),
]
)

assert self.history_manager.list(filters=filters) == [history1, history2, history3, history4]

# test username eq filter (inequality)
filters = self.filter_parser.parse_filters(
[
("username", "eq", "user"),
]
)

assert self.history_manager.list(filters=filters) == []

# test annotation filter
filters = self.filter_parser.parse_filters(
[
("annotation", "has", "no play"),
Expand Down

0 comments on commit c6f1998

Please sign in to comment.