fix(接口测试): 修复场景调试权限

--bug=1027266 --user=王孝刚 【接口测试】接口自动化开启编辑权限,可在详情哪逐个步骤执行调试
https://www.tapd.cn/55049933/s/1384729
This commit is contained in:
wxg0103 2023-06-21 11:40:29 +08:00 committed by fit2-zhao
parent 5001c33004
commit 07db38916a
11 changed files with 72 additions and 26 deletions

View File

@ -112,8 +112,9 @@
<el-tooltip v-if="!debugLoading" content="Ctrl + R" placement="top">
<el-dropdown split-button type="primary" @click="runDebug" class="ms-message-right" size="mini"
@command="handleCommand"
v-permission="['PROJECT_API_SCENARIO:READ+EDIT', 'PROJECT_API_SCENARIO:READ+CREATE', 'PROJECT_API_SCENARIO:READ+COPY',
'PROJECT_API_SCENARIO:READ+RUN', 'PROJECT_API_SCENARIO:READ+DEBUG']">
v-permission="[
'PROJECT_API_SCENARIO:READ+RUN',
'PROJECT_API_SCENARIO:READ+DEBUG']">
{{ $t('api_test.request.debug') }}
<el-dropdown-menu slot="dropdown">
<el-dropdown-item>{{ $t('api_test.automation.generate_report') }}</el-dropdown-item>
@ -1458,7 +1459,7 @@ export default {
})
},
runDebug(runScenario) {
if (!hasPermission('PROJECT_API_SCENARIO:READ+EDIT')) {
if (!hasPermissions('PROJECT_API_SCENARIO:READ+DEBUG','PROJECT_API_SCENARIO:READ+RUN')) {
return;
}
this.mergeScenario(this.scenarioDefinition);

View File

@ -32,8 +32,7 @@
</slot>
</span>
<div v-if="!ifFromVariableAdvance" class="header-right" @click.stop
v-permission="['PROJECT_API_SCENARIO:READ+EDIT', 'PROJECT_API_SCENARIO:READ+CREATE', 'PROJECT_API_SCENARIO:READ+COPY']">
<div v-if="!ifFromVariableAdvance" class="header-right" @click.stop>
<slot name="message" v-show="!isMax"></slot>
<slot name="debugStepCode"></slot>
@ -46,10 +45,20 @@
<el-button v-if="showVersion && showCopy" size="mini" icon="el-icon-copy-document" circle @click="copyRow"
style="padding: 5px"
v-permission="[
'PROJECT_API_SCENARIO:READ+EDIT',
'PROJECT_API_SCENARIO:READ+CREATE',
'PROJECT_API_SCENARIO:READ+COPY',
]"
:disabled="(data.disabled && !data.root && !data.isCopy) || !showVersion || isDeleted"/>
<el-button v-show="isSingleButton" size="mini" icon="el-icon-delete" type="danger" style="padding: 5px" circle
@click="remove"
v-permission="[
'PROJECT_API_SCENARIO:READ+EDIT',
'PROJECT_API_SCENARIO:READ+CREATE',
'PROJECT_API_SCENARIO:READ+COPY',
]"
:disabled="(data.disabled && !data.root && !data.isCopy) || !showVersion || isDeleted"/>
<step-extend-btns style="display: contents"
@ -62,6 +71,11 @@
@copy="copyRow"
@remove="remove"
@openScenario="openScenario"
v-permission="[
'PROJECT_API_SCENARIO:READ+EDIT',
'PROJECT_API_SCENARIO:READ+CREATE',
'PROJECT_API_SCENARIO:READ+COPY',
]"
v-show="isMoreButton"/>
</div>

View File

@ -60,11 +60,19 @@
</template>
<template v-slot:button v-if="!ifFromVariableAdvance">
<el-tooltip :content="$t('api_test.run')" placement="top" v-if="!loading">
<el-button :disabled="!request.enable" @click="run" icon="el-icon-video-play" class="ms-btn" size="mini" circle/>
<el-button :disabled="!request.enable" @click="run" icon="el-icon-video-play" class="ms-btn" size="mini" circle
v-permission="[
'PROJECT_API_SCENARIO:READ+DEBUG',
'PROJECT_API_SCENARIO:READ+RUN'
]"/>
</el-tooltip>
<el-tooltip :content="$t('report.stop_btn')" placement="top" :enterable="false" v-else>
<el-button @click.once="stop" size="mini" style="color:white;padding: 0 0.1px;width: 24px;height: 24px;"
class="stop-btn" circle>
class="stop-btn" circle
v-permission="[
'PROJECT_API_SCENARIO:READ+DEBUG',
'PROJECT_API_SCENARIO:READ+RUN'
]">
<div style="transform: scale(0.66)">
<span style="margin-left: -4.5px;font-weight: bold;">STOP</span>
</div>

View File

@ -32,12 +32,18 @@
</template>
<template v-slot:behindHeaderLeft>
<el-tag size="small" class="ms-tag" v-if="scenario.referenced==='Deleted'" type="danger">{{ $t('api_test.automation.reference_deleted') }}</el-tag>
<el-tag size="small" class="ms-tag" v-if="scenario.referenced==='Deleted'" type="danger">
{{ $t('api_test.automation.reference_deleted') }}
</el-tag>
<el-tag size="small" class="ms-tag" v-if="scenario.referenced==='Copy'">{{ $t('commons.copy') }}</el-tag>
<el-tag size="small" class="ms-tag" v-if="scenario.referenced==='REF'">{{ $t('api_test.scenario.reference') }}</el-tag>
<el-tag size="small" class="ms-tag" v-if="scenario.referenced==='REF'">{{
$t('api_test.scenario.reference')
}}
</el-tag>
<span class="ms-tag ms-step-name-api">{{ getProjectName(scenario.projectId) }}</span>
<el-tooltip v-if="(!scenario.hashTree || scenario.hashTree.length === 0) && scenario.referenced==='REF'"
class="ms-num" effect="dark" :content="$t('api_test.scenario.base_scenario_step_is_empty')" placement="top" style="margin-left: 5px">
class="ms-num" effect="dark" :content="$t('api_test.scenario.base_scenario_step_is_empty')"
placement="top" style="margin-left: 5px">
<i class="el-icon-warning"/>
</el-tooltip>
</template>
@ -46,16 +52,27 @@
<i class="el-icon-loading" style="font-size: 16px"/>
{{ $t('commons.testing') }}
</span>
<span class="ms-step-debug-code" :class="node.data.code ==='error'?'ms-req-error':'ms-req-success'" v-if="!loading && node.data.debug && !node.data.testing">
<span class="ms-step-debug-code" :class="node.data.code ==='error'?'ms-req-error':'ms-req-success'"
v-if="!loading && node.data.debug && !node.data.testing">
{{ getCode() }}
</span>
</template>
<template v-slot:button v-if="!ifFromVariableAdvance">
<el-tooltip :content="$t('api_test.run')" placement="top" v-if="!scenario.run">
<el-button :disabled="!scenario.enable" @click="run" icon="el-icon-video-play" style="padding: 5px" class="ms-btn" size="mini" circle/>
<el-button :disabled="!scenario.enable" @click="run" icon="el-icon-video-play" style="padding: 5px"
class="ms-btn" size="mini" circle
v-permission="[
'PROJECT_API_SCENARIO:READ+DEBUG',
'PROJECT_API_SCENARIO:READ+RUN'
]"/>
</el-tooltip>
<el-tooltip :content="$t('report.stop_btn')" placement="top" :enterable="false" v-else>
<el-button :disabled="!scenario.enable" @click.once="stop" size="mini" style="color:white;padding: 0 0.1px;width: 24px;height: 24px;" class="stop-btn" circle>
<el-button :disabled="!scenario.enable" @click.once="stop" size="mini"
style="color:white;padding: 0 0.1px;width: 24px;height: 24px;" class="stop-btn" circle
v-permission="[
'PROJECT_API_SCENARIO:READ+DEBUG',
'PROJECT_API_SCENARIO:READ+RUN'
]">
<div style="transform: scale(0.66)">
<span style="margin-left: -4.5px;font-weight: bold;">STOP</span>
</div>
@ -308,7 +325,13 @@ export default {
gotoTurn(resource, workspaceId, isTurnSpace) {
let automationData = this.$router.resolve({
name: 'ApiAutomation',
params: {redirectID: getUUID(), dataType: "scenario", dataSelectRange: 'edit:' + resource.id, projectId: resource.projectId, workspaceId: workspaceId}
params: {
redirectID: getUUID(),
dataType: "scenario",
dataSelectRange: 'edit:' + resource.id,
projectId: resource.projectId,
workspaceId: workspaceId
}
});
if (isTurnSpace) {
window.open(automationData.href, '_blank');

View File

@ -23,7 +23,7 @@
@command="handleCommand" size="small" v-if="testCase===undefined && !scenario">
{{ $t('commons.test') }}
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="save_as">{{
<el-dropdown-item command="save_as" v-permission="['PROJECT_API_DEFINITION:READ+CREATE_CASE']">{{
$t('api_test.definition.request.save_as_case')
}}
</el-dropdown-item>

View File

@ -1,7 +1,7 @@
<template>
<div>
<ms-database-from :config="currentConfig" :callback="saveConfig" ref="databaseFrom" :is-read-only="isReadOnly"/>
<ms-database-config-list @rowSelect="rowSelect" v-if="configs.length > 0" :table-data="configs"/>
<ms-database-config-list @rowSelect="rowSelect" v-if="configs.length > 0" :table-data="configs" :is-read-only="isReadOnly"/>
</div>
</template>

View File

@ -17,9 +17,9 @@
<template v-slot:default="scope">
<div>
<ms-table-operator-button :tip="$t('commons.copy')" icon="el-icon-document-copy" type="success"
@exec="handleCopy(scope.$index, scope.row)"/>
@exec="handleCopy(scope.$index, scope.row)" :disabled="isReadOnly"/>
<ms-table-operator-button :tip="$t('commons.delete')" icon="el-icon-delete" type="danger"
@exec="handleDelete(scope.$index)"/>
@exec="handleDelete(scope.$index)" :disabled="isReadOnly"/>
</div>
</template>
</el-table-column>

View File

@ -32,7 +32,7 @@
<el-form-item>
<el-dropdown split-button type="primary" class="ms-api-buttion" @click="handleCommand('add')"
@command="handleCommand" size="small" v-if="!runLoading"
v-permission="['PROJECT_API_DEFINITION:READ+EDIT_API']">
v-permission="['PROJECT_API_DEFINITION:READ+EDIT_API', 'PROJECT_API_DEFINITION:READ+CREATE_CASE']">
{{ $t('commons.test') }}
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="load_case">{{ $t('api_test.definition.request.load_case') }}

View File

@ -1,7 +1,7 @@
<template>
<div>
<el-form :model="commonConfig" :rules="rules" ref="commonConfig" :disabled="isReadOnly" label-width="30px">
<ms-api-scenario-variables :show-copy="false" :items="commonConfig.variables"/>
<ms-api-scenario-variables :show-copy="false" :items="commonConfig.variables" :is-read-only="isReadOnly"/>
<el-form-item>
<el-switch v-model="commonConfig.enableHost" active-text="Hosts"/>
</el-form-item>

View File

@ -14,7 +14,7 @@
<slot name="other"></slot>
</div>
<div class="ms_btn">
<el-button type="primary" @click="confirm" @keydown.enter.native.prevent>
<el-button type="primary" @click="confirm" @keydown.enter.native.prevent :disabled="isReadOnly">
{{ $t('commons.confirm') }}
</el-button>
</div>

View File

@ -44,18 +44,18 @@
<p>{{ $t('api_test.request.headers') }}</p>
<el-row>
<el-link class="ms-el-link" @click="batchAdd" style="color: #783887"> {{ $t("commons.batch_add") }}</el-link>
<el-link class="ms-el-link" @click="batchAdd" style="color: #783887" :disabled="isReadOnly"> {{ $t("commons.batch_add") }}</el-link>
</el-row>
<ms-api-key-value :items="condition.headers" :isShowEnable="true" :suggestions="headerSuggestions"/>
<ms-api-key-value :items="condition.headers" :isShowEnable="true" :suggestions="headerSuggestions" :disabled="isReadOnly"/>
<div style="margin-top: 20px">
<el-button v-if="!condition.id" type="primary" style="float: right" size="mini" @click="add">
<el-button v-if="!condition.id" type="primary" style="float: right" size="mini" @click="add" :disabled="isReadOnly">
{{ $t('commons.add') }}
</el-button>
<div v-else>
<el-button type="primary" style="float: right;margin-left: 10px" size="mini" @click="clear">
<el-button type="primary" style="float: right;margin-left: 10px" size="mini" @click="clear" :disabled="isReadOnly">
{{ $t('commons.clear') }}
</el-button>
<el-button type="primary" style="float: right" size="mini" @click="update(condition)">{{
<el-button type="primary" style="float: right" size="mini" @click="update(condition)" :disabled="isReadOnly">{{
$t('commons.update')
}}
</el-button>