summaryrefslogtreecommitdiff
path: root/spec/frontend/tracking_spec.js
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-05-19 15:44:42 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-05-19 15:44:42 +0000
commit4555e1b21c365ed8303ffb7a3325d773c9b8bf31 (patch)
tree5423a1c7516cffe36384133ade12572cf709398d /spec/frontend/tracking_spec.js
parente570267f2f6b326480d284e0164a6464ba4081bc (diff)
downloadgitlab-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.js26
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;