#add jira & message sync

This commit is contained in:
2025-12-02 10:16:32 +08:00
parent 5c4492d8f8
commit 2ec44b5665
49 changed files with 6633 additions and 1209 deletions

View File

@@ -0,0 +1,98 @@
<?php
namespace Tests\Feature;
use Tests\TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;
class MessageSyncTest extends TestCase
{
/**
* 测试admin框架页面是否可以访问
*/
public function test_admin_page_accessible(): void
{
$response = $this->get('/');
$response->assertStatus(200);
$response->assertViewIs('admin.index');
}
/**
* 测试查询消息API端点
*/
public function test_query_messages_api_validation(): void
{
// 测试空请求
$response = $this->postJson('/api/message-sync/query', []);
$response->assertStatus(422);
$response->assertJsonStructure([
'success',
'message',
'errors'
]);
// 测试无效的消息ID格式
$response = $this->postJson('/api/message-sync/query', [
'message_ids' => ['']
]);
$response->assertStatus(422);
$response->assertJson([
'success' => false
]);
}
/**
* 测试同步消息API端点
*/
public function test_sync_messages_api_validation(): void
{
// 测试空请求
$response = $this->postJson('/api/message-sync/sync', []);
$response->assertStatus(422);
$response->assertJsonStructure([
'success',
'message',
'errors'
]);
// 测试无效的消息ID格式
$response = $this->postJson('/api/message-sync/sync', [
'message_ids' => ['']
]);
$response->assertStatus(422);
$response->assertJson([
'success' => false
]);
}
/**
* 测试获取agent配置API端点
*/
public function test_get_agent_config_api(): void
{
$response = $this->getJson('/api/message-sync/config');
$response->assertStatus(200);
$response->assertJsonStructure([
'success',
'data' => [
'agent_url',
'timeout'
]
]);
}
/**
* 测试数据库连接测试API端点
*/
public function test_database_connection_test_api(): void
{
$response = $this->getJson('/api/message-sync/test-connection');
// 由于测试环境可能没有配置crmslave数据库这里测试端点是否存在
// 可能返回200连接成功或500连接失败都是正常的
$this->assertContains($response->status(), [200, 500]);
$response->assertJsonStructure([
'success'
]);
}
}