feat: queue device import review tasks

This commit is contained in:
kris
2026-03-31 22:38:57 +08:00
parent dcbff3cc7d
commit 87ffe19f78
7 changed files with 347 additions and 117 deletions

View File

@@ -36,6 +36,7 @@ public class DeviceImportDraftActivityTest {
activity,
"applyPayload",
ReflectionHelpers.ClassParameter.from(JSONObject.class, buildPendingDraft()),
ReflectionHelpers.ClassParameter.from(JSONObject.class, null),
ReflectionHelpers.ClassParameter.from(JSONObject.class, null)
);
@@ -62,7 +63,8 @@ public class DeviceImportDraftActivityTest {
activity,
"applyPayload",
ReflectionHelpers.ClassParameter.from(JSONObject.class, buildAppliedDraft()),
ReflectionHelpers.ClassParameter.from(JSONObject.class, buildAppliedResolution())
ReflectionHelpers.ClassParameter.from(JSONObject.class, buildAppliedResolution()),
ReflectionHelpers.ClassParameter.from(JSONObject.class, null)
);
View content = activity.findViewById(R.id.screen_content);
@@ -73,6 +75,32 @@ public class DeviceImportDraftActivityTest {
assertTrue(viewTreeContainsText(content, "已导入"));
}
@Test
public void renderCurrentStateShowsQueuedReviewTaskCopy() throws Exception {
TestDeviceImportDraftActivity activity = Robolectric
.buildActivity(
TestDeviceImportDraftActivity.class,
new Intent()
.putExtra(DeviceImportDraftActivity.EXTRA_DEVICE_ID, "device-1")
.putExtra(DeviceImportDraftActivity.EXTRA_DEVICE_NAME, "Mac Studio")
)
.setup()
.get();
ReflectionHelpers.callInstanceMethod(
activity,
"applyPayload",
ReflectionHelpers.ClassParameter.from(JSONObject.class, buildPendingResolutionDraft()),
ReflectionHelpers.ClassParameter.from(JSONObject.class, null),
ReflectionHelpers.ClassParameter.from(JSONObject.class, buildQueuedReviewTask())
);
View content = activity.findViewById(R.id.screen_content);
assertTrue(viewTreeContainsText(content, "主 Agent 审核中"));
assertTrue(viewTreeContainsText(content, "审核任务"));
assertTrue(viewTreeContainsText(content, "状态queued"));
}
private static JSONObject buildPendingDraft() throws Exception {
return new JSONObject()
.put("draftId", "draft-1")
@@ -125,6 +153,24 @@ public class DeviceImportDraftActivityTest {
.put("suggestedImport", true)));
}
private static JSONObject buildPendingResolutionDraft() throws Exception {
return new JSONObject()
.put("draftId", "draft-1")
.put("deviceId", "device-1")
.put("status", "pending_resolution")
.put("selectedCandidateIds", new JSONArray().put("candidate-1"))
.put("appliedProjectNames", new JSONArray())
.put("candidates", new JSONArray()
.put(new JSONObject()
.put("candidateId", "candidate-1")
.put("deviceId", "device-1")
.put("folderName", "北区试产线")
.put("threadId", "thread-1")
.put("threadDisplayName", "北区试产线回归")
.put("lastActiveAt", "2026-03-30T10:18:00+08:00")
.put("suggestedImport", true)));
}
private static JSONObject buildAppliedResolution() throws Exception {
return new JSONObject()
.put("resolutionId", "resolution-1")
@@ -147,6 +193,13 @@ public class DeviceImportDraftActivityTest {
.put("reason", "作为独立聊天窗口导入。")));
}
private static JSONObject buildQueuedReviewTask() throws Exception {
return new JSONObject()
.put("taskId", "mastertask-1")
.put("taskType", "device_import_resolution")
.put("status", "queued");
}
private static boolean viewTreeContainsText(View root, String expectedText) {
if (root instanceof TextView) {
CharSequence text = ((TextView) root).getText();