workarea-google_tag_manager 4.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +11 -0
  3. data/.rubocop.yml +37 -0
  4. data/CHANGELOG.md +100 -0
  5. data/Gemfile +14 -0
  6. data/README.md +339 -0
  7. data/Rakefile +65 -0
  8. data/app/assets/javascripts/workarea/storefront/google_tag_manager/modules/adapter.js +233 -0
  9. data/app/views/workarea/storefront/google_tag_manager/_no_script.html.haml +3 -0
  10. data/app/views/workarea/storefront/google_tag_manager/_script.html.haml +3 -0
  11. data/bin/rails +18 -0
  12. data/config/initializers/appends.rb +16 -0
  13. data/config/initializers/workarea.rb +3 -0
  14. data/lib/workarea/google_tag_manager.rb +60 -0
  15. data/lib/workarea/google_tag_manager/engine.rb +8 -0
  16. data/lib/workarea/google_tag_manager/version.rb +5 -0
  17. data/script/admin_ci +9 -0
  18. data/script/ci +11 -0
  19. data/script/core_ci +9 -0
  20. data/script/plugins_ci +9 -0
  21. data/script/storefront_ci +9 -0
  22. data/test/dummy/Rakefile +6 -0
  23. data/test/dummy/bin/bundle +3 -0
  24. data/test/dummy/bin/rails +4 -0
  25. data/test/dummy/bin/rake +4 -0
  26. data/test/dummy/bin/setup +34 -0
  27. data/test/dummy/bin/update +29 -0
  28. data/test/dummy/config.ru +5 -0
  29. data/test/dummy/config/application.rb +28 -0
  30. data/test/dummy/config/boot.rb +5 -0
  31. data/test/dummy/config/cable.yml +9 -0
  32. data/test/dummy/config/environment.rb +5 -0
  33. data/test/dummy/config/environments/development.rb +54 -0
  34. data/test/dummy/config/environments/production.rb +86 -0
  35. data/test/dummy/config/environments/test.rb +43 -0
  36. data/test/dummy/config/initializers/application_controller_renderer.rb +6 -0
  37. data/test/dummy/config/initializers/assets.rb +11 -0
  38. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  39. data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
  40. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  41. data/test/dummy/config/initializers/inflections.rb +16 -0
  42. data/test/dummy/config/initializers/mime_types.rb +4 -0
  43. data/test/dummy/config/initializers/new_framework_defaults.rb +21 -0
  44. data/test/dummy/config/initializers/session_store.rb +3 -0
  45. data/test/dummy/config/initializers/workarea.rb +5 -0
  46. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  47. data/test/dummy/config/locales/en.yml +23 -0
  48. data/test/dummy/config/puma.rb +47 -0
  49. data/test/dummy/config/routes.rb +5 -0
  50. data/test/dummy/config/secrets.yml +22 -0
  51. data/test/dummy/config/spring.rb +6 -0
  52. data/test/dummy/lib/assets/.keep +0 -0
  53. data/test/dummy/log/.keep +0 -0
  54. data/test/javascripts/fixtures/payloads.js +231 -0
  55. data/test/javascripts/google_tag_manager_spec.js +382 -0
  56. data/test/javascripts/spec_helper.js +5 -0
  57. data/test/teaspoon_env.rb +10 -0
  58. data/test/test_helper.rb +10 -0
  59. data/workarea-google_tag_manager.gemspec +18 -0
  60. metadata +151 -0
@@ -0,0 +1,3 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ Rails.application.config.session_store :cookie_store, key: '_dummy_session'
@@ -0,0 +1,5 @@
1
+ Workarea.configure do |config|
2
+ # Basic site info
3
+ config.site_name = 'Workarea Google Tag Manager'
4
+ config.host = 'www.example.com'
5
+ end
@@ -0,0 +1,14 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # This file contains settings for ActionController::ParamsWrapper which
4
+ # is enabled by default.
5
+
6
+ # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7
+ ActiveSupport.on_load(:action_controller) do
8
+ wrap_parameters format: [:json]
9
+ end
10
+
11
+ # To enable root element in JSON for ActiveRecord objects.
12
+ # ActiveSupport.on_load(:active_record) do
13
+ # self.include_root_in_json = true
14
+ # end
@@ -0,0 +1,23 @@
1
+ # Files in the config/locales directory are used for internationalization
2
+ # and are automatically loaded by Rails. If you want to use locales other
3
+ # than English, add the necessary files in this directory.
4
+ #
5
+ # To use the locales, use `I18n.t`:
6
+ #
7
+ # I18n.t 'hello'
8
+ #
9
+ # In views, this is aliased to just `t`:
10
+ #
11
+ # <%= t('hello') %>
12
+ #
13
+ # To use a different locale, set it with `I18n.locale`:
14
+ #
15
+ # I18n.locale = :es
16
+ #
17
+ # This would use the information in config/locales/es.yml.
18
+ #
19
+ # To learn more, please read the Rails Internationalization guide
20
+ # available at http://guides.rubyonrails.org/i18n.html.
21
+
22
+ en:
23
+ hello: "Hello world"
@@ -0,0 +1,47 @@
1
+ # Puma can serve each request in a thread from an internal thread pool.
2
+ # The `threads` method setting takes two numbers a minimum and maximum.
3
+ # Any libraries that use thread pools should be configured to match
4
+ # the maximum value specified for Puma. Default is set to 5 threads for minimum
5
+ # and maximum, this matches the default thread size of Active Record.
6
+ #
7
+ threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i
8
+ threads threads_count, threads_count
9
+
10
+ # Specifies the `port` that Puma will listen on to receive requests, default is 3000.
11
+ #
12
+ port ENV.fetch("PORT") { 3000 }
13
+
14
+ # Specifies the `environment` that Puma will run in.
15
+ #
16
+ environment ENV.fetch("RAILS_ENV") { "development" }
17
+
18
+ # Specifies the number of `workers` to boot in clustered mode.
19
+ # Workers are forked webserver processes. If using threads and workers together
20
+ # the concurrency of the application would be max `threads` * `workers`.
21
+ # Workers do not work on JRuby or Windows (both of which do not support
22
+ # processes).
23
+ #
24
+ # workers ENV.fetch("WEB_CONCURRENCY") { 2 }
25
+
26
+ # Use the `preload_app!` method when specifying a `workers` number.
27
+ # This directive tells Puma to first boot the application and load code
28
+ # before forking the application. This takes advantage of Copy On Write
29
+ # process behavior so workers use less memory. If you use this option
30
+ # you need to make sure to reconnect any threads in the `on_worker_boot`
31
+ # block.
32
+ #
33
+ # preload_app!
34
+
35
+ # The code in the `on_worker_boot` will be called if you are using
36
+ # clustered mode by specifying a number of `workers`. After each worker
37
+ # process is booted this block will be run, if you are using `preload_app!`
38
+ # option you will want to use this block to reconnect to any threads
39
+ # or connections that may have been created at application boot, Ruby
40
+ # cannot share connections between processes.
41
+ #
42
+ # on_worker_boot do
43
+ # ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
44
+ # end
45
+
46
+ # Allow puma to be restarted by `rails restart` command.
47
+ plugin :tmp_restart
@@ -0,0 +1,5 @@
1
+ Rails.application.routes.draw do
2
+ mount Workarea::Core::Engine => '/'
3
+ mount Workarea::Admin::Engine => '/admin', as: 'admin'
4
+ mount Workarea::Storefront::Engine => '/', as: 'storefront'
5
+ end
@@ -0,0 +1,22 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key is used for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+
6
+ # Make sure the secret is at least 30 characters and all random,
7
+ # no regular words or you'll be exposed to dictionary attacks.
8
+ # You can use `rails secret` to generate a secure secret key.
9
+
10
+ # Make sure the secrets in this file are kept private
11
+ # if you're sharing your code publicly.
12
+
13
+ development:
14
+ secret_key_base: 270afb934659470d02c777e8ca1bc0abd7f127b3b6bcdea6e2c93a32ad0bbd97fd591af5bd730a560cb9576a1512b8af19f83d532e6a19cb043a578ae4f3ba3a
15
+
16
+ test:
17
+ secret_key_base: 744d8b81e1f24bba29f0cd9601b59daff7a0c58a3be4db9a79923ac8f1438e95f286be4f08aa088ba6aaa97027a41d673b577e9cc5674bedb09e4bd2b0ffe73b
18
+
19
+ # Do not keep production secrets in the repository,
20
+ # instead read values from the environment.
21
+ production:
22
+ secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
@@ -0,0 +1,6 @@
1
+ %w(
2
+ .ruby-version
3
+ .rbenv-vars
4
+ tmp/restart.txt
5
+ tmp/caching-dev.txt
6
+ ).each { |path| Spring.watch(path) }
File without changes
File without changes
@@ -0,0 +1,231 @@
1
+ /*eslint no-unused-vars: 0 */
2
+ function productListPayload() {
3
+ return {
4
+ "name": "Electronics",
5
+ "page": 1,
6
+ "per_page": 20,
7
+ "impressions": [
8
+ {
9
+ "id": "4AF99AB7C8",
10
+ "name": "Heavy Duty Iron Bag",
11
+ "sku": "288457637-1",
12
+ "sale": false,
13
+ "price": 19.77,
14
+ "category": "Automotive",
15
+ "position": 0
16
+ },
17
+ {
18
+ "id": "A77BE95FD8",
19
+ "name": "Gorgeous Linen Computer",
20
+ "sku": "087096987-0",
21
+ "sale": false,
22
+ "price": 0.42,
23
+ "category": "Automotive",
24
+ "position": 1
25
+ },
26
+ {
27
+ "id": "CD2B8085BE",
28
+ "name": "Sleek Linen Gloves",
29
+ "sku": "441641257-6",
30
+ "sale": false,
31
+ "price": 18.67,
32
+ "category": "Automotive",
33
+ "position": 2
34
+ },
35
+ {
36
+ "id": "3034884ECA",
37
+ "name": "Durable Wool Hat",
38
+ "sku": "610796205-0",
39
+ "sale": false,
40
+ "price": 63.16,
41
+ "category": "Automotive",
42
+ "position": 3
43
+ },
44
+ {
45
+ "id": "3B35A19DFF",
46
+ "name": "Lightweight Rubber Coat",
47
+ "sku": "124560496-1",
48
+ "sale": false,
49
+ "price": 13.15,
50
+ "category": "Automotive",
51
+ "position": 4
52
+ },
53
+ {
54
+ "id": "F7BBD9B1D2",
55
+ "name": "Rustic Paper Keyboard",
56
+ "sku": "243345833-1",
57
+ "sale": false,
58
+ "price": 7.77,
59
+ "category": "Automotive",
60
+ "position": 5
61
+ },
62
+ {
63
+ "id": "5286E1F9EA",
64
+ "name": "Incredible Cotton Shirt",
65
+ "sku": "873666584-3",
66
+ "sale": false,
67
+ "price": 45.11,
68
+ "category": "Automotive",
69
+ "position": 6
70
+ },
71
+ {
72
+ "id": "E538866CFC",
73
+ "name": "Small Bronze Hat",
74
+ "sku": "710835615-5",
75
+ "sale": false,
76
+ "price": 12.34,
77
+ "category": "Automotive",
78
+ "position": 7
79
+ },
80
+ {
81
+ "id": "952B3D844B",
82
+ "name": "Aerodynamic Paper Clock",
83
+ "sku": "392558208-8",
84
+ "sale": false,
85
+ "price": 22.59,
86
+ "category": "Automotive",
87
+ "position": 8
88
+ },
89
+ {
90
+ "id": "B6BD620005",
91
+ "name": "Durable Iron Table",
92
+ "sku": "795417242-2",
93
+ "sale": false,
94
+ "price": 23.07,
95
+ "category": "Automotive",
96
+ "position": 9
97
+ },
98
+ {
99
+ "id": "546CB731CB",
100
+ "name": "Fantastic Leather Hat",
101
+ "sku": "857899444-2",
102
+ "sale": false,
103
+ "price": 29.59,
104
+ "category": "Automotive",
105
+ "position": 10
106
+ },
107
+ {
108
+ "id": "9FF7028768",
109
+ "name": "Gorgeous Leather Knife",
110
+ "sku": "887139418-6",
111
+ "sale": false,
112
+ "price": 42.41,
113
+ "category": "Automotive",
114
+ "position": 11
115
+ },
116
+ {
117
+ "id": "9F729D69C6",
118
+ "name": "Synergistic Copper Coat",
119
+ "sku": "423424193-8",
120
+ "sale": false,
121
+ "price": 29.59,
122
+ "category": "Automotive",
123
+ "position": 12
124
+ },
125
+ {
126
+ "id": "4011335B6B",
127
+ "name": "Intelligent Wool Clock",
128
+ "sku": "464990513-3",
129
+ "sale": false,
130
+ "price": 31.2,
131
+ "category": "Automotive",
132
+ "position": 13
133
+ },
134
+ {
135
+ "id": "B28798CDAD",
136
+ "name": "Durable Bronze Bag",
137
+ "sku": "547390027-5",
138
+ "sale": false,
139
+ "price": 12.46,
140
+ "category": "Automotive",
141
+ "position": 14
142
+ },
143
+ {
144
+ "id": "84EACAB9F7",
145
+ "name": "Lightweight Leather Bottle",
146
+ "sku": "027837187-6",
147
+ "sale": false,
148
+ "price": 17.47,
149
+ "category": "Automotive",
150
+ "position": 15
151
+ },
152
+ {
153
+ "id": "C02747F6C6",
154
+ "name": "Practical Wooden Coat",
155
+ "sku": "181342040-8",
156
+ "sale": false,
157
+ "price": 42.33,
158
+ "category": "Automotive",
159
+ "position": 16
160
+ },
161
+ {
162
+ "id": "44459088C3",
163
+ "name": "Gorgeous Linen Computer",
164
+ "sku": "226387489-5",
165
+ "sale": false,
166
+ "price": 24.9,
167
+ "category": "Automotive",
168
+ "position": 17
169
+ },
170
+ {
171
+ "id": "F1EDB5846B",
172
+ "name": "Mediocre Bronze Chair",
173
+ "sku": "380482668-7",
174
+ "sale": false,
175
+ "price": 20.55,
176
+ "category": "Automotive",
177
+ "position": 18
178
+ },
179
+ {
180
+ "id": "1A05D231CB",
181
+ "name": "Incredible Rubber Bag",
182
+ "sku": "050606049-7",
183
+ "sale": false,
184
+ "price": 10.02,
185
+ "category": "Automotive",
186
+ "position": 19
187
+ }
188
+ ]
189
+ };
190
+ }
191
+
192
+ function orderPayload() {
193
+ return {
194
+ "site_name": "Dummy App",
195
+ "id": "6705E78231",
196
+ "promo_codes": ['promo_1', 'promo_2'],
197
+ "shipping_service": "Ground",
198
+ "shipping_total": 7.0,
199
+ "tax_total": 0.0,
200
+ "total_price": 152.92,
201
+ "tenders": [],
202
+ "items": [
203
+ {
204
+ "id": "5964ef7d9d1fa2f1d0626c86",
205
+ "product_id": "4AF99AB7C8",
206
+ "product_name": "Heavy Duty Iron Bag",
207
+ "sku": "288457637-1",
208
+ "options": {
209
+ "Size": "Medium",
210
+ "Color": "Silver"
211
+ },
212
+ "price": 80.76,
213
+ "quantity": 1,
214
+ "category": "Automotive"
215
+ },
216
+ {
217
+ "id": "595fbf819d1fa2b3a0c4bd00",
218
+ "product_id": "F7BBD9B1D2",
219
+ "product_name": "Rustic Paper Keyboard",
220
+ "sku": "517371131-0",
221
+ "options": {
222
+ "Size": "Small",
223
+ "Color": "Fuchsia"
224
+ },
225
+ "price": 65.16,
226
+ "quantity": 1,
227
+ "category": "Automotive"
228
+ }
229
+ ]
230
+ };
231
+ }
@@ -0,0 +1,382 @@
1
+ /* global productListPayload, orderPayload */
2
+ (function () {
3
+ 'use strict';
4
+
5
+ function teardown() {
6
+ window.dataLayer = [];
7
+ }
8
+
9
+ describe('WORKAREA.googleTagManager', function () {
10
+ describe('setup', function () {
11
+ it('Adds a dataLayer to the window', function () {
12
+ expect(window.dataLayer).to.be.an('array');
13
+ });
14
+ });
15
+
16
+ describe('categoryView', function () {
17
+ before(function(){
18
+ WORKAREA.analytics.fireCallback('categoryView',
19
+ {
20
+ "name" : "Games",
21
+ "sort" : "top_sellers",
22
+ "page" : 1,
23
+ "filters" : {}
24
+ }
25
+ );
26
+ });
27
+
28
+ it('pushes the category view event to the dataLayer', function () {
29
+ expect(window.dataLayer[0].event).to.eq('categoryView');
30
+ });
31
+
32
+ it('adds the payload to the dataLayer', function () {
33
+ expect(window.dataLayer[0].name).to.eq('Games');
34
+ expect(window.dataLayer[0].sort).to.eq('top_sellers');
35
+ expect(window.dataLayer[0].page).to.eq(1);
36
+ });
37
+
38
+ after(teardown);
39
+ });
40
+
41
+ describe('searchResultsView', function () {
42
+ before(function(){
43
+ WORKAREA.analytics.fireCallback('searchResultsView',
44
+ {
45
+ "terms" : "query string",
46
+ "sort" : "relevance",
47
+ "page" : 1,
48
+ }
49
+ );
50
+ });
51
+
52
+ it('pushes the searchResultsView event to the dataLayer', function () {
53
+ expect(window.dataLayer[0].event).to.eq('searchResultsView');
54
+ });
55
+
56
+ it('adds the payload to the dataLayer', function () {
57
+ expect(window.dataLayer[0].terms).to.eq('query string');
58
+ expect(window.dataLayer[0].sort).to.eq('relevance');
59
+ expect(window.dataLayer[0].page).to.eq(1);
60
+ });
61
+
62
+ after(teardown);
63
+ });
64
+
65
+ describe('productList', function () {
66
+ before(function(){
67
+ WORKAREA.analytics.fireCallback('productList', productListPayload());
68
+ });
69
+
70
+ it('pushes an ecommerce event for impressions to the dataLayer', function () {
71
+ expect(window.dataLayer[0].ecommerce.impressions).to.exist;
72
+ expect(window.dataLayer[0].ecommerce.impressions.length).to.eq(20);
73
+ });
74
+
75
+ after(teardown);
76
+ });
77
+
78
+
79
+ describe('productClick', function () {
80
+ before(function(){
81
+ WORKAREA.analytics.fireCallback('productClick',
82
+ {
83
+ 'category' : "Automotive",
84
+ 'id' : "4AF99AB7C8",
85
+ 'list' : "Movies & Shoes",
86
+ 'name' : "Heavy Duty Iron Bag",
87
+ 'position' : 0,
88
+ 'price' : 19.77,
89
+ 'sale' : false,
90
+ 'sku' : "288457637-1"
91
+ }
92
+ );
93
+ });
94
+
95
+ it('pushes the productClick event to the dataLayer', function () {
96
+ expect(window.dataLayer[0].event).to.eq('productClick');
97
+ });
98
+
99
+ it('announces ecommerce event to the dataLayer with correct data', function () {
100
+ var ecommerceEvent = window.dataLayer[0].ecommerce,
101
+ product = ecommerceEvent.click.products[0];
102
+
103
+ expect(ecommerceEvent).to.exist;
104
+
105
+ expect(ecommerceEvent.click.actionField.list).to.eq('Movies & Shoes');
106
+ expect(product.name).to.eq('Heavy Duty Iron Bag');
107
+ expect(product.id).to.eq('4AF99AB7C8');
108
+ expect(product.price).to.eq(19.77);
109
+ expect(product.category).to.eq('Automotive');
110
+ expect(product.variant).to.eq('288457637-1');
111
+ expect(product.position).to.eq(0);
112
+ });
113
+
114
+ after(teardown);
115
+ });
116
+
117
+
118
+ describe('productQuickView', function () {
119
+ before(function(){
120
+ WORKAREA.analytics.fireCallback('productQuickView',
121
+ {
122
+ "terms" : "query string",
123
+ "sort" : "top_sellers",
124
+ "page" : 1,
125
+ }
126
+ );
127
+ });
128
+
129
+ it('pushes the quickview event to the dataLayer', function () {
130
+ expect(window.dataLayer[0].event).to.eq('quickview');
131
+ });
132
+
133
+ after(teardown);
134
+ });
135
+
136
+
137
+ describe('productView', function () {
138
+ before(function(){
139
+ WORKAREA.analytics.fireCallback('productView',
140
+ {
141
+ 'category' : 'Automotive',
142
+ 'id' : '4AF99AB7C8',
143
+ 'name' : 'Heavy Duty Iron Bag',
144
+ 'price' : 80.76,
145
+ 'quantity' : '1',
146
+ 'sale' : false,
147
+ 'sku' : '288457637-1'
148
+ }
149
+ );
150
+ });
151
+
152
+ it('pushes an ecommerce detail event to the dataLayer', function () {
153
+ expect(window.dataLayer[0].ecommerce.detail).to.exist;
154
+ });
155
+
156
+ it('announces the products details in the ecommerce event', function () {
157
+ var product = window.dataLayer[0].ecommerce.detail.products[0];
158
+ expect(product.name).to.eq('Heavy Duty Iron Bag');
159
+ expect(product.id).to.eq('4AF99AB7C8');
160
+ expect(product.price).to.eq(80.76);
161
+ expect(product.category).to.eq('Automotive');
162
+ expect(product.variant).to.eq('288457637-1');
163
+ });
164
+
165
+ after(teardown);
166
+ });
167
+
168
+ describe('addToCart', function () {
169
+ before(function(){
170
+ WORKAREA.analytics.fireCallback('addToCart',
171
+ {
172
+ 'category' : 'Automotive',
173
+ 'id' : '4AF99AB7C8',
174
+ 'name' : 'Heavy Duty Iron Bag',
175
+ 'price' : 80.76,
176
+ 'quantity' : '1',
177
+ 'sale' : false,
178
+ 'sku' : '288457637-1'
179
+ }
180
+ );
181
+ });
182
+
183
+ it('pushes the addToCart event to the dataLayer', function () {
184
+ expect(window.dataLayer[0].event).to.eq('addToCart');
185
+ });
186
+
187
+ it('announces an ecommerce add event with product data to the dataLayer', function () {
188
+ expect(window.dataLayer[0].ecommerce.add).to.exist;
189
+ });
190
+
191
+ it('adds correct product data in dataLayer', function () {
192
+ var product = window.dataLayer[0].ecommerce.add.products[0];
193
+ expect(product.name).to.eq('Heavy Duty Iron Bag');
194
+ expect(product.id).to.eq('4AF99AB7C8');
195
+ expect(product.category).to.eq('Automotive');
196
+ expect(product.variant).to.eq('288457637-1');
197
+ expect(product.price).to.eq(80.76);
198
+ expect(product.quantity).to.eq('1');
199
+ });
200
+
201
+ after(teardown);
202
+ });
203
+
204
+ describe('removeFromCart', function () {
205
+ before(function(){
206
+ WORKAREA.analytics.fireCallback('removeFromCart',
207
+ {
208
+ 'category' : 'Automotive',
209
+ 'id' : '4AF99AB7C8',
210
+ 'name' : 'Heavy Duty Iron Bag',
211
+ 'price' : 80.76,
212
+ 'quantity' : '1',
213
+ 'sale' : false,
214
+ 'sku' : '288457637-1'
215
+ }
216
+ );
217
+ });
218
+
219
+ it('pushes the removeFromCart event to the dataLayer', function () {
220
+ expect(window.dataLayer[0].event).to.eq('removeFromCart');
221
+ });
222
+
223
+ it('announces an ecommerce add event with product data to the dataLayer', function () {
224
+ expect(window.dataLayer[0].ecommerce.remove).to.exist;
225
+ });
226
+
227
+ it('adds correct product data in dataLayer', function () {
228
+ var product = window.dataLayer[0].ecommerce.remove.products[0];
229
+ expect(product.name).to.eq('Heavy Duty Iron Bag');
230
+ expect(product.id).to.eq('4AF99AB7C8');
231
+ expect(product.category).to.eq('Automotive');
232
+ expect(product.variant).to.eq('288457637-1');
233
+ expect(product.price).to.eq(80.76);
234
+ expect(product.quantity).to.eq('1');
235
+ });
236
+
237
+ after(teardown);
238
+ });
239
+
240
+ describe('cartView', function () {
241
+ before(function(){
242
+ WORKAREA.analytics.fireCallback('cartView', orderPayload());
243
+ });
244
+
245
+ it('announces a checkout event in the dataLayer', function () {
246
+ expect(window.dataLayer[0].event).to.eq('checkout');
247
+ });
248
+
249
+ it('announces a checkout enhanced ecommerce event in the dataLayer', function () {
250
+ expect(window.dataLayer[0].ecommerce.checkout).to.exist;
251
+ });
252
+
253
+ it('announces step 1 of checkout in the dataLayer', function () {
254
+ var step = window.dataLayer[0].ecommerce.checkout.actionField.step;
255
+ expect(step).to.eq(1);
256
+ });
257
+
258
+ after(teardown);
259
+ });
260
+
261
+ describe('checkoutAddressesView', function () {
262
+ before(function(){
263
+ WORKAREA.analytics.fireCallback('checkoutAddressesView',orderPayload());
264
+ });
265
+
266
+ it('announces a checkout event in the dataLayer', function () {
267
+ expect(window.dataLayer[0].event).to.eq('checkout');
268
+ });
269
+
270
+ it('announces step 2 of checkout in the dataLayer', function () {
271
+ var step = window.dataLayer[0].ecommerce.checkout.actionField.step;
272
+ expect(step).to.eq(2);
273
+ });
274
+
275
+ after(teardown);
276
+ });
277
+
278
+ describe('checkoutShippingView', function () {
279
+ before(function(){
280
+ WORKAREA.analytics.fireCallback('checkoutShippingView', orderPayload());
281
+ });
282
+
283
+ it('announces a checkout event in the dataLayer', function () {
284
+ expect(window.dataLayer[0].event).to.eq('checkout');
285
+ });
286
+
287
+ it('announces step 3 of checkout in the dataLayer', function () {
288
+ var step = window.dataLayer[0].ecommerce.checkout.actionField.step;
289
+ expect(step).to.eq(3);
290
+ });
291
+
292
+ after(teardown);
293
+ });
294
+
295
+ describe('checkoutShippingServiceSelected', function () {
296
+ before(function(){
297
+ WORKAREA.analytics.fireCallback('checkoutShippingServiceSelected',
298
+ {
299
+ "name" : "Ground",
300
+ 'price' : 7
301
+ }
302
+ );
303
+ });
304
+
305
+ it('announces a checkoutOption event in the dataLayer', function () {
306
+ expect(window.dataLayer[0].event).to.eq('checkoutOption');
307
+ });
308
+
309
+ it('adds the shipping service to the dataLayer', function () {
310
+ var actionField = window.dataLayer[0].ecommerce.checkout_option.actionField;
311
+
312
+ expect(actionField.step).to.eq(3);
313
+ expect(actionField.option).to.eq('Ground');
314
+ });
315
+
316
+ after(teardown);
317
+ });
318
+
319
+ describe('checkoutPaymentView', function() {
320
+ before(function(){
321
+ WORKAREA.analytics.fireCallback('checkoutPaymentView',orderPayload());
322
+ });
323
+
324
+ it('announces a checkout event in the dataLayer', function () {
325
+ expect(window.dataLayer[0].event).to.eq('checkout');
326
+ });
327
+
328
+ it('announces step 4 of checkout in the dataLayer', function () {
329
+ var step = window.dataLayer[0].ecommerce.checkout.actionField.step;
330
+ expect(step).to.eq(4);
331
+ });
332
+
333
+ after(teardown);
334
+ });
335
+
336
+ describe('checkoutPaymentSelected', function () {
337
+ before(function(){
338
+ WORKAREA.analytics.fireCallback('checkoutPaymentSelected',
339
+ {
340
+ "type" : "new_card"
341
+ }
342
+ );
343
+ });
344
+
345
+ it('announces a checkoutOption event in the dataLayer', function () {
346
+ expect(window.dataLayer[0].event).to.eq('checkoutOption');
347
+ });
348
+
349
+ it('adds the payment method to the dataLayer', function () {
350
+ var actionField = window.dataLayer[0].ecommerce.checkout_option.actionField;
351
+
352
+ expect(actionField.step).to.eq(4);
353
+ expect(actionField.option).to.eq('new_card');
354
+ });
355
+
356
+ after(teardown);
357
+ });
358
+
359
+ describe('checkoutOrderPlaced', function () {
360
+ before(function(){
361
+ WORKAREA.analytics.fireCallback('checkoutOrderPlaced', orderPayload());
362
+ });
363
+
364
+ it('announces an ecommerce purchase event in the dataLayer', function () {
365
+ expect(window.dataLayer[0].ecommerce.purchase).to.exist;
366
+ });
367
+
368
+ it('announces transaction data in dataLayer', function() {
369
+ var actionField = window.dataLayer[0].ecommerce.purchase.actionField;
370
+
371
+ expect(actionField.id).to.eq('6705E78231');
372
+ expect(actionField.affiliation).to.eq('Dummy App');
373
+ expect(actionField.revenue).to.eq(152.92);
374
+ expect(actionField.tax).to.eq(0.00);
375
+ expect(actionField.shipping).to.eq(7.00);
376
+ expect(actionField.coupon).to.eq('promo_1,promo_2');
377
+ });
378
+
379
+ after(teardown);
380
+ });
381
+ });
382
+ }());