mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-02 19:02:28 +00:00
Ensure comment snapshots show in video modal on first open
This commit is contained in:
1 parent
2c8066fd9d
commit
16539400e8
2 files changed
+61
No files matched your search
@@ -413,6 +413,7 @@ export default class VideoModalCommentController {
|
||||
}
|
||||
|
||||
const sanitizedSnapshot = this.buildModalCommentSnapshot(snapshot);
|
||||
this.videoModal.setCommentsVisibility?.(true);
|
||||
this.videoModal.renderComments?.(sanitizedSnapshot);
|
||||
this.videoModal.setCommentStatus?.("");
|
||||
this.applyCommentComposerAuthState();
|
||||
|
||||
@@ -240,6 +240,66 @@ test(
|
||||
},
|
||||
);
|
||||
|
||||
test(
|
||||
"Thread ready snapshots force comments visible before composer gating",
|
||||
async (t) => {
|
||||
const { modal, cleanup } = await setupModal();
|
||||
t.after(cleanup);
|
||||
|
||||
const visibilityCalls = [];
|
||||
const instrumentedModal = {
|
||||
...modal,
|
||||
setCommentsVisibility: (isVisible) => {
|
||||
visibilityCalls.push(isVisible);
|
||||
modal.setCommentsVisibility(isVisible);
|
||||
},
|
||||
};
|
||||
|
||||
const snapshot = {
|
||||
videoEventId: "video-visibility-snapshot",
|
||||
parentCommentId: null,
|
||||
commentsById: new Map([
|
||||
[
|
||||
"visible-comment",
|
||||
createCommentEvent({
|
||||
id: "visible-comment",
|
||||
pubkey: "pk-visible",
|
||||
content: "Rendered as soon as thread is ready",
|
||||
createdAt: 1700000300,
|
||||
}),
|
||||
],
|
||||
]),
|
||||
childrenByParent: new Map([[null, ["visible-comment"]]]),
|
||||
profiles: new Map([["pk-visible", { name: "Visible" }]]),
|
||||
};
|
||||
|
||||
const controller = new VideoModalCommentController({
|
||||
commentThreadService: {
|
||||
defaultLimit: 1,
|
||||
setCallbacks: () => {},
|
||||
teardown: () => {},
|
||||
loadThread: () => Promise.resolve(snapshot),
|
||||
},
|
||||
videoModal: instrumentedModal,
|
||||
auth: {
|
||||
isLoggedIn: () => false,
|
||||
},
|
||||
});
|
||||
|
||||
controller.load({ id: "video-visibility-snapshot", enableComments: true });
|
||||
await controller.modalCommentLoadPromise;
|
||||
|
||||
assert.ok(visibilityCalls.length >= 2);
|
||||
assert.equal(visibilityCalls.pop(), true);
|
||||
|
||||
const renderedComments = Array.from(
|
||||
modal.commentsList.querySelectorAll("[data-comment-id]") || [],
|
||||
);
|
||||
assert.equal(renderedComments.length, 1);
|
||||
assert.equal(renderedComments[0].dataset.commentId, "visible-comment");
|
||||
},
|
||||
);
|
||||
|
||||
test(
|
||||
"Controller renders synchronous loadThread snapshots immediately",
|
||||
async (t) => {
|
||||
|
||||
Reference in new issue
Block a user