feat: add long-term projects with AI creation
- Add project model, schema v4, sync triggers, and server support\n- Add project panel, deadline countdown, manual create/edit/complete/delete\n- Parse AI project operations and show them in the proposal diff\n- Sync projects to Android and display them read-only\n- Rebuild AppImage and update validation docs and screenshots
This commit is contained in:
@@ -82,6 +82,7 @@ private slots:
|
||||
void forcesSplitWhenUserAllowsIt();
|
||||
void localDeleteAllMeetingsFallback();
|
||||
void retriesNoDiffActionableRequest();
|
||||
void createsLongTermProjectFromOperation();
|
||||
};
|
||||
|
||||
namespace
|
||||
@@ -742,5 +743,41 @@ void TestAI::retriesNoDiffActionableRequest()
|
||||
QVERIFY(proposal.entries.first().title == QStringLiteral("深度工作"));
|
||||
}
|
||||
|
||||
void TestAI::createsLongTermProjectFromOperation()
|
||||
{
|
||||
Context context;
|
||||
QVERIFY(context.initialize());
|
||||
|
||||
const QDate deadline = QDate::currentDate().addDays(30);
|
||||
context.mock->responses = {
|
||||
diffResponse(
|
||||
QStringLiteral("这是一个跨月目标,我会把它作为长期项目管理。"),
|
||||
QStringLiteral(
|
||||
"{\"operations\":[{\"type\":\"project\",\"title\":\"飞行控制器项目\","
|
||||
"\"description\":\"完成固件、测试与文档\",\"deadline\":\"%1\",\"priority\":2}]}")
|
||||
.arg(deadline.toString(QStringLiteral("yyyy-MM-dd"))))};
|
||||
|
||||
QSignalSpy proposalSpy(context.ai.get(), &AIService::proposalReady);
|
||||
QSignalSpy failedSpy(context.ai.get(), &AIService::requestFailed);
|
||||
QSignalSpy appliedSpy(context.ai.get(), &AIService::diffApplied);
|
||||
context.ai->request(QStringLiteral("一个月内完成飞行控制器项目,先不用安排具体时间"));
|
||||
|
||||
QCOMPARE(failedSpy.count(), 0);
|
||||
QCOMPARE(proposalSpy.count(), 1);
|
||||
const ScheduleProposal proposal = proposalSpy.first().at(0).value<ScheduleProposal>();
|
||||
QCOMPARE(proposal.entries.size(), 0);
|
||||
QCOMPARE(proposal.projects.size(), 1);
|
||||
QCOMPARE(proposal.projects.first().title, QStringLiteral("飞行控制器项目"));
|
||||
QCOMPARE(proposal.projects.first().deadline.value(), deadline);
|
||||
|
||||
context.ai->applyDiff(proposal.diffId, {proposal.projects.first().tempId});
|
||||
QCOMPARE(appliedSpy.count(), 1);
|
||||
const QVector<Project> projects = context.service->projects();
|
||||
QCOMPARE(projects.size(), 1);
|
||||
QCOMPARE(projects.first().title, QStringLiteral("飞行控制器项目"));
|
||||
QCOMPARE(projects.first().deadline.value(), deadline);
|
||||
QCOMPARE(projects.first().source, QStringLiteral("ai_chat"));
|
||||
}
|
||||
|
||||
QTEST_GUILESS_MAIN(TestAI)
|
||||
#include "test_ai.moc"
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "ui/MainWindow.h"
|
||||
#include "ui/dialogs/BlockEditDialog.h"
|
||||
#include "ui/dialogs/DailyReviewDialog.h"
|
||||
#include "ui/dialogs/ProjectDialog.h"
|
||||
#include "ui/dialogs/SearchDialog.h"
|
||||
#include "ui/dialogs/SettingsDialog.h"
|
||||
#include "ui/panels/DiffPreviewCard.h"
|
||||
@@ -68,6 +69,7 @@ private slots:
|
||||
void opensDailyReview();
|
||||
void searchDialogFindsSchedules();
|
||||
void repeatDialogShowsOptions();
|
||||
void projectDialogShowsFields();
|
||||
void aiChatShowsDiffAndAccepts();
|
||||
void aiChatShowsMultiOperationDiff();
|
||||
|
||||
@@ -123,6 +125,12 @@ void TestCompactWindow::createSampleData(ScheduleService& service, const QDate&
|
||||
QVERIFY(create(QStringLiteral("写周报"),
|
||||
QDateTime(today, QTime(9, 0), Qt::LocalTime),
|
||||
QDateTime(today, QTime(10, 30), Qt::LocalTime)));
|
||||
QString projectError;
|
||||
QVERIFY2(service.createProject(QStringLiteral("飞行控制器项目"),
|
||||
QStringLiteral("完成固件、测试与文档"),
|
||||
today.addDays(30),
|
||||
&projectError),
|
||||
qPrintable(projectError));
|
||||
QVERIFY(create(QStringLiteral("团队同步"),
|
||||
QDateTime(today, QTime(10, 0), Qt::LocalTime),
|
||||
QDateTime(today, QTime(11, 0), Qt::LocalTime)));
|
||||
@@ -379,6 +387,24 @@ void TestCompactWindow::repeatDialogShowsOptions()
|
||||
QCOMPARE(dialog.recurrenceUntil(), start.date().addMonths(3));
|
||||
}
|
||||
|
||||
void TestCompactWindow::projectDialogShowsFields()
|
||||
{
|
||||
ThemeManager theme(*m_settings);
|
||||
theme.initialize();
|
||||
ProjectDialog dialog(theme.tokens());
|
||||
const QDate deadline = QDate::currentDate().addDays(30);
|
||||
dialog.setValues(QStringLiteral("飞行控制器项目"),
|
||||
QStringLiteral("完成固件、测试与文档"),
|
||||
deadline);
|
||||
dialog.show();
|
||||
QVERIFY(QTest::qWaitForWindowExposed(&dialog));
|
||||
QTest::qWait(300);
|
||||
saveWindow(&dialog, QStringLiteral("project-dialog.png"));
|
||||
QCOMPARE(dialog.titleValue(), QStringLiteral("飞行控制器项目"));
|
||||
QCOMPARE(dialog.deadlineValue(), deadline);
|
||||
dialog.accept();
|
||||
}
|
||||
|
||||
void TestCompactWindow::aiChatShowsDiffAndAccepts()
|
||||
{
|
||||
QTemporaryDir databaseDir;
|
||||
|
||||
@@ -29,6 +29,7 @@ private slots:
|
||||
void searchFindsSchedules();
|
||||
void createsRecurringSchedules();
|
||||
void startAndLeadReminders();
|
||||
void projectCrudAndPersistence();
|
||||
};
|
||||
|
||||
namespace
|
||||
@@ -474,5 +475,45 @@ void TestServices::startAndLeadReminders()
|
||||
QCOMPARE(leadSpy.count(), 1);
|
||||
}
|
||||
|
||||
void TestServices::projectCrudAndPersistence()
|
||||
{
|
||||
Context context;
|
||||
QVERIFY(context.open());
|
||||
|
||||
const QDate deadline = QDate::currentDate().addMonths(1);
|
||||
QString error;
|
||||
QVERIFY2(context.service->createProject(QStringLiteral("飞行控制器项目"),
|
||||
QStringLiteral("完成飞控板固件与测试"),
|
||||
deadline,
|
||||
&error),
|
||||
qPrintable(error));
|
||||
QVector<Project> projects = context.service->projects();
|
||||
QCOMPARE(projects.size(), 1);
|
||||
QCOMPARE(projects.first().title, QStringLiteral("飞行控制器项目"));
|
||||
QCOMPARE(projects.first().deadline.value(), deadline);
|
||||
const QString id = projects.first().id;
|
||||
|
||||
QVERIFY2(context.service->updateProject(id,
|
||||
QStringLiteral("飞行控制器项目 v2"),
|
||||
QStringLiteral("完成固件、测试与文档"),
|
||||
deadline.addDays(7),
|
||||
&error),
|
||||
qPrintable(error));
|
||||
auto updated = context.service->projectById(id);
|
||||
QVERIFY(updated.has_value());
|
||||
QCOMPARE(updated->title, QStringLiteral("飞行控制器项目 v2"));
|
||||
QCOMPARE(updated->deadline.value(), deadline.addDays(7));
|
||||
|
||||
ScheduleService reloaded(*context.store, QStringLiteral("test-device"));
|
||||
QCOMPARE(reloaded.projects().size(), 1);
|
||||
|
||||
QVERIFY2(context.service->setProjectStatus(id, QStringLiteral("done"), &error), qPrintable(error));
|
||||
QVERIFY(context.service->projects().isEmpty());
|
||||
QCOMPARE(context.store->outboxCount() > 0, true);
|
||||
|
||||
QVERIFY2(context.service->deleteProject(id, &error), qPrintable(error));
|
||||
QVERIFY(!context.service->projectById(id).has_value());
|
||||
}
|
||||
|
||||
QTEST_GUILESS_MAIN(TestServices)
|
||||
#include "test_services.moc"
|
||||
|
||||
@@ -27,10 +27,10 @@ void TestStorage::migrationCreatesSchema()
|
||||
SqliteStore store(dir.filePath(QStringLiteral("schedule.db")));
|
||||
QString error;
|
||||
QVERIFY2(store.open(&error), qPrintable(error));
|
||||
QCOMPARE(store.schemaVersion(), 3);
|
||||
QCOMPARE(store.schemaVersion(), 4);
|
||||
store.close();
|
||||
QVERIFY2(store.open(&error), qPrintable(error));
|
||||
QCOMPARE(store.schemaVersion(), 3);
|
||||
QCOMPARE(store.schemaVersion(), 4);
|
||||
}
|
||||
|
||||
void TestStorage::taskAndBlockRoundTrip()
|
||||
|
||||
@@ -189,6 +189,26 @@ void TestSyncIntegration::twoClientsConverge()
|
||||
}
|
||||
QVERIFY(sawOffline);
|
||||
|
||||
const QDate projectDeadline = QDate::currentDate().addMonths(1);
|
||||
QVERIFY2(serviceA.createProject(QStringLiteral("长期项目"),
|
||||
QStringLiteral("跨月目标"),
|
||||
projectDeadline,
|
||||
&error),
|
||||
qPrintable(error));
|
||||
QTRY_VERIFY_WITH_TIMEOUT(serviceB.projects().size() == 1, 20000);
|
||||
QCOMPARE(serviceB.projects().first().title, QStringLiteral("长期项目"));
|
||||
QVERIFY2(serviceB.updateProject(serviceB.projects().first().id,
|
||||
QStringLiteral("长期项目 v2"),
|
||||
QStringLiteral("跨月目标 v2"),
|
||||
projectDeadline.addDays(14),
|
||||
&error),
|
||||
qPrintable(error));
|
||||
QTRY_VERIFY_WITH_TIMEOUT(!serviceA.projects().isEmpty() &&
|
||||
serviceA.projects().first().title == QStringLiteral("长期项目 v2"),
|
||||
20000);
|
||||
QVERIFY2(serviceA.deleteProject(serviceA.projects().first().id, &error), qPrintable(error));
|
||||
QTRY_VERIFY_WITH_TIMEOUT(serviceB.projects().isEmpty(), 20000);
|
||||
|
||||
syncA.stop();
|
||||
syncB.stop();
|
||||
serverProcess.terminate();
|
||||
|
||||
Reference in New Issue
Block a user