// SchedulerDialog::buildSchedule unit tests. Lane GUI. // // Red when unchecking "use a schedule" stops sending JSON null (Schedule.schema.json: // null clears it and leaves the queue under manual control), "run until it drains" stops // nulling stopTime, or daysOfWeek/onceDate leak into the mode that ignores them. #include #include #include "dialogs/SchedulerDialog.hpp" using velox::gui::SchedulerDialog; class TstSchedulerDialog : public QObject { Q_OBJECT private slots: void disabledIsNull(); void periodicIncludesDaysNotOnceDate(); void onceIncludesOnceDateNotDays(); void runUntilDrainsNullsStopTime(); void explicitStopTimeIsKept(); }; void TstSchedulerDialog::disabledIsNull() { const QJsonValue v = SchedulerDialog::buildSchedule(false, "once", "09:00", true, "17:00", {}, "2026-01-01"); QVERIFY(v.isNull()); } void TstSchedulerDialog::periodicIncludesDaysNotOnceDate() { const QJsonValue v = SchedulerDialog::buildSchedule(true, "periodic", "09:00", true, "17:00", {1, 3, 5}, "2026-01-01"); QVERIFY(v.isObject()); const QJsonObject s = v.toObject(); QCOMPARE(s.value("mode").toString(), QStringLiteral("periodic")); QCOMPARE(s.value("daysOfWeek").toArray().size(), 3); QVERIFY(!s.contains("onceDate")); } void TstSchedulerDialog::onceIncludesOnceDateNotDays() { const QJsonValue v = SchedulerDialog::buildSchedule(true, "once", "09:00", true, "17:00", {1, 3, 5}, "2026-01-01"); const QJsonObject s = v.toObject(); QCOMPARE(s.value("onceDate").toString(), QStringLiteral("2026-01-01")); QVERIFY(!s.contains("daysOfWeek")); } void TstSchedulerDialog::runUntilDrainsNullsStopTime() { const QJsonValue v = SchedulerDialog::buildSchedule(true, "once", "09:00", true, "17:00", {}, "2026-01-01"); QVERIFY(v.toObject().value("stopTime").isNull()); } void TstSchedulerDialog::explicitStopTimeIsKept() { const QJsonValue v = SchedulerDialog::buildSchedule(true, "once", "09:00", false, "17:00", {}, "2026-01-01"); QCOMPARE(v.toObject().value("stopTime").toString(), QStringLiteral("17:00")); } QTEST_MAIN(TstSchedulerDialog) #include "tst_schedulerdialog.moc"