Backend: - Migration: beacon_monitors table (binary_id PK, org/user FK, check_type, target_url, config, monitoring fields) - Schema: BeaconMonitor with changeset (pattern-matched port validation, check_type inclusion) - Query: BeaconMonitorQuery — composable scopes (by org, by user, by type, enabled, ordered, preloaded) - Context: Towerops.Beacons — CRUD, toggle, record_check_result (36/36 tests pass) Frontend: - User LiveView: /beacons — stream-based list, create/edit modals, toggle/delete actions - Admin LiveView: /admin/beacons — cross-org view with preloads (20/20 tests pass) - Form component: LiveComponent modal with validation - Helpers: check_type badges, status indicators, response time formatting - Router: user routes + admin route configured - Nav: sidebar + mobile links added - 30+ gettext translations Verification: compile ✓, format ✓, credo ✓, 56/56 new tests pass
27 lines
750 B
Elixir
27 lines
750 B
Elixir
defmodule Towerops.BeaconsFixtures do
|
|
@moduledoc """
|
|
This module defines test helpers for creating
|
|
entities via the `Towerops.Beacons` context.
|
|
"""
|
|
|
|
@doc """
|
|
Creates a beacon monitor fixture.
|
|
|
|
Accepts optional attrs to override defaults.
|
|
Requires `organization_id` and `user_id` to be provided.
|
|
"""
|
|
def beacon_monitor_fixture(organization_id, user_id, attrs \\ %{}) do
|
|
defaults = %{
|
|
name: "Test Beacon #{System.unique_integer()}",
|
|
check_type: "http",
|
|
target_url: "https://example.com",
|
|
organization_id: organization_id,
|
|
user_id: user_id,
|
|
interval_seconds: 60,
|
|
timeout_ms: 5000
|
|
}
|
|
|
|
{:ok, beacon} = Towerops.Beacons.create_beacon(Map.merge(defaults, attrs))
|
|
beacon
|
|
end
|
|
end
|