Skip to content

Commit 234a215

Browse files
authored
Merge pull request galaxyproject#22301 from mvdbeek/fix-flaky-tests
Fix flaky selenium tests ``test_refresh_preserves_state``, and``test_tool_discovery_landing``
2 parents 4012134 + 0528097 commit 234a215

4 files changed

Lines changed: 23 additions & 20 deletions

File tree

client/src/components/ToolsList/ToolsListTable.vue

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script setup lang="ts">
22
import { BAlert } from "bootstrap-vue";
33
import { storeToRefs } from "pinia";
4-
import { watchEffect } from "vue";
4+
import { computed } from "vue";
55
66
import { type Tool, useToolStore } from "@/stores/toolStore";
77
@@ -42,18 +42,15 @@ async function loadTools(offset: number, limit: number): Promise<{ items: Tool[]
4242
return { items, total: props.tools.length };
4343
}
4444
45-
// Watch for changes in tools array to preload initial help data
46-
watchEffect(() => {
47-
if (props.tools.length > 0) {
48-
const initialItems = props.tools.slice(0, FETCH_LIMIT + PREFETCH_AHEAD);
49-
Promise.all(initialItems.map((tool) => toolStore.fetchHelpForId(tool.id)));
50-
}
51-
});
45+
// Force ScrollList remount when tools change (e.g. after search),
46+
// ensuring loadTools is called again to await help data for new results.
47+
const toolsKey = computed(() => `${props.tools.length}-${props.tools[0]?.id}`);
5248
</script>
5349

5450
<template>
5551
<ScrollList
5652
ref="root"
53+
:key="toolsKey"
5754
:loader="loadTools"
5855
:limit="FETCH_LIMIT"
5956
:item-key="(tool) => tool.id"

client/src/stores/toolStore.ts

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export const useToolStore = defineStore("toolStore", () => {
116116
const toolsById = shallowRef<Record<string, Tool>>({});
117117
const toolResults = ref<Record<string, string[]>>({});
118118
const toolSections = ref<Record<string, Record<string, ToolPanelItem>>>({});
119-
const fetchedHelpIds = ref<Set<string>>(new Set());
119+
const fetchedHelpIds = ref<Map<string, Promise<void>>>(new Map());
120120
const helpDataCached = ref<Record<string, ToolHelpData>>({});
121121

122122
const currentToolSections = computed(() => {
@@ -281,10 +281,15 @@ export const useToolStore = defineStore("toolStore", () => {
281281
}
282282

283283
async function fetchHelpForId(toolId: string) {
284-
try {
285-
if (!helpDataCached.value[toolId] && !fetchedHelpIds.value.has(toolId)) {
286-
fetchedHelpIds.value.add(toolId);
287-
284+
if (helpDataCached.value[toolId]) {
285+
return;
286+
}
287+
const existing = fetchedHelpIds.value.get(toolId);
288+
if (existing) {
289+
return existing;
290+
}
291+
const promise = (async () => {
292+
try {
288293
const toolHelpData: ToolHelpData = {};
289294

290295
const { data } = (await axios.get(
@@ -300,11 +305,13 @@ export const useToolStore = defineStore("toolStore", () => {
300305
}
301306

302307
Vue.set(helpDataCached.value, toolId, toolHelpData);
308+
} catch (error) {
309+
console.error("Error fetching help:", error);
310+
fetchedHelpIds.value.delete(toolId); // Allow retrying on next request
303311
}
304-
} catch (error) {
305-
console.error("Error fetching help:", error);
306-
fetchedHelpIds.value.delete(toolId); // Allow retrying on next request
307-
}
312+
})();
313+
fetchedHelpIds.value.set(toolId, promise);
314+
return promise;
308315
}
309316

310317
async function initializePanel() {

lib/galaxy_test/selenium/test_history_panel.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ def clear_tags(self, expected_tags_size):
156156
close_btn.click()
157157
self.sleep_for(self.wait_types.UX_RENDER)
158158

159-
@selenium_only("Not yet migrated to support Playwright backend")
160159
@selenium_test
161160
def test_refresh_preserves_state(self):
162161
self.perform_upload(self.get_filename("1.txt"))
@@ -175,7 +174,7 @@ def test_refresh_preserves_state(self):
175174
assert self.history_panel_item_showing_details(hid=1)
176175

177176
# Close the detailed display, refresh, and ensure they are still closed.
178-
self.history_panel_click_item_title(hid=1, wait=False)
177+
self.history_panel_click_item_title(hid=1, wait=True)
179178
assert not self.history_panel_item_showing_details(hid=1)
180179

181180
self._refresh()

lib/galaxy_test/selenium/test_tool_discovery_view.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class TestToolDiscoveryViewAnonymous(SeleniumTestCase):
1616
advanced search, and list vs grid view toggling.
1717
"""
1818

19-
@transient_failure(issue=21225)
19+
@transient_failure(issue=21225, potentially_fixed=True)
2020
@selenium_test
2121
def test_tool_discovery_landing(self):
2222
"""Test navigation to the tool discovery view."""

0 commit comments

Comments
 (0)