vicky469_aside/tests/sidebarCommentSections.test.ts
vicky469 0cdc6ca29d refactor(comments): remove resolved feature
Removes the resolved/unresolve comment feature entirely. Comments are
now always visible — there is no archived state or toggle.

- Removes `resolved?: boolean` from CommentThread, Comment, and all
  storage/normalization paths
- Removes resolveComment/unresolveComment from CommentManager,
  CommentMutationController, and public plugin API
- Removes shouldShowResolvedComments/setShowResolvedComments from
  session, mutation, and persistence controllers
- Removes sidebar resolve button, toolbar chip, and resolved empty
  states from AsideView
- Removes setThreadResolved sync event generation; keeps the op in the
  union type as a backward-compatible no-op so old stored events parse
  without error
- Deletes resolvedCommentVisibility.ts, commentSelectionVisibility.ts,
  and resolve-note-comment.mjs scripts
- Updates README to remove resolved feature mentions
- Updates all tests accordingly

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-06 18:11:45 +08:00

74 lines
2.4 KiB
TypeScript

import * as assert from "node:assert/strict";
import test from "node:test";
import {
formatSidebarCommentMeta,
formatSidebarCommentSelectedTextPreview,
formatSidebarCommentTimestamp,
} from "../src/ui/views/sidebarCommentSections";
test("formatSidebarCommentMeta omits repeated page and anchored labels", () => {
const anchoredMeta = formatSidebarCommentMeta({
timestamp: Date.UTC(2024, 0, 1, 13, 30),
anchorKind: "selection",
});
const pageMeta = formatSidebarCommentMeta({
timestamp: Date.UTC(2024, 0, 1, 13, 30),
anchorKind: "page",
});
const orphanedMeta = formatSidebarCommentMeta({
timestamp: Date.UTC(2024, 0, 1, 13, 30),
anchorKind: "selection",
orphaned: true,
});
assert.equal(anchoredMeta.includes("anchored"), false);
assert.equal(pageMeta.includes("page note"), false);
assert.equal(orphanedMeta.includes("orphaned"), true);
});
test("formatSidebarCommentSelectedTextPreview normalizes anchored selections and skips page notes", () => {
assert.equal(
formatSidebarCommentSelectedTextPreview({
anchorKind: "selection",
selectedText: " first line\nsecond\tline ",
}),
"first line second line",
);
assert.equal(
formatSidebarCommentSelectedTextPreview({
anchorKind: "page",
selectedText: "Page label",
}),
null,
);
});
test("formatSidebarCommentTimestamp uses compact calendar-style formatting for recent dates", () => {
const referenceNow = new Date("2026-04-19T15:00:00").getTime();
assert.equal(
formatSidebarCommentTimestamp(new Date("2026-04-19T13:30:00").getTime(), referenceNow),
"1:30 PM",
);
assert.equal(
formatSidebarCommentTimestamp(new Date("2026-04-18T13:30:00").getTime(), referenceNow),
"Yesterday",
);
assert.equal(
formatSidebarCommentTimestamp(new Date("2026-04-17T13:30:00").getTime(), referenceNow),
"Fri 1:30 PM",
);
});
test("formatSidebarCommentTimestamp falls back to compact dates for older timestamps", () => {
const referenceNow = new Date("2026-04-19T15:00:00").getTime();
assert.equal(
formatSidebarCommentTimestamp(new Date("2026-03-10T13:30:00").getTime(), referenceNow),
"Mar 10",
);
assert.equal(
formatSidebarCommentTimestamp(new Date("2025-12-31T13:30:00").getTime(), referenceNow),
"2025-12-31",
);
});