清理废弃模块并完善测试基础设施
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
#include "TestHarness.h"
|
||||
|
||||
#include "src/config/AIConfig.h"
|
||||
#include "src/web/WebCapabilityDetector.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
AIConfig completeConfig(const QString &provider)
|
||||
{
|
||||
AIConfig config = defaultAIConfigForProvider(provider);
|
||||
config.model = QStringLiteral("test-model");
|
||||
config.apiKey = QStringLiteral("test-key-not-a-real-secret");
|
||||
return config;
|
||||
}
|
||||
}
|
||||
|
||||
QA_TEST(WebCapability, RespectsGlobalDisable)
|
||||
{
|
||||
WebConfig webConfig;
|
||||
webConfig.enabled = false;
|
||||
const WebCapability capability = WebCapabilityDetector::detect(completeConfig(QStringLiteral("openai")), webConfig);
|
||||
QA_EXPECT(!capability.supported);
|
||||
QA_EXPECT(capability.statusText.contains(QStringLiteral("已关闭")));
|
||||
}
|
||||
|
||||
QA_TEST(WebCapability, AcceptsOfficialOpenAI)
|
||||
{
|
||||
const WebCapability capability = WebCapabilityDetector::detect(completeConfig(QStringLiteral("openai")));
|
||||
QA_EXPECT(capability.supported);
|
||||
QA_EXPECT_EQ(capability.kind, WebProviderKind::OpenAIResponses);
|
||||
}
|
||||
|
||||
QA_TEST(WebCapability, RejectsThirdPartyOpenAIBaseUrl)
|
||||
{
|
||||
AIConfig config = completeConfig(QStringLiteral("openai"));
|
||||
config.baseUrl = QStringLiteral("https://relay.example.com/v1");
|
||||
const WebCapability capability = WebCapabilityDetector::detect(config);
|
||||
QA_EXPECT(!capability.supported);
|
||||
QA_EXPECT(capability.userMessage.contains(QStringLiteral("api.openai.com")));
|
||||
}
|
||||
|
||||
QA_TEST(WebCapability, AcceptsGeminiProtocol)
|
||||
{
|
||||
const WebCapability capability = WebCapabilityDetector::detect(completeConfig(QStringLiteral("google")));
|
||||
QA_EXPECT(capability.supported);
|
||||
QA_EXPECT_EQ(capability.kind, WebProviderKind::GeminiGrounding);
|
||||
}
|
||||
|
||||
QA_TEST(WebCapability, RejectsDeepSeekAndCustomProviders)
|
||||
{
|
||||
const WebCapability deepSeek = WebCapabilityDetector::detect(completeConfig(QStringLiteral("deepseek")));
|
||||
const WebCapability custom = WebCapabilityDetector::detect(completeConfig(QStringLiteral("custom")));
|
||||
QA_EXPECT(!deepSeek.supported);
|
||||
QA_EXPECT(deepSeek.statusText.contains(QStringLiteral("DeepSeek")));
|
||||
QA_EXPECT(!custom.supported);
|
||||
QA_EXPECT(custom.statusText.contains(QStringLiteral("无法确认")));
|
||||
}
|
||||
|
||||
QA_TEST(WebCapability, RequiresCompleteConfiguration)
|
||||
{
|
||||
AIConfig config = defaultAIConfigForProvider(QStringLiteral("openai"));
|
||||
const WebCapability capability = WebCapabilityDetector::detect(config);
|
||||
QA_EXPECT(!capability.supported);
|
||||
QA_EXPECT(capability.statusText.contains(QStringLiteral("未配置完整")));
|
||||
}
|
||||
Reference in New Issue
Block a user