Verify fresh role snapshots and admin transfer cancellation ownership

This commit is contained in:
evgeny committed 2026-10-28 00:58:59 +01:00
1 parent b78fd7a8e6
commit 1515a37b8a
1 file changed
+22
@@ -188,6 +188,7 @@ private slots:
if (failure == "none") QTRY_COMPARE_WITH_TIMEOUT(accepted.count(), 1, 3000);
else QTRY_VERIFY_WITH_TIMEOUT(!errorLabel(dialog.get())->text().isEmpty(), 3000);
core.pause(); QVERIFY(!probe.gui);
QCOMPARE(probe.updates, failure == "missing" && properties ? 0 : 1);
if (failure == "commit") QCOMPARE(probe.commitRefusals, 1);
if (failure == "none") QVERIFY(core.snapshot().startsWith(QString::fromUtf8("Новый ник\n").toUtf8()));
else {
@@ -271,6 +272,27 @@ private slots:
QVERIFY(!gui_bridge_save_member(core.db.m_db, core.channel, core.node, "Nick", {}, nullptr, callback));
QCoreApplication::processEvents(); QVERIFY(!called);
}
void roleSnapshot() {
MemberCore core; QVERIFY(core.start());
MemberPropsDialog dialog(&core.db, core.channel, core.node, "Member",
core.flags ^ (CHAT_MEMBER_FLAG_ADMIN | CHAT_MEMBER_FLAG_SUPERNODE));
const auto boxes = dialog.findChildren<QCheckBox*>(); QVERIFY(boxes.size() >= 2);
QCOMPARE(boxes[0]->isChecked(), bool(core.flags & CHAT_MEMBER_FLAG_ADMIN));
QCOMPARE(boxes[1]->isChecked(), bool(core.flags & CHAT_MEMBER_FLAG_SUPERNODE));
}
void transferOwnership() {
MemberCore core; QVERIFY(core.start());
QVERIFY(!gui_bridge_transfer_admin(nullptr, core.channel, core.node));
QVERIFY(!gui_bridge_transfer_admin(core.db.m_db, "01", core.node));
#ifdef UTUN_TEST_MEMBER_ALLOC_FAILURES
for (int allocation : {1, 2}) {
failCalloc = allocation; QVERIFY(!gui_bridge_transfer_admin(core.db.m_db, core.channel, core.node));
QCOMPARE(failCalloc, 0);
}
#endif
QVERIFY(gui_bridge_transfer_admin(core.db.m_db, core.channel, core.node));
core.stop(); QCoreApplication::processEvents(); // Owned transfer освобождается при отмене, не отправляя ключ.
}
#ifdef UTUN_TEST_MEMBER_ALLOC_FAILURES
void allocations_data() {
QTest::addColumn<bool>("properties"); QTest::addColumn<bool>("queue");