mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-27 07:52:24 +00:00
Clicking Send threw "this.controller.handleDmAppShellSendMessage is not a function". The DM app-shell renderer wires its callbacks on `this.controller` (ProfileDirectMessageController), but the controller never delegated them to `this.actions` — so Send, mark-read, mark-all-read, read-receipt/typing toggles and open-settings all threw and did nothing. Add the six delegations. The send path itself (encrypt -> sign -> publish) was fine. Regression test asserts the controller delegates each app-shell callback to this.actions. Co-Authored-By: Claude Opus 4.8 <[email protected]>
52 lines
1.7 KiB
JavaScript
52 lines
1.7 KiB
JavaScript
// Regression (#19): the DM app-shell renderer wires its callbacks on
|
|
// `this.controller` (the ProfileDirectMessageController), but the controller was
|
|
// missing the delegation methods that forward to `this.actions` — so clicking Send
|
|
// threw "this.controller.handleDmAppShellSendMessage is not a function" and no DM
|
|
// could be sent (same class for mark-read / settings / toggles).
|
|
|
|
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
|
|
const { ProfileDirectMessageController } = await import(
|
|
"../js/ui/profileModal/ProfileDirectMessageController.js"
|
|
);
|
|
|
|
// These are the app-shell callbacks the renderer invokes on the controller; each
|
|
// must exist and forward to the matching method on `this.actions`.
|
|
const DELEGATED = [
|
|
"handleDmAppShellSendMessage",
|
|
"handleDmConversationMarkRead",
|
|
"handleDmMarkAllConversationsRead",
|
|
"handleReadReceiptsToggle",
|
|
"handleTypingIndicatorsToggle",
|
|
"openDmSettingsModal",
|
|
];
|
|
|
|
test("controller delegates every DM app-shell callback to this.actions", () => {
|
|
const proto = ProfileDirectMessageController.prototype;
|
|
for (const name of DELEGATED) {
|
|
assert.equal(
|
|
typeof proto[name],
|
|
"function",
|
|
`controller.${name} delegation must exist (renderer calls it)`,
|
|
);
|
|
|
|
const received = [];
|
|
const fakeController = {
|
|
actions: {
|
|
[name]: (...args) => {
|
|
received.push(args);
|
|
return `ok:${name}`;
|
|
},
|
|
},
|
|
};
|
|
const result = proto[name].call(fakeController, "arg-a", "arg-b");
|
|
assert.equal(result, `ok:${name}`, `${name} must return the actions result`);
|
|
assert.deepEqual(
|
|
received[0],
|
|
["arg-a", "arg-b"],
|
|
`${name} must forward its arguments to this.actions.${name}`,
|
|
);
|
|
}
|
|
});
|