Feature: Expand test-setup script with threads, reactions, and emoji #50

Closed
opened 2026-04-26 16:46:07 +00:00 by icub3d · 0 comments
Owner

Migrated from GitHub issue icub3d/decentcom#70
Original Author: @icub3d
Original Date: 2026-04-17T00:40:23Z


Feature: Expand test-setup script with threads, reactions, and emoji

Overview

The current scripts/test-setup.py seeds test databases with users, channels, roles, and basic messages. Expand it to include sample threads, message reactions (emoji), and threaded conversations so developers can manually test the threads and reactions features without manually creating them.

Background

The test-setup script in scripts/test-setup.py bootstraps three test servers (Open, Private, Strict) with realistic conversation data to allow rapid local testing. However, it currently only creates flat messages. With the recent implementation of message threads (#21) and emoji reactions (#19), the script should be extended to include:

  • Threads on selected messages with nested replies
  • Emoji reactions on messages (single and multiple users reacting with the same emoji)
  • Real-world examples of how threads and reactions look in practice

This makes it much faster to visually test the UI, threading UI, unread indicators, etc. without manually clicking through the app to create sample data.

Requirements

  • Extend test-setup.py to accept and insert thread data (parent message → replies)
  • Extend SQLite message insertion to optionally set thread_id on reply messages
  • Create sample thread configurations for at least one server (e.g., Open Server) with realistic conversations
  • Extend test-setup.py to accept and insert reaction data (message → emoji → list of users who reacted)
  • Insert reactions into the reactions table with proper (message_id, user_id, emoji) tuples
  • Add at least 2-3 example reactions per server showing variety: single reactions, multiple users on same emoji, multiple emojis on same message
  • Update the summary output to document what threads and reactions are available for testing
  • Ensure all existing tests and manual testing still work as before

Design

API / Interface Changes

No API changes; this is a test data generation script.

Data Model Changes

The schema itself doesn't change — only the data inserted. The script will use the existing threads, thread_followers, and reactions tables that were added in #21 and #19.

Script Changes

File: scripts/test-setup.py

Add new helper functions and config sections:

  1. make_thread_id(parent_msg_id: str, idx: int) -> str — generate consistent thread IDs
  2. seed_threads(db_path, config) — insert threads and thread replies from config
  3. seed_reactions(db_path, config) — insert emoji reactions from config
  4. Extend OPEN_CONFIG, PRIVATE_CONFIG, STRICT_CONFIG dictionaries with optional threads and reactions sections

Example config structure:

OPEN_CONFIG = {
    # ... existing users, roles, channels, messages ...
    "threads": [
        {
            "parent_message_id": "msg-ch-general-001",  # "Welcome everyone..." from Alice
            "replies": [
                {"author": "bob", "content": "Thanks Alice! Glad to be here.", "offset_min": 1},
                {"author": "charlie", "content": "This looks great so far.", "offset_min": 3},
                {"author": "alice", "content": "Thanks! Still a WIP but getting there.", "offset_min": 5},
            ]
        },
        {
            "parent_message_id": "msg-ch-frontend-002",  # "Should we add drag-and-drop?" from Dave
            "replies": [
                {"author": "alice", "content": "Sounds good. Can you create an issue for that?", "offset_min": 2},
                {"author": "dave", "content": "Will do. I'll add mockups too.", "offset_min": 4},
            ]
        },
    ],
    "reactions": [
        {
            "message_id": "msg-ch-general-000",  # "Welcome everyone..." 
            "reactions": [
                {"emoji": "👋", "users": ["bob", "charlie", "dave"]},
                {"emoji": "🎉", "users": ["alice", "bob"]},
            ]
        },
        {
            "message_id": "msg-ch-general-004",  # "Setting up the test environment..."
            "reactions": [
                {"emoji": "👍", "users": ["bob", "dave"]},
                {"emoji": "💯", "users": ["charlie"]},
            ]
        },
        {
            "message_id": "msg-ch-random-000",  # "Anyone else think decentralized chat is the future?"
            "reactions": [
                {"emoji": "🚀", "users": ["alice", "dave", "charlie"]},
            ]
        },
    ],
}

Component Changes

None — this is a developer tooling script, not a code component.

Task List

  • Add make_thread_id() helper function to generate thread IDs
  • Add seed_threads(db_path, config) function that:
    • Iterates over config["threads"]
    • Creates a thread record via INSERT into threads table
    • Inserts each reply as a message with thread_id set
    • Updates thread reply_count and last_reply_at
  • Add seed_reactions(db_path, config) function that:
    • Iterates over config["reactions"]
    • For each reaction, inserts into reactions table: (message_id, user_id, emoji, created_at)
  • Call seed_threads() and seed_reactions() in the main seed flow (after messages are inserted but before commit)
  • Add sample thread data to OPEN_CONFIG with at least 2 threads (at least one with 3+ replies)
  • Add sample reactions to OPEN_CONFIG with at least 5 different reactions showing variety
  • Add sample thread data to PRIVATE_CONFIG with at least 1 thread
  • Add sample reactions to PRIVATE_CONFIG
  • Update print_summary() to document available threads and reactions:
    • e.g., "Sample threads: #general (Alice's welcome → 3 replies), #frontend (Dave's D&D question → 2 replies)"
    • e.g., "Sample reactions: 5 messages with emoji reactions (various), testing single/multi-user scenarios"
  • Verify no regressions: run test-setup, start servers, open client, spot-check threads and reactions render correctly

Test List

  • Manual: run python3 scripts/test-setup.py, verify script completes without errors
  • Manual: start servers via make dev; open client
  • Manual: navigate to #general in Open Server, click on Alice's welcome message, verify "N replies" indicator and thread panel show the 3 sample replies
  • Manual: verify thread unread/read state works (open thread to mark read, close and reopen to verify unread is gone)
  • Manual: in #general, hover over a message with sample reactions (e.g., Alice's welcome), verify emoji pills render with counts and "me" flag
  • Manual: verify multiple reactions on the same message display correctly
  • Manual: verify participating in a thread (add a new reply) doesn't break the test data
  • Manual: repeat for Private Server, verify sample thread and reactions exist

Open Questions

  • Should the script also seed thread followers (the thread_followers table) to simulate users who have previously seen threads? Currently, no pre-seeding of followers (users discover threads by opening them). This may be fine for testing.
  • Should emoji be emoji codepoints (👋) or emoji short codes (:wave:)? The schema stores raw emoji, so using codepoints is correct, but this requires copy-pasting emoji or using Python's emoji support.
**Migrated from GitHub issue icub3d/decentcom#70** **Original Author:** @icub3d **Original Date:** 2026-04-17T00:40:23Z --- # Feature: Expand test-setup script with threads, reactions, and emoji ## Overview The current `scripts/test-setup.py` seeds test databases with users, channels, roles, and basic messages. Expand it to include sample threads, message reactions (emoji), and threaded conversations so developers can manually test the threads and reactions features without manually creating them. ## Background The test-setup script in `scripts/test-setup.py` bootstraps three test servers (Open, Private, Strict) with realistic conversation data to allow rapid local testing. However, it currently only creates flat messages. With the recent implementation of message threads (#21) and emoji reactions (#19), the script should be extended to include: - Threads on selected messages with nested replies - Emoji reactions on messages (single and multiple users reacting with the same emoji) - Real-world examples of how threads and reactions look in practice This makes it much faster to visually test the UI, threading UI, unread indicators, etc. without manually clicking through the app to create sample data. ## Requirements - [ ] Extend `test-setup.py` to accept and insert thread data (parent message → replies) - [ ] Extend SQLite message insertion to optionally set `thread_id` on reply messages - [ ] Create sample thread configurations for at least one server (e.g., Open Server) with realistic conversations - [ ] Extend `test-setup.py` to accept and insert reaction data (message → emoji → list of users who reacted) - [ ] Insert reactions into the `reactions` table with proper `(message_id, user_id, emoji)` tuples - [ ] Add at least 2-3 example reactions per server showing variety: single reactions, multiple users on same emoji, multiple emojis on same message - [ ] Update the summary output to document what threads and reactions are available for testing - [ ] Ensure all existing tests and manual testing still work as before ## Design ### API / Interface Changes No API changes; this is a test data generation script. ### Data Model Changes The schema itself doesn't change — only the data inserted. The script will use the existing `threads`, `thread_followers`, and `reactions` tables that were added in #21 and #19. ### Script Changes **File: `scripts/test-setup.py`** Add new helper functions and config sections: 1. `make_thread_id(parent_msg_id: str, idx: int) -> str` — generate consistent thread IDs 2. `seed_threads(db_path, config)` — insert threads and thread replies from config 3. `seed_reactions(db_path, config)` — insert emoji reactions from config 4. Extend `OPEN_CONFIG`, `PRIVATE_CONFIG`, `STRICT_CONFIG` dictionaries with optional `threads` and `reactions` sections **Example config structure:** ```python OPEN_CONFIG = { # ... existing users, roles, channels, messages ... "threads": [ { "parent_message_id": "msg-ch-general-001", # "Welcome everyone..." from Alice "replies": [ {"author": "bob", "content": "Thanks Alice! Glad to be here.", "offset_min": 1}, {"author": "charlie", "content": "This looks great so far.", "offset_min": 3}, {"author": "alice", "content": "Thanks! Still a WIP but getting there.", "offset_min": 5}, ] }, { "parent_message_id": "msg-ch-frontend-002", # "Should we add drag-and-drop?" from Dave "replies": [ {"author": "alice", "content": "Sounds good. Can you create an issue for that?", "offset_min": 2}, {"author": "dave", "content": "Will do. I'll add mockups too.", "offset_min": 4}, ] }, ], "reactions": [ { "message_id": "msg-ch-general-000", # "Welcome everyone..." "reactions": [ {"emoji": "👋", "users": ["bob", "charlie", "dave"]}, {"emoji": "🎉", "users": ["alice", "bob"]}, ] }, { "message_id": "msg-ch-general-004", # "Setting up the test environment..." "reactions": [ {"emoji": "👍", "users": ["bob", "dave"]}, {"emoji": "💯", "users": ["charlie"]}, ] }, { "message_id": "msg-ch-random-000", # "Anyone else think decentralized chat is the future?" "reactions": [ {"emoji": "🚀", "users": ["alice", "dave", "charlie"]}, ] }, ], } ``` ### Component Changes None — this is a developer tooling script, not a code component. ## Task List - [ ] Add `make_thread_id()` helper function to generate thread IDs - [ ] Add `seed_threads(db_path, config)` function that: - Iterates over `config["threads"]` - Creates a thread record via INSERT into `threads` table - Inserts each reply as a message with `thread_id` set - Updates thread `reply_count` and `last_reply_at` - [ ] Add `seed_reactions(db_path, config)` function that: - Iterates over `config["reactions"]` - For each reaction, inserts into `reactions` table: `(message_id, user_id, emoji, created_at)` - [ ] Call `seed_threads()` and `seed_reactions()` in the main seed flow (after messages are inserted but before commit) - [ ] Add sample thread data to `OPEN_CONFIG` with at least 2 threads (at least one with 3+ replies) - [ ] Add sample reactions to `OPEN_CONFIG` with at least 5 different reactions showing variety - [ ] Add sample thread data to `PRIVATE_CONFIG` with at least 1 thread - [ ] Add sample reactions to `PRIVATE_CONFIG` - [ ] Update `print_summary()` to document available threads and reactions: - e.g., "Sample threads: #general (Alice's welcome → 3 replies), #frontend (Dave's D&D question → 2 replies)" - e.g., "Sample reactions: 5 messages with emoji reactions (various), testing single/multi-user scenarios" - [ ] Verify no regressions: run test-setup, start servers, open client, spot-check threads and reactions render correctly ## Test List - [ ] Manual: run `python3 scripts/test-setup.py`, verify script completes without errors - [ ] Manual: start servers via `make dev`; open client - [ ] Manual: navigate to #general in Open Server, click on Alice's welcome message, verify "N replies" indicator and thread panel show the 3 sample replies - [ ] Manual: verify thread unread/read state works (open thread to mark read, close and reopen to verify unread is gone) - [ ] Manual: in #general, hover over a message with sample reactions (e.g., Alice's welcome), verify emoji pills render with counts and "me" flag - [ ] Manual: verify multiple reactions on the same message display correctly - [ ] Manual: verify participating in a thread (add a new reply) doesn't break the test data - [ ] Manual: repeat for Private Server, verify sample thread and reactions exist ## Open Questions - Should the script also seed thread followers (the `thread_followers` table) to simulate users who have previously seen threads? Currently, no pre-seeding of followers (users discover threads by opening them). This may be fine for testing. - Should emoji be emoji codepoints (👋) or emoji short codes (`:wave:`)? The schema stores raw emoji, so using codepoints is correct, but this requires copy-pasting emoji or using Python's emoji support.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
icub3d/decentcom#50
No description provided.