|
|
|
|
@ -9,10 +9,11 @@ import {
|
|
|
|
|
deleteTestCase,
|
|
|
|
|
exportTemplate,
|
|
|
|
|
exportTestCases,
|
|
|
|
|
importTestCases
|
|
|
|
|
importTestCases, startTestCase
|
|
|
|
|
} from '@/api/componentTestCase';
|
|
|
|
|
import TestCaseModal from './testCaseModal';
|
|
|
|
|
import useWebSocket from '@/hooks/useWebSocket';
|
|
|
|
|
import { getToken } from '@/utils/auth';
|
|
|
|
|
|
|
|
|
|
const CollapseItem = Collapse.Item;
|
|
|
|
|
|
|
|
|
|
@ -99,24 +100,27 @@ const TestInstance = ({ instance, parentId, onBack }: { instance: any; parentId:
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 链接实例
|
|
|
|
|
const handleLinkInstance = () => {
|
|
|
|
|
const handleLinkInstance = async () => {
|
|
|
|
|
if (isSocketConnected) {
|
|
|
|
|
disconnect();
|
|
|
|
|
Message.info('已断开连接');
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
// WebSocket连接前置
|
|
|
|
|
const res: any = await startTestCase(instance.id);
|
|
|
|
|
console.log('res:', res);
|
|
|
|
|
|
|
|
|
|
// 构建WebSocket URL,根据你的实际后端配置调整
|
|
|
|
|
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
|
|
|
|
|
const host = window.location.host;
|
|
|
|
|
let wsUrl = '';
|
|
|
|
|
if (window.location.host.includes('localhost')) {
|
|
|
|
|
wsUrl = `${process.env.NEXT_PUBLIC_DEV_SOCKET_HOST}/ws/v1/bpms-workbench/test-case/${instance.id}/${cryptoRandom()}`;
|
|
|
|
|
wsUrl = `${process.env.NEXT_PUBLIC_DEV_SOCKET_HOST}/ws/v1/bpms-workbench/test-case/${instance.id}/${cryptoRandom()}?Authorization=Bearer ${getToken()}`;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
wsUrl = `${protocol}//${host}/ws/v1/bpms-workbench/test-case/${instance.id}/${cryptoRandom()}`;
|
|
|
|
|
wsUrl = `${protocol}//${host}/ws/v1/bpms-workbench/test-case/${instance.id}/${cryptoRandom()}?Authorization=Bearer ${getToken()}`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
connect(wsUrl);
|
|
|
|
|
addLog('正在连接测试实例...');
|
|
|
|
|
}
|
|
|
|
|
@ -311,6 +315,7 @@ const TestInstance = ({ instance, parentId, onBack }: { instance: any; parentId:
|
|
|
|
|
<div className={styles['tab-left']}>
|
|
|
|
|
<Button
|
|
|
|
|
type="primary"
|
|
|
|
|
status={isSocketConnected ?'danger' : 'default'}
|
|
|
|
|
icon={<IconLink />}
|
|
|
|
|
onClick={handleLinkInstance}
|
|
|
|
|
style={{ minWidth: 250 }}
|
|
|
|
|
|