@eturnity/eturnity_reusable_components 7.39.4-EPDM-11717.0 → 7.39.4-EPDM-10609.1

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eturnity/eturnity_reusable_components",
3
- "version": "7.39.4-EPDM-11717.0",
3
+ "version": "7.39.4-EPDM-10609.1",
4
4
  "files": [
5
5
  "dist",
6
6
  "src"
@@ -63,6 +63,7 @@
63
63
  "jest-styled-components": "7.2.0",
64
64
  "jsdom": "24.1.1",
65
65
  "prettier": "2.8.4",
66
+ "styled-components": "^6.1.13",
66
67
  "vite": "4.0.0",
67
68
  "vite-svg-loader": "5.1.0",
68
69
  "vue-jest": "5.0.0-alpha.10",
@@ -11,6 +11,7 @@ const theme = {
11
11
  lightGray: '#f2f2f2',
12
12
  white: '#ffffff',
13
13
  blue: '#48a2d0',
14
+ blue2: '#6CD4D4',
14
15
  red: '#ff5656',
15
16
  blue1: '#e4efff',
16
17
  brightBlue: '#0068DE',
@@ -1,13 +1,14 @@
1
1
  <template>
2
2
  <ComponentWrapper>
3
- <IconWrapper :size="size">
3
+ <IconWrapper :size="type === 'dot' ? 'unset' : size">
4
4
  <IconImg
5
- data-test-id="infoText_trigger"
6
5
  @click.prevent="toggleShowInfo()"
7
6
  @mouseenter="openTrigger == 'onHover' ? toggleShowInfo() : ''"
8
7
  @mouseleave="openTrigger == 'onHover' ? toggleShowInfo() : ''"
9
8
  >
9
+ <Dot v-if="type === 'dot'" :color="dotColor" />
10
10
  <IconComponent
11
+ v-else
11
12
  :color="iconColor"
12
13
  cursor="pointer"
13
14
  name="info"
@@ -95,6 +96,14 @@
95
96
  height: ${(props) => props.size};
96
97
  `
97
98
 
99
+ const Dot = styled('div')`
100
+ width: 5px;
101
+ height: 5px;
102
+ background-color: ${(props) => props.color};
103
+ border-radius: 50%;
104
+ display: inline-block;
105
+ `
106
+
98
107
  const IconImg = styled.div`
99
108
  line-height: 0;
100
109
  `
@@ -106,6 +115,7 @@
106
115
  export default {
107
116
  name: 'InfoText',
108
117
  components: {
118
+ Dot,
109
119
  IconWrapper,
110
120
  TextOverlay,
111
121
  ComponentWrapper,
@@ -114,21 +124,27 @@
114
124
  },
115
125
  props: {
116
126
  text: {
127
+ type: String,
117
128
  required: false,
129
+ default: '',
118
130
  },
119
131
  size: {
132
+ type: String,
120
133
  required: false,
121
134
  default: '14px',
122
135
  },
123
136
  alignArrow: {
137
+ type: String,
124
138
  required: false,
125
139
  default: 'center',
126
140
  },
127
141
  openTrigger: {
142
+ type: String,
128
143
  required: false,
129
144
  default: 'onHover', // onHover, onClick
130
145
  },
131
146
  width: {
147
+ type: String,
132
148
  required: false,
133
149
  default: '200px',
134
150
  },
@@ -136,6 +152,16 @@
136
152
  type: String,
137
153
  default: '400px',
138
154
  },
155
+ dotColor: {
156
+ type: String,
157
+ required: false,
158
+ default: theme.colors.blue2,
159
+ },
160
+ type: {
161
+ type: String,
162
+ required: false,
163
+ default: 'info', // info, dot
164
+ },
139
165
  },
140
166
  data() {
141
167
  return {
@@ -1,77 +1,58 @@
1
- import { useArgs } from '@storybook/preview-api'
2
- import { action } from '@storybook/addon-actions'
3
- import defaultRadioButtonProps from './defaultProps'
4
1
  import RadioButton from './index.vue'
5
2
 
6
3
  export default {
7
4
  title: 'RadioButton',
8
5
  component: RadioButton,
9
- tags: ['autodocs'],
6
+ // argTypes: {},
10
7
  }
11
8
 
12
- // To use:
13
- // import RadioButton from "@eturnity/eturnity_reusable_components/src/components/inputs/radioButton"
14
- // <radio-button
15
- // checkmarkColor="red"
16
- // dataId="radio_button"
17
- // layout="horizontal" //2 options: 'vertical' (only 1 per row) & 'horizontal' (many per row)
18
- // name="Name for Radio buttons"
19
- // :options="radioOptions"
20
- // :selectedOption="checkedOption"
21
- // size="medium" // small, medium, large
22
- // @on-radio-change="onInputChange($event)"
23
- // />
24
- // Data being passed should look like:
25
- // radioOptions: [
26
- // { label: 'Option 1', value: 'option_1', img: 'www.imagesrc.com', infoText: 'my info text' },
27
- // { label: 'Option 2', value: 'option_2', img: 'www.imagesrc.com', infoText: 'my info text 2' },
28
- // { label: 'Option 3', value: 'option_3', img: 'www.imagesrc.com', disabled: true },
29
- // { label: 'Option 4', value: 'option_4', disabled: true }
30
- // ]
31
-
32
- const defaultProps = defaultRadioButtonProps
33
-
34
- const Template = (args) => {
35
- const [currentArgs, updateArgs] = useArgs()
36
-
37
- const handleRadioChange = ($event) => {
38
- action('on-radio-change')($event)
39
- updateArgs({ selectedOption: $event })
40
- }
41
-
42
- return {
43
- components: { RadioButton },
44
- setup() {
45
- return { args: currentArgs, handleRadioChange }
46
- },
47
- template: `
48
- <RadioButton
49
- v-bind="args"
50
- @on-radio-change="handleRadioChange"
51
- />
52
- `,
53
- }
54
- }
9
+ const Template = (args, { argTypes }) => ({
10
+ // Components used in your story `template` are defined in the `components` object
11
+ components: { RadioButton },
12
+ // The story's `args` need to be mapped into the template through the `setup()` method
13
+ props: Object.keys(argTypes),
14
+ template: '<radio-button v-bind="$props" />',
15
+
16
+ // import RadioButton from "@eturnity/eturnity_reusable_components/src/components/inputs/radioButton"
17
+ // To use:
18
+ // <radio-button
19
+ // :options="radioOptions"
20
+ // :selectedOption="checkedOption"
21
+ // @on-radio-change="onInputChange($event)"
22
+ // layout="vertical"
23
+ // size="large"
24
+ // />
25
+ // Data being passed should look like:
26
+ // radioOptions: [
27
+ // { label: 'Button 1', value: 'button_1', img: 'www.imagesrc.com', infoText: 'my info text' },
28
+ // { label: 'Button 2', value: 'button_2', img: 'www.imagesrc.com', infoText: 'my info text 2' },
29
+ // { label: 'Button 3', value: 'button_3', img: 'www.imagesrc.com', disabled: true },
30
+ // { label: 'Button 4', value: 'button_4', disabled: true }
31
+ // ]
32
+ })
55
33
 
56
34
  export const Default = Template.bind({})
57
35
  Default.args = {
58
- ...defaultProps,
59
- }
60
-
61
- export const BlueCheckmark = Template.bind({})
62
- BlueCheckmark.args = {
63
- ...defaultProps,
64
- checkmarkColor: '#00f',
65
- }
66
-
67
- export const Small = Template.bind({})
68
- Small.args = {
69
- ...defaultProps,
70
- size: 'small',
36
+ options: [
37
+ { label: 'Button 1', value: 'button_1', infoText: 'my info text' },
38
+ { label: 'Button 2', value: 'button_2', infoText: 'my info text 2' },
39
+ { label: 'Button 3', value: 'button_3', disabled: true },
40
+ { label: 'Button 4', value: 'button_4', disabled: true },
41
+ ],
42
+ selectedOption: 'button_2',
43
+ layout: 'horizontal',
44
+ size: 'medium',
71
45
  }
72
46
 
73
- export const Vertical = Template.bind({})
74
- Vertical.args = {
75
- ...defaultProps,
47
+ export const VerticalLayout = Template.bind({})
48
+ VerticalLayout.args = {
49
+ options: [
50
+ { label: 'Button 1', value: 'button_1' },
51
+ { label: 'Button 2', value: 'button_2' },
52
+ { label: 'Button 3', value: 'button_3' },
53
+ { label: 'Button 4', value: 'button_4', disabled: true },
54
+ ],
55
+ selectedOption: 'button_2',
76
56
  layout: 'vertical',
57
+ size: 'medium',
77
58
  }
@@ -1,10 +1,6 @@
1
1
  <template>
2
2
  <ComponentWrapper :layout="layout">
3
- <RadioWrapper
4
- v-for="(item, index) in options"
5
- :key="item.value"
6
- :data-test-id="'radioWrapper_' + item.value"
7
- >
3
+ <RadioWrapper v-for="(item, index) in options" :key="item.value">
8
4
  <LabelContainer
9
5
  :checkmark-color="checkmarkColor"
10
6
  :has-label="!!item.label"
@@ -15,7 +11,6 @@
15
11
  <Radio
16
12
  :checked="selectedOption === item.value"
17
13
  :data-id="`radio_button_${dataId}_option_${item.value}`"
18
- :data-test-id="'radioInput_' + item.value"
19
14
  :disabled="item.disabled"
20
15
  :name="'radioButtons_' + radioName"
21
16
  type="radio"
@@ -23,32 +18,15 @@
23
18
  @click="onInputHandler(item.value)"
24
19
  />
25
20
  <span class="checkmark"></span>
26
- <LabelText
27
- v-if="item.label"
28
- :data-test-id="'radioLabel_' + item.value"
29
- :is-disabled="item.disabled"
30
- >
21
+ <LabelText v-if="item.label" :is-disabled="item.disabled">
31
22
  {{ item.label }}
32
23
  </LabelText>
33
- <InfoText
34
- v-if="item.infoText"
35
- :data-test-id="'radioInfo_' + item.value"
36
- size="16px"
37
- :text="item.infoText"
38
- />
24
+ <InfoText v-if="item.infoText" size="16px" :text="item.infoText" />
39
25
  </LabelContainer>
40
26
  <ImageContainer v-if="item.img">
41
- <RadioImage
42
- :data-test-id="'radioImage_' + item.value"
43
- :src="item.img"
44
- />
45
- <div
46
- class="search-icn-container"
47
- :data-test-id="'radioOpenImage_' + item.value"
48
- @click="toggleImageModal(index)"
49
- >
27
+ <RadioImage :src="item.img" />
28
+ <div class="search-icn-container" @click="toggleImageModal(index)">
50
29
  <img
51
- alt=""
52
30
  class="search-icn"
53
31
  :src="require('../../../assets/icons/search_icon.png')"
54
32
  />
@@ -56,7 +34,6 @@
56
34
  </ImageContainer>
57
35
  <Modal
58
36
  v-if="item.img"
59
- :data-test-id="'radioModal_' + item.value"
60
37
  :is-open="isImageOpen(index)"
61
38
  @on-close="toggleImageModal(null)"
62
39
  >
@@ -72,21 +49,18 @@
72
49
  // import RadioButton from "@eturnity/eturnity_reusable_components/src/components/inputs/radioButton"
73
50
  // To use:
74
51
  // <radio-button
75
- // checkmarkColor="red"
76
- // dataId="radio_button"
77
- // layout="horizontal"
78
- // name="Name for Radio buttons"
79
52
  // :options="radioOptions"
80
53
  // :selectedOption="checkedOption"
81
- // size="large"
82
54
  // @on-radio-change="onInputChange($event)"
55
+ // layout="vertical"
56
+ // size="large"
83
57
  // />
84
58
  // Data being passed should look like:
85
59
  // radioOptions: [
86
- // { label: 'Option 1', value: 'option_1', img: 'www.imagesrc.com', infoText: 'my info text' },
87
- // { label: 'Option 2', value: 'option_2', img: 'www.imagesrc.com', infoText: 'my info text 2' },
88
- // { label: 'Option 3', value: 'option_3', img: 'www.imagesrc.com', disabled: true },
89
- // { label: 'Option 4', value: 'option_4', disabled: true }
60
+ // { label: 'Button 1', value: 'button_1', img: 'www.imagesrc.com', infoText: 'my info text' },
61
+ // { label: 'Button 2', value: 'button_2', img: 'www.imagesrc.com', infoText: 'my info text 2' },
62
+ // { label: 'Button 3', value: 'button_3', img: 'www.imagesrc.com', disabled: true },
63
+ // { label: 'Button 4', value: 'button_4', disabled: true }
90
64
  // ]
91
65
 
92
66
  import styled from 'vue3-styled-components'
@@ -108,6 +82,7 @@
108
82
  cursor: pointer;
109
83
  position: absolute;
110
84
  opacity: 0;
85
+ cursor: pointer;
111
86
  height: 0;
112
87
  width: 0;
113
88
  `
@@ -246,42 +221,33 @@
246
221
  props: {
247
222
  selectedOption: {
248
223
  required: true,
249
- type: [String, Number],
224
+ default: false,
250
225
  },
251
226
  options: {
252
- default() {
253
- return []
254
- },
255
227
  required: true,
256
- type: Array,
228
+ default: [],
257
229
  },
258
230
  layout: {
259
- default: 'horizontal', //2 options: 'vertical' (only 1 per row) & 'horizontal' (many per row)
260
231
  required: false,
261
- type: String,
232
+ default: 'horizontal', //2 options: 'vertical' (only 1 per row) & 'horizontal' (many per row)
262
233
  },
263
234
  size: {
264
- default: 'medium', // small, medium, large
265
235
  required: false,
266
- type: String,
236
+ default: 'medium', // small, medium, large
267
237
  },
268
238
  name: {
269
- default: '',
270
239
  required: false,
271
- type: String,
240
+ default: '',
272
241
  },
273
242
  checkmarkColor: {
274
- default: '',
275
243
  required: false,
276
- type: String,
244
+ default: '',
277
245
  },
278
246
  dataId: {
279
- default: 'key',
280
- required: false,
281
247
  type: String,
248
+ default: 'key',
282
249
  },
283
250
  },
284
- emits: ['on-radio-change'],
285
251
  data() {
286
252
  return {
287
253
  selectedImage: null,
@@ -294,9 +260,7 @@
294
260
  },
295
261
  methods: {
296
262
  onInputHandler(value) {
297
- if (value !== this.selectedOption) {
298
- this.$emit('on-radio-change', value)
299
- }
263
+ this.$emit('on-radio-change', value)
300
264
  },
301
265
  isImageOpen(index) {
302
266
  return this.selectedImage === index
@@ -1,33 +0,0 @@
1
- const defaultRadioButtonProps = {
2
- dataId: 'radio_buttons',
3
- name: 'options',
4
- options: [
5
- {
6
- label: 'Option 1',
7
- value: 'option_1',
8
- img: 'https://staging-01-backend.eturnity.dev/static/e_templates/base/styles/solar_img_i.png',
9
- },
10
- {
11
- label: 'Option 2',
12
- value: 'option_2',
13
- img: 'https://staging-01-backend.eturnity.dev/static/e_templates/base/styles/switcher_img_i.png',
14
- infoText: 'Option 2 info text',
15
- },
16
- {
17
- label: 'Option 3',
18
- value: 'option_3',
19
- img: 'https://staging-01-backend.eturnity.dev/static/e_templates/base/styles/varta_img_i.png',
20
- infoText: 'Option 3 info text',
21
- disabled: true,
22
- },
23
- {
24
- label: 'Option 4',
25
- value: 'option_4',
26
- disabled: true,
27
- infoText: 'Option 4 info text',
28
- },
29
- ],
30
- selectedOption: 'option_2',
31
- }
32
-
33
- export default defaultRadioButtonProps
@@ -1,269 +0,0 @@
1
- import { mount, DOMWrapper } from '@vue/test-utils'
2
- import RadioButton from '@/components/inputs/radioButton'
3
- import defaultRadioButtonProps from './defaultProps'
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('mocked-icon-url.svg')),
9
- }))
10
- jest.mock('../../../assets/icons/search_icon.png', () => 'search_icon.png')
11
-
12
- describe('RadioButton.vue', () => {
13
- const radioButtons = mount(RadioButton, {
14
- props: defaultRadioButtonProps,
15
- global: {
16
- provide: {
17
- theme,
18
- },
19
- },
20
- })
21
- function findRadioWrappersByCriteria(criteria) {
22
- // criteria === ['active', ..., 'hasImage'], can include any number of criteria
23
- // This function is used for getting a list of
24
- // RadioWrapper components which matches
25
- // all the requested criteria (conjunctive filtering).
26
- // Make sure that criteria don't contradict each other.
27
- // List of possible criteria =
28
- // - active || disabled
29
- // - checked || unchecked
30
- // - hasInfoIcon
31
- // - hasImage
32
-
33
- function getParentRadioWrapper(element) {
34
- // function is used for getting a parent RadioWrapper component
35
- const radioWrapper = element.element.closest(
36
- '[data-test-id^="radioWrapper_"]'
37
- )
38
- return radioWrapper ? new DOMWrapper(radioWrapper) : null
39
- }
40
-
41
- const elementsWithTestIds = radioButtons.findAll('[data-test-id]')
42
- let resultsObject = {}
43
-
44
- criteria.forEach((criterion) => {
45
- resultsObject[criterion] = []
46
- if (criterion === 'active' || criterion === 'disabled') {
47
- const criteriaRelatedElements = elementsWithTestIds.filter((element) =>
48
- element.attributes('data-test-id').startsWith('radioInput_')
49
- )
50
- criteriaRelatedElements.forEach((el) => {
51
- const element = el.element
52
- if (criterion === 'active' ? !element.disabled : element.disabled) {
53
- resultsObject[criterion].push(getParentRadioWrapper(el))
54
- }
55
- })
56
- }
57
- if (criterion === 'checked' || criterion === 'unchecked') {
58
- const criteriaRelatedElements = elementsWithTestIds.filter((element) =>
59
- element.attributes('data-test-id').startsWith('radioInput_')
60
- )
61
- criteriaRelatedElements.forEach((el) => {
62
- const element = el.element
63
- if (criterion === 'checked' ? element.checked : !element.checked) {
64
- resultsObject[criterion].push(getParentRadioWrapper(el))
65
- }
66
- })
67
- }
68
- if (criterion === 'hasInfoIcon') {
69
- const criteriaRelatedElements = elementsWithTestIds.filter((element) =>
70
- element.attributes('data-test-id').startsWith('radioInfo_')
71
- )
72
- criteriaRelatedElements.forEach((element) => {
73
- resultsObject[criterion].push(getParentRadioWrapper(element))
74
- })
75
- }
76
- if (criterion === 'hasImage') {
77
- const criteriaRelatedElements = elementsWithTestIds.filter((element) =>
78
- element.attributes('data-test-id').startsWith('radioOpenImage_')
79
- )
80
- criteriaRelatedElements.forEach((element) => {
81
- resultsObject[criterion].push(getParentRadioWrapper(element))
82
- })
83
- }
84
- })
85
-
86
- let resultArray = []
87
- Object.keys(resultsObject).forEach((criterion, index) => {
88
- if (index === 0) {
89
- resultArray = [...resultsObject[criterion]]
90
- } else {
91
- resultArray = resultArray.filter((element) =>
92
- resultsObject[criterion]
93
- .map((item) => item.attributes('data-test-id'))
94
- .includes(element.attributes('data-test-id'))
95
- )
96
- }
97
- })
98
-
99
- return resultArray
100
- }
101
-
102
- it('Radio buttons are rendered and emit correct payload on change', async () => {
103
- //check that all the options have been rendered
104
- let radioBtnWrappers = radioButtons.findAll('[data-test-id]')
105
- radioBtnWrappers = radioBtnWrappers.filter((wrapper) =>
106
- wrapper.attributes('data-test-id').startsWith('radioWrapper_')
107
- )
108
- const numberOfOptions = radioButtons.props('options').length
109
- expect(radioBtnWrappers).toHaveLength(numberOfOptions)
110
-
111
- // check that the selected element exists and there is only a single copy of it and has correct value
112
- const checkedWrapperArray = findRadioWrappersByCriteria(['checked'])
113
- expect(checkedWrapperArray.length).toBe(1)
114
- const checkedWrapper = checkedWrapperArray[0]
115
- const checkedRadioInput = checkedWrapper.find('input[type="radio"]')
116
- const defaultValueFromProps = radioButtons.props('selectedOption')
117
- expect(checkedRadioInput.attributes('value')).toBe(
118
- defaultValueFromProps
119
- )
120
-
121
- // Log attributes to see what is rendered (commented out just for reference)
122
- // console.log('checkedRadioInput attributes', checkedRadioInput.attributes())
123
-
124
- // Test the label
125
- const labelOfDefaultValue = radioButtons
126
- .props('options')
127
- .find((option) => option.value === defaultValueFromProps).label
128
- expect(checkedWrapper.text()).toContain(labelOfDefaultValue)
129
-
130
- // Test the click on unselected active element
131
- const uncheckedWrapperArray = findRadioWrappersByCriteria([
132
- 'unchecked',
133
- 'active',
134
- ])
135
- const expectedValueOfEmittedEvent = uncheckedWrapperArray[0]
136
- .attributes('data-test-id')
137
- .replace('radioWrapper_', '')
138
- const uncheckedLabelWrapper = uncheckedWrapperArray[0].find('label')
139
- await uncheckedLabelWrapper.trigger('click')
140
- expect(radioButtons.emitted('on-radio-change')).toBeTruthy()
141
- const emittedEvents = radioButtons.emitted('on-radio-change')
142
- expect(emittedEvents).toHaveLength(1) // Check if the event was emitted exactly once
143
- // Check the payload of the event
144
- expect(emittedEvents[emittedEvents.length - 1]).toEqual([
145
- expectedValueOfEmittedEvent,
146
- ])
147
- await radioButtons.setProps({ selectedOption: expectedValueOfEmittedEvent })
148
- }),
149
- it('click on disabled element (|| selected element || info icon || image) does not emit anything', async () => {
150
- // Remember the number of emitted events before triggering clicks
151
- const initialNumberOfEvents =
152
- radioButtons.emitted('on-radio-change').length
153
-
154
- // Test RadioWrapper with disabled element
155
- const disabledWrapperArray = findRadioWrappersByCriteria(['disabled'])
156
- const disabledLabelWrapper = disabledWrapperArray[0].find('label')
157
- await disabledLabelWrapper.trigger('click')
158
- // Check if we still have the same number of emitted events as at the beginning
159
- expect(radioButtons.emitted('on-radio-change')).toHaveLength(
160
- initialNumberOfEvents
161
- )
162
-
163
- // Get RadioWrapper with selected element
164
- const checkedWrapperArray = findRadioWrappersByCriteria(['checked'])
165
- const checkedLabelWrapper = checkedWrapperArray[0].find('label')
166
- await checkedLabelWrapper.trigger('click')
167
- // Check if we still have the same number of emitted events as at the beginning
168
- expect(radioButtons.emitted('on-radio-change')).toHaveLength(
169
- initialNumberOfEvents
170
- )
171
-
172
- // Get RadioWrapper with info icon
173
- const arrayOfWrappersWithInfoIcons = findRadioWrappersByCriteria([
174
- 'active',
175
- 'unchecked',
176
- 'hasInfoIcon',
177
- ])
178
- const infoIconForClick = arrayOfWrappersWithInfoIcons[0].find(
179
- '[data-test-id="infoText_trigger"]'
180
- )
181
- await infoIconForClick.trigger('click')
182
- // Check if we still have the same number of emitted events as at the beginning
183
- expect(radioButtons.emitted('on-radio-change')).toHaveLength(
184
- initialNumberOfEvents
185
- )
186
-
187
- // Get RadioWrapper with image
188
- const arrayOfWrappersWithImage = findRadioWrappersByCriteria([
189
- 'active',
190
- 'unchecked',
191
- 'hasImage',
192
- ])
193
- const testedRadioWrapperWithImage = arrayOfWrappersWithImage[0]
194
- const openImageWrapperTestId = testedRadioWrapperWithImage
195
- .attributes('data-test-id')
196
- .replace('radioWrapper_', 'radioOpenImage_')
197
- const openImageWrapper = testedRadioWrapperWithImage.find(
198
- `[data-test-id="${openImageWrapperTestId}"]`
199
- )
200
- await openImageWrapper.trigger('click')
201
- // Check if we still have the same number of emitted events as at the beginning
202
- expect(radioButtons.emitted('on-radio-change')).toHaveLength(
203
- initialNumberOfEvents
204
- )
205
-
206
- // Since we just clicked on image miniature
207
- // lets check has the corresponding modal been opened
208
- // and is the correct image displayed
209
- const imageModalWrapperTestId = testedRadioWrapperWithImage
210
- .attributes('data-test-id')
211
- .replace('radioWrapper_', 'radioModal_')
212
- const imageModalWrapper = testedRadioWrapperWithImage.find(
213
- `[data-test-id="${imageModalWrapperTestId}"]`
214
- )
215
- expect(imageModalWrapper.attributes('class')).toContain('visible')
216
- const imageWrapperTestId = testedRadioWrapperWithImage
217
- .attributes('data-test-id')
218
- .replace('radioWrapper_', 'radioImage_')
219
- const imageWrapper = testedRadioWrapperWithImage.find(
220
- `[data-test-id="${imageWrapperTestId}"]`
221
- )
222
- const expectedImageSrc = imageWrapper.attributes('src')
223
- const modalImageSrc = imageModalWrapper.find('img').attributes('src')
224
- expect(modalImageSrc).toBe(expectedImageSrc)
225
- //Close the modal
226
- radioButtons.find('.visible .close').trigger('click')
227
- await radioButtons.vm.$nextTick()
228
- expect(imageModalWrapper.attributes('class')).toContain('hidden')
229
- }),
230
- it('test hover on Info Icon', async () => {
231
- // Get RadioWrapper with Info Icon
232
- const arrayOfWrappersWithInfoIcon = findRadioWrappersByCriteria([
233
- 'hasInfoIcon',
234
- ])
235
- //Select tested item and get expected text within the info badge
236
- const testedRadioWrapper =
237
- arrayOfWrappersWithInfoIcon[arrayOfWrappersWithInfoIcon.length - 1]
238
- const valueOfTestedRadioWrapper = testedRadioWrapper
239
- .attributes('data-test-id')
240
- .replace('radioWrapper_', '')
241
- const expectedText = defaultRadioButtonProps.options.find((el) => el.value === valueOfTestedRadioWrapper).infoText
242
- const iconForHover = testedRadioWrapper.find(
243
- '[data-test-id="infoText_trigger"]'
244
- )
245
- await iconForHover.trigger('mouseenter')
246
- expect(testedRadioWrapper.text()).toContain(expectedText)
247
- }),
248
- it('Test the click again after all the manipulations', async () => {
249
- const uncheckedWrapperArray = findRadioWrappersByCriteria([
250
- 'unchecked',
251
- 'active',
252
- ])
253
- const expectedValueOfEmittedEvent = uncheckedWrapperArray[0]
254
- .attributes('data-test-id')
255
- .replace('radioWrapper_', '')
256
- const uncheckedLabelWrapper = uncheckedWrapperArray[0].find('label')
257
- await uncheckedLabelWrapper.trigger('click')
258
- expect(radioButtons.emitted('on-radio-change')).toBeTruthy()
259
- const emittedEvents = radioButtons.emitted('on-radio-change')
260
- expect(emittedEvents).toHaveLength(2) // Check that this is just 2nd emitted event
261
- // Check the payload of the event
262
- expect(emittedEvents[emittedEvents.length - 1]).toEqual([
263
- expectedValueOfEmittedEvent,
264
- ])
265
- await radioButtons.setProps({
266
- selectedOption: expectedValueOfEmittedEvent,
267
- })
268
- })
269
- })