Skip to content

Added specType to the E2E test reports - #11

Merged
arxdsilva merged 26 commits into
arxdsilva:mainfrom
RaihanSultana:main
Jun 19, 2026
Merged

Added specType to the E2E test reports#11
arxdsilva merged 26 commits into
arxdsilva:mainfrom
RaihanSultana:main

Conversation

@RaihanSultana

@RaihanSultana RaihanSultana commented Jun 16, 2026

Copy link
Copy Markdown
Contributor
  1. Introduced specType in E2E test reports to support and differentiate test results from multiple pipeline types (e.g., happyPath, negativePath).
  2. Added specType filters to the E2E Dashboard and Heatmap for easier analysis and reporting.

Summary by CodeRabbit

  • New Features
    • E2E test specifications are now classified by type (happy path, negative path, setup) for better organization
    • Added spec type filtering to E2E runs screen and heatmap overlay, enabling focused analysis by specification category
    • Failed specs details table now includes spec type column for enhanced visibility

rsultana1418 and others added 24 commits June 3, 2026 11:43
added e2e test heatmap and coverage dashboard
replaced logs with slog and added check in e2e migration file
moved check constraint from the table
@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@RaihanSultana, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 58 minutes and 57 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: fc6889b9-2245-4a6a-87c1-6050675d1dae

📥 Commits

Reviewing files that changed from the base of the PR and between 0e19dbe and 8974ef8.

📒 Files selected for processing (6)
  • cmd/coveragecli/main.go
  • cmd/frontend/web/assets/e2e.js
  • internal/application/e2e_usecase.go
  • internal/application/e2e_usecase_test.go
  • internal/application/ports.go
  • migrations/004_add_spec_type.sql
📝 Walkthrough

Walkthrough

Adds a specType classification field (happyPath, negativePath, setup) to E2E spec results. The field is derived from file paths in the Playwright CLI normalizer, stored in a new spec_type database column, propagated through domain/application/repository layers with validation, exposed as HTTP query parameters, and surfaced in the frontend as filter dropdowns and a new table column.

Changes

specType end-to-end feature

Layer / File(s) Summary
Domain model and DB migration
internal/domain/e2e.go, migrations/004_add_spec_type.sql
E2ESpecResult gains a SpecType field; migration adds the spec_type TEXT column with a CHECK constraint and a composite index on (e2e_run_id, spec_type).
Application contracts, validation, and tests
internal/application/ports.go, internal/application/e2e_usecase.go, internal/application/integration_usecase.go, internal/application/mock_application.go, internal/application/e2e_usecase_test.go
Updates E2ETestRunRepository interface signatures; adds SpecType to IngestSpecReport, ListE2ERunsInput, E2EHeatmapInput, and FailedSpecResponse; defines validSpecTypes and enforces it in ingest, list, and heatmap use cases; tests cover entity building, validation rejection, and invalid-filter error codes.
Postgres repositories
internal/adapters/postgres/e2e_spec_result_repository.go, internal/adapters/postgres/e2e_test_run_repository.go
CreateBatch writes spec_type; ListByRunID and ListFailedByRunID select and scan it; ListByProject and HeatmapData add conditional EXISTS subquery filters when specType is non-empty.
HTTP handler wiring
internal/adapters/http/handlers.go
ListE2ERuns and GetE2EHeatmap read the specType query parameter and pass it into their respective use-case input structs.
Playwright CLI normalizer
cmd/coveragecli/main.go
normalizePlaywrightReport derives spec_type from file path substrings (setup, happyPath, negativePath) and emits suite_type and specType on each normalized leaf spec object.
Frontend filters and table column
cmd/frontend/web/e2eTest.html, cmd/frontend/web/assets/e2e.js
Adds e2eSpecTypeFilter and heatmapSpecTypeFilter dropdowns with happyPath/negativePath options; wires change listeners; includes specType in API calls; adds a specType cell per failed spec; updates colspans; fixes pass-rate display to 100% for zero failed runs.

Sequence Diagram(s)

sequenceDiagram
  participant Browser as Browser (e2eTest.html + e2e.js)
  participant Handler as HTTP Handler (handlers.go)
  participant UseCase as ListE2ERunsUseCase / GetE2EHeatmapUseCase
  participant Repo as E2ETestRunRepository (Postgres)
  participant DB as e2e_test_spec_results (spec_type column)

  Browser->>Handler: GET /e2e/runs?specType=happyPath
  Handler->>UseCase: Execute(ListE2ERunsInput{SpecType: "happyPath"})
  UseCase->>UseCase: validate specType ∈ validSpecTypes
  UseCase->>Repo: ListByProject(..., specType="happyPath", ...)
  Repo->>DB: SELECT with EXISTS subquery on spec_type
  DB-->>Repo: filtered run rows
  Repo-->>UseCase: []E2ETestRun
  UseCase-->>Handler: run list + failed specs (SpecType in FailedSpecResponse)
  Handler-->>Browser: JSON response
  Browser->>Browser: render specType column in failed-specs table
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • arxdsilva/opencoverage#10: Directly introduces the E2E heatmap, Playwright report normalization, and the CLI/repository patterns that this PR extends with the specType field.

Suggested reviewers

  • arxdsilva

Poem

🐇 A bunny hops through spec-land with glee,
Sorting happyPath from negativePath with care,
Each test leaf tagged so filters run free,
The heatmap glows, specType floating in air,
No more "∞%"—just 100% to declare!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately captures the main change: adding specType field support to E2E test reports across the application layer, infrastructure, and UI components.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🧹 Nitpick comments (1)
internal/application/e2e_usecase.go (1)

122-127: ⚡ Quick win

Replace package-level mutable validSpecTypes with an immutable validator helper.

This introduces avoidable shared mutable state in the application package.

Refactor sketch
-var validSpecTypes = map[string]bool{
-	"":             true,
-	"happyPath":    true,
-	"negativePath": true,
-	"setup":        true,
-}
+func isValidSpecType(v string) bool {
+	switch v {
+	case "", "happyPath", "negativePath", "setup":
+		return true
+	default:
+		return false
+	}
+}

As per coding guidelines, "Avoid package-level mutable state."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/application/e2e_usecase.go` around lines 122 - 127, Replace the
package-level mutable `validSpecTypes` map with a validator helper function that
performs the same validation without introducing shared mutable state. Create a
function that takes a spec type string as input and returns a boolean indicating
whether it's valid (accepting empty string, "happyPath", "negativePath", and
"setup"), then update all code locations that currently reference
`validSpecTypes` to call this new validator helper instead of accessing the map
directly.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@cmd/coveragecli/main.go`:
- Around line 677-688: The switch statement that determines spec_type currently
falls back to using projectID in the default case, but projectID values are not
guaranteed to be valid spec types and can break the ingest process. Remove or
modify the default case in the switch statement (currently assigning spec_type =
projectID) so that it does not use projectID as a fallback value. Either remove
the default case entirely to leave spec_type unchanged when none of the
file-path patterns match (setup, happyPath, negativePath), or assign it to a
known valid default spec type instead of projectID.

In `@cmd/frontend/web/assets/e2e.js`:
- Around line 714-715: Multiple placeholder rows displayed in the E2E results
table are using colspan="4" when the table now has 5 columns, causing
misalignment. Find all placeholder HTML strings in the e2e.js file that render
messages like "No run selected" and "No failed specs" (including instances
around line 812), and update any colspan="4" attributes to colspan="5" to match
the corrected colspan="5" shown in the diff at line 714. Ensure all table
placeholders have consistent colspan="5" across all states.

In `@cmd/frontend/web/e2eTest.html`:
- Around line 109-113: Add a new option with value "setup" to both spec-type
filter dropdowns. The e2eSpecTypeFilter select element and the second spec-type
filter dropdown (noted as also applying to lines 190-194) both need to include
an option element with value="setup" and text content "setup" to allow users to
filter setup runs/specs from the UI. Insert this option between the existing
"All spec types" header option and the "happyPath" option in both select
elements.

In `@internal/application/e2e_usecase_test.go`:
- Around line 623-629: The validation test table for specType in the
e2e_usecase_test.go file is missing a test case for the setup specType, which is
a valid value according to the use-case contract. Add a new test case entry to
the table following the same structure as the existing empty specType case. This
new case should set SpecType to "setup" in the mutate function and have wantErr
set to false to ensure regressions for setup specType values are caught in
future changes.

In `@internal/application/e2e_usecase.go`:
- Around line 388-390: The validation of spec.SpecType against validSpecTypes is
checking the raw input without trimming whitespace, causing valid values with
leading or trailing spaces like " happyPath " to be rejected. Before the
validation check in the if condition that references
validSpecTypes[spec.SpecType], trim the spec.SpecType value to remove any
leading or trailing whitespace (use strings.TrimSpace or equivalent), then
update the validation check to use the trimmed value when looking it up in the
validSpecTypes map. This ensures that semantically valid spec type values are
accepted regardless of whitespace.

In `@migrations/004_add_spec_type.sql`:
- Line 4: The CHECK constraint in the spec_type column definition only allows
'setup', 'happyPath', and 'negativePath', but the ingest validation currently
accepts empty strings as valid specType values, creating a mismatch where
validation passes but database insertion fails. Decide whether empty strings
should be allowed: if yes, add an empty string option to the CHECK constraint
list (modify the ADD COLUMN statement to include '' in the allowed values); if
no, update the ingest validation logic that currently accepts empty specType to
reject it instead, ensuring both sides of the contract are aligned.

---

Nitpick comments:
In `@internal/application/e2e_usecase.go`:
- Around line 122-127: Replace the package-level mutable `validSpecTypes` map
with a validator helper function that performs the same validation without
introducing shared mutable state. Create a function that takes a spec type
string as input and returns a boolean indicating whether it's valid (accepting
empty string, "happyPath", "negativePath", and "setup"), then update all code
locations that currently reference `validSpecTypes` to call this new validator
helper instead of accessing the map directly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 0284b9c0-950d-4188-b376-f47983f7fa71

📥 Commits

Reviewing files that changed from the base of the PR and between ff76824 and 0e19dbe.

📒 Files selected for processing (13)
  • cmd/coveragecli/main.go
  • cmd/frontend/web/assets/e2e.js
  • cmd/frontend/web/e2eTest.html
  • internal/adapters/http/handlers.go
  • internal/adapters/postgres/e2e_spec_result_repository.go
  • internal/adapters/postgres/e2e_test_run_repository.go
  • internal/application/e2e_usecase.go
  • internal/application/e2e_usecase_test.go
  • internal/application/integration_usecase.go
  • internal/application/mock_application.go
  • internal/application/ports.go
  • internal/domain/e2e.go
  • migrations/004_add_spec_type.sql

Comment thread cmd/coveragecli/main.go
Comment thread cmd/frontend/web/assets/e2e.js
Comment thread cmd/frontend/web/e2eTest.html
Comment thread internal/application/e2e_usecase_test.go
Comment thread internal/application/e2e_usecase.go Outdated
Comment thread migrations/004_add_spec_type.sql Outdated
@RaihanSultana
RaihanSultana requested a review from asilvall June 17, 2026 21:46
@arxdsilva
arxdsilva merged commit 53429ef into arxdsilva:main Jun 19, 2026
2 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Jun 24, 2026
@coderabbitai coderabbitai Bot mentioned this pull request Jul 2, 2026
RaihanSultana referenced this pull request in RaihanSultana/opencoverage Jul 2, 2026
* added e2e heatmap and coverage dashboard

* removed unused imports

* added unit tests

* fixed typo errors

* replaced the dummy playwright report with minimal fields for test

* replaced logs with slog and added check in e2e migration file

* removed duplicate table drop query

* moved check constraint from the table

* added spec type to e2e tests report

* added spec type filter in the dashboard and heatmap

* updated the success ratio

* refactor to save the spec type

* updated failed spec query

* resolved pr comment - refactored spec type normalization and frontend

---------

Co-authored-by: rsultana1418 <rsultana@lodgelink.com>
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.

4 participants