Commit c38a3cdc authored by Olena Horal-Koretska's avatar Olena Horal-Koretska

Merge branch 'tracking-event-value-2' into 'master'

Tracking event value spec fixes

See merge request gitlab-org/gitlab!62805
parents f21dd104 0c173189
...@@ -204,7 +204,7 @@ Below is a list of supported `data-track-*` attributes: ...@@ -204,7 +204,7 @@ Below is a list of supported `data-track-*` attributes:
| `data-track-action` | true | Action the user is taking. Clicks must be prepended with `click` and activations must be prepended with `activate`. For example, focusing a form field would be `activate_form_input` and clicking a button would be `click_button`. Replaces `data-track-event`, which was [deprecated](https://gitlab.com/gitlab-org/gitlab/-/issues/290962) in GitLab 13.11. | | `data-track-action` | true | Action the user is taking. Clicks must be prepended with `click` and activations must be prepended with `activate`. For example, focusing a form field would be `activate_form_input` and clicking a button would be `click_button`. Replaces `data-track-event`, which was [deprecated](https://gitlab.com/gitlab-org/gitlab/-/issues/290962) in GitLab 13.11. |
| `data-track-label` | false | The `label` as described in our [Structured event taxonomy](#structured-event-taxonomy). | | `data-track-label` | false | The `label` as described in our [Structured event taxonomy](#structured-event-taxonomy). |
| `data-track-property` | false | The `property` as described in our [Structured event taxonomy](#structured-event-taxonomy). | | `data-track-property` | false | The `property` as described in our [Structured event taxonomy](#structured-event-taxonomy). |
| `data-track-value` | false | The `value` as described in our [Structured event taxonomy](#structured-event-taxonomy). If omitted, this is the element's `value` property or an empty string. For checkboxes, the default value is the element's checked attribute or `false` when unchecked. | | `data-track-value` | false | The `value` as described in our [Structured event taxonomy](#structured-event-taxonomy). If omitted, this is the element's `value` property or `undefined`. For checkboxes, the default value is the element's checked attribute or `0` when unchecked. |
| `data-track-extra` | false | A key-value pairs object passed as a valid JSON string. This is added to the `extra` property in our [`gitlab_standard`](#gitlab_standard) schema. | | `data-track-extra` | false | A key-value pairs object passed as a valid JSON string. This is added to the `extra` property in our [`gitlab_standard`](#gitlab_standard) schema. |
| `data-track-context` | false | The `context` as described in our [Structured event taxonomy](#structured-event-taxonomy). | | `data-track-context` | false | The `context` as described in our [Structured event taxonomy](#structured-event-taxonomy). |
...@@ -369,7 +369,7 @@ button.addEventListener('click', () => { ...@@ -369,7 +369,7 @@ button.addEventListener('click', () => {
property: 'template_preview', property: 'template_preview',
extra: { extra: {
templateVariant: 'primary', templateVariant: 'primary',
valid: true, valid: 1,
}, },
}); });
}); });
......
...@@ -231,9 +231,9 @@ describe('Tracking', () => { ...@@ -231,9 +231,9 @@ describe('Tracking', () => {
eventSpy = jest.spyOn(Tracking, 'event'); eventSpy = jest.spyOn(Tracking, 'event');
Tracking.bindDocument('_category_'); // only happens once Tracking.bindDocument('_category_'); // only happens once
setHTMLFixture(` setHTMLFixture(`
<input data-track-${term}="click_input1" data-track-label="_label_" value="_value_"/> <input data-track-${term}="click_input1" data-track-label="_label_" value=0 />
<input data-track-${term}="click_input2" data-track-value="_value_override_" value=0/> <input data-track-${term}="click_input2" data-track-value=0 value=0/>
<input type="checkbox" data-track-${term}="toggle_checkbox" value="_value_" checked/> <input type="checkbox" data-track-${term}="toggle_checkbox" value=1 checked/>
<input class="dropdown" data-track-${term}="toggle_dropdown"/> <input class="dropdown" data-track-${term}="toggle_dropdown"/>
<div data-track-${term}="nested_event"><span class="nested"></span></div> <div data-track-${term}="nested_event"><span class="nested"></span></div>
<input data-track-bogus="click_bogusinput" data-track-label="_label_" value="_value_"/> <input data-track-bogus="click_bogusinput" data-track-label="_label_" value="_value_"/>
...@@ -248,7 +248,7 @@ describe('Tracking', () => { ...@@ -248,7 +248,7 @@ describe('Tracking', () => {
expect(eventSpy).toHaveBeenCalledWith('_category_', 'click_input1', { expect(eventSpy).toHaveBeenCalledWith('_category_', 'click_input1', {
label: '_label_', label: '_label_',
value: '_value_', value: '0',
}); });
}); });
...@@ -262,7 +262,7 @@ describe('Tracking', () => { ...@@ -262,7 +262,7 @@ describe('Tracking', () => {
document.querySelector(`[data-track-${term}="click_input2"]`).click(); document.querySelector(`[data-track-${term}="click_input2"]`).click();
expect(eventSpy).toHaveBeenCalledWith('_category_', 'click_input2', { expect(eventSpy).toHaveBeenCalledWith('_category_', 'click_input2', {
value: '_value_override_', value: '0',
}); });
}); });
...@@ -278,7 +278,7 @@ describe('Tracking', () => { ...@@ -278,7 +278,7 @@ describe('Tracking', () => {
checkbox.click(); // checking checkbox.click(); // checking
expect(eventSpy).toHaveBeenCalledWith('_category_', 'toggle_checkbox', { expect(eventSpy).toHaveBeenCalledWith('_category_', 'toggle_checkbox', {
value: '_value_', value: '1',
}); });
}); });
...@@ -341,8 +341,8 @@ describe('Tracking', () => { ...@@ -341,8 +341,8 @@ describe('Tracking', () => {
beforeEach(() => { beforeEach(() => {
eventSpy = jest.spyOn(Tracking, 'event'); eventSpy = jest.spyOn(Tracking, 'event');
setHTMLFixture(` setHTMLFixture(`
<input data-track-${term}="render" data-track-label="label1" value="_value_" data-track-property="_property_"/> <input data-track-${term}="render" data-track-label="label1" value=1 data-track-property="_property_"/>
<span data-track-${term}="render" data-track-label="label2" data-track-value="_value_"> <span data-track-${term}="render" data-track-label="label2" data-track-value=1>
Something Something
</span> </span>
<input data-track-${term}="_render_bogus_" data-track-label="label3" value="_value_" data-track-property="_property_"/> <input data-track-${term}="_render_bogus_" data-track-label="label3" value="_value_" data-track-property="_property_"/>
...@@ -357,7 +357,7 @@ describe('Tracking', () => { ...@@ -357,7 +357,7 @@ describe('Tracking', () => {
'render', 'render',
{ {
label: 'label1', label: 'label1',
value: '_value_', value: '1',
property: '_property_', property: '_property_',
}, },
], ],
...@@ -366,7 +366,7 @@ describe('Tracking', () => { ...@@ -366,7 +366,7 @@ describe('Tracking', () => {
'render', 'render',
{ {
label: 'label2', label: 'label2',
value: '_value_', value: '1',
}, },
], ],
]); ]);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment