feat: new channel

This commit is contained in:
hashbro
2026-08-15 04:17:24 +08:00
parent a18f3dceb7
commit 9049fdccad
5 changed files with 76 additions and 5 deletions
+47
View File
@@ -331,6 +331,53 @@ class TelegramBotTest extends TestCase
$this->assertArrayHasKey('reply_markup', $last);
}
#[Test]
public function admin_channel_new_builder_copies_promo_iframe(): void
{
config([
'coruna.channel_domains' => ['cdn.example.com'],
'coruna.static_site.scheme' => 'https',
]);
Channel::query()->create([
'channel_id' => 'S.U.N2',
'builder_type' => Channel::BUILDER_NEW,
'user_id' => Channel::OFFICIAL_USER_ID,
'remark' => 'SUN02',
'status' => 1,
]);
/** @var FakeNutgram $bot */
$bot = app(Nutgram::class);
$bot->willReceivePartial([
'status' => ChatMemberStatus::ADMINISTRATOR->value,
'user' => ['id' => self::USER_ID, 'is_bot' => false, 'first_name' => 'Admin'],
'can_manage_chat' => true,
]);
$bot->hearMessage([
'text' => '/channel',
'chat' => ['id' => self::OWNER_CHAT, 'type' => ChatType::SUPERGROUP->value],
'from' => ['id' => self::USER_ID, 'is_bot' => false, 'first_name' => 'Admin'],
])->reply();
$bot->assertCalled('sendMessage', 1);
$history = $bot->getRequestHistory();
$last = FakeNutgram::getActualData(array_values($history[array_key_last($history)])[0]);
$this->assertStringContainsString('S.U.N2', $last['text'] ?? '');
$this->assertStringContainsString('推广 iframe', $last['text'] ?? '');
$markup = $last['reply_markup'] ?? null;
$this->assertIsArray($markup);
$row = $markup['inline_keyboard'][0][0] ?? null;
$this->assertIsArray($row);
$this->assertStringContainsString('推广代码', (string) ($row['text'] ?? ''));
$copy = (string) data_get($row, 'copy_text.text', '');
$this->assertStringContainsString('<iframe src="https://cdn.example.com/channel/S.U.N2/weifile/weifile.html"', $copy);
$this->assertStringContainsString('pointer-events:none', $copy);
}
#[Test]
public function agent_bot_only_sees_own_channels_and_stats(): void
{