test: add tests for admin modal components (30+ modals) #7

Open
opened 2026-02-20 02:35:52 +00:00 by Clotho · 0 comments
Member

Issue

30+ Livewire modal components have no test coverage despite containing complex business logic.

Missing Test Coverage

High Priority - Complex Business Logic

PlatformUser.php - User management:

  • Tier changes (saveTier())
  • User verification (saveVerification())
  • User data export (exportUserData())
  • Entitlement provisioning
  • Tab switching and workspace loading

ServiceManager.php - Service CRUD:

  • Service creation/update/deletion
  • Database seeding integration
  • Service listing and filtering

WaitlistManager.php - Waitlist operations:

  • Export functionality
  • Query filtering (getFilteredQuery())
  • Invitation sending

Settings.php - User settings:

  • Profile updates (updateProfile())
  • Password changes (updatePassword())
  • Preferences (updatePreferences())
  • Account deletion requests (requestAccountDeletion())
  • 2FA stub methods (5 methods)

Medium Priority - Admin Features

Analytics.php - Analytics dashboard
Console.php - Admin console
Databases.php - Database management
Deployments.php - Deployment history
Honeypot.php - Honeypot hit viewer
Platform.php - Platform admin
Profile.php - User profile editing
PromptManager.php - AI prompt management
Sites.php - Workspace/site listing
UsageDashboard.php - Usage metrics
WorkspaceSwitcher.php - Workspace switching
WpConnectorSettings.php - WordPress connector config

Entitlement modals (3):

  • Entitlement/Dashboard.php
  • Entitlement/FeatureManager.php
  • Entitlement/PackageManager.php

Lower Priority

AIServices.php - AI service configuration
BoostPurchase.php - Boost purchase flow (stub)
Content.php* (3 modals) - Content management
ActivityLog.php - Activity viewing
ServicesAdmin.php - Services admin dashboard

Test Requirements

Each modal should have tests for:

  1. Lifecycle: Mount, render, property initialization
  2. User actions: Form submissions, button clicks, tab changes
  3. Validation: Input validation, error messages
  4. Authorization: Permission checks (where applicable)
  5. Side effects: Database updates, email sending, event dispatching
  6. Error cases: Failed operations, invalid input

Example Test Structure

it("updates user tier successfully", function () {
    $user = User::factory()->create();
    Livewire::test(PlatformUser::class)
        ->set("tier", "premium")
        ->call("saveTier")
        ->assertDispatched("toast", type: "success");
    expect($user->fresh()->tier)->toBe(UserTier::Premium);
});

it("validates tier change authorization", function () {
    // Test unauthorized access...
});

Convention

From CLAUDE.md:

Pest - Write tests using Pest syntax

Priority

High - Critical admin functionality lacks test coverage.

Discovered by

Automatic codebase scan (issue #3)

## Issue 30+ Livewire modal components have no test coverage despite containing complex business logic. ## Missing Test Coverage ### High Priority - Complex Business Logic **PlatformUser.php** - User management: - Tier changes (`saveTier()`) - User verification (`saveVerification()`) - User data export (`exportUserData()`) - Entitlement provisioning - Tab switching and workspace loading **ServiceManager.php** - Service CRUD: - Service creation/update/deletion - Database seeding integration - Service listing and filtering **WaitlistManager.php** - Waitlist operations: - Export functionality - Query filtering (`getFilteredQuery()`) - Invitation sending **Settings.php** - User settings: - Profile updates (`updateProfile()`) - Password changes (`updatePassword()`) - Preferences (`updatePreferences()`) - Account deletion requests (`requestAccountDeletion()`) - 2FA stub methods (5 methods) ### Medium Priority - Admin Features **Analytics.php** - Analytics dashboard **Console.php** - Admin console **Databases.php** - Database management **Deployments.php** - Deployment history **Honeypot.php** - Honeypot hit viewer **Platform.php** - Platform admin **Profile.php** - User profile editing **PromptManager.php** - AI prompt management **Sites.php** - Workspace/site listing **UsageDashboard.php** - Usage metrics **WorkspaceSwitcher.php** - Workspace switching **WpConnectorSettings.php** - WordPress connector config **Entitlement modals (3):** - `Entitlement/Dashboard.php` - `Entitlement/FeatureManager.php` - `Entitlement/PackageManager.php` ### Lower Priority **AIServices.php** - AI service configuration **BoostPurchase.php** - Boost purchase flow (stub) **Content*.php** (3 modals) - Content management **ActivityLog.php** - Activity viewing **ServicesAdmin.php** - Services admin dashboard ## Test Requirements Each modal should have tests for: 1. **Lifecycle:** Mount, render, property initialization 2. **User actions:** Form submissions, button clicks, tab changes 3. **Validation:** Input validation, error messages 4. **Authorization:** Permission checks (where applicable) 5. **Side effects:** Database updates, email sending, event dispatching 6. **Error cases:** Failed operations, invalid input ## Example Test Structure ```php it("updates user tier successfully", function () { $user = User::factory()->create(); Livewire::test(PlatformUser::class) ->set("tier", "premium") ->call("saveTier") ->assertDispatched("toast", type: "success"); expect($user->fresh()->tier)->toBe(UserTier::Premium); }); it("validates tier change authorization", function () { // Test unauthorized access... }); ``` ## Convention From CLAUDE.md: > **Pest** - Write tests using Pest syntax ## Priority **High** - Critical admin functionality lacks test coverage. ## Discovered by Automatic codebase scan (issue #3)
Clotho added the
discovery
label 2026-02-20 02:35:52 +00:00
Charon added
PHP
testing
P2
and removed
discovery
labels 2026-02-20 12:16:55 +00:00
Clotho was assigned by Charon 2026-02-20 12:20:55 +00:00
Charon added the
agent-ready
label 2026-02-21 01:30:25 +00:00
Sign in to join this conversation.
No description provided.