feat(FN-2383): persist task priority across core storage
- Add task-priority contract, normalization helpers, and exports in @fusion/core types/index - Store task priority in SQLite and migrate existing databases with default values - Update task store behavior and sorting tests to preserve and order by persisted priority - Add migration/regression coverage for archived tasks and refresh storage/task-management docs
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { describe, it, expect, beforeEach, afterEach } from "vitest";
|
||||
import { TaskStore } from "../store.js";
|
||||
import { sortTasksByPriorityThenAgeAndId } from "../task-priority.js";
|
||||
import { rm } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import { mkdtempSync } from "node:fs";
|
||||
@@ -52,4 +53,16 @@ describe("TaskStore.listTasks() sort order", () => {
|
||||
expect(nums[i]).toBeGreaterThan(nums[i - 1]);
|
||||
}
|
||||
});
|
||||
|
||||
it("provides deterministic helper ordering by priority then age then id", () => {
|
||||
const sorted = sortTasksByPriorityThenAgeAndId([
|
||||
{ id: "FN-010", createdAt: "2026-01-02T00:00:00Z", priority: "normal" },
|
||||
{ id: "FN-001", createdAt: "2026-01-01T00:00:00Z", priority: "high" },
|
||||
{ id: "FN-002", createdAt: "2026-01-01T00:00:00Z", priority: "high" },
|
||||
{ id: "FN-003", createdAt: "2026-01-01T00:00:00Z" },
|
||||
{ id: "FN-004", createdAt: "2026-01-01T00:00:00Z", priority: "urgent" },
|
||||
]);
|
||||
|
||||
expect(sorted.map((task) => task.id)).toEqual(["FN-004", "FN-001", "FN-002", "FN-003", "FN-010"]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -51,7 +51,7 @@ describe("TaskStore task documents", () => {
|
||||
|
||||
expect(tableNames.has("task_documents")).toBe(true);
|
||||
expect(tableNames.has("task_document_revisions")).toBe(true);
|
||||
expect(db.getSchemaVersion()).toBe(42);
|
||||
expect(db.getSchemaVersion()).toBe(43);
|
||||
|
||||
const index = db
|
||||
.prepare(
|
||||
|
||||
Reference in New Issue
Block a user