Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix angular tests #2466

Merged
merged 1 commit into from
Dec 23, 2024
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
15 changes: 5 additions & 10 deletions app/assets/javascripts/shared/AnalyticsService.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,15 @@ AnalyticsService = ($state) ->
Service = {}
Service.timer = {}

Service.resetProperties = {
# Any properties that should be reset on each event
}

Service.trackEvent = (event, properties) ->
dataLayer = window.dataLayer || []
combinedProperties = Object.assign({}, Service.resetProperties, properties)
unless combinedProperties.label
unless properties.label
# by default, grab the end of the URL e.g. the "contact" from "/x/y/z/contact"
current_path = _.first(_.last($state.current.url.split('/')).split('?'))
combinedProperties.label = current_path
combinedProperties.event = event
combinedProperties.event_timestamp = new Date().toISOString();
dataLayer.push(combinedProperties)
properties.label = current_path
properties.event = event
properties.event_timestamp = new Date().toISOString();
dataLayer.push(properties)
Comment on lines 9 to +17
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I wanted to keep the resetProperties object around, but it was causing issues with the tests so I figured it was more trouble than it was worth


# Tracks the current page as the user navigates
Service.trackCurrentPage = ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -916,8 +916,8 @@ ShortFormApplicationController = (
if $window.ACCOUNT_INFORMATION_PAGES_REACT is "true"
$window.removeEventListener('beforeunload', ShortFormApplicationService.onExit)
$window.removeEventListener('unload', $scope.onUnload)

AnalyticsService.trackApplicationAbandon($scope.listing.Id, AccountService.loggedInUser.id, 'Logged In Save and Finish Later')
# user id should always be present, but we are being cautious
AnalyticsService.trackApplicationAbandon($scope.listing.Id, AccountService.loggedInUser?.id, 'Logged In Save and Finish Later')
# ShortFormNavigationService.isLoading(false) will happen after My Apps are loaded
# go to my applications without tracking Form Success
$scope.go('dahlia.my-applications', {skipConfirm: true})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ do ->
trackFormSuccess: jasmine.createSpy()
trackFormError: jasmine.createSpy()
trackFormAbandon: jasmine.createSpy()
trackApplicationStart: jasmine.createSpy()
trackApplicationComplete: jasmine.createSpy()
trackApplicationAbandon: jasmine.createSpy()
fakeShortFormApplicationService =
form:
applicationForm:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ do ->
describe 'goToApplicationPage', ->
it 'calls AnalyticsService.trackFormSuccess with "Application"', ->
ShortFormNavigationService.goToApplicationPage()
expect(fakeAnalyticsService.trackFormSuccess).toHaveBeenCalledWith('Application')
expect(fakeAnalyticsService.trackFormSuccess).toHaveBeenCalledWith('Application Page View')

describe 'when params are not provided', ->
it 'calls $state.go with the given path', ->
Expand Down
Loading