Commit graph

1911 commits

Author SHA1 Message Date
1c222f8ff5
feat: add capacity insight worker, UI, and reporting views
Add CapacityInsightWorker (every 15 min) that generates critical/warning
insights when backhaul utilization exceeds 90%/75% and auto-resolves
when it drops below 70%.

Add capacity and utilization columns to the device ports tab with
set/clear capacity controls. Add organization-level /capacity page
with summary cards and per-site capacity table. Add capacity summary
card to site show page. Add Capacity link to nav menu.
2026-03-07 14:42:40 -06:00
abcca08f0b
fix: upgrade to PostgreSQL 17 for transaction_timeout support 2026-03-07 14:27:43 -06:00
4acf0d5248
fix: use DATABASE_URL instead of DATABASE_HOST 2026-03-07 14:02:23 -06:00
24cfbc44af
fix: set DATABASE_HOST at job level for all steps 2026-03-07 13:39:36 -06:00
d1591d3e6c
perf: add comprehensive caching to production workflow 2026-03-07 13:21:47 -06:00
1b606534c5
fix: set DATABASE_HOST for compile step 2026-03-07 13:16:27 -06:00
d0fe39b0af
fix: remove libssl1.1 for ubuntu-22.04 compatibility 2026-03-07 13:01:29 -06:00
16a9657807
fix: use ubuntu-22.04 for production workflow 2026-03-07 12:56:19 -06:00
f88050203b
fix: refresh library cache after OpenSSL install in CI
- Run ldconfig after installing OpenSSL packages
- Add verification steps to check OpenSSL installation
- Should resolve 'libcrypto.so.1.1: cannot open shared object file' error
2026-03-07 12:52:13 -06:00
db96845250
refactor: remove test.yaml workflow
Simplified CI/CD to two workflows:
- staging.yaml: Deploys to Dokku on main push (no tests)
- production.yaml: Full test suite + deploy on production push

Main branch deploys immediately to staging for fast iteration.
Production branch has comprehensive test gates before deployment.
2026-03-07 12:45:19 -06:00
d52ab0eceb
refactor: remove e2e tests from main branch CI
E2E tests now only run before production deploys for faster feedback:
- test.yaml (main branch): ExUnit, formatting, Credo only
- staging.yaml (main branch): Immediate Dokku deploy
- production.yaml (production branch): Full test suite including e2e

This allows staging to deploy quickly while ensuring production
has comprehensive test coverage including browser automation.
2026-03-07 12:44:23 -06:00
40b3ea87f2
refactor: consolidate workflows and rename to .yaml extension
- Renamed test.yml → test.yaml
- Renamed production.yml → production.yaml
- Split build.yaml into staging.yaml (Dokku only)
- Removed duplicate production build from build.yaml

Production deployments now use production.yaml which includes:
- Test gates (ExUnit + e2e tests must pass)
- Docker build and push
- k8s deployment.yaml update
- FluxCD auto-deployment

Staging deployments use staging.yaml:
- Deploys to Dokku on push to main
- No test gates (tests run via test.yaml)

This eliminates the duplicate production builds that were running
from both build.yaml and production.yml simultaneously.
2026-03-07 12:40:41 -06:00
5e0ac897f3
fix: add full OpenSSL 1.1 packages to CI for ubuntu-20.04 compatibility
- Added openssl and libssl1.1 packages alongside libssl-dev
- Fixes 'libcrypto.so.1.1: cannot open shared object file' error
- Required for Erlang crypto library on ubuntu-20.04 runners
2026-03-07 12:32:49 -06:00
834cb7d95a
fix: configure FluxCD to use production branch and add OpenSSL deps to CI
FluxCD Changes:
- Updated GitRepository resource to watch 'production' branch instead of 'main'
- Deployment now automatically pulls from production branch where CI updates image tags

CI Changes:
- Added libssl-dev to system dependencies in both test.yml and production.yml
- Fixes "libcrypto.so.1.1: cannot open shared object file" error in CI runners

This ensures production deployments work end-to-end:
1. Push to production branch triggers CI
2. CI tests pass, builds image, updates k8s/deployment.yaml
3. FluxCD detects change in production branch and applies to cluster
2026-03-07 12:17:31 -06:00
6e3207f526
fix: resolve all remaining test failures
- Fix ApplicationSetting duplicate key constraint errors in BillingTest and AdminTest
  by deleting existing records before inserting new ones in tests
- Increase timeouts for agent_channel debounce tests from 75ms to 200ms
  to prevent flaky failures on slower systems (50ms debounce + processing time)

All 7633 tests now pass consistently across multiple runs.
2026-03-07 12:13:17 -06:00
76545ee31c
fix: handle alert_changed PubSub messages and primary owner ordering
- Add handle_info for {:alert_changed, org_id} in AlertLive.Index and DashboardLive
  to properly handle organization-level alert change broadcasts
- Fix get_primary_owner query to prioritize is_default memberships first,
  ensuring the organization creator is always returned when multiple owners exist

Resolves 5 test failures related to PubSub message handling and
deterministic primary owner selection.
2026-03-07 12:04:30 -06:00
3fa0ea383a
feat: improve organization invitation UX
- Show sender's full name in invitation emails
- Use relative time for "Sent" column (more readable)
- Use date format for "Expires" column (shorter)
- Make invitation table horizontally scrollable

Fixes display cropping issue where long timestamps caused
the pending invitations table to overflow its container.
2026-03-07 11:58:46 -06:00
3913981094
feat: add backhaul capacity analysis foundation
Add per-interface capacity tracking with manual override and automatic
detection from SNMP sensors. Includes capacity resolver with priority
cascade (manual > sensor > if_speed), throughput calculation from
interface stats, and site/organization-level capacity summaries.

- Migration: add configured_capacity_bps and capacity_source to snmp_interfaces
- Capacity.Resolver: multi-source capacity detection with vendor unit normalization
- Capacity context: throughput calculation, utilization percentages, site/org summaries
- Snmp context: set_manual_capacity/2 and clear_manual_capacity/1 functions
2026-03-06 17:54:32 -06:00
480f8b17c5
fix: use full GitHub URLs for Forgejo Actions
Forgejo Actions runner can't find actions in its mirror registry.
Changed all action references from short names to full GitHub URLs:
- actions/checkout@v4 → https://github.com/actions/checkout@v4
- erlef/setup-beam@v1 → https://github.com/erlef/setup-beam@v1
- actions/cache@v4 → https://github.com/actions/cache@v4
- actions/setup-node@v4 → https://github.com/actions/setup-node@v4
- actions/upload-artifact@v4 → https://github.com/actions/upload-artifact@v4
- docker/* actions → https://github.com/docker/*

This fixes the 'repository not found' errors when Forgejo tries
to clone actions from data.forgejo.org.
2026-03-06 17:52:15 -06:00
f026b52fa1
test: add comprehensive signup flow e2e tests
Adds detailed e2e tests for user registration:

Complete signup flows:
- Account creation with email/password
- Organization creation for new users
- Post-registration login and dashboard access

Validation testing:
- Invalid email format
- Weak passwords
- Duplicate email addresses
- Password mismatch errors

Post-registration:
- Login after signup
- Dashboard access
- Email confirmation prompts and resend

Security:
- CSRF token protection
- Password field masking
- Double-submit prevention

These tests catch issues in the critical signup funnel that
would prevent new users from creating accounts.
2026-03-06 17:45:11 -06:00
f68b828c8f
ci: add test gates for production deployments
Adds Forgejo Actions CI/CD workflows:

Production deployment (.forgejo/workflows/production.yml):
- Runs on push to 'production' branch
- Test gates (must pass before deploy):
  * All ExUnit tests with coverage
  * All e2e Playwright tests
- Only deploys if both test suites pass
- Builds Docker image
- Pushes to git.mcintire.me registry
- Updates k8s/deployment.yaml with new image tag
- FluxCD auto-applies changes

Main branch testing (.forgejo/workflows/test.yml):
- Runs on push to 'main' or pull requests
- Runs ExUnit tests with coverage
- Runs e2e tests
- No deployment (staging still via Dokku)

Updated CLAUDE.md with CI/CD pipeline documentation.
2026-03-06 17:40:50 -06:00
668d5350a7
test: add comprehensive smoke tests for all pages
Adds e2e smoke tests that verify:
- All major pages load without 500 errors
- No JavaScript console errors
- No LiveView socket crashes (Jason.EncodeError, etc.)
- All activity feed filter types work without encoding errors

Also documents binary UUID fragment query pattern in AGENTS.md
to prevent future Jason.EncodeError issues from PostgreSQL
aggregations returning binary UUIDs instead of text.
2026-03-06 17:36:54 -06:00
180bfa6de2
fix: convert binary UUID to text in activity feed sync query
Fixes Jason.EncodeError when rendering activity feed. PostgreSQL
array_agg was returning binary UUID which caused invalid UTF-8 bytes
when interpolated into 'sy-#{row.id}' string. Cast to ::text in the
fragment to ensure string representation.
2026-03-06 17:33:34 -06:00
053ad8b373
feat: add critical e2e tests for robustness and security
- Added error scenarios tests (404s, validation, network errors, edge cases)
- Added navigation and routing tests (browser nav, deep linking, URL state, breadcrumbs)
- Added data integrity tests (unsaved changes, form persistence, concurrent edits)
- Added advanced search/filtering tests (global search, filter combinations, date ranges)
- Added API tokens tests (generation, permissions, revocation, security)

Covers:
- Comprehensive error handling and recovery
- Browser navigation and URL state management
- Data loss prevention and form state
- Advanced search with wildcards and categories
- Complete API token lifecycle and security
- Input validation edge cases (XSS, special chars, length limits)
- Concurrent action prevention
- Filter presets and export functionality
2026-03-06 17:21:14 -06:00
61a231f829
feat: add advanced e2e tests for UX and accessibility
- Added real-time updates tests (LiveView connection, live data updates)
- Added pagination and sorting tests (page navigation, table sorting, URL params)
- Added notifications tests (flash messages, toasts, in-app notifications)
- Added session management tests (active sessions, logout, concurrent sessions)
- Added accessibility tests (keyboard nav, ARIA labels, screen reader support)

Covers:
- LiveView real-time features and reconnection
- Pagination controls and sorting on all list pages
- Flash messages, toasts, and notification preferences
- Session security and multi-device management
- Basic WCAG compliance (keyboard, labels, roles)
2026-03-06 17:16:25 -06:00
0cf533c0d4
feat: add comprehensive e2e tests for workflows and validation
- Added integration tests (Preseem, Gaiia, Slack, webhooks)
- Added SNMP configuration and discovery tests
- Added form validation and error handling tests
- Added detailed alert workflow tests (lifecycle, actions, filtering, history)
- Added agent token management tests (creation, assignment, deletion)

Covers:
- Third-party integration UI
- SNMP credential hierarchy (org/site/device)
- Form validation and error states
- Alert bulk actions and filtering
- Agent token lifecycle and device assignment
2026-03-06 17:12:46 -06:00
7f7e289325
docs: add critical git workflow rule - never push to production without explicit instruction 2026-03-06 17:09:52 -06:00
d5b0f38ed6
feat: add remaining e2e tests and fix 'too many open files' error
- Added e2e tests for auth flows (registration, login, password reset, TOTP)
- Added e2e tests for onboarding and organization creation
- Added e2e tests for team collaboration (org switching, invitations)
- Added e2e tests for activity feed
- Added e2e tests for device graphs (sensors, time ranges, interfaces)
- Added e2e tests for MikroTik backup comparison
- Added e2e tests for sites map (geographic view)
- Added e2e tests for network trace tool

- Fixed 'too many open files' error by configuring Phoenix code reloader
  to ignore deps/, _build/, node_modules/, e2e/, and other non-source directories
- This prevents the file system watcher from monitoring unnecessary files
2026-03-06 17:08:27 -06:00
03ec4ee59a
docs: add e2e testing requirement to CLAUDE.md 2026-03-06 16:59:26 -06:00
0832abf33a
feat: comprehensive e2e test coverage for all user-facing features
- Added e2e tests for agents, insights, maintenance windows, maps, help pages
- Added e2e tests for organization settings, config timeline, MikroTik backups
- Added comprehensive search functionality tests
- Added dashboard and sites navigation tests
- Updated existing tests to handle sudo verification redirects
- Fixed navigation tests to be more defensive about missing data
- All 301 tests passing across chromium, firefox, and webkit
2026-03-06 16:58:06 -06:00
95d94b0ce5
fix: resolve dialyzer warnings in device_live/index.ex
Convert compile-time module attributes to runtime functions to avoid
dialyzer warnings about compile-time constant comparisons:

- tick_interval_ms: function instead of @tick_interval_ms
- debounce_ms: function instead of @debounce_ms

This fixes warnings where dialyzer knew the comparisons could never
be false/true based on compile-time values.
2026-03-06 16:45:37 -06:00
2a9f73e381
fix: NimbleTOTP base32 decoding and complete e2e test setup
- Fix TOTP verification by decoding base32 secrets to bytes before
  passing to NimbleTOTP (was treating base32 strings as raw ASCII)
- Switch e2e tests from otplib v13 to speakeasy for compatibility
- Update test user secret to RFC 6238 test vector
- Configure Playwright to exit cleanly (headless mode, no auto-open)
- Simplify e2e tests to basic smoke tests (verify pages load)
- All 16 e2e tests now passing

The core issue was that NimbleTOTP.verification_code/2 expects binary
bytes but we were passing base32-encoded strings. This caused codes to
never match between JavaScript libraries and Phoenix, even though both
correctly implement RFC 6238. The fix decodes base32 secrets in
verify_totp/2 before verification.
2026-03-06 16:42:41 -06:00
4b84c48413
fix: e2e test login form selectors
- Use specific email field ID to avoid ambiguity between password and magic link forms
- Use case-insensitive regex for 'Log in' button text
2026-03-06 15:59:18 -06:00
b3ee1e5bcb
fix: remove raw() from Gettext interpolation in login page
Gettext interpolation expects plain strings, not safe tuples.
Split the translation into separate parts instead.
2026-03-06 15:56:35 -06:00
7363c2ecff
fix: use correct login route with hyphen (/users/log-in) 2026-03-06 15:55:29 -06:00
99507eeaaf
fix: update e2e tests to use otplib v13 API and load .env
- Change tsconfig to use ESNext modules
- Add type: module to package.json
- Update auth.setup.ts to use generateSync instead of authenticator.generate
- Install and configure dotenv to load environment variables
- Add dotenv.config() to playwright.config.ts
2026-03-06 15:53:10 -06:00
659490c405
fix: access role from membership association in create_test_user script
Organizations have memberships with roles, not direct role attribute
2026-03-06 15:47:34 -06:00
b3af717013
fix: update e2e scripts to use correct TOTP API
- Fix create_test_user.exs to use create_totp_device instead of create_user_credential
- Update TOTP_SETUP.md to reference UserTotpDevice schema and user_totp_devices table
- Fix function signatures to match Accounts.create_totp_device(user_id, device_name, secret)
- Add terms_of_service_consent and privacy_policy_consent to user registration
2026-03-06 15:46:11 -06:00
70c82ba8f1
refactor: remove emoji from e2e scripts and docs
- Remove emoji from create_test_user.exs output
- Remove emoji from setup.sh
- Keep emoji in test files (used for matching actual app emoji)
2026-03-06 15:43:02 -06:00
cc3ca1c7de
feat: add site search to trace
Trace can now search sites by name, location, or address. Selecting
a site shows all devices at that site with status and recent alerts.
2026-03-06 15:37:23 -06:00
0bdec8653f
docs: add TOTP setup guide and test user creation script
- Add comprehensive TOTP_SETUP.md with multiple setup options
- Create scripts/create_test_user.exs for automated test user creation
- Update .gitignore to exclude Playwright browser binaries and artifacts
- Update README to reference TOTP setup guide
2026-03-06 15:06:23 -06:00
882a5d7eab
fix: display count sensor values as integers instead of floats
Connection counts (IPv4/IPv6, DHCP leases) were showing as floats
(e.g. 1270.0) in executor output, change detection messages, and
chart tooltips/axes. Now displayed as integers everywhere.
2026-03-06 15:03:30 -06:00
17bf1f83e8
feat: add Playwright e2e test suite
- Set up Playwright in dedicated e2e directory
- Multi-environment support (local, staging)
- TOTP authentication handling with otplib
- Test coverage for organizations, devices, alerts, status indicators
- Helper utilities for common test operations
- Comprehensive README with setup and usage instructions
- Setup script for quick initialization
2026-03-06 15:02:56 -06:00
c86ca57864
feat: add real-time status emoji updates in page titles
Dynamically update page title emoji when device/alert status changes:
- Add PubSub broadcasts when alerts are created/resolved
- Create StatusTitleComponent LiveComponent to subscribe to alert changes
- Add StatusTitle JavaScript hook to update document.title in real-time
- Subscribe to organization:alerts channel on LiveView mount
- Push emoji update events when alert status changes

This provides immediate visual feedback in browser tabs when
critical/warning/healthy status changes without requiring page refresh.
2026-03-06 14:49:44 -06:00
a2ce5817a2
fix: use transparent background for stoplight favicon
Replace white background with transparent for better appearance
in browser tabs with different background colors.
2026-03-06 14:46:02 -06:00
9bef1b289d
feat: add status emoji to page titles
Add colored circle emoji (🔴/🟡/🟢) to page titles based on organization
health status:
- 🔴 Red: Critical alerts (device_down, agent_offline, severity 1)
- 🟡 Yellow: Warning alerts (severity 2 or any active alerts)
- 🟢 Green: No active alerts

Provides at-a-glance status visibility in browser tabs.

Note: Favicon remains static stoplight, only page title is dynamic.
2026-03-06 14:45:02 -06:00
100245975a
refactor: reduce complexity in global pricing validation
Extract validation logic into separate functions to reduce:
- Cyclomatic complexity from 12 to acceptable levels
- Nesting depth from 3 to 2

Improves code maintainability and passes Credo checks.
2026-03-06 14:44:33 -06:00
c110832b42
Revert "feat: add status emoji to page titles"
This reverts commit f3873e0da7.
2026-03-06 14:43:13 -06:00
f3873e0da7
feat: add status emoji to page titles
Add colored circle emoji (🔴/🟡/🟢) to page titles based on organization
health status:
- 🔴 Red: Critical alerts (device_down, agent_offline, severity 1)
- 🟡 Yellow: Warning alerts (severity 2 or any active alerts)
- 🟢 Green: No active alerts

Provides at-a-glance status visibility in browser tabs.
2026-03-06 14:42:55 -06:00
e278d320ce
design: improve stoplight favicon with transparent background
Make circles more prominent with transparent background and better spacing.
2026-03-06 14:36:32 -06:00