feat: support shared pet care tasks and smooth daily page return
This commit is contained in:
@@ -57,6 +57,33 @@ test("编辑任务走 PUT,并保留选中的宠物", async () => {
|
||||
});
|
||||
});
|
||||
|
||||
test("新建任务可选择全部宠物,编辑后保留范围", async () => {
|
||||
const writes = [];
|
||||
const pets = [{ id: "a", name: "奶盖" }, { id: "b", name: "布丁" }];
|
||||
const task = { id: "task-all", all_pets: true, pet_id: null, title: "换水", category: "water", time_of_day: "09:00", repeat_rule: "daily" };
|
||||
const screen = page("tasks", async (route, method, body) => {
|
||||
if (method === "POST" || method === "PUT") writes.push({ route, method, body });
|
||||
if (route === "/pets") return pets;
|
||||
if (route.startsWith("/tasks?")) return { items: [task] };
|
||||
return task;
|
||||
});
|
||||
await screen.load();
|
||||
assert.equal(screen.data.petOptions[2].name, "全部宠物");
|
||||
assert.equal(screen.data.tasks[0].petName, "全部宠物");
|
||||
screen.open();
|
||||
screen.petChange({ detail: { value: "2" } });
|
||||
screen.setData({ title: "换水" });
|
||||
await screen.save();
|
||||
assert.equal(writes[0].method, "POST");
|
||||
assert.equal(writes[0].body.all_pets, true);
|
||||
assert.equal(writes[0].body.pet_id, undefined);
|
||||
screen.edit({ currentTarget: { dataset: { index: 0 } } });
|
||||
assert.equal(screen.data.petIndex, 2);
|
||||
await screen.save();
|
||||
assert.equal(writes[1].method, "PUT");
|
||||
assert.equal(writes[1].body.all_pets, true);
|
||||
});
|
||||
|
||||
test("多宠物遛狗发送全部 ID,结束后可再次开始", async () => {
|
||||
const calls = [];
|
||||
const active = { id: "walk-1", status: "active", started_at: new Date().toISOString(), pet_ids: ["a", "b"], distance_meters: 0, points: [] };
|
||||
|
||||
Reference in New Issue
Block a user