@eturnity/eturnity_reusable_components 8.19.8-EPIC-8593.1 → 8.19.8-EPIC-8593.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eturnity/eturnity_reusable_components",
3
- "version": "8.19.8-EPIC-8593.1",
3
+ "version": "8.19.8-EPIC-8593.2",
4
4
  "files": [
5
5
  "dist",
6
6
  "src"
@@ -0,0 +1,101 @@
1
+ /* eslint-disable */
2
+ import { mount } from '@vue/test-utils'
3
+ import TabsHeader from './index.vue'
4
+ import theme from '@/assets/theme'
5
+
6
+ jest.mock('@/components/icon/iconCache.mjs', () => ({
7
+ // need to mock this due to how jest handles import.meta
8
+ fetchIcon: jest.fn(() => Promise.resolve('')),
9
+ }))
10
+
11
+ describe('TabsHeader', () => {
12
+ const mockTabsData = [
13
+ {
14
+ text: 'Tab 1',
15
+ id: 0,
16
+ hasError: true,
17
+ icon: 'home',
18
+ subText: 'Subtext 1',
19
+ },
20
+ {
21
+ text: 'Tab 2',
22
+ id: 1,
23
+ hasError: false,
24
+ icon: 'settings',
25
+ subText: 'Subtext 2',
26
+ },
27
+ ]
28
+
29
+ const createWrapper = (props = {}) => {
30
+ return mount(TabsHeader, {
31
+ props: {
32
+ tabsData: mockTabsData,
33
+ activeTab: 0,
34
+ fullSize: true,
35
+ ...props,
36
+ },
37
+ global: {
38
+ mocks: {
39
+ theme,
40
+ },
41
+ },
42
+ })
43
+ }
44
+
45
+ it('renders all tabs correctly', () => {
46
+ const wrapper = createWrapper()
47
+ const tabs = wrapper.findAll('[data-test-id="tab-item"]')
48
+ expect(tabs).toHaveLength(mockTabsData.length)
49
+ })
50
+
51
+ it('displays correct tab text', () => {
52
+ const wrapper = createWrapper()
53
+ const firstTab = wrapper.find('[data-test-id="tab-text"]')
54
+ expect(firstTab.text()).toBe('Tab 1')
55
+ })
56
+
57
+ it('emits on-tab-change event when clicking a tab', async () => {
58
+ const wrapper = createWrapper()
59
+ const tabs = wrapper.findAll('[data-test-id="tab-item"]')
60
+ await tabs[1].trigger('click')
61
+ expect(wrapper.emitted('on-tab-change')).toBeTruthy()
62
+ expect(wrapper.emitted('on-tab-change')[0]).toEqual([1])
63
+ })
64
+
65
+ it('does not emit on-tab-change when clicking active tab', async () => {
66
+ const wrapper = createWrapper()
67
+ const activeTab = wrapper.find('[data-test-id="tab-item"]')
68
+ await activeTab.trigger('click')
69
+ expect(wrapper.emitted('on-tab-change')).toBeFalsy()
70
+ })
71
+
72
+ it('applies correct styles for active tab', () => {
73
+ const wrapper = createWrapper()
74
+ const activeTab = wrapper.find('[data-test-active="true"]')
75
+ expect(activeTab.exists()).toBe(true)
76
+ })
77
+
78
+ it('renders error icon when tab has error', () => {
79
+ const wrapper = createWrapper()
80
+ const warningIcon = wrapper.find('[data-test-id="warning-icon"]')
81
+ expect(warningIcon.exists()).toBe(true)
82
+ })
83
+
84
+ it('renders subtext when provided', () => {
85
+ const wrapper = createWrapper()
86
+ const subtext = wrapper.find('[data-test-id="tab-subtext"]')
87
+ expect(subtext.text()).toBe('Subtext 1')
88
+ })
89
+
90
+ it('renders icon when provided', () => {
91
+ const wrapper = createWrapper()
92
+ const icon = wrapper.find('[data-test-id="tab-icon"]')
93
+ expect(icon.exists()).toBe(true)
94
+ })
95
+
96
+ it('applies fullSize prop correctly', () => {
97
+ const wrapper = createWrapper({ fullSize: true })
98
+ const tabs = wrapper.findAll('[data-test-id="tab-item"]')
99
+ expect(tabs.length).toBeGreaterThan(0)
100
+ })
101
+ })
@@ -1,10 +1,12 @@
1
1
  <template>
2
- <PageContainer>
3
- <TabsContainer>
2
+ <PageContainer data-test-id="tabs-header-container">
3
+ <TabsContainer data-test-id="tabs-container">
4
4
  <TabItem
5
5
  v-for="item in tabsData"
6
6
  :key="item.id"
7
7
  :data-id="item.dataId"
8
+ :data-test-active="activeTab === item.id"
9
+ data-test-id="tab-item"
8
10
  :full-size="fullSize"
9
11
  :is-active="activeTab === item.id"
10
12
  @click="onTabClick({ id: item.id })"
@@ -16,6 +18,7 @@
16
18
  ? theme.semanticColors.purple[500]
17
19
  : theme.semanticColors.teal[800]
18
20
  "
21
+ data-test-id="tab-icon"
19
22
  :hovered-color="
20
23
  activeTab === item.id
21
24
  ? theme.semanticColors.purple[500]
@@ -24,10 +27,21 @@
24
27
  :name="item.icon"
25
28
  size="14px"
26
29
  />
27
- <div>{{ item.text }}</div>
28
- <DotIcon v-if="item.subText" :is-active="activeTab === item.id" />
29
- <SubText v-if="item.subText">{{ item.subText }}</SubText>
30
- <RCIcon v-if="item.hasError" name="warning" size="14px" />
30
+ <div data-test-id="tab-text">{{ item.text }}</div>
31
+ <DotIcon
32
+ v-if="item.subText"
33
+ data-test-id="dot-icon"
34
+ :is-active="activeTab === item.id"
35
+ />
36
+ <SubText v-if="item.subText" data-test-id="tab-subtext">{{
37
+ item.subText
38
+ }}</SubText>
39
+ <RCIcon
40
+ v-if="item.hasError"
41
+ data-test-id="warning-icon"
42
+ name="warning"
43
+ size="14px"
44
+ />
31
45
  </TabItem>
32
46
  </TabsContainer>
33
47
  </PageContainer>
@@ -112,7 +126,6 @@
112
126
  components: {
113
127
  PageContainer,
114
128
  TabsContainer,
115
- NameContainer,
116
129
  TabItem,
117
130
  SubText,
118
131
  DotIcon,