Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 17 additions & 14 deletions docs/plans/test-coverage-implementation/tracker.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
| ---------- | ------- | ------------- | ----------- | --------- |
| CRITICAL | 8 | 0 | 8 | 0 |
| HIGH | 6 | 0 | 6 | 0 |
| MEDIUM | 7 | 0 | 0 | 0 |
| MEDIUM | 7 | 0 | 7 | 0 |
| LOW (Models) | 5 | 0 | 0 | 0 |
| LOW (Components) | 13 | 0 | 0 | 0 |
| SYSTEM | 1 | 0 | 0 | 0 |
| **TOTAL** | **43** | **0** | **17** | **0** |
| **TOTAL** | **43** | **0** | **24** | **0** |

---

Expand Down Expand Up @@ -50,13 +50,13 @@

| # | Item | Status | Notes |
| --- | ------ | -------- | ------- |
| 15 | Translator Service | ⬜ Not Started | File: `spec/services/translator_spec.rb` |
| 16 | Locations Searcher Service | ⬜ Not Started | File: `spec/services/locations/searcher_spec.rb` |
| 17 | Google Maps Services | ⬜ Not Started | File: `spec/services/locations/google_maps_services_spec.rb` |
| 18 | Vancouver City Syncer Service | ⬜ Not Started | File: `spec/services/external/vancouver_city/syncer_spec.rb` |
| 19 | Analytics Visit Model | ⬜ Not Started | File: `spec/models/analytics/visit_spec.rb` |
| 20 | Analytics Event Model | ⬜ Not Started | File: `spec/models/analytics/event_spec.rb` |
| 21 | Analytics Impression Model | ⬜ Not Started | File: `spec/models/analytics/impression_spec.rb` |
| 15 | Translator Service | ✅ Completed | File: `spec/services/translator_spec.rb` (42 examples) |
| 16 | Locations Searcher Service | ✅ Completed | File: `spec/services/locations/searcher_spec.rb` (38 examples) |
| 17 | Google Maps Services | ✅ Completed | File: `spec/services/locations/google_maps_services_spec.rb` (55 examples) |
| 18 | Vancouver City Syncer Service | ✅ Completed | File: `spec/services/external/vancouver_city/syncer_spec.rb` (63 examples) |
| 19 | Analytics Visit Model | ✅ Completed | File: `spec/models/analytics/visit_spec.rb` (47 examples) + factory created |
| 20 | Analytics Event Model | ✅ Completed | File: `spec/models/analytics/event_spec.rb` (51 examples) |
| 21 | Analytics Impression Model | ✅ Completed | File: `spec/models/analytics/impression_spec.rb` (72 examples) |

---

Expand Down Expand Up @@ -120,9 +120,9 @@ Track creation of needed FactoryBot factories:
| `zones.rb` | ✅ Completed | For Zone model specs |
| `facility_schedule.rb` | ✅ Exists | Update if needed |
| `facility_time_slot.rb` | ✅ Exists | Update if needed |
| `analytics/visit.rb` | ⬜ Not Started | For Analytics::Visit specs |
| `analytics/event.rb` | ⬜ Not Started | For Analytics::Event specs |
| `analytics/impression.rb` | ⬜ Not Started | For Analytics::Impression specs |
| `analytics/visit.rb` | ✅ Completed | For Analytics::Visit specs |
| `analytics/event.rb` | ✅ Completed | For Analytics::Event specs |
| `analytics/impression.rb` | ✅ Completed | For Analytics::Impression specs |

---

Expand Down Expand Up @@ -153,15 +153,15 @@ Track creation of shared example groups:
```plain
CRITICAL: ██████████ 8/8 (100%)
HIGH: ██████████ 6/6 (100%)
MEDIUM: ░░░░░░░░░░ 0/7 (0%)
MEDIUM: ██████████ 7/7 (100%)
LOW: ░░░░░░░░░░ 0/18 (0%)
SYSTEM: ░░░░░░░░░░ 0/1 (0%)
```

### Overall Progress

```plain
TOTAL: ████████████████████████░░░░░ 17/43 (40%)
TOTAL: █████████████████████████████████░░░░░ 24/43 (56%)
```

---
Expand All @@ -179,6 +179,9 @@ TOTAL: ████████████████████████

| Date | Item # | Action | Notes |
| ------ | -------- | -------- | ------- |
| 2026-01-25 | 15-21 | Completed | Phase 1 (MEDIUM priority) completed - 7 service and analytics model tests with 368 examples |
| 2026-01-25 | All | Coverage | Improved coverage from 64.3% to 71.33% with Phase 1 completion |
| 2026-01-25 | Factories | Completed | Created analytics factories: `visit.rb`, `event.rb`, `impression.rb` |
| 2026-01-18 | 41 | Completed | Fixed critical bugs in Facility model (`this.user_id` → `user_id`, distance method parameter handling) |
| 2026-01-18 | 42 | Completed | Added SimpleCov to Gemfile and configured coverage reporting |
| 2026-01-18 | 43 | Completed | Achieved 64.3% overall code coverage with detailed HTML reports |
Expand Down
26 changes: 26 additions & 0 deletions spec/factories/analytics/event.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# frozen_string_literal: true

FactoryBot.define do
factory :analytics_event, class: "Analytics::Event" do
association :visit, factory: :analytics_visit

controller_name { "facilities" }
action_name { "index" }
request_url { "https://example.com/facilities" }

trait :show_action do
action_name { "show" }
request_url { "https://example.com/facilities/1" }
end

trait :create_action do
action_name { "create" }
request_url { "https://example.com/facilities" }
end

trait :update_action do
action_name { "update" }
request_url { "https://example.com/facilities/1" }
end
end
end
16 changes: 16 additions & 0 deletions spec/factories/analytics/impression.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# frozen_string_literal: true

FactoryBot.define do
factory :analytics_impression, class: "Analytics::Impression" do
association :event, factory: :analytics_event
association :impressionable, factory: :facility

trait :for_service do
association :impressionable, factory: :service
end

trait :for_zone do
association :impressionable, factory: :zone
end
end
end
82 changes: 82 additions & 0 deletions spec/factories/analytics/visit.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# frozen_string_literal: true

FactoryBot.define do
factory :analytics_visit, class: "Analytics::Visit" do
sequence(:uuid, 1000) { |n| "visit-#{n}-#{SecureRandom.hex(8)}" }
sequence(:session_id, "aa") { |n| "session-#{n}-#{SecureRandom.hex(4)}" }

# Coordinates are nullable - default to nil for basic factory
lat { nil }
long { nil }

# Factory with coordinates
trait :with_coordinates do
lat { 49.2827 + ((rand - 0.5) * 0.1) } # Vancouver area with some variation
long { -123.1207 + ((rand - 0.5) * 0.1) }
end

# Factory with specific Vancouver coordinates
trait :vancouver_center do
lat { 49.2827 }
long { -123.1207 }
end

# Factory with downtown Vancouver coordinates
trait :downtown_vancouver do
lat { 49.2848 }
long { -123.1228 }
end

# Factory with coordinates but slightly outside Vancouver
trait :outside_vancouver do
lat { 49.0 + (rand * 2) } # Random latitude around Vancouver area
long { -123.0 + (rand * 2) } # Random longitude around Vancouver area
end

# Factory with invalid coordinates (negative latitude, positive longitude - wrong hemisphere)
trait :invalid_coordinates do
lat { -33.8688 } # Sydney, Australia
long { 151.2093 }
end

# Trait for visits that need manual event creation
trait :requires_events do
# This trait indicates that events should be created manually in tests
# Useful when you want to test associations without depending on event factories
end

# Trait for new session visits (different creation time)
trait :new_session do
transient do
session_start_time { 1.hour.ago }
end

created_at { session_start_time }
updated_at { session_start_time }
end

# Trait for returning session visits (updated later)
trait :returning_session do
transient do
initial_visit_time { 1.day.ago }
return_time { 10.minutes.ago }
end

created_at { initial_visit_time }
updated_at { return_time }
end

# Trait for mobile session patterns
trait :mobile_session do
with_coordinates
# Mobile sessions typically have coordinates and are updated more frequently
end

# Trait for desktop session patterns
trait :desktop_session do
# Desktop sessions typically don't have coordinates
lat { nil }
long { nil }
end
end
end
Loading