@eturnity/eturnity_reusable_components 8.16.3 → 8.16.4

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.16.3",
3
+ "version": "8.16.4",
4
4
  "files": [
5
5
  "dist",
6
6
  "src"
@@ -1,5 +1,4 @@
1
1
  /* eslint-disable */
2
- import { h } from 'vue'
3
2
  import { mount } from '@vue/test-utils'
4
3
  import InfoBanner from '@/components/banner/infoBanner'
5
4
  import theme from '@/assets/theme'
@@ -10,59 +9,47 @@ jest.mock('@/components/icon/iconCache.mjs', () => ({
10
9
  }))
11
10
 
12
11
  describe('Info Banner Component', () => {
13
- const props = {
14
- isOpen: false,
15
- buttonLabel: 'Gotcha',
16
- }
17
-
18
- const global = {
19
- provide: {
20
- theme,
21
- },
22
- }
23
-
24
- it('info banner is shown when isOpen props is true', async () => {
25
- const wrapper = mount(InfoBanner, {
26
- props,
27
- global,
12
+ let wrapper
13
+
14
+ beforeEach(() => {
15
+ wrapper = mount(InfoBanner, {
16
+ props: {
17
+ isOpen: true,
18
+ buttonLabel: 'Gotcha',
19
+ },
20
+ slots: {
21
+ title: 'Sample title',
22
+ body: 'Sample body text',
23
+ },
24
+ global: {
25
+ provide: {
26
+ theme,
27
+ },
28
+ },
29
+ })
28
30
  })
29
31
 
32
+
33
+ it('info banner is shown when isOpen props is true', async () => {
34
+
30
35
  const bannerWrapper = wrapper.find('[data-test-id="info_banner_wrapper"]')
31
36
  expect(bannerWrapper.exists()).toBe(true)
32
- expect(bannerWrapper.classes()).not.toContain('visible')
33
- expect(bannerWrapper.classes()).toContain('hidden')
34
- await wrapper.setProps({ isOpen: true })
35
- expect(bannerWrapper.classes()).toContain('visible')
36
- expect(bannerWrapper.classes()).not.toContain('hidden')
37
37
  })
38
38
 
39
- it('info banner slots is display when user passed slots content', async () => {
40
- const titleText = 'Sample title'
41
- const bodyText = 'Sample body text'
42
-
43
- const wrapper = mount(InfoBanner, {
44
- props,
45
- slots: {
46
- title: titleText,
47
- body: bodyText,
48
- },
49
- global,
50
- })
51
-
39
+
40
+ it('info banner slots is display when user passed slots content', () => {
52
41
  const modalTitleEl = wrapper.find('[data-test-id="modal_title"]')
53
- expect(modalTitleEl.text()).toBe(titleText)
42
+ expect(modalTitleEl.text()).toBe('Sample title')
54
43
  const modalBodyEl = wrapper.find('[data-test-id="modal_body"]')
55
- expect(modalBodyEl.text()).toBe(bodyText)
44
+ expect(modalBodyEl.text()).toBe('Sample body text')
56
45
  })
57
46
 
58
47
  it('info banner on-close event is emitted when modal close button is clicked', async () => {
59
- const wrapper = mount(InfoBanner, {
60
- props,
61
- global,
62
- })
63
-
64
48
  const modalCloseButton = wrapper.find('.close')
65
- await modalCloseButton.trigger('click')
49
+
50
+ modalCloseButton.trigger('click')
51
+ await wrapper.vm.$nextTick()
52
+
66
53
  expect(wrapper.emitted('on-close')).toBeTruthy()
67
54
  const emittedEvent = wrapper.emitted('on-close')
68
55
  expect(emittedEvent).toHaveLength(1)
@@ -0,0 +1,34 @@
1
+ import { mount } from '@vue/test-utils'
2
+ import ErrorMessage from '@/components/errorMessage'
3
+ import theme from '@/assets/theme'
4
+
5
+ /* eslint-disable */
6
+
7
+ describe('ErrorMessage Component', () => {
8
+ let wrapper
9
+
10
+ beforeEach(() => {
11
+ wrapper = mount(ErrorMessage, {
12
+ props: {},
13
+ slots: {
14
+ default: '<div data-test-id="fake-msg">testing</div>',
15
+ },
16
+ global: {
17
+ provide: {
18
+ theme,
19
+ },
20
+ },
21
+ })
22
+ })
23
+
24
+ test('renders ErrorMessage component with default props', () => {
25
+ expect(wrapper.findAll('[data-test-id="fake-msg"]').length).toBe(1)
26
+ })
27
+
28
+ test('applies the correct CSS class for styling', async () => {
29
+ wrapper.setProps({ marginTop: '20px' })
30
+
31
+ await wrapper.vm.$nextTick()
32
+ expect(wrapper.props().marginTop).toBe('20px')
33
+ })
34
+ })
@@ -0,0 +1,35 @@
1
+ import ErrorMessage from './index.vue'
2
+
3
+ export default {
4
+ title: 'ErrorMessage',
5
+ component: ErrorMessage,
6
+ tags: ['autodocs'],
7
+ parameters: {
8
+ layout: 'centered',
9
+ },
10
+ }
11
+
12
+ // import ErrorMessage from "@eturnity/eturnity_reusable_components/src/components/errorMessage"
13
+ //
14
+ //To use:
15
+ // <error-message>
16
+ // <span>
17
+ // testing error message
18
+ // </span>
19
+ // </error-message>
20
+
21
+ const Template = (args, { argTypes }) => ({
22
+ components: { ErrorMessage },
23
+ props: Object.keys(argTypes),
24
+ template: `
25
+ <ErrorMessage v-bind="$props">
26
+ <span>
27
+ testing error message
28
+ </span>
29
+ </ErrorMessage>`,
30
+ })
31
+
32
+ export const Default = Template.bind({})
33
+ Default.args = {
34
+ marginTop: '13px',
35
+ }
@@ -46,7 +46,7 @@
46
46
  </IconWrapper>
47
47
  </div>
48
48
  <Teleport v-if="isVisible" to="body">
49
- <TextWrapper :style="wrapperStyle">
49
+ <TextWrapper data-test-id="info_text_wrapper" :style="wrapperStyle">
50
50
  <TextOverlay
51
51
  ref="infoBox"
52
52
  :app-theme="appTheme"
@@ -29,6 +29,9 @@ describe('InfoText Component', () => {
29
29
  provide: {
30
30
  theme,
31
31
  },
32
+ stubs: {
33
+ teleport: true
34
+ }
32
35
  },
33
36
  })
34
37
  })
@@ -38,7 +41,6 @@ describe('InfoText Component', () => {
38
41
  expect(wrapper.vm.text).toContain('default text')
39
42
  expect(wrapper.vm.size).toContain('14px')
40
43
  expect(wrapper.vm.infoPosition).toContain('bottom')
41
- expect(wrapper.vm.alignArrow).toContain('center')
42
44
  })
43
45
 
44
46
  test('openTrigger prop is set to onClick', async () => {
@@ -48,8 +50,11 @@ describe('InfoText Component', () => {
48
50
  expect(wrapper.find('[data-test-id="info_text_wrapper"]').exists()).toBe(
49
51
  false
50
52
  )
53
+
51
54
  //should see text upon click
52
55
  await wrapper.find('[data-test-id="infoText_trigger"]').trigger('click')
56
+ expect(wrapper.vm.isVisible).toBe(true)
57
+
53
58
  expect(wrapper.find('[data-test-id="info_text_wrapper"]').exists()).toBe(
54
59
  true
55
60
  )
@@ -0,0 +1,52 @@
1
+ /* eslint-disable */
2
+ import { mount } from '@vue/test-utils'
3
+ import ActionModal from '@/components/modals/actionModal'
4
+ import theme from '@/assets/theme'
5
+
6
+ describe('ActionModal Component', () => {
7
+ let wrapper
8
+
9
+ beforeEach(() => {
10
+ wrapper = mount(ActionModal, {
11
+ props: {
12
+ isOpen: true,
13
+ buttonText: 'Close',
14
+ },
15
+ slots: {
16
+ title: 'Sample title',
17
+ body: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed tincidunt commodo mollis. Fusce urna felis, malesuada sed elementum et, fermentum ac massa. Integer in massa vel orci fermentum bibendum in ut ante. Donec risus risus, luctus quis ex a, pulvinar placerat lacus. Sed pharetra augue a elit volutpat, eu dignissim ex pretium. Aenean imperdiet, nulla in pharetra rutrum, mauris mauris tincidunt tellus, non tempus quam lorem laoreet lectus.',
18
+ buttons: '<button @click="closeAction">Close</button>',
19
+ },
20
+ global: {
21
+ provide: {
22
+ theme,
23
+ },
24
+ },
25
+ })
26
+ })
27
+
28
+ test('renders ActionModal component with default props', () => {
29
+ expect(wrapper.find('[data-test-id="actionModal"]').exists()).toBe(true)
30
+
31
+ expect(wrapper.vm.isOpen).toBe(true)
32
+ })
33
+
34
+ test('action modal slots is display when user passed slots content', () => {
35
+ const modalTitleEl = wrapper.find('[data-test-id="modal_title"]')
36
+ expect(modalTitleEl.text()).toBe('Sample title')
37
+
38
+ const modalBodyEl = wrapper.find('[data-test-id="modal_body"]')
39
+ expect(modalBodyEl.text()).toContain('Lorem ipsum dolor sit amet')
40
+
41
+ const modalActionButton = wrapper.find('[data-test-id="modal_buttons"]')
42
+ expect(modalActionButton.text()).toContain('Close')
43
+ })
44
+
45
+ test('action modal on-close event is emitted when modal close button is clicked', async () => {
46
+ const modalCloseButton = wrapper.find('.close')
47
+
48
+ modalCloseButton.trigger('click')
49
+ await wrapper.vm.$nextTick()
50
+ expect(wrapper.emitted('on-close')).toBeTruthy()
51
+ })
52
+ })
@@ -0,0 +1,53 @@
1
+ import ActionModal from './index.vue'
2
+
3
+ export default {
4
+ title: 'Components/ActionModal',
5
+ component: ActionModal,
6
+ tags: ['autodocs'],
7
+ parameters: {
8
+ layout: 'centered',
9
+ },
10
+ }
11
+
12
+ // import ActionModal from "@eturnity/eturnity_reusable_components/src/components/modals/ActionModal"
13
+ // This is a reusable modal component that can be used to display information to the user.
14
+ // To use:
15
+ // <ActionModal :isOpen="isOpen" @on-close="$emit('on-close-summary')" >
16
+ // <template #title>
17
+ // <h1>Header</h1>
18
+ // </template>
19
+ // <template #body>
20
+ // <p>Body</p>
21
+ // </template>
22
+ // <template #buttons>
23
+ // <button @click="closeModal">Close</button>
24
+ // </template>
25
+ // </ActionModal>
26
+
27
+ export const Default = {
28
+ args: {
29
+ isOpen: true,
30
+ },
31
+ render: (args) => ({
32
+ components: { ActionModal },
33
+ setup() {
34
+ return { args }
35
+ },
36
+ template: `
37
+ <ActionModal v-bind="args">
38
+ <template #title>Sample title</template>
39
+ <template #body>
40
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed tincidunt commodo mollis. Fusce urna felis,
41
+ malesuada sed elementum et, fermentum ac massa. Integer in massa vel orci fermentum bibendum in ut ante.
42
+ Donec risus risus, luctus quis ex a, pulvinar placerat lacus. Sed pharetra augue a elit volutpat, eu dignissim
43
+ ex pretium. Aenean imperdiet, nulla in pharetra rutrum, mauris mauris tincidunt tellus, non tempus quam lorem
44
+ laoreet lectus.
45
+ </template>
46
+ <template #buttons>
47
+ <button @click="saveAction">Save</button>
48
+ <button @click="closeAction">Close</button>
49
+ </template>
50
+ </ActionModal>
51
+ `,
52
+ }),
53
+ }
@@ -1,13 +1,13 @@
1
1
  <template>
2
- <Modal :is-open="isOpen" @on-close="closeModal">
2
+ <Modal data-test-id="actionModal" :is-open="isOpen" @on-close="closeModal">
3
3
  <ModalContainer>
4
- <ModalTitle v-if="$slots.title">
4
+ <ModalTitle v-if="$slots.title" data-test-id="modal_title">
5
5
  <slot name="title"></slot>
6
6
  </ModalTitle>
7
- <TextContainer v-if="$slots.body">
7
+ <TextContainer v-if="$slots.body" data-test-id="modal_body">
8
8
  <slot name="body"></slot>
9
9
  </TextContainer>
10
- <ButtonContainer v-if="$slots.buttons">
10
+ <ButtonContainer v-if="$slots.buttons" data-test-id="modal_buttons">
11
11
  <slot name="buttons"></slot>
12
12
  </ButtonContainer>
13
13
  </ModalContainer>
@@ -23,7 +23,7 @@
23
23
  `
24
24
  const ModalTitle = styled.div`
25
25
  color: ${(props) => props.theme.colors.black};
26
- font-family: ${(props) => props.theme.fonts.mainFont};
26
+ font-family: inherit;
27
27
  font-size: 18px;
28
28
  font-style: normal;
29
29
  font-weight: 700;
@@ -37,7 +37,7 @@
37
37
  `
38
38
  const TextContainer = styled.div`
39
39
  color: ${(props) => props.theme.colors.black};
40
- font-family: ${(props) => props.theme.fonts.mainFont};
40
+ font-family: inherit;
41
41
  font-size: 13px;
42
42
  font-style: normal;
43
43
  font-weight: 400;
@@ -1,48 +1,78 @@
1
1
  <template>
2
- <ActionModal :is-open="isOpen" @on-close="closeModal">
2
+ <RCModal data-test-id="infoModal" :is-open="isOpen" @on-close="closeModal">
3
3
  <ModalContainer>
4
- <template #title>
4
+ <ModalTitle v-if="$slots.title" data-test-id="modal_title">
5
5
  <slot name="title"></slot>
6
- </template>
7
- <template #body>
6
+ </ModalTitle>
7
+ <TextContainer v-if="$slots.body" data-test-id="modal_body">
8
8
  <slot name="body"></slot>
9
- </template>
10
- <template #buttons>
11
- <ButtonContainer>
12
- <RCMainButton
13
- min-width="150px"
14
- :text="$gettext('Got it')"
15
- type="primary"
16
- @click="closeModal"
17
- />
18
- </ButtonContainer>
19
- </template>
9
+ </TextContainer>
10
+ <ButtonContainer>
11
+ <RCMainButton
12
+ min-width="150px"
13
+ :text="buttonText"
14
+ type="primary"
15
+ @click="closeModal"
16
+ />
17
+ </ButtonContainer>
20
18
  </ModalContainer>
21
- </ActionModal>
19
+ </RCModal>
22
20
  </template>
23
21
  <script>
24
22
  import styled from 'vue3-styled-components'
25
- import ActionModal from '../actionModal'
23
+ import RCModal from '../modal'
26
24
  import RCMainButton from '../../buttons/mainButton'
25
+
27
26
  const ModalContainer = styled.div`
28
27
  width: 450px;
29
28
  min-height: 205px;
30
29
  padding: 40px 40px 30px 40px;
31
30
  `
31
+ const ModalTitle = styled.div`
32
+ color: ${(props) => props.theme.colors.black};
33
+ font-family: inherit;
34
+ font-size: 18px;
35
+ font-style: normal;
36
+ font-weight: 700;
37
+ line-height: 120%;
38
+ text-transform: uppercase;
39
+ `
32
40
  const ButtonContainer = styled.div`
33
41
  display: inline-flex;
34
42
  align-items: flex-start;
35
43
  gap: 20px;
36
44
  `
45
+ const TextContainer = styled.div`
46
+ color: ${(props) => props.theme.colors.black};
47
+ font-family: inherit;
48
+ font-size: 13px;
49
+ font-style: normal;
50
+ font-weight: 400;
51
+ line-height: normal;
52
+ padding: 30px 0px;
53
+ white-space: pre-wrap;
54
+ `
55
+
37
56
  export default {
38
57
  name: 'InfoModal',
39
58
  components: {
59
+ RCModal,
40
60
  ModalContainer,
61
+ ModalTitle,
41
62
  ButtonContainer,
42
- ActionModal,
63
+ TextContainer,
43
64
  RCMainButton,
44
65
  },
45
- props: ['isOpen'],
66
+ props: {
67
+ isOpen: {
68
+ type: Boolean,
69
+ required: true,
70
+ },
71
+ buttonText: {
72
+ type: String,
73
+ default: 'Got it',
74
+ },
75
+ },
46
76
  methods: {
47
77
  closeModal() {
48
78
  this.$emit('on-close')
@@ -0,0 +1,55 @@
1
+ /* eslint-disable */
2
+ import { mount } from '@vue/test-utils'
3
+ import InfoModal from '@/components/modals/infoModal'
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
+
12
+ describe('InfoModal Component', () => {
13
+ let wrapper
14
+
15
+ beforeEach(() => {
16
+ wrapper = mount(InfoModal, {
17
+ props: {
18
+ isOpen: true,
19
+ buttonText: 'Close',
20
+ },
21
+ slots: {
22
+ title: 'Sample title',
23
+ body: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed tincidunt commodo mollis. Fusce urna felis, malesuada sed elementum et, fermentum ac massa. Integer in massa vel orci fermentum bibendum in ut ante. Donec risus risus, luctus quis ex a, pulvinar placerat lacus. Sed pharetra augue a elit volutpat, eu dignissim ex pretium. Aenean imperdiet, nulla in pharetra rutrum, mauris mauris tincidunt tellus, non tempus quam lorem laoreet lectus.',
24
+ },
25
+ global: {
26
+ provide: {
27
+ theme,
28
+ },
29
+ },
30
+ })
31
+ })
32
+
33
+ test('renders InfoModal component with default props', () => {
34
+ expect(wrapper.find('[data-test-id="infoModal"]').exists()).toBe(true)
35
+
36
+ expect(wrapper.vm.isOpen).toBe(true)
37
+ expect(wrapper.vm.buttonText).toContain('Close')
38
+ })
39
+
40
+ test('info modal slots is display when user passed slots content', () => {
41
+ const modalTitleEl = wrapper.find('[data-test-id="modal_title"]')
42
+ expect(modalTitleEl.text()).toBe('Sample title')
43
+
44
+ const modalBodyEl = wrapper.find('[data-test-id="modal_body"]')
45
+ expect(modalBodyEl.text()).toContain('Lorem ipsum dolor sit amet')
46
+ })
47
+
48
+ test('info modal on-close event is emitted when modal close button is clicked', async () => {
49
+ const modalCloseButton = wrapper.find('.close')
50
+
51
+ modalCloseButton.trigger('click')
52
+ await wrapper.vm.$nextTick()
53
+ expect(wrapper.emitted('on-close')).toBeTruthy()
54
+ })
55
+ })
@@ -0,0 +1,47 @@
1
+ import InfoModal from './index.vue'
2
+
3
+ export default {
4
+ title: 'Components/InfoModal',
5
+ component: InfoModal,
6
+ tags: ['autodocs'],
7
+ parameters: {
8
+ layout: 'centered',
9
+ },
10
+ }
11
+
12
+ // import InfoModal from "@eturnity/eturnity_reusable_components/src/components/modals/infoModal"
13
+ // This is a reusable modal component that can be used to display information to the user.
14
+ // To use:
15
+ // <InfoModal :isOpen="isOpen" @on-close="$emit('on-close-summary')" >
16
+ // <template #title>
17
+ // <h1>Header</h1>
18
+ // </template>
19
+ // <template #body>
20
+ // <p>Body</p>
21
+ // </template>
22
+ // </InfoModal>
23
+
24
+ export const Default = {
25
+ args: {
26
+ isOpen: true,
27
+ buttonText: 'Close',
28
+ },
29
+ render: (args) => ({
30
+ components: { InfoModal },
31
+ setup() {
32
+ return { args }
33
+ },
34
+ template: `
35
+ <InfoModal v-bind="args">
36
+ <template #title>Sample title</template>
37
+ <template #body>
38
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed tincidunt commodo mollis. Fusce urna felis,
39
+ malesuada sed elementum et, fermentum ac massa. Integer in massa vel orci fermentum bibendum in ut ante.
40
+ Donec risus risus, luctus quis ex a, pulvinar placerat lacus. Sed pharetra augue a elit volutpat, eu dignissim
41
+ ex pretium. Aenean imperdiet, nulla in pharetra rutrum, mauris mauris tincidunt tellus, non tempus quam lorem
42
+ laoreet lectus.
43
+ </template>
44
+ </InfoModal>
45
+ `,
46
+ }),
47
+ }
@@ -16,7 +16,6 @@ export default {
16
16
  description: 'Text for tooltip',
17
17
  },
18
18
  },
19
- tags: ['autodocs'],
20
19
  }
21
20
 
22
21
  // To use: