* Mock the `add_reaction` Tauri command. Mirrors the real Rust command: a * kind:7 whose content is the emoji, plus — for a custom emoji — the NIP-30 * `["emoji", shortcode, url]` tag (shortcode normalized to match the relay). * Recorded into the target's channel store and emitted live so the tim
(
args: { eventId: string; emoji: string; emojiUrl?: string | null },
config: E2eConfig | undefined,
)
| 7191 | * kind:7). Unicode reactions carry no emoji tag, like the real command. |
| 7192 | */ |
| 7193 | async function handleAddReaction( |
| 7194 | args: { eventId: string; emoji: string; emojiUrl?: string | null }, |
| 7195 | config: E2eConfig | undefined, |
| 7196 | ): Promise<void> { |
| 7197 | const channelId = findMockEventChannel(args.eventId); |
| 7198 | if (!channelId) { |
| 7199 | throw new Error(`mock add_reaction: unknown target event ${args.eventId}`); |
| 7200 | } |
| 7201 | |
| 7202 | const emoji = args.emoji.trim(); |
| 7203 | // `h` routes the live event to the channel store (getChannelIdFromTags); |
| 7204 | // `e` names the reaction target. For a custom emoji, the NIP-30 |
| 7205 | // `["emoji", shortcode, url]` tag carries the image URL. |
| 7206 | const tags: string[][] = [ |
| 7207 | ["h", channelId], |
| 7208 | ["e", args.eventId], |
| 7209 | ]; |
| 7210 | if (args.emojiUrl) { |
| 7211 | const shortcode = emoji.replace(/^:+/, "").replace(/:+$/, "").toLowerCase(); |
| 7212 | tags.push(["emoji", shortcode, args.emojiUrl]); |
| 7213 | } |
| 7214 | |
| 7215 | const event = createMockEvent( |
| 7216 | KIND_REACTION, |
| 7217 | emoji, |
| 7218 | tags, |
| 7219 | getMockMemberPubkey(config), |
| 7220 | Math.floor(Date.now() / 1000), |
| 7221 | // 64-hex id so the kind:5 deletion emitted by remove_reaction is accepted |
| 7222 | // by the timeline (getDeletionTargets requires a 64-hex `e` tag). |
| 7223 | mockEventId(), |
| 7224 | ); |
| 7225 | recordMockMessage(channelId, event); |
| 7226 | emitMockLiveEvent(channelId, event); |
| 7227 | } |
| 7228 | |
| 7229 | /** |
| 7230 | * Mock the `remove_reaction` Tauri command. Finds the active member's own |
no test coverage detected