@myparcel-dev/pdk-admin-component-tests 1.13.0

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 (113) hide show
  1. package/CHANGELOG.md +260 -0
  2. package/dist/TestSuite.d.ts +21 -0
  3. package/dist/common/index.d.ts +4 -0
  4. package/dist/common/runCommonComponentTests.d.ts +1 -0
  5. package/dist/common/runCommonInputTests.d.ts +2 -0
  6. package/dist/common/runHasPropTest.d.ts +1 -0
  7. package/dist/common/runHasSlotTest.d.ts +4 -0
  8. package/dist/components/index.d.ts +36 -0
  9. package/dist/components/runBadgeTest.d.ts +1 -0
  10. package/dist/components/runBoxTest.d.ts +1 -0
  11. package/dist/components/runButtonTest.d.ts +1 -0
  12. package/dist/components/runCheckboxGroupTest.d.ts +1 -0
  13. package/dist/components/runCheckboxInputTest.d.ts +1 -0
  14. package/dist/components/runCodeEditorTest.d.ts +1 -0
  15. package/dist/components/runColTest.d.ts +1 -0
  16. package/dist/components/runCurrencyInputTest.d.ts +1 -0
  17. package/dist/components/runDropDownButtonTest.d.ts +1 -0
  18. package/dist/components/runDropOffInputTest.d.ts +1 -0
  19. package/dist/components/runFormGroupTest.d.ts +1 -0
  20. package/dist/components/runHeadingTest.d.ts +1 -0
  21. package/dist/components/runIconTest.d.ts +1 -0
  22. package/dist/components/runImageTest.d.ts +1 -0
  23. package/dist/components/runLinkTest.d.ts +1 -0
  24. package/dist/components/runLoaderTest.d.ts +1 -0
  25. package/dist/components/runModalTest.d.ts +1 -0
  26. package/dist/components/runMultiDateInputTest.d.ts +1 -0
  27. package/dist/components/runMultiSelectInputTest.d.ts +1 -0
  28. package/dist/components/runNotificationTest.d.ts +1 -0
  29. package/dist/components/runNumberInputTest.d.ts +1 -0
  30. package/dist/components/runPlainWrapperTest.d.ts +1 -0
  31. package/dist/components/runRadioGroupTest.d.ts +1 -0
  32. package/dist/components/runRadioInputTest.d.ts +1 -0
  33. package/dist/components/runRowTest.d.ts +1 -0
  34. package/dist/components/runSelectInputTest.d.ts +1 -0
  35. package/dist/components/runSettingsDividerTest.d.ts +1 -0
  36. package/dist/components/runShippingMethodsInputTest.d.ts +1 -0
  37. package/dist/components/runTabNavButtonTest.d.ts +1 -0
  38. package/dist/components/runTableColTest.d.ts +1 -0
  39. package/dist/components/runTableRowTest.d.ts +1 -0
  40. package/dist/components/runTableTest.d.ts +1 -0
  41. package/dist/components/runTextAreaTest.d.ts +1 -0
  42. package/dist/components/runTextInputTest.d.ts +1 -0
  43. package/dist/components/runTimeInputTest.d.ts +1 -0
  44. package/dist/components/runToggleInputTest.d.ts +1 -0
  45. package/dist/components/runTriStateInputTest.d.ts +1 -0
  46. package/dist/helpers/createInputOptions.d.ts +4 -0
  47. package/dist/helpers/index.d.ts +1 -0
  48. package/dist/helpers/wrapperPlugin.d.ts +2 -0
  49. package/dist/index.d.ts +3 -0
  50. package/dist/setup.d.ts +1 -0
  51. package/dist/tests/executeAdminComponentTest.d.ts +3 -0
  52. package/dist/tests/executePdkComponentTests.d.ts +2 -0
  53. package/dist/tests/index.d.ts +3 -0
  54. package/dist/tests/testMap.d.ts +4 -0
  55. package/dist/types.d.ts +10 -0
  56. package/package.json +62 -0
  57. package/src/TestSuite.ts +147 -0
  58. package/src/__tests__/__snapshots__/exports.spec.ts.snap +177 -0
  59. package/src/__tests__/exports.spec.ts +8 -0
  60. package/src/common/index.ts +4 -0
  61. package/src/common/runCommonComponentTests.ts +15 -0
  62. package/src/common/runCommonInputTests.ts +66 -0
  63. package/src/common/runHasPropTest.ts +17 -0
  64. package/src/common/runHasSlotTest.ts +25 -0
  65. package/src/components/index.ts +36 -0
  66. package/src/components/runBadgeTest.ts +9 -0
  67. package/src/components/runBoxTest.ts +17 -0
  68. package/src/components/runButtonTest.ts +37 -0
  69. package/src/components/runCheckboxGroupTest.ts +29 -0
  70. package/src/components/runCheckboxInputTest.ts +13 -0
  71. package/src/components/runCodeEditorTest.ts +11 -0
  72. package/src/components/runColTest.ts +11 -0
  73. package/src/components/runCurrencyInputTest.ts +13 -0
  74. package/src/components/runDropDownButtonTest.ts +81 -0
  75. package/src/components/runDropOffInputTest.ts +32 -0
  76. package/src/components/runFormGroupTest.ts +17 -0
  77. package/src/components/runHeadingTest.ts +12 -0
  78. package/src/components/runIconTest.ts +16 -0
  79. package/src/components/runImageTest.ts +22 -0
  80. package/src/components/runLinkTest.ts +12 -0
  81. package/src/components/runLoaderTest.ts +9 -0
  82. package/src/components/runModalTest.ts +28 -0
  83. package/src/components/runMultiDateInputTest.ts +10 -0
  84. package/src/components/runMultiSelectInputTest.ts +17 -0
  85. package/src/components/runNotificationTest.ts +40 -0
  86. package/src/components/runNumberInputTest.ts +13 -0
  87. package/src/components/runPlainWrapperTest.ts +12 -0
  88. package/src/components/runRadioGroupTest.ts +26 -0
  89. package/src/components/runRadioInputTest.ts +13 -0
  90. package/src/components/runRowTest.ts +11 -0
  91. package/src/components/runSelectInputTest.ts +30 -0
  92. package/src/components/runSettingsDividerTest.ts +16 -0
  93. package/src/components/runShippingMethodsInputTest.ts +23 -0
  94. package/src/components/runTabNavButtonTest.ts +17 -0
  95. package/src/components/runTableColTest.ts +11 -0
  96. package/src/components/runTableRowTest.ts +11 -0
  97. package/src/components/runTableTest.ts +13 -0
  98. package/src/components/runTextAreaTest.ts +12 -0
  99. package/src/components/runTextInputTest.ts +12 -0
  100. package/src/components/runTimeInputTest.ts +13 -0
  101. package/src/components/runToggleInputTest.ts +16 -0
  102. package/src/components/runTriStateInputTest.ts +15 -0
  103. package/src/helpers/createInputOptions.ts +19 -0
  104. package/src/helpers/index.ts +1 -0
  105. package/src/helpers/wrapperPlugin.ts +20 -0
  106. package/src/index.ts +5 -0
  107. package/src/setup.ts +4 -0
  108. package/src/tests/executeAdminComponentTest.ts +47 -0
  109. package/src/tests/executePdkComponentTests.ts +19 -0
  110. package/src/tests/index.ts +3 -0
  111. package/src/tests/testMap.ts +111 -0
  112. package/src/types.ts +24 -0
  113. package/src/vue.shims.d.ts +26 -0
@@ -0,0 +1,81 @@
1
+ /* eslint-disable no-console */
2
+ import {expect, it, vi} from 'vitest';
3
+ import {type ComponentMountingOptions, mount} from '@vue/test-utils';
4
+ import {AdminComponent, type DropdownButtonProps} from '@myparcel-dev/pdk-admin';
5
+ import {type AdminComponentTest} from '../tests';
6
+ import {TestSuite} from '../TestSuite';
7
+
8
+ export const runDropDownButtonTest = ((component) => {
9
+ const suite = new TestSuite(AdminComponent.DropdownButton, component);
10
+
11
+ const action1Handler = vi.fn();
12
+ const action2Handler = vi.fn();
13
+ const action3Handler = vi.fn();
14
+
15
+ const DEFAULT_OPTIONS = {
16
+ props: {
17
+ actions: [
18
+ {
19
+ label: 'Action 1',
20
+ id: 'action1',
21
+ standalone: true,
22
+ handler: action1Handler,
23
+ },
24
+ {
25
+ label: 'Action 2',
26
+ id: 'action2',
27
+ handler: action2Handler,
28
+ },
29
+ {
30
+ label: 'Action 3',
31
+ id: 'action3',
32
+ handler: action3Handler,
33
+ },
34
+ ],
35
+ },
36
+ } satisfies ComponentMountingOptions<any, DropdownButtonProps>;
37
+
38
+ suite.runCommonComponentTests();
39
+ suite.runCommonComponentTests(DEFAULT_OPTIONS);
40
+
41
+ suite.runHasPropTest('actions', DEFAULT_OPTIONS.props.actions);
42
+ suite.runHasPropTest('disabled', true);
43
+
44
+ it('emits click event when standalone action is clicked', async () => {
45
+ expect.assertions(1);
46
+ const wrapper = mount(component, DEFAULT_OPTIONS);
47
+ const button = wrapper.findByTestId([AdminComponent.DropdownButton, 'standalone']);
48
+ await button.trigger('click');
49
+
50
+ expect(wrapper.emitted().click).toHaveLength(1);
51
+ });
52
+
53
+ it('emits click event when dropdown action is clicked', async () => {
54
+ expect.assertions(1);
55
+ const wrapper = mount(component, DEFAULT_OPTIONS);
56
+ const button = wrapper.findByTestId([AdminComponent.DropdownButton, 'item']);
57
+ await button.trigger('click');
58
+
59
+ expect(wrapper.emitted().click).toHaveLength(1);
60
+ });
61
+
62
+ it('can be disabled', async () => {
63
+ expect.assertions(2);
64
+ const wrapper = mount(component, {
65
+ ...DEFAULT_OPTIONS,
66
+ props: {
67
+ ...DEFAULT_OPTIONS.props,
68
+ disabled: true,
69
+ },
70
+ });
71
+
72
+ const button = wrapper.findByTestId([AdminComponent.DropdownButton, 'button']);
73
+ expect(button.attributes('disabled')).toBeDefined();
74
+
75
+ await button.trigger('click');
76
+ await wrapper.vm.$nextTick();
77
+ expect(wrapper.emitted().click).toBeUndefined();
78
+ });
79
+
80
+ // TODO write more tests
81
+ }) satisfies AdminComponentTest;
@@ -0,0 +1,32 @@
1
+ import {AdminComponent, type DropOffInputModelValue} from '@myparcel-dev/pdk-admin';
2
+ import {type AdminComponentTest} from '../tests';
3
+ import {TestSuite} from '../TestSuite';
4
+
5
+ export const runDropOffInputTest = ((component) => {
6
+ const suite = new TestSuite(AdminComponent.DropOffInput, component);
7
+
8
+ suite.setOptions({
9
+ dropOffDays: [
10
+ {
11
+ date: {date: '', timezone: '', timezone_type: 3},
12
+ cutoffTime: '12:00',
13
+ dispatch: true,
14
+ sameDayCutoffTime: '',
15
+ weekday: 2,
16
+ },
17
+ ],
18
+ dropOffDaysDeviations: [],
19
+ } satisfies DropOffInputModelValue);
20
+
21
+ suite.runCommonComponentTests();
22
+ suite.runCommonInputTests({
23
+ value: {
24
+ date: {date: '1234', timezone: '', timezone_type: 3},
25
+ cutoffTime: '15:00',
26
+ dispatch: true,
27
+ sameDayCutoffTime: '',
28
+ weekday: 4,
29
+ },
30
+ });
31
+ // TODO write more tests
32
+ }) satisfies AdminComponentTest;
@@ -0,0 +1,17 @@
1
+ import {AdminComponent, createFormElement} from '@myparcel-dev/pdk-admin';
2
+ import {type AdminComponentTest} from '../tests';
3
+ import {TestSuite} from '../TestSuite';
4
+
5
+ export const runFormGroupTest = ((component) => {
6
+ const suite = new TestSuite(AdminComponent.FormGroup, component);
7
+
8
+ suite.setOptions({
9
+ props: {
10
+ element: createFormElement({}),
11
+ },
12
+ });
13
+
14
+ suite.runCommonComponentTests();
15
+ suite.runHasSlotTest();
16
+ // TODO write more tests
17
+ }) satisfies AdminComponentTest;
@@ -0,0 +1,12 @@
1
+ import {AdminComponent} from '@myparcel-dev/pdk-admin';
2
+ import {type AdminComponentTest} from '../tests';
3
+ import {TestSuite} from '../TestSuite';
4
+
5
+ export const runHeadingTest = ((component) => {
6
+ const suite = new TestSuite(AdminComponent.Heading, component);
7
+
8
+ suite.runCommonComponentTests();
9
+
10
+ suite.runHasSlotTest();
11
+ suite.runHasPropTest('level', 1);
12
+ }) satisfies AdminComponentTest;
@@ -0,0 +1,16 @@
1
+ import {AdminComponent, AdminIcon} from '@myparcel-dev/pdk-admin';
2
+ import {type PartialComponentTest} from '../types';
3
+ import {TestSuite} from '../TestSuite';
4
+
5
+ export const runIconTest = ((component) => {
6
+ const suite = new TestSuite(AdminComponent.Icon, component);
7
+
8
+ suite.setOptions({
9
+ props: {
10
+ icon: AdminIcon.ArrowUp,
11
+ },
12
+ });
13
+
14
+ suite.runCommonComponentTests();
15
+ suite.runHasPropTest('icon');
16
+ }) satisfies PartialComponentTest;
@@ -0,0 +1,22 @@
1
+ import {AdminComponent} from '@myparcel-dev/pdk-admin';
2
+ import {type AdminComponentTest} from '../tests';
3
+ import {TestSuite} from '../TestSuite';
4
+
5
+ export const runImageTest = ((component) => {
6
+ const suite = new TestSuite(AdminComponent.Image, component);
7
+
8
+ suite.setOptions({
9
+ props: {
10
+ src: 'https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png',
11
+ alt: 'Google Logo',
12
+ },
13
+ });
14
+
15
+ suite.runCommonComponentTests();
16
+ suite.runHasPropTest('src');
17
+ suite.runHasPropTest('alt');
18
+ suite.runHasPropTest('width');
19
+ suite.runHasPropTest('height');
20
+
21
+ // TODO write more tests
22
+ }) satisfies AdminComponentTest;
@@ -0,0 +1,12 @@
1
+ import {AdminComponent} from '@myparcel-dev/pdk-admin';
2
+ import {type AdminComponentTest} from '../tests';
3
+ import {TestSuite} from '../TestSuite';
4
+
5
+ export const runLinkTest = ((component) => {
6
+ const suite = new TestSuite(AdminComponent.Link, component);
7
+
8
+ suite.runCommonComponentTests();
9
+ suite.runHasSlotTest();
10
+
11
+ // TODO write more tests
12
+ }) satisfies AdminComponentTest;
@@ -0,0 +1,9 @@
1
+ import {AdminComponent} from '@myparcel-dev/pdk-admin';
2
+ import {type AdminComponentTest} from '../tests';
3
+ import {TestSuite} from '../TestSuite';
4
+
5
+ export const runLoaderTest = ((component) => {
6
+ const suite = new TestSuite(AdminComponent.Loader, component);
7
+
8
+ suite.runCommonComponentTests();
9
+ }) satisfies AdminComponentTest;
@@ -0,0 +1,28 @@
1
+ import {AdminComponent, AdminModalKey, useModalStore} from '@myparcel-dev/pdk-admin';
2
+ import {type AdminComponentTest} from '../tests';
3
+ import {TestSuite} from '../TestSuite';
4
+
5
+ export const runModalTest = ((component) => {
6
+ const suite = new TestSuite(AdminComponent.Modal, component);
7
+
8
+ const modalStore = useModalStore();
9
+
10
+ modalStore.$patch({opened: AdminModalKey.ShipmentOptions});
11
+
12
+ suite.setOptions({
13
+ props: {
14
+ // todo
15
+ actions: [],
16
+ modalKey: AdminModalKey.ShipmentOptions,
17
+ title: 'title',
18
+ },
19
+ });
20
+
21
+ suite.runCommonComponentTests();
22
+
23
+ suite.runHasSlotTest();
24
+
25
+ suite.runHasPropTest('modalKey');
26
+ suite.runHasPropTest('title');
27
+ suite.runHasPropTest('actions');
28
+ }) satisfies AdminComponentTest;
@@ -0,0 +1,10 @@
1
+ import {AdminComponent} from '@myparcel-dev/pdk-admin';
2
+ import {type AdminComponentTest} from '../tests';
3
+ import {TestSuite} from '../TestSuite';
4
+
5
+ export const runMultiDateInputTest = ((component) => {
6
+ const suite = new TestSuite(AdminComponent.MultiDateInput, component);
7
+
8
+ suite.runCommonComponentTests();
9
+ // TODO write more tests
10
+ }) satisfies AdminComponentTest;
@@ -0,0 +1,17 @@
1
+ import {AdminComponent, type SelectOption} from '@myparcel-dev/pdk-admin';
2
+ import {type AdminComponentTest} from '../tests';
3
+ import {TestSuite} from '../TestSuite';
4
+
5
+ const selectOptions = [
6
+ {value: 'one', label: 'One'},
7
+ {value: 'two', label: 'Two'},
8
+ ] satisfies SelectOption[];
9
+
10
+ export const runMultiSelectInputTest = ((component) => {
11
+ const suite = new TestSuite(AdminComponent.MultiSelectInput, component);
12
+
13
+ suite.createInputOptions('two', {props: {options: selectOptions}});
14
+
15
+ suite.runCommonComponentTests();
16
+ suite.runCommonInputTests({value: 'one'});
17
+ }) satisfies AdminComponentTest;
@@ -0,0 +1,40 @@
1
+ import {expect, it} from 'vitest';
2
+ import {mount} from '@vue/test-utils';
3
+ import {AdminComponent} from '@myparcel-dev/pdk-admin';
4
+ import {type AdminComponentTest} from '../tests';
5
+ import {TestSuite} from '../TestSuite';
6
+
7
+ export const runNotificationTest = ((component) => {
8
+ const suite = new TestSuite(AdminComponent.Notification, component);
9
+
10
+ const options = suite.setOptions({
11
+ props: {
12
+ notification: {
13
+ variant: 'error',
14
+ content: 'This is a plain string',
15
+ },
16
+ },
17
+ });
18
+
19
+ suite.runCommonComponentTests();
20
+
21
+ it('renders notification with string content', () => {
22
+ const wrapper = mount(component, options);
23
+
24
+ expect(wrapper.findAll('*').map((wrapper) => wrapper.text())).toContain('This is a plain string');
25
+ });
26
+
27
+ it('renders notification with array content', () => {
28
+ const wrapper = mount(component, {
29
+ props: {
30
+ notification: {
31
+ variant: 'error',
32
+ content: ['This is a notification', 'With multiple strings'],
33
+ },
34
+ },
35
+ });
36
+
37
+ expect(wrapper.findAll('*').map((wrapper) => wrapper.text())).toContain('This is a notification');
38
+ expect(wrapper.findAll('*').map((wrapper) => wrapper.text())).toContain('With multiple strings');
39
+ });
40
+ }) satisfies AdminComponentTest;
@@ -0,0 +1,13 @@
1
+ import {AdminComponent} from '@myparcel-dev/pdk-admin';
2
+ import {type AdminComponentTest} from '../tests';
3
+ import {TestSuite} from '../TestSuite';
4
+
5
+ export const runNumberInputTest = ((component) => {
6
+ const suite = new TestSuite(AdminComponent.NumberInput, component);
7
+
8
+ suite.createInputOptions(24);
9
+
10
+ suite.runCommonComponentTests();
11
+ suite.runCommonInputTests();
12
+ // TODO write more tests
13
+ }) satisfies AdminComponentTest;
@@ -0,0 +1,12 @@
1
+ import {type AdminComponentTest} from '../tests';
2
+ import {TestSuite} from '../TestSuite';
3
+
4
+ export const runPlainWrapperTest = ((component) => {
5
+ const suite = new TestSuite('PlainWrapper', component);
6
+
7
+ suite.runCommonComponentTests();
8
+
9
+ suite.runHasSlotTest();
10
+
11
+ // TODO write more tests
12
+ }) satisfies AdminComponentTest;
@@ -0,0 +1,26 @@
1
+ import {AdminComponent, type SelectOption} from '@myparcel-dev/pdk-admin';
2
+ import {type AdminComponentTest} from '../tests';
3
+ import {TestSuite} from '../TestSuite';
4
+
5
+ export const runRadioGroupTest = ((component) => {
6
+ const suite = new TestSuite(AdminComponent.RadioGroup, component);
7
+
8
+ suite.createInputOptions('test1', {
9
+ props: {
10
+ options: [
11
+ {
12
+ label: 'Test1',
13
+ value: 'test1',
14
+ },
15
+ {
16
+ label: 'Test2',
17
+ value: 'test2',
18
+ },
19
+ ] satisfies SelectOption[],
20
+ },
21
+ });
22
+
23
+ suite.runCommonComponentTests();
24
+ suite.runCommonInputTests();
25
+ // TODO write more tests
26
+ }) satisfies AdminComponentTest;
@@ -0,0 +1,13 @@
1
+ import {AdminComponent} from '@myparcel-dev/pdk-admin';
2
+ import {type AdminComponentTest} from '../tests';
3
+ import {TestSuite} from '../TestSuite';
4
+
5
+ export const runRadioInputTest = ((component) => {
6
+ const suite = new TestSuite(AdminComponent.RadioInput, component);
7
+
8
+ suite.createInputOptions(true);
9
+
10
+ suite.runCommonComponentTests();
11
+ suite.runCommonInputTests();
12
+ // TODO write more tests
13
+ }) satisfies AdminComponentTest;
@@ -0,0 +1,11 @@
1
+ import {AdminComponent} from '@myparcel-dev/pdk-admin';
2
+ import {type AdminComponentTest} from '../tests';
3
+ import {TestSuite} from '../TestSuite';
4
+
5
+ export const runRowTest = ((component) => {
6
+ const suite = new TestSuite(AdminComponent.Row, component);
7
+
8
+ suite.runCommonComponentTests();
9
+
10
+ suite.runHasSlotTest();
11
+ }) satisfies AdminComponentTest;
@@ -0,0 +1,30 @@
1
+ import {expect, it} from 'vitest';
2
+ import {mount} from '@vue/test-utils';
3
+ import {AdminComponent, type SelectOption} from '@myparcel-dev/pdk-admin';
4
+ import {type PartialComponentTest} from '../types';
5
+ import {TestSuite} from '../TestSuite';
6
+
7
+ const selectOptions = [
8
+ {value: '1', label: 'One'},
9
+ {value: '2', label: 'Two'},
10
+ ] satisfies SelectOption[];
11
+
12
+ export const runSelectInputTest = ((component) => {
13
+ const suite = new TestSuite(AdminComponent.SelectInput, component);
14
+
15
+ const options = suite.createInputOptions('2', {props: {options: selectOptions}});
16
+
17
+ suite.runCommonComponentTests();
18
+ suite.runCommonInputTests({value: '1'});
19
+
20
+ it('sets options from props', () => {
21
+ const wrapper = mount(component, options);
22
+
23
+ expect(
24
+ wrapper
25
+ .find('select')
26
+ .findAll('option')
27
+ .map((wrapper) => wrapper.element.value),
28
+ ).toEqual(['1', '2']);
29
+ });
30
+ }) satisfies PartialComponentTest;
@@ -0,0 +1,16 @@
1
+ import {AdminComponent} from '@myparcel-dev/pdk-admin';
2
+ import {type AdminComponentTest} from '../tests';
3
+ import {TestSuite} from '../TestSuite';
4
+
5
+ export const runSettingsDividerTest = ((component) => {
6
+ const suite = new TestSuite(AdminComponent.SettingsDivider, component);
7
+
8
+ suite.createInputOptions('text', {
9
+ props: {
10
+ level: 2,
11
+ heading: 'test',
12
+ },
13
+ });
14
+
15
+ suite.runCommonComponentTests();
16
+ }) satisfies AdminComponentTest;
@@ -0,0 +1,23 @@
1
+ import {AdminComponent, type SelectOption} from '@myparcel-dev/pdk-admin';
2
+ import {type AdminComponentTest} from '../tests';
3
+ import {TestSuite} from '../TestSuite';
4
+
5
+ const SELECT_OPTIONS = Object.freeze([
6
+ {value: '1', label: 'One'},
7
+ {value: '2', label: 'Two'},
8
+ {value: '3', label: 'Three'},
9
+ {value: '4', label: 'Four'},
10
+ {value: '5', label: 'Five'},
11
+ ] satisfies SelectOption[]);
12
+
13
+ export const runShippingMethodsInputTest = ((component) => {
14
+ const suite = new TestSuite(AdminComponent.ShippingMethodsInput, component);
15
+
16
+ suite.createInputOptions('2', {props: {options: SELECT_OPTIONS}});
17
+
18
+ suite.runCommonComponentTests();
19
+ // TODO: figure out why this throws an undefined import error on AdminComponent
20
+ // runCommonInputTests(component, options, {value: '1'});
21
+
22
+ // TODO add more tests
23
+ }) satisfies AdminComponentTest;
@@ -0,0 +1,17 @@
1
+ import {AdminComponent} from '@myparcel-dev/pdk-admin';
2
+ import {type AdminComponentTest} from '../tests';
3
+ import {TestSuite} from '../TestSuite';
4
+
5
+ export const runTabNavButtonTest = ((component) => {
6
+ const suite = new TestSuite(AdminComponent.SelectInput, component);
7
+
8
+ suite.setOptions({
9
+ props: {
10
+ tab: {name: 'tab', label: 'Tab'},
11
+ },
12
+ });
13
+
14
+ suite.runCommonComponentTests();
15
+
16
+ suite.runHasPropTest('active', false);
17
+ }) satisfies AdminComponentTest;
@@ -0,0 +1,11 @@
1
+ import {AdminComponent} from '@myparcel-dev/pdk-admin';
2
+ import {type AdminComponentTest} from '../tests';
3
+ import {TestSuite} from '../TestSuite';
4
+
5
+ export const runTableColTest = ((component) => {
6
+ const suite = new TestSuite(AdminComponent.TableCol, component);
7
+
8
+ suite.runCommonComponentTests();
9
+
10
+ suite.runHasSlotTest();
11
+ }) satisfies AdminComponentTest;
@@ -0,0 +1,11 @@
1
+ import {AdminComponent} from '@myparcel-dev/pdk-admin';
2
+ import {type AdminComponentTest} from '../tests';
3
+ import {TestSuite} from '../TestSuite';
4
+
5
+ export const runTableRowTest = ((component) => {
6
+ const suite = new TestSuite(AdminComponent.TableRow, component);
7
+
8
+ suite.runCommonComponentTests();
9
+
10
+ suite.runHasSlotTest();
11
+ }) satisfies AdminComponentTest;
@@ -0,0 +1,13 @@
1
+ import {AdminComponent} from '@myparcel-dev/pdk-admin';
2
+ import {type AdminComponentTest} from '../tests';
3
+ import {TestSuite} from '../TestSuite';
4
+
5
+ export const runTableTest = ((component) => {
6
+ const suite = new TestSuite(AdminComponent.Table, component);
7
+
8
+ suite.runCommonComponentTests();
9
+
10
+ suite.runHasSlotTest();
11
+ suite.runHasSlotTest('header');
12
+ suite.runHasSlotTest('footer');
13
+ }) satisfies AdminComponentTest;
@@ -0,0 +1,12 @@
1
+ import {AdminComponent} from '@myparcel-dev/pdk-admin';
2
+ import {type AdminComponentTest} from '../tests';
3
+ import {TestSuite} from '../TestSuite';
4
+
5
+ export const runTextAreaTest = ((component) => {
6
+ const suite = new TestSuite(AdminComponent.SelectInput, component);
7
+
8
+ suite.createInputOptions('test');
9
+
10
+ suite.runCommonComponentTests();
11
+ // runCommonInputTests(component, options);
12
+ }) satisfies AdminComponentTest;
@@ -0,0 +1,12 @@
1
+ import {AdminComponent} from '@myparcel-dev/pdk-admin';
2
+ import {type AdminComponentTest} from '../tests';
3
+ import {TestSuite} from '../TestSuite';
4
+
5
+ export const runTextInputTest = ((component) => {
6
+ const suite = new TestSuite(AdminComponent.SelectInput, component);
7
+
8
+ suite.createInputOptions('text');
9
+
10
+ suite.runCommonComponentTests();
11
+ suite.runCommonInputTests();
12
+ }) satisfies AdminComponentTest;
@@ -0,0 +1,13 @@
1
+ import {AdminComponent} from '@myparcel-dev/pdk-admin';
2
+ import {type AdminComponentTest} from '../tests';
3
+ import {TestSuite} from '../TestSuite';
4
+
5
+ export const runTimeInputTest = ((component) => {
6
+ const suite = new TestSuite(AdminComponent.TimeInput, component);
7
+
8
+ suite.createInputOptions('12:00');
9
+
10
+ suite.runCommonComponentTests();
11
+ suite.runCommonInputTests({value: '13:00'});
12
+ // TODO write more tests
13
+ }) satisfies AdminComponentTest;
@@ -0,0 +1,16 @@
1
+ import {AdminComponent, createFormElement} from '@myparcel-dev/pdk-admin';
2
+ import {type AdminComponentTest} from '../tests';
3
+ import {TestSuite} from '../TestSuite';
4
+
5
+ export const runToggleInputTest = ((component) => {
6
+ const suite = new TestSuite(AdminComponent.ToggleInput, component);
7
+
8
+ suite.setOptions({
9
+ props: {
10
+ element: createFormElement({}),
11
+ },
12
+ });
13
+
14
+ suite.runCommonComponentTests();
15
+ suite.runCommonInputTests();
16
+ }) satisfies AdminComponentTest;
@@ -0,0 +1,15 @@
1
+ import {TriState} from '@myparcel-dev/pdk-common';
2
+ import {AdminComponent} from '@myparcel-dev/pdk-admin';
3
+ import {type AdminComponentTest} from '../tests';
4
+ import {TestSuite} from '../TestSuite';
5
+
6
+ export const runTriStateInputTest = ((component) => {
7
+ const suite = new TestSuite(AdminComponent.SelectInput, component);
8
+
9
+ suite.createInputOptions(TriState.On);
10
+
11
+ suite.runCommonComponentTests();
12
+ suite.runCommonInputTests();
13
+
14
+ // TODO: write more tests
15
+ }) satisfies AdminComponentTest;
@@ -0,0 +1,19 @@
1
+ import {type Component as ComponentType} from 'vue';
2
+ import {createFormElement} from '@myparcel-dev/pdk-admin';
3
+ import {type InteractiveElementConfiguration} from '@myparcel-dev/vue-form-builder';
4
+ import {type TestComponentMountingOptions} from '../types';
5
+
6
+ export const createInputOptions = <
7
+ T,
8
+ Component extends ComponentType = ComponentType,
9
+ Options extends Record<string, unknown> = Record<string, unknown>,
10
+ >(
11
+ modelValue?: T,
12
+ options?: Partial<InteractiveElementConfiguration>,
13
+ ): TestComponentMountingOptions<Component, Options> =>
14
+ ({
15
+ props: {
16
+ element: createFormElement(options),
17
+ ...(modelValue === undefined ? {} : {modelValue}),
18
+ },
19
+ } as TestComponentMountingOptions<Component, Options>);
@@ -0,0 +1 @@
1
+ export * from './createInputOptions';
@@ -0,0 +1,20 @@
1
+ import {createWrapperError, DOMWrapper, type VueWrapper} from '@vue/test-utils';
2
+
3
+ export const wrapperPlugin = (wrapper: VueWrapper): Record<string, any> => {
4
+ const findByTestId = (selector: string | string[]): DOMWrapper<any> => {
5
+ const resolvedSelector = Array.isArray(selector) ? selector.join('--') : selector;
6
+
7
+ const dataSelector = `[data-test-id="${resolvedSelector}"]`;
8
+ const element = wrapper.element.querySelector(dataSelector);
9
+
10
+ if (element) {
11
+ return new DOMWrapper(element);
12
+ }
13
+
14
+ return createWrapperError('DOMWrapper');
15
+ };
16
+
17
+ return {
18
+ findByTestId,
19
+ };
20
+ };
package/src/index.ts ADDED
@@ -0,0 +1,5 @@
1
+ export * from '@myparcel-dev/pdk-admin';
2
+
3
+ export {TestSuite} from './TestSuite';
4
+
5
+ export {executeAdminComponentTest, executePdkComponentTests} from './tests';
package/src/setup.ts ADDED
@@ -0,0 +1,4 @@
1
+ import {config} from '@vue/test-utils';
2
+ import {wrapperPlugin} from './helpers/wrapperPlugin';
3
+
4
+ config.plugins.VueWrapper.install(wrapperPlugin);