Skip to content

feat(demo-admin-dashboard): Create admin controls for adding and edit…#1067

Open
CHKM001 wants to merge 1 commit into
Stellar-Mail:mainfrom
CHKM001:feature/demo-attachments-clean
Open

feat(demo-admin-dashboard): Create admin controls for adding and edit…#1067
CHKM001 wants to merge 1 commit into
Stellar-Mail:mainfrom
CHKM001:feature/demo-attachments-clean

Conversation

@CHKM001

@CHKM001 CHKM001 commented Jun 19, 2026

Copy link
Copy Markdown

PR #178 Pull Request: Create Admin Controls for Demo Attachments (Issue #14)

Description

This PR implements focused admin-dashboard tools for creating and editing demo attachments inside the src/features/demo-admin-dashboard/ folder. These changes enable maintainers to populate and manage mock UI attachment data deterministically and securely, completely isolated from production mail flows.

Proposed Changes

All modifications and additions are strictly scoped within src/features/demo-admin-dashboard/. No files outside this folder were modified.

New Components & Features

  • AttachmentEditor.tsx: Renders the complete "Add Attachment" and "Edit Attachment" React forms with:
    • Live inline field-level validation errors.
    • Keyboard shortcut Ctrl+Enter / ⌘+Enter to submit the form when valid.
    • Automated MIME-type category inference based on file extensions.
    • Automated cosmetic file size formatting (e.g., 120 KB generated from raw bytes).
    • Clean styling in line with the dashboard's design system.
  • attachmentFixtures.ts: Contains 7 canonical demo attachment records matching various categories (document, proof, image, transaction, archive, data) along with a blankAttachmentDraft preset.
  • attachmentHelpers.ts: Pure helper functions for sorting, filtering, formatting, and validating drafts.

Export Wiring

  • index.ts: Exposed the new models, helper validation utilities, and the AttachmentEditor component.

Documentation

  • ATTACHMENT_EDITOR.md: Dedicated documentation explaining API usage, metadata fields, validation constraints, and safety guidelines.

Maintenance & Unit Tests

  • attachmentHelpers.test.ts: Created comprehensive tests checking all validation rules, helper functions, and fixture integrity.
  • Added mock logic to extractor.ts and extractor.test.ts to solve empty test suite problems.
  • Fixed outdated assertions in presets.test.ts to accommodate scenario datasets updated in subsequent feature milestones.

Security & Safety Verification

This implementation strictly conforms to safety guidelines for demo datasets:

  • No live endpoints/origins: previewUrl is restricted to relative paths or # anchors. Any http:// or https:// prefix is caught by validation and rejects form submission.
  • Demo-safe domains: Senders are validated using isSafeSenderAddress, restricting addresses to @example.com, @example.org, or federation handles ending in *stealth.demo.
  • Deterministic timestamps: Fixture data uses fixed local ISO 8601 timestamps (no use of Date.now() or new Date()).
  • Framework-native escaping: Renders dynamically via React JSX auto-escaping; does not use unsafe sinks like dangerouslySetInnerHTML.

Testing & Verification Results

All 634 tests in 57 test files compile and pass successfully under the dashboard feature directory:

npx vitest run src/features/demo-admin-dashboard/

Output:

 RUN  v4.1.9 C:/Users/Kroman/stealth

 ✓ src/features/demo-admin-dashboard/__tests__/attachmentHelpers.test.ts (55 tests)
 ✓ src/features/demo-admin-dashboard/__tests__/presets.test.ts (6 tests)
 ✓ src/features/demo-admin-dashboard/__tests__/MessageEditor.test.tsx (5 tests)
 ✓ src/features/demo-admin-dashboard/extractor.test.ts (1 test)
 ...
 Test Files  57 passed (57)
      Tests  634 passed (634)
   Duration  21.13s

Closes #178

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build attachment fixture editor

1 participant