api-client/components/http/Tests.vue

101 lines
2.4 KiB
Vue
Raw Normal View History

<template>
<AppSection id="script" :label="$t('test.script')">
<div
class="
bg-primary
border-b border-dividerLight
flex flex-1
top-upperSecondaryStickyFold
pl-4
z-10
sticky
items-center
justify-between
"
2021-07-30 19:21:41 +00:00
>
<label class="font-semibold text-secondaryLight">
{{ $t("test.javascript_code") }}
</label>
2021-08-17 07:26:36 +00:00
<div class="flex">
<ButtonSecondary
v-tippy="{ theme: 'tooltip' }"
2021-08-19 06:16:22 +00:00
to="https://docs.hoppscotch.io/features/tests"
2021-08-17 07:26:36 +00:00
blank
:title="$t('app.wiki')"
2021-08-28 00:17:33 +00:00
svg="help-circle"
2021-08-17 07:26:36 +00:00
/>
<ButtonSecondary
v-tippy="{ theme: 'tooltip' }"
:title="$t('action.clear')"
2021-08-28 00:17:33 +00:00
svg="trash-2"
2021-08-17 07:26:36 +00:00
@click.native="clearContent"
/>
</div>
</div>
2021-08-14 10:44:08 +00:00
<div class="border-b border-dividerLight flex">
<div class="border-r border-dividerLight w-2/3">
<SmartJsEditor
v-model="testScript"
:options="{
maxLines: Infinity,
minLines: 16,
autoScrollEditorIntoView: true,
showPrintMargin: false,
useWorker: false,
}"
complete-mode="test"
/>
</div>
<div
class="
2021-08-27 04:07:29 +00:00
bg-primary
h-full
top-upperTertiaryStickyFold
min-w-46
max-w-1/3
p-4
z-9
sticky
overflow-auto
"
>
<div class="text-secondaryLight pb-2">
{{ $t("helpers.post_request_tests") }}
</div>
<SmartAnchor
:label="$t('test.learn')"
2021-08-19 17:08:50 +00:00
to="https://docs.hoppscotch.io/features/tests"
blank
/>
2021-08-16 08:48:45 +00:00
<h4 class="font-bold text-secondaryLight pt-6">
{{ $t("test.snippets") }}
</h4>
<div class="flex flex-col pt-4">
2021-08-17 07:26:36 +00:00
<TabSecondary
v-for="(snippet, index) in testSnippets"
2021-08-16 08:48:45 +00:00
:key="`snippet-${index}`"
:label="snippet.name"
2021-08-17 07:26:36 +00:00
active
2021-08-16 08:48:45 +00:00
@click.native="useSnippet(snippet.script)"
/>
</div>
</div>
</div>
</AppSection>
</template>
<script setup lang="ts">
import { useTestScript } from "~/newstore/RESTSession"
2021-08-16 08:48:45 +00:00
import testSnippets from "~/helpers/testSnippets"
const testScript = useTestScript()
2021-08-17 07:26:36 +00:00
const useSnippet = (script: string) => {
testScript.value += script
}
2021-08-17 07:26:36 +00:00
const clearContent = () => {
testScript.value = ""
}
</script>