Commit graph

114 commits

Author SHA1 Message Date
Yussif Mohammed
83ac8ca0a3 Merge remote-tracking branch 'origin/master' into teams 2025-12-17 06:38:46 +00:00
Anthony Alaribe
e212df0b96
Tests in prs. And fix hlint warnings and failing UI tests (#230)
* Enable tests and hlint in pull request workflow

- Add hlint job to run on all PRs

- Make test jobs run even if build fails (using if: always())

- Fix shadowing binding in Table.hs colAttrs function

- Fix LLM.hs type error by using langchain-hs standard pattern

- Fix TypeScript error in log-worker-functions.ts with optional chaining

This ensures CI checks run independently and provide feedback even when some jobs fail.

* Convert PR workflow from stack to cabal

- Replace stack with cabal commands throughout

- Update caching to use dist-newstyle and ~/.cabal/store

- Use awalsh128/cache-apt-pkgs-action for system deps

- Set OpenSSL env vars properly for GitHub Actions

- Add fail-fast: false to test matrix

- Add ::group:: annotations for better log organization

* Revert LLM.hs changes - they were stack-related, not actual bugs

* minor linting error

* run hlint refactor in prs

* Apply hlint fixes across codebase

Fixed 239 hlint warnings: use toText, simplify encoding chains, replace fromMaybe with maybe, use ordNub, convert to guards, use unless, eta reduction, list comprehensions, newtype conversions, and remove unused imports. Updated .hlint.yaml to allow flexible imports for Data.List and Data.Aeson.

* Auto-format code with fourmolu

* Fix UI test failures in GitHub Actions

Update Node.js version from 18 to 20 to satisfy happy-dom requirement

Add CSS.escape mock for Monaco Editor theme initialization

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2025-12-17 00:34:01 +01:00
Anthony Alaribe
e9f828e866
Attempt at a versatile table component (#229)
* attempt at a versatile table component

* Auto-format code with fourmolu

* pr updates based on feedback

* Auto-format code with fourmolu

* refactor

* fix ui differences in the tables

* Auto-format code with fourmolu

* remove redundancies

* Auto-format code with fourmolu

* remove redundancies

* Auto-format code with fourmolu

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2025-12-16 22:38:46 +01:00
Yussif Mohammed
2bfc2abfb5 add dashboards spec 2025-12-08 11:21:44 +00:00
Yussif Mohammed
351d12a641 add more tests 2025-12-07 21:45:35 +00:00
Yussif Mohammed
0cdf4f961c fix and passing tests 2025-12-07 19:51:44 +00:00
Yussif Mohammed
2053dc64b9 more tests cases 2025-12-03 18:28:45 +00:00
Yussif Mohammed
c75f2f1102 towards tests 2025-12-01 21:54:16 +00:00
Yussif Mohammed
03107e3adc fix tests and docker file 2025-11-28 10:28:18 +00:00
Anthony Alaribe
ba651f5040 Fix GHC 9.12 TypeAbstractions errors in test files
Replace type synonym Projects.ProjectId with UUIDId constructor
in all test files to fix "Illegal term-level use of type constructor"
errors that occur with GHC 9.12's TypeAbstractions extension.
2025-11-27 23:29:55 +01:00
Anthony Alaribe
4fe33fac2e Consolidate Telemetry, Anomalies, and Monitors modules
- Merged Pages/Telemetry/Metrics.hs and Trace.hs into Pages/Telemetry.hs
- Moved Pages/Anomalies/AnomalyList.hs to Pages/Anomalies.hs
- Moved Pages/Monitors/Alerts.hs to Pages/Monitors.hs
- Fixed FromRow type errors in several files (Only wrapper)
- Fixed import issues in Pages/Projects.hs
2025-11-27 23:29:54 +01:00
Anthony Alaribe
318b62d430 Consolidate Pages/Projects into single module
Merged CreateProject, Integrations, ListProjects, and ManageMembers
into Pages.Projects, reducing ~60 lines from import overhead.
2025-11-27 23:29:38 +01:00
Anthony Alaribe
ddf832f621 Consolidate modules to reduce codebase size
- Delete unused Pkg.Google (empty) and Models.Projects.ProjectsEmail (unused)
- Merge Pkg.Parser.Core into Pkg.Parser.Expr
- Merge Models.Apis.Fields.Query into Fields.Types, delete Fields.hs wrapper
- Merge Models.Projects.LemonSqueezy into Projects.hs
- Merge Pkg.Components.Modals into Pages.Components
- Merge Models.Apis.Formats into Models.Apis.Fields.Types

Reduces codebase from ~33k to ~32.8k lines by eliminating 9 modules.
2025-11-27 23:29:16 +01:00
Anthony Alaribe
e1397ea721 Fix type mismatch in ProjectsSpec integration tests
The ListProjectsGet handler returns a 3-tuple containing projects, demo project, and showDemoProject flag. Updated test destructuring to match the actual return type.
2025-11-23 21:01:20 +01:00
Anthony Alaribe
873b71e13c Refactor test infrastructure and fix onboarding session caching
- Add refreshSession and runTestEffect helpers to eliminate duplication
- Skip session cache for ONBOARDING projects (actively being updated)
- Use pattern guards in sessionAndProject for cleaner control flow
- Simplify test setup: UPDATE sudo status instead of INSERT with conflict handling
- Restructure BusinessFlowsSpec with TestContext and withTestProject
- Rename projectOnboarding to projectOnboardingH for consistency
- Fix LemonSqueezy payment plan enum (FREE vs Free)
2025-11-17 17:16:41 +01:00
Anthony Alaribe
4b0e92659b Fix integration test compilation errors after testServant refactoring
Update all integration tests to properly unpack tuple response from testServant helper, which now returns (RespHeaders a, a).

Key changes:
- Add servant and servant-htmx to integration test dependencies
- Fix tuple unpacking in all test specs (AnomalyList, Log, Alerts, ManageMembers, Projects, BusinessFlows, Reports, Api, ApiCatalog, GrpcIngestion)
- Fix BusinessFlowsSpec imports to use ResponseHeader data constructor
- Fix type-level string usage for header lookups
- Fix ProjectId to Text conversions using .toText
- Add missing pattern match cases to avoid incomplete pattern warnings
2025-11-17 11:30:07 +01:00
Anthony Alaribe
c13704adf3 Rename onboarding handlers for consistency and cleanup config
- Renamed onboardingInfoPost -> onboardingInfoPostH
- Renamed onboardingConfPost -> onboardingConfPostH
- Updated Routes to use renamed handlers
- Removed unused notifChannels function
- Cleaned up BusinessFlowsSpec comments
- Updated auto-instrument config (commented out ATBackgroundCtx target and some span attributes)
2025-11-17 09:25:29 +01:00
Anthony Alaribe
f10795b158 Refactor integration tests to use simplified testServant helper
Simplified test code by:
- Replacing verbose toServantResponse pattern with concise testServant helper
- Changed test lambdas from \tr@TestResources{..} to \tr for cleaner syntax
- Updated field access to use dot notation (tr.trPool, tr.trATCtx, etc.)

This reduces boilerplate and improves test readability across all integration
test suites while maintaining the same functionality.

Affected test suites:
- Pages (ApiSpec, LogExplorer, Anomalies, Projects, Endpoints, Reports,
  Monitors, BusinessFlows, Share)
- MonitoringSpec
- ProcessMessageSpec
2025-11-17 09:04:28 +01:00
Anthony Alaribe
04e21f37ee Add business flows integration test suite
Add comprehensive integration tests for business-critical workflows:

- Onboarding flow: Test all steps (Info, Survey, NotifChannel,
  Integration) through handlers, verifying data persistence via
  GET endpoints
- LemonSqueezy billing: Table-driven tests for webhook events
  (subscription_created, cancelled, resumed, expired)
- Replay session recording: Test event ingestion and retrieval
- S3 configuration: Validation and removal tests (pending Minio setup)

Tests use the new structured response types to verify handler behavior
without HTML parsing. Includes table-driven testing patterns for
webhook scenarios and helper functions for creating test payloads.
2025-11-16 01:46:02 +00:00
Anthony Alaribe
c8a9007920 Refactor OTLP test helpers into TestUtils module
Move test helper functions for creating API keys and ingesting
telemetry data (logs, traces, metrics) from GrpcIngestionSpec into
the shared TestUtils module. This includes:
- createTestAPIKey: Create API keys via handler
- ingestLog/Trace/Metric: Ingest via resource attributes
- ingestLogWithHeader/TraceWithHeader/MetricWithHeader: Ingest via gRPC Authorization header
- toBaseServantResponse: Run base context handlers in tests

Add necessary imports (Proto, OTLP modules, Api module) and derive
Generic for AuthContext to support the new test infrastructure.
2025-11-16 01:43:22 +00:00
Anthony Alaribe
8477228369 Update integration tests to pass logger to logging helper
Pass logger parameter to logBackgroundJobsInfo calls to support
the new structured logging interface.
2025-11-15 21:48:42 +00:00
Anthony Alaribe
c28d1f6f20 Update test infrastructure to support log levels
Load environment config in test setup to respect LOG_LEVEL setting.
Update logBackgroundJobsInfo to use structured logging and accept logger parameter.
2025-11-15 21:48:12 +00:00
Anthony Alaribe
8c2b7e1b3e Add gRPC metadata authentication and fix grapesy API compatibility
Metadata authentication:
- Add OtlpRequestMetadata type to parse Authorization header from gRPC metadata
- Support both 'Bearer <token>' and raw token formats
- Update processTraceRequest, processLogsRequest, processMetricsRequest to accept
  metadata API key parameter
- Add RPC handlers that extract API key from gRPC metadata
- Combine metadata API key with resource attribute keys for authentication
- Add test helpers for ingesting telemetry with gRPC headers

Grapesy API compatibility (for upgraded library):
- Replace NoMethods with NoMoreMethods constructor
- Update sendFinalOutput calls to pass tuple (defMessage, NoMetadata)
- Add type instance declarations for response metadata
2025-11-15 20:06:37 +00:00
Anthony Alaribe
499b7038c5 Fix test assertions and exception handling in GrpcIngestionSpec
Update expectLogsJson helper to use fail instead of expectationFailure
for proper IO type compatibility, add handling for LogsPatternList
constructor, and fix Test 3.2 to properly expect GrpcUnauthenticated
exception when API key is missing.
2025-11-15 05:59:13 +00:00
Anthony Alaribe
32a4be21c4 Fix type signatures and add missing import in GrpcIngestionSpec
- Add Data.Aeson qualified import
- Fix queryLogs return type: LogsResp -> LogsGet
- Make expectLogsJson type more specific
- Add LogsQueryLibrary case to expectLogsJson pattern match
2025-11-15 05:59:12 +00:00
Anthony Alaribe
8b0d315756 Add test infrastructure for gRPC ingestion tests
- Export gRPC handlers and process functions from OtlpServer for testing
- Add runQueryEffect helper in TestUtils for chart query testing
- Fix ProjectsSpec test to verify updates in list instead of relying on index
2025-11-15 05:59:12 +00:00
Anthony Alaribe
b977108665 Refactor GrpcIngestionSpec with helper functions
- Add testTimeRange constant for common time range setup
- Add helper functions: ingestLog, ingestTrace, ingestMetric
- Add queryLogs helper to replace repetitive 22-parameter apiLogH calls
- Add expectLogsJson helper for unified response extraction
- Use traverse and zip/zip3 for cleaner iteration patterns
- Reduced from 447 lines to 176 lines (60% reduction)
- All tests still target complete handler chains
2025-11-15 05:59:11 +00:00
Anthony Alaribe
a4ccb14bd2 Refactor integration tests to use TestResources pattern
Update integration tests to use the new TestResources pattern for better
test organization and consistency.

Changes:
- Replace withSetup callback with withTestResources
- Use runTestBg helper instead of runTestBackground
- Access test resources via TestResources record fields
- Remove redundant imports (execute from DBT)
- Simplify test setup code

This refactoring improves test readability and reduces boilerplate.
2025-11-15 05:59:09 +00:00
Anthony Alaribe
5ab5c35edd improve background job handling and make tests more precise in job handling 2025-11-15 05:54:10 +00:00
Anthony Alaribe
614715b313 fix tests and reduce default limit to 500 for weaker conections 2025-10-26 23:10:32 +01:00
Anthony Alaribe
b9ed4c58be fix unit tests 2025-10-26 22:42:05 +01:00
Yussif Mohammed
d6fa7c1f66 fix integration tests with events table updates enabled 2025-10-22 21:00:39 +00:00
Anthony Alaribe
c66d11b7c3 fix unit test unsuported test case 2025-10-18 02:21:48 +02:00
Yussif Mohammed
446604315f fix test and remove redundant imports 2025-10-14 18:14:58 +00:00
Anthony Alaribe
f344f88dac fix the argument issues from apiLogH in the tests, so tests compile 2025-10-12 20:17:13 +02:00
Yussif Mohammed
172d56083d fix tests 2025-10-05 07:58:27 +00:00
Yussif Mohammed
3b2fcae21b fmt and fix tests 2025-10-02 11:22:14 +00:00
Yussif Mohammed
a46a118ef3 fix limit clause 2025-10-01 18:10:56 +00:00
Yussif Mohammed
6b59c7ae3f fix tests and format 2025-09-30 16:26:23 +00:00
Yussif Mohammed
48fa3ed938 fix tests 2025-09-30 13:18:49 +00:00
Yussif Mohammed
cbc5daf0ca trace grouping to avoid dangling child spans/logs 2025-09-30 11:53:22 +00:00
Yussif Mohammed
3678d62308 fix tests 2025-09-28 08:51:55 +00:00
Yussif Mohammed
53a5c740a1 replaceAllFormats to handle additional patterns 2025-09-27 15:02:18 +00:00
Yussif Mohammed
cda9e22322 drain pkg and unit tests 2025-09-27 15:02:08 +00:00
Yussif Mohammed
da952749ca fix tests 2025-09-21 21:34:11 +00:00
Anthony Alaribe
31e5f55e3f deploy irrespective of the tests status 2025-09-14 22:53:50 +02:00
Anthony Alaribe
4b4ed0252a rename project to monoscope 2025-09-14 19:55:26 +02:00
Anthony Alaribe
63d8ef3369 remove base64-bytestring 2025-09-13 21:36:57 +02:00
Anthony Alaribe
6e948c7bd6 update service worker 2025-09-13 20:07:01 +02:00
Anthony Alaribe
8d1cca45bd switch back to 149 responses and fix tests 2025-09-13 19:51:58 +02:00