diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 15:44:42 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 15:44:42 +0000 |
commit | 4555e1b21c365ed8303ffb7a3325d773c9b8bf31 (patch) | |
tree | 5423a1c7516cffe36384133ade12572cf709398d /spec/frontend/tracking_spec.js | |
parent | e570267f2f6b326480d284e0164a6464ba4081bc (diff) | |
download | gitlab-ce-4555e1b21c365ed8303ffb7a3325d773c9b8bf31.tar.gz |
Add latest changes from gitlab-org/gitlab@13-12-stable-eev13.12.0-rc42
Diffstat (limited to 'spec/frontend/tracking_spec.js')
-rw-r--r-- | spec/frontend/tracking_spec.js | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/frontend/tracking_spec.js b/spec/frontend/tracking_spec.js index 2c7bcaa98b0..dd4c8198b72 100644 --- a/spec/frontend/tracking_spec.js +++ b/spec/frontend/tracking_spec.js @@ -155,6 +155,32 @@ describe('Tracking', () => { }); }); + describe('.enableFormTracking', () => { + it('tells snowplow to enable form tracking', () => { + const config = { forms: { whitelist: [''] }, fields: { whitelist: [''] } }; + Tracking.enableFormTracking(config, ['_passed_context_']); + + expect(snowplowSpy).toHaveBeenCalledWith('enableFormTracking', config, [ + { data: { source: 'gitlab-javascript' }, schema: undefined }, + '_passed_context_', + ]); + }); + + it('throws an error if no whitelist rules are provided', () => { + const expectedError = new Error( + 'Unable to enable form event tracking without whitelist rules.', + ); + + expect(() => Tracking.enableFormTracking()).toThrow(expectedError); + expect(() => Tracking.enableFormTracking({ fields: { whitelist: [] } })).toThrow( + expectedError, + ); + expect(() => Tracking.enableFormTracking({ fields: { whitelist: [1] } })).not.toThrow( + expectedError, + ); + }); + }); + describe('.flushPendingEvents', () => { it('flushes any pending events', () => { Tracking.initialized = false; |