Skip to content

Commit

Permalink
fix selenium fails waiting on CSS selectors for tool panel
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedhamidawan committed Oct 13, 2023
1 parent b0146ac commit 058d727
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 10 deletions.
39 changes: 29 additions & 10 deletions client/src/components/Panels/ToolPanel.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { storeToRefs } from "pinia";
import { ref, watch, watchEffect } from "vue";
import { ref, watch } from "vue";
import { useConfig } from "@/composables/config";
import { useToolStore } from "@/stores/toolStore";
Expand Down Expand Up @@ -41,17 +41,36 @@ watch(
}
);
watchEffect(async () => {
if (isConfigLoaded.value) {
panelViews.value = config.value.panel_views;
try {
await toolStore.fetchTools();
await toolStore.initCurrentPanelView(config.value.default_panel_view);
} catch (error: any) {
console.error("ToolPanel - Load tools error:", error);
// as soon as config is loaded, load tools
watch(
() => isConfigLoaded.value,
async (newVal) => {
if (newVal) {
await loadTools();
}
},
{ immediate: true }
);
// if currentPanelView ever becomes null || "", load tools
watch(
() => currentPanelView.value,
async (newVal) => {
if (!newVal && isConfigLoaded.value) {
await loadTools();
}
}
});
);
async function loadTools() {
panelViews.value = panelViews.value === null ? config.value.panel_views : panelViews.value;
try {
await toolStore.fetchTools();
await toolStore.initCurrentPanelView(config.value.default_panel_view);
} catch (error: any) {
console.error("ToolPanel - Load tools error:", error);
}
}
async function updatePanelView(panelView: string) {
await toolStore.setCurrentPanelView(panelView);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { shallowMount } from "@vue/test-utils";
import axios from "axios";
import MockAdapter from "axios-mock-adapter";
import { getAppRoot } from "onload/loadConfig";
import { createPinia } from "pinia";
import { getLocalVue } from "tests/jest/helpers";
Expand Down Expand Up @@ -31,6 +33,8 @@ Services.mockImplementation(() => {

describe("RepositoryDetails", () => {
it("test repository details index", async () => {
const axiosMock = new MockAdapter(axios);
axiosMock.onGet("api/tools?in_panel=true&view=default").reply(200, {});
mockFetcher.path("/api/configuration").method("get").mock({ data: {} });
const localVue = getLocalVue();
const pinia = createPinia();
Expand Down

0 comments on commit 058d727

Please sign in to comment.