fix(query): deduplicate timeout setting actions
This commit is contained in:
4 files changed
+40
-4
No files matched your search
@@ -1,4 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from "vue";
|
||||
import { Bot, Wrench } from "@lucide/vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { Button } from "@/components/ui/button";
|
||||
@@ -18,14 +19,16 @@ const emit = defineEmits<{
|
||||
}>();
|
||||
|
||||
const { t } = useI18n();
|
||||
const showConnectionTimeout = computed(() => !!props.connectionId && isConnectionTimeoutErrorMessage(props.errorMessage, props.backendError));
|
||||
const showQueryTimeout = computed(() => !!props.connectionId && !showConnectionTimeout.value && isQueryTimeoutErrorMessage(props.errorMessage, props.backendError));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Button v-if="connectionId && isConnectionTimeoutErrorMessage(errorMessage, backendError)" variant="outline" size="sm" class="h-7 gap-1.5 px-2.5 text-xs" @click="emit('changeConnectionTimeout')">
|
||||
<Button v-if="showConnectionTimeout" variant="outline" size="sm" class="h-7 gap-1.5 px-2.5 text-xs" @click="emit('changeConnectionTimeout')">
|
||||
<Wrench class="h-3.5 w-3.5" />
|
||||
{{ t("editor.changeConnectionTimeout") }}
|
||||
</Button>
|
||||
<Button v-if="connectionId && isQueryTimeoutErrorMessage(errorMessage, backendError)" variant="outline" size="sm" class="h-7 gap-1.5 px-2.5 text-xs" @click="emit('changeQueryTimeout')">
|
||||
<Button v-if="showQueryTimeout" variant="outline" size="sm" class="h-7 gap-1.5 px-2.5 text-xs" @click="emit('changeQueryTimeout')">
|
||||
<Wrench class="h-3.5 w-3.5" />
|
||||
{{ t("editor.changeQueryTimeout") }}
|
||||
</Button>
|
||||
|
||||
@@ -41,4 +41,20 @@ describe("QueryErrorActions", () => {
|
||||
expect(host.textContent).not.toContain("Change connection timeout");
|
||||
expect(host.textContent).toContain("Change query timeout");
|
||||
});
|
||||
|
||||
it("shows only connection timeout settings for connect-stage agent RPC timeouts", async () => {
|
||||
const { host } = await mountActions("Agent RPC call timed out at connect");
|
||||
const labels = Array.from(host.querySelectorAll("button"), (button) => button.textContent?.trim());
|
||||
|
||||
expect(labels).toContain("Change connection timeout");
|
||||
expect(labels).not.toContain("Change query timeout");
|
||||
});
|
||||
|
||||
it("does not offer query timeout settings for non-query Agent RPC stages", async () => {
|
||||
for (const stage of ["request", "validate", "cancel", "close"]) {
|
||||
const { host } = await mountActions(`Agent RPC call timed out at ${stage}`);
|
||||
|
||||
expect(host.textContent).not.toContain("Change query timeout");
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user