@zap-wunschlachen/wl-shared-components 1.0.35 → 1.0.38

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.
Files changed (30) hide show
  1. package/App.vue +2 -7
  2. package/package.json +1 -1
  3. package/src/components/Audio/Waveform.vue +1 -0
  4. package/src/components/Button/Button.vue +39 -1
  5. package/src/components/CheckBox/CheckBox.css +29 -0
  6. package/src/components/CheckBox/Checkbox.vue +10 -2
  7. package/src/components/Dialog/Dialog.vue +14 -5
  8. package/src/components/Input/Input.vue +8 -2
  9. package/src/components/Loader/Loader.css +20 -0
  10. package/src/components/Loader/Loader.vue +1 -0
  11. package/src/components/OtpInput/OtpInput.vue +1 -1
  12. package/src/components/Select/Select.vue +1 -0
  13. package/src/components/StagingBanner/StagingBanner.css +19 -0
  14. package/src/components/StagingBanner/StagingBanner.vue +82 -0
  15. package/src/components/accessibility.css +218 -0
  16. package/src/components/index.ts +1 -0
  17. package/tests/unit/accessibility/component-a11y.spec.ts +469 -0
  18. package/tests/unit/components/Accordion/AccordionGroup.spec.ts +228 -0
  19. package/tests/unit/components/Accordion/AccordionItem.spec.ts +292 -0
  20. package/tests/unit/components/Appointment/AnamneseNotification.spec.ts +176 -0
  21. package/tests/unit/components/Background/Background.spec.ts +177 -0
  22. package/tests/unit/components/ErrorPage/ErrorPage.spec.ts +313 -0
  23. package/tests/unit/components/ErrorPage/ErrorPageLogo.spec.ts +153 -0
  24. package/tests/unit/components/Icons/AdvanceAppointments.spec.ts +61 -0
  25. package/tests/unit/components/Icons/Logo.spec.ts +228 -0
  26. package/tests/unit/components/Icons/MiniLogo.spec.ts +38 -0
  27. package/tests/unit/components/Icons/SolidArrowRight.spec.ts +49 -0
  28. package/tests/unit/components/Loader/Loader.spec.ts +197 -0
  29. package/tests/unit/components/MaintenanceBanner/MaintenanceBanner.spec.ts +302 -0
  30. package/tests/unit/utils/accessibility.spec.ts +318 -0
@@ -0,0 +1,313 @@
1
+ import { describe, it, expect, vi } from 'vitest';
2
+ import { mount } from '@vue/test-utils';
3
+ import ErrorPage from '@components/ErrorPage/ErrorPage.vue';
4
+
5
+ // Mock siteColors
6
+ vi.mock('@/utils/index', () => ({
7
+ siteColors: {
8
+ domain: 'domain-dental',
9
+ font_color_code: '#172774',
10
+ font_color_title_code: '#172774'
11
+ }
12
+ }));
13
+
14
+ // Mock child components
15
+ vi.mock('@components/Background/Background.vue', () => ({
16
+ default: {
17
+ name: 'Background',
18
+ template: '<div class="background"><slot /></div>'
19
+ }
20
+ }));
21
+
22
+ vi.mock('@components/ErrorPage/ErrorPageLogo.vue', () => ({
23
+ default: {
24
+ name: 'ErrorPageLogo',
25
+ template: '<div class="error-page-logo"></div>'
26
+ }
27
+ }));
28
+
29
+ vi.mock('@components/Icons/Logo.vue', () => ({
30
+ default: {
31
+ name: 'Logo',
32
+ template: '<div class="logo"></div>',
33
+ props: ['width', 'height']
34
+ }
35
+ }));
36
+
37
+ vi.mock('@components/Button/Button.vue', () => ({
38
+ default: {
39
+ name: 'Button',
40
+ template: '<button class="wl-button" @click="$emit(\'click\')">{{ label }}</button>',
41
+ props: ['variant', 'color', 'label'],
42
+ emits: ['click']
43
+ }
44
+ }));
45
+
46
+ describe('ErrorPage', () => {
47
+ const defaultProps = {
48
+ statusCode: 404
49
+ };
50
+
51
+ describe('Default Behavior', () => {
52
+ it('renders with required props', () => {
53
+ const wrapper = mount(ErrorPage, {
54
+ props: defaultProps
55
+ });
56
+
57
+ expect(wrapper.find('.error-page__main').exists()).toBe(true);
58
+ });
59
+
60
+ it('renders status code', () => {
61
+ const wrapper = mount(ErrorPage, {
62
+ props: { statusCode: 500 }
63
+ });
64
+
65
+ expect(wrapper.text()).toContain('500');
66
+ });
67
+
68
+ it('renders error title', () => {
69
+ const wrapper = mount(ErrorPage, {
70
+ props: defaultProps
71
+ });
72
+
73
+ expect(wrapper.find('h1').exists()).toBe(true);
74
+ });
75
+
76
+ it('renders error description', () => {
77
+ const wrapper = mount(ErrorPage, {
78
+ props: defaultProps
79
+ });
80
+
81
+ expect(wrapper.find('.error-page__description').exists()).toBe(true);
82
+ });
83
+
84
+ it('renders back to home button', () => {
85
+ const wrapper = mount(ErrorPage, {
86
+ props: defaultProps
87
+ });
88
+
89
+ const button = wrapper.find('.wl-button');
90
+ expect(button.exists()).toBe(true);
91
+ expect(button.text()).toContain('Zurück zur Startseite');
92
+ });
93
+ });
94
+
95
+ describe('Props', () => {
96
+ it('accepts statusCode as number', () => {
97
+ const wrapper = mount(ErrorPage, {
98
+ props: { statusCode: 403 }
99
+ });
100
+
101
+ expect(wrapper.text()).toContain('403');
102
+ });
103
+
104
+ it('accepts custom redirectTo prop', () => {
105
+ const wrapper = mount(ErrorPage, {
106
+ props: {
107
+ statusCode: 404,
108
+ redirectTo: '/custom-page'
109
+ }
110
+ });
111
+
112
+ expect(wrapper.vm.redirectTo).toBe('/custom-page');
113
+ });
114
+
115
+ it('uses default redirect when redirectTo is not provided', () => {
116
+ const wrapper = mount(ErrorPage, {
117
+ props: { statusCode: 404 }
118
+ });
119
+
120
+ expect(wrapper.vm.redirectTo).toBeUndefined();
121
+ });
122
+ });
123
+
124
+ describe('Content', () => {
125
+ it('displays German error title for dental domain', () => {
126
+ const wrapper = mount(ErrorPage, {
127
+ props: defaultProps
128
+ });
129
+
130
+ expect(wrapper.find('h1').text()).toBe('Huch hier ist eine Lücke...');
131
+ });
132
+
133
+ it('displays German error message', () => {
134
+ const wrapper = mount(ErrorPage, {
135
+ props: defaultProps
136
+ });
137
+
138
+ const description = wrapper.find('.error-page__description');
139
+ expect(description.text()).toContain('Leider ist etwas schiefgelaufen');
140
+ });
141
+ });
142
+
143
+ describe('Accessibility', () => {
144
+ it('has semantic main element', () => {
145
+ const wrapper = mount(ErrorPage, {
146
+ props: defaultProps
147
+ });
148
+
149
+ expect(wrapper.find('main').exists()).toBe(true);
150
+ });
151
+
152
+ it('has h1 heading for error title', () => {
153
+ const wrapper = mount(ErrorPage, {
154
+ props: defaultProps
155
+ });
156
+
157
+ const h1 = wrapper.find('h1');
158
+ expect(h1.exists()).toBe(true);
159
+ expect(h1.text()).toBeTruthy();
160
+ });
161
+
162
+ it('provides meaningful status code display', () => {
163
+ const wrapper = mount(ErrorPage, {
164
+ props: { statusCode: 404 }
165
+ });
166
+
167
+ expect(wrapper.text()).toContain('404');
168
+ });
169
+
170
+ it('has accessible button for navigation', () => {
171
+ const wrapper = mount(ErrorPage, {
172
+ props: defaultProps
173
+ });
174
+
175
+ const button = wrapper.find('button');
176
+ expect(button.exists()).toBe(true);
177
+ expect(button.text()).toBeTruthy();
178
+ });
179
+
180
+ it('has proper visual hierarchy with h1', () => {
181
+ const wrapper = mount(ErrorPage, {
182
+ props: defaultProps
183
+ });
184
+
185
+ const headings = wrapper.findAll('h1, h2, h3, h4, h5, h6');
186
+ expect(headings.length).toBeGreaterThan(0);
187
+
188
+ // First heading should be h1
189
+ expect(headings[0].element.tagName.toLowerCase()).toBe('h1');
190
+ });
191
+
192
+ it('contains descriptive text for screen readers', () => {
193
+ const wrapper = mount(ErrorPage, {
194
+ props: defaultProps
195
+ });
196
+
197
+ const description = wrapper.find('.error-page__description');
198
+ expect(description.text()).toContain('Bitte versuchen Sie es gleich noch einmal');
199
+ });
200
+ });
201
+
202
+ describe('User Interaction', () => {
203
+ let originalLocation: Location | undefined;
204
+
205
+ beforeEach(() => {
206
+ // Save original location and provide a safe mock for tests
207
+ originalLocation = window.location;
208
+
209
+ Object.defineProperty(window, 'location', {
210
+ configurable: true,
211
+ writable: true,
212
+ value: { href: '' } as unknown as Location
213
+ });
214
+ });
215
+
216
+ afterEach(() => {
217
+ // Restore real location
218
+ if (originalLocation) {
219
+ Object.defineProperty(window, 'location', {
220
+ configurable: true,
221
+ writable: true,
222
+ value: originalLocation
223
+ });
224
+ }
225
+ });
226
+
227
+ it('button click triggers redirect', async () => {
228
+ const wrapper = mount(ErrorPage, {
229
+ props: {
230
+ statusCode: 404,
231
+ redirectTo: '/home'
232
+ }
233
+ });
234
+
235
+ const button = wrapper.find('button');
236
+ await button.trigger('click');
237
+
238
+ expect(window.location.href).toBe('/home');
239
+ });
240
+
241
+ it('uses default "/" redirect when no redirectTo provided', async () => {
242
+ const wrapper = mount(ErrorPage, {
243
+ props: { statusCode: 404 }
244
+ });
245
+
246
+ const button = wrapper.find('button');
247
+ await button.trigger('click');
248
+
249
+ expect(window.location.href).toBe('/');
250
+ });
251
+ });
252
+
253
+ describe('Visual Structure', () => {
254
+ it('has proper grid layout', () => {
255
+ const wrapper = mount(ErrorPage, {
256
+ props: defaultProps
257
+ });
258
+
259
+ expect(wrapper.find('.error-page__grid').exists()).toBe(true);
260
+ });
261
+
262
+ it('has status code section with divider', () => {
263
+ const wrapper = mount(ErrorPage, {
264
+ props: defaultProps
265
+ });
266
+
267
+ expect(wrapper.find('.error-page__status-code').exists()).toBe(true);
268
+ expect(wrapper.find('.error-page__divider').exists()).toBe(true);
269
+ });
270
+
271
+ it('renders Logo component', () => {
272
+ const wrapper = mount(ErrorPage, {
273
+ props: defaultProps
274
+ });
275
+
276
+ expect(wrapper.find('.logo').exists()).toBe(true);
277
+ });
278
+ });
279
+
280
+ describe('Error Status Codes', () => {
281
+ const statusCodes = [400, 401, 403, 404, 500, 502, 503];
282
+
283
+ statusCodes.forEach(code => {
284
+ it(`renders correctly for status code ${code}`, () => {
285
+ const wrapper = mount(ErrorPage, {
286
+ props: { statusCode: code }
287
+ });
288
+
289
+ expect(wrapper.text()).toContain(code.toString());
290
+ expect(wrapper.find('h1').exists()).toBe(true);
291
+ expect(wrapper.find('.error-page__description').exists()).toBe(true);
292
+ });
293
+ });
294
+ });
295
+
296
+ describe('Edge Cases', () => {
297
+ it('handles status code 0', () => {
298
+ const wrapper = mount(ErrorPage, {
299
+ props: { statusCode: 0 }
300
+ });
301
+
302
+ expect(wrapper.text()).toContain('0');
303
+ });
304
+
305
+ it('handles large status codes', () => {
306
+ const wrapper = mount(ErrorPage, {
307
+ props: { statusCode: 99999 }
308
+ });
309
+
310
+ expect(wrapper.text()).toContain('99999');
311
+ });
312
+ });
313
+ });
@@ -0,0 +1,153 @@
1
+ import { describe, it, expect, vi } from 'vitest';
2
+ import { mount } from '@vue/test-utils';
3
+ import ErrorPageLogo from '@components/ErrorPage/ErrorPageLogo.vue';
4
+
5
+ // Mock siteColors
6
+ vi.mock('@/utils/index', () => ({
7
+ siteColors: {
8
+ domain: 'domain-dental',
9
+ font_color_code: '#172774'
10
+ }
11
+ }));
12
+
13
+ describe('ErrorPageLogo', () => {
14
+ describe('Default Behavior', () => {
15
+ it('renders SVG element', () => {
16
+ const wrapper = mount(ErrorPageLogo);
17
+ expect(wrapper.find('svg').exists()).toBe(true);
18
+ });
19
+
20
+ it('renders with default size', () => {
21
+ const wrapper = mount(ErrorPageLogo);
22
+ const svg = wrapper.find('svg');
23
+ expect(svg.attributes('width')).toBe('120');
24
+ expect(svg.attributes('height')).toBe('30');
25
+ });
26
+ });
27
+
28
+ describe('Props', () => {
29
+ it('accepts custom width', () => {
30
+ const wrapper = mount(ErrorPageLogo, {
31
+ props: { width: '200' }
32
+ });
33
+
34
+ const svg = wrapper.find('svg');
35
+ expect(svg.attributes('width')).toBe('200');
36
+ });
37
+
38
+ it('accepts custom height', () => {
39
+ const wrapper = mount(ErrorPageLogo, {
40
+ props: { height: '100' }
41
+ });
42
+
43
+ const svg = wrapper.find('svg');
44
+ expect(svg.attributes('height')).toBe('100');
45
+ });
46
+
47
+ it('accepts both width and height', () => {
48
+ const wrapper = mount(ErrorPageLogo, {
49
+ props: {
50
+ width: '250',
51
+ height: '340'
52
+ }
53
+ });
54
+
55
+ const svg = wrapper.find('svg');
56
+ expect(svg.attributes('width')).toBe('250');
57
+ expect(svg.attributes('height')).toBe('340');
58
+ });
59
+ });
60
+
61
+ describe('SVG Structure', () => {
62
+ it('has proper viewBox attribute', () => {
63
+ const wrapper = mount(ErrorPageLogo);
64
+ const svg = wrapper.find('svg');
65
+ expect(svg.attributes('viewBox')).toBeDefined();
66
+ });
67
+
68
+ it('has preserveAspectRatio attribute', () => {
69
+ const wrapper = mount(ErrorPageLogo);
70
+ const svg = wrapper.find('svg');
71
+ expect(svg.attributes('preserveAspectRatio')).toBe('xMidYMid meet');
72
+ });
73
+
74
+ it('contains path elements', () => {
75
+ const wrapper = mount(ErrorPageLogo);
76
+ const paths = wrapper.findAll('path');
77
+ expect(paths.length).toBeGreaterThan(0);
78
+ });
79
+ });
80
+
81
+ describe('Accessibility', () => {
82
+ it('SVG is decorative and hidden from screen readers when appropriate', () => {
83
+ const wrapper = mount(ErrorPageLogo);
84
+ const svg = wrapper.find('svg');
85
+
86
+ // For decorative images, aria-hidden should be true or role="presentation"
87
+ // This logo is decorative when used alongside text
88
+ const ariaHidden = svg.attributes('aria-hidden');
89
+ const role = svg.attributes('role');
90
+ expect(ariaHidden === 'true' || role === 'presentation').toBe(true);
91
+ });
92
+
93
+ it('uses proper fill attributes for theming', () => {
94
+ const wrapper = mount(ErrorPageLogo);
95
+ const paths = wrapper.findAll('path');
96
+
97
+ // All paths should have fill attribute
98
+ paths.forEach(path => {
99
+ expect(path.attributes('fill')).toBeDefined();
100
+ });
101
+ });
102
+
103
+ it('maintains aspect ratio for various sizes', () => {
104
+ const wrapper = mount(ErrorPageLogo, {
105
+ props: {
106
+ width: '500',
107
+ height: '680'
108
+ }
109
+ });
110
+
111
+ const svg = wrapper.find('svg');
112
+ expect(svg.attributes('preserveAspectRatio')).toBe('xMidYMid meet');
113
+ });
114
+ });
115
+
116
+ describe('Domain-specific Rendering', () => {
117
+ it('renders for dental domain', () => {
118
+ const wrapper = mount(ErrorPageLogo);
119
+ expect(wrapper.find('svg').exists()).toBe(true);
120
+ });
121
+ });
122
+
123
+ describe('Edge Cases', () => {
124
+ it('handles empty string width', () => {
125
+ const wrapper = mount(ErrorPageLogo, {
126
+ props: { width: '' }
127
+ });
128
+
129
+ expect(wrapper.find('svg').exists()).toBe(true);
130
+ });
131
+
132
+ it('handles empty string height', () => {
133
+ const wrapper = mount(ErrorPageLogo, {
134
+ props: { height: '' }
135
+ });
136
+
137
+ expect(wrapper.find('svg').exists()).toBe(true);
138
+ });
139
+
140
+ it('renders correctly with numeric string values', () => {
141
+ const wrapper = mount(ErrorPageLogo, {
142
+ props: {
143
+ width: '100',
144
+ height: '50'
145
+ }
146
+ });
147
+
148
+ const svg = wrapper.find('svg');
149
+ expect(svg.attributes('width')).toBe('100');
150
+ expect(svg.attributes('height')).toBe('50');
151
+ });
152
+ });
153
+ });
@@ -0,0 +1,61 @@
1
+ import { describe, it, expect, vi } from 'vitest';
2
+ import { mount } from '@vue/test-utils';
3
+ import AdvanceAppointments from '@components/Icons/AdvanceAppointments.vue';
4
+
5
+ // Mock siteColors if used
6
+ vi.mock('@/utils/index', () => ({
7
+ siteColors: {
8
+ font_color_code: '#172774'
9
+ }
10
+ }));
11
+
12
+ describe('AdvanceAppointments', () => {
13
+ describe('Default Behavior', () => {
14
+ it('renders SVG element', () => {
15
+ const wrapper = mount(AdvanceAppointments);
16
+ expect(wrapper.find('svg').exists()).toBe(true);
17
+ });
18
+ });
19
+
20
+ describe('Accessibility', () => {
21
+ it('is decorative when no accessible props provided (aria-hidden=true)', () => {
22
+ const wrapper = mount(AdvanceAppointments);
23
+ const svg = wrapper.find('svg');
24
+ expect(svg.exists()).toBe(true);
25
+
26
+ // Decorative icons should be hidden from assistive tech
27
+ expect(svg.attributes('aria-hidden')).toBe('true');
28
+ // Should not have an accessible name
29
+ expect(svg.attributes('aria-label')).toBeUndefined();
30
+ expect(svg.attributes('role')).toBeUndefined();
31
+ });
32
+
33
+ it('exposes accessible name and role when labelled', () => {
34
+ const wrapper = mount(AdvanceAppointments, {
35
+ attrs: {
36
+ 'aria-label': 'Advance appointments',
37
+ role: 'img',
38
+ tabindex: '0'
39
+ }
40
+ });
41
+
42
+ const svg = wrapper.find('svg');
43
+ expect(svg.exists()).toBe(true);
44
+
45
+ expect(svg.attributes('aria-hidden')).toBeUndefined();
46
+ expect(svg.attributes('aria-label')).toBe('Advance appointments');
47
+ expect(svg.attributes('role')).toBe('img');
48
+ // When interactive or focusable, should expose tabindex
49
+ expect(svg.attributes('tabindex')).toBe('0');
50
+ });
51
+ });
52
+
53
+ describe('Visual Structure', () => {
54
+ it('contains path elements', () => {
55
+ const wrapper = mount(AdvanceAppointments);
56
+ const paths = wrapper.findAll('path');
57
+ // Icon should have at least one path
58
+ expect(paths.length).toBeGreaterThan(0);
59
+ });
60
+ });
61
+ });