feat: add snapshot tests for eventsub messages (#5965)

This commit is contained in:
nerix
2025-02-21 21:33:29 +01:00
committed by GitHub
parent bb4c6d6f6e
commit a86df7087d
17 changed files with 885 additions and 21 deletions
+13 -2
View File
@@ -55,7 +55,10 @@ void Connection::onChannelBan(
BanAction action{};
action.timestamp = std::chrono::steady_clock::now();
if (!getApp()->isTest())
{
action.timestamp = std::chrono::steady_clock::now();
}
action.roomID = roomID;
action.source = ActionUser{
.id = QString::fromStdString(payload.event.moderatorUserID),
@@ -85,6 +88,10 @@ void Connection::onChannelBan(
runInGuiThread([action{std::move(action)}, chan{std::move(chan)}] {
auto time = QDateTime::currentDateTime();
if (getApp()->isTest())
{
time = QDateTime::fromSecsSinceEpoch(0).toUTC();
}
MessageBuilder msg(action, time);
msg->flags.set(MessageFlag::PubSub);
chan->addOrReplaceTimeout(msg.release(), QDateTime::currentDateTime());
@@ -162,7 +169,11 @@ void Connection::onChannelModerate(
return;
}
const auto now = QDateTime::currentDateTime();
auto now = QDateTime::currentDateTime();
if (getApp()->isTest())
{
now = QDateTime::fromSecsSinceEpoch(0).toUTC();
}
std::visit(
[&](auto &&action) {