summaryrefslogtreecommitdiff
path: root/spec/frontend/super_sidebar
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-03-28 15:08:36 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2023-03-28 15:08:36 +0000
commitee7db70e1185876e97eca97ce8efabfc64c360b9 (patch)
tree4c09297635be43c0189a2a85dd2a38d5f72bc523 /spec/frontend/super_sidebar
parent3fa33c82f9c49f4b53ddcf017fe77f1bff48a460 (diff)
downloadgitlab-ce-ee7db70e1185876e97eca97ce8efabfc64c360b9.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/super_sidebar')
-rw-r--r--spec/frontend/super_sidebar/components/nav_item_spec.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/frontend/super_sidebar/components/nav_item_spec.js b/spec/frontend/super_sidebar/components/nav_item_spec.js
index 22989c1a5f9..f273e45bf23 100644
--- a/spec/frontend/super_sidebar/components/nav_item_spec.js
+++ b/spec/frontend/super_sidebar/components/nav_item_spec.js
@@ -1,6 +1,7 @@
import { GlBadge } from '@gitlab/ui';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import NavItem from '~/super_sidebar/components/nav_item.vue';
+import { CLICK_MENU_ITEM_ACTION, TRACKING_UNKNOWN_ID } from '~/super_sidebar/constants';
describe('NavItem component', () => {
let wrapper;
@@ -46,4 +47,33 @@ describe('NavItem component', () => {
expect(findLink().attributes('class')).toContain(customClass);
});
+
+ describe('Data Tracking Attributes', () => {
+ it('adds no labels on sections', () => {
+ const id = 'my-id';
+ createWrapper({ title: 'Foo', id, items: [{ title: 'Baz' }] });
+
+ expect(findLink().attributes('data-track-action')).toBeUndefined();
+ expect(findLink().attributes('data-track-label')).toBeUndefined();
+ expect(findLink().attributes('data-track-extra')).toBeUndefined();
+ });
+
+ it('adds appropriate data tracking labels on links with ID', () => {
+ const id = 'my-id';
+ createWrapper({ title: 'Foo', id });
+
+ expect(findLink().attributes('data-track-action')).toBe(CLICK_MENU_ITEM_ACTION);
+ expect(findLink().attributes('data-track-label')).toBe(id);
+ expect(findLink().attributes('data-track-extra')).toBeUndefined();
+ });
+
+ it('adds data tracking labels on links without id', () => {
+ const title = 'Foo';
+ createWrapper({ title });
+
+ expect(findLink().attributes('data-track-action')).toBe(CLICK_MENU_ITEM_ACTION);
+ expect(findLink().attributes('data-track-label')).toBe(TRACKING_UNKNOWN_ID);
+ expect(findLink().attributes('data-track-extra')).toBe(JSON.stringify({ title }));
+ });
+ });
});