@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.
- package/CHANGELOG.md +260 -0
- package/dist/TestSuite.d.ts +21 -0
- package/dist/common/index.d.ts +4 -0
- package/dist/common/runCommonComponentTests.d.ts +1 -0
- package/dist/common/runCommonInputTests.d.ts +2 -0
- package/dist/common/runHasPropTest.d.ts +1 -0
- package/dist/common/runHasSlotTest.d.ts +4 -0
- package/dist/components/index.d.ts +36 -0
- package/dist/components/runBadgeTest.d.ts +1 -0
- package/dist/components/runBoxTest.d.ts +1 -0
- package/dist/components/runButtonTest.d.ts +1 -0
- package/dist/components/runCheckboxGroupTest.d.ts +1 -0
- package/dist/components/runCheckboxInputTest.d.ts +1 -0
- package/dist/components/runCodeEditorTest.d.ts +1 -0
- package/dist/components/runColTest.d.ts +1 -0
- package/dist/components/runCurrencyInputTest.d.ts +1 -0
- package/dist/components/runDropDownButtonTest.d.ts +1 -0
- package/dist/components/runDropOffInputTest.d.ts +1 -0
- package/dist/components/runFormGroupTest.d.ts +1 -0
- package/dist/components/runHeadingTest.d.ts +1 -0
- package/dist/components/runIconTest.d.ts +1 -0
- package/dist/components/runImageTest.d.ts +1 -0
- package/dist/components/runLinkTest.d.ts +1 -0
- package/dist/components/runLoaderTest.d.ts +1 -0
- package/dist/components/runModalTest.d.ts +1 -0
- package/dist/components/runMultiDateInputTest.d.ts +1 -0
- package/dist/components/runMultiSelectInputTest.d.ts +1 -0
- package/dist/components/runNotificationTest.d.ts +1 -0
- package/dist/components/runNumberInputTest.d.ts +1 -0
- package/dist/components/runPlainWrapperTest.d.ts +1 -0
- package/dist/components/runRadioGroupTest.d.ts +1 -0
- package/dist/components/runRadioInputTest.d.ts +1 -0
- package/dist/components/runRowTest.d.ts +1 -0
- package/dist/components/runSelectInputTest.d.ts +1 -0
- package/dist/components/runSettingsDividerTest.d.ts +1 -0
- package/dist/components/runShippingMethodsInputTest.d.ts +1 -0
- package/dist/components/runTabNavButtonTest.d.ts +1 -0
- package/dist/components/runTableColTest.d.ts +1 -0
- package/dist/components/runTableRowTest.d.ts +1 -0
- package/dist/components/runTableTest.d.ts +1 -0
- package/dist/components/runTextAreaTest.d.ts +1 -0
- package/dist/components/runTextInputTest.d.ts +1 -0
- package/dist/components/runTimeInputTest.d.ts +1 -0
- package/dist/components/runToggleInputTest.d.ts +1 -0
- package/dist/components/runTriStateInputTest.d.ts +1 -0
- package/dist/helpers/createInputOptions.d.ts +4 -0
- package/dist/helpers/index.d.ts +1 -0
- package/dist/helpers/wrapperPlugin.d.ts +2 -0
- package/dist/index.d.ts +3 -0
- package/dist/setup.d.ts +1 -0
- package/dist/tests/executeAdminComponentTest.d.ts +3 -0
- package/dist/tests/executePdkComponentTests.d.ts +2 -0
- package/dist/tests/index.d.ts +3 -0
- package/dist/tests/testMap.d.ts +4 -0
- package/dist/types.d.ts +10 -0
- package/package.json +62 -0
- package/src/TestSuite.ts +147 -0
- package/src/__tests__/__snapshots__/exports.spec.ts.snap +177 -0
- package/src/__tests__/exports.spec.ts +8 -0
- package/src/common/index.ts +4 -0
- package/src/common/runCommonComponentTests.ts +15 -0
- package/src/common/runCommonInputTests.ts +66 -0
- package/src/common/runHasPropTest.ts +17 -0
- package/src/common/runHasSlotTest.ts +25 -0
- package/src/components/index.ts +36 -0
- package/src/components/runBadgeTest.ts +9 -0
- package/src/components/runBoxTest.ts +17 -0
- package/src/components/runButtonTest.ts +37 -0
- package/src/components/runCheckboxGroupTest.ts +29 -0
- package/src/components/runCheckboxInputTest.ts +13 -0
- package/src/components/runCodeEditorTest.ts +11 -0
- package/src/components/runColTest.ts +11 -0
- package/src/components/runCurrencyInputTest.ts +13 -0
- package/src/components/runDropDownButtonTest.ts +81 -0
- package/src/components/runDropOffInputTest.ts +32 -0
- package/src/components/runFormGroupTest.ts +17 -0
- package/src/components/runHeadingTest.ts +12 -0
- package/src/components/runIconTest.ts +16 -0
- package/src/components/runImageTest.ts +22 -0
- package/src/components/runLinkTest.ts +12 -0
- package/src/components/runLoaderTest.ts +9 -0
- package/src/components/runModalTest.ts +28 -0
- package/src/components/runMultiDateInputTest.ts +10 -0
- package/src/components/runMultiSelectInputTest.ts +17 -0
- package/src/components/runNotificationTest.ts +40 -0
- package/src/components/runNumberInputTest.ts +13 -0
- package/src/components/runPlainWrapperTest.ts +12 -0
- package/src/components/runRadioGroupTest.ts +26 -0
- package/src/components/runRadioInputTest.ts +13 -0
- package/src/components/runRowTest.ts +11 -0
- package/src/components/runSelectInputTest.ts +30 -0
- package/src/components/runSettingsDividerTest.ts +16 -0
- package/src/components/runShippingMethodsInputTest.ts +23 -0
- package/src/components/runTabNavButtonTest.ts +17 -0
- package/src/components/runTableColTest.ts +11 -0
- package/src/components/runTableRowTest.ts +11 -0
- package/src/components/runTableTest.ts +13 -0
- package/src/components/runTextAreaTest.ts +12 -0
- package/src/components/runTextInputTest.ts +12 -0
- package/src/components/runTimeInputTest.ts +13 -0
- package/src/components/runToggleInputTest.ts +16 -0
- package/src/components/runTriStateInputTest.ts +15 -0
- package/src/helpers/createInputOptions.ts +19 -0
- package/src/helpers/index.ts +1 -0
- package/src/helpers/wrapperPlugin.ts +20 -0
- package/src/index.ts +5 -0
- package/src/setup.ts +4 -0
- package/src/tests/executeAdminComponentTest.ts +47 -0
- package/src/tests/executePdkComponentTests.ts +19 -0
- package/src/tests/index.ts +3 -0
- package/src/tests/testMap.ts +111 -0
- package/src/types.ts +24 -0
- package/src/vue.shims.d.ts +26 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/* eslint-disable no-magic-numbers */
|
|
2
|
+
import {type Component} from 'vue';
|
|
3
|
+
import {afterAll, beforeAll, beforeEach, describe, vi} from 'vitest';
|
|
4
|
+
import {
|
|
5
|
+
type AdminComponent,
|
|
6
|
+
type AdminInstance,
|
|
7
|
+
type AdminView,
|
|
8
|
+
createAdminConfig,
|
|
9
|
+
createLogger,
|
|
10
|
+
} from '@myparcel-dev/pdk-admin';
|
|
11
|
+
import {testMap} from './testMap';
|
|
12
|
+
|
|
13
|
+
export const executeAdminComponentTest = (name: AdminComponent, component: Omit<Component, 'props'>): void => {
|
|
14
|
+
const componentTest = testMap[name];
|
|
15
|
+
|
|
16
|
+
if (!componentTest) {
|
|
17
|
+
// eslint-disable-next-line no-console
|
|
18
|
+
console.warn(`No test found for component: ${name}`);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
describe(name, () => {
|
|
23
|
+
beforeEach(() => {
|
|
24
|
+
vi.spyOn(console, 'warn').mockImplementation(() => undefined);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
beforeAll(() => {
|
|
28
|
+
vi.mock('../usePdkInstance', () => ({
|
|
29
|
+
usePdkInstance: (): AdminInstance => ({
|
|
30
|
+
appName: 'test',
|
|
31
|
+
config: createAdminConfig(),
|
|
32
|
+
context: {},
|
|
33
|
+
logger: createLogger('test'),
|
|
34
|
+
view: 'test' as AdminView,
|
|
35
|
+
}),
|
|
36
|
+
}));
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
describe(name, () => {
|
|
40
|
+
componentTest(component);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
afterAll(() => {
|
|
44
|
+
vi.restoreAllMocks();
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {config} from '@vue/test-utils';
|
|
2
|
+
import {doComponentTestSetup} from '@myparcel-dev/pdk-admin/testing';
|
|
3
|
+
import {type AdminComponent, type AdminComponentMap} from '@myparcel-dev/pdk-admin';
|
|
4
|
+
import {wrapperPlugin} from '../helpers/wrapperPlugin';
|
|
5
|
+
import {executeAdminComponentTest} from './executeAdminComponentTest';
|
|
6
|
+
|
|
7
|
+
export const executePdkComponentTests = (components: Partial<AdminComponentMap> = {}): void => {
|
|
8
|
+
config.plugins.VueWrapper.install(wrapperPlugin);
|
|
9
|
+
|
|
10
|
+
doComponentTestSetup(components);
|
|
11
|
+
|
|
12
|
+
Object.entries(components).forEach(([name, component]) => {
|
|
13
|
+
if (!component) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
executeAdminComponentTest(name as AdminComponent, component);
|
|
18
|
+
});
|
|
19
|
+
};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import {type Component} from 'vue';
|
|
2
|
+
import {AdminComponent} from '@myparcel-dev/pdk-admin';
|
|
3
|
+
import {runMultiDateInputTest} from '../components/runMultiDateInputTest';
|
|
4
|
+
import {
|
|
5
|
+
runBadgeTest,
|
|
6
|
+
runBoxTest,
|
|
7
|
+
runButtonTest,
|
|
8
|
+
runCheckboxGroupTest,
|
|
9
|
+
runCheckboxInputTest,
|
|
10
|
+
runCodeEditorTest,
|
|
11
|
+
runColTest,
|
|
12
|
+
runCurrencyInputTest,
|
|
13
|
+
runDropDownButtonTest,
|
|
14
|
+
runDropOffInputTest,
|
|
15
|
+
runFormGroupTest,
|
|
16
|
+
runHeadingTest,
|
|
17
|
+
runIconTest,
|
|
18
|
+
runImageTest,
|
|
19
|
+
runLinkTest,
|
|
20
|
+
runLoaderTest,
|
|
21
|
+
runModalTest,
|
|
22
|
+
runMultiSelectInputTest,
|
|
23
|
+
runNotificationTest,
|
|
24
|
+
runNumberInputTest,
|
|
25
|
+
runPlainWrapperTest,
|
|
26
|
+
runRadioGroupTest,
|
|
27
|
+
runRadioInputTest,
|
|
28
|
+
runRowTest,
|
|
29
|
+
runSelectInputTest,
|
|
30
|
+
runSettingsDividerTest,
|
|
31
|
+
runShippingMethodsInputTest,
|
|
32
|
+
runTableColTest,
|
|
33
|
+
runTableRowTest,
|
|
34
|
+
runTableTest,
|
|
35
|
+
runTabNavButtonTest,
|
|
36
|
+
runTextAreaTest,
|
|
37
|
+
runTextInputTest,
|
|
38
|
+
runTimeInputTest,
|
|
39
|
+
runToggleInputTest,
|
|
40
|
+
} from '../components';
|
|
41
|
+
|
|
42
|
+
export type AdminComponentTest = (component: Omit<Component, 'props'>) => void;
|
|
43
|
+
|
|
44
|
+
export const testMap: Readonly<Record<AdminComponent, AdminComponentTest>> = Object.freeze({
|
|
45
|
+
/**
|
|
46
|
+
* Inputs
|
|
47
|
+
*/
|
|
48
|
+
[AdminComponent.CheckboxGroup]: runCheckboxGroupTest,
|
|
49
|
+
[AdminComponent.CheckboxInput]: runCheckboxInputTest,
|
|
50
|
+
[AdminComponent.CodeEditor]: runCodeEditorTest,
|
|
51
|
+
[AdminComponent.CurrencyInput]: runCurrencyInputTest,
|
|
52
|
+
[AdminComponent.DropOffInput]: runDropOffInputTest,
|
|
53
|
+
[AdminComponent.MultiSelectInput]: runMultiSelectInputTest,
|
|
54
|
+
[AdminComponent.NumberInput]: runNumberInputTest,
|
|
55
|
+
[AdminComponent.RadioGroup]: runRadioGroupTest,
|
|
56
|
+
[AdminComponent.RadioInput]: runRadioInputTest,
|
|
57
|
+
[AdminComponent.SelectInput]: runSelectInputTest,
|
|
58
|
+
[AdminComponent.ShippingMethodsInput]: runShippingMethodsInputTest,
|
|
59
|
+
[AdminComponent.TextArea]: runTextAreaTest,
|
|
60
|
+
[AdminComponent.TextInput]: runTextInputTest,
|
|
61
|
+
[AdminComponent.TimeInput]: runTimeInputTest,
|
|
62
|
+
[AdminComponent.ToggleInput]: runToggleInputTest,
|
|
63
|
+
[AdminComponent.MultiDateInput]: runMultiDateInputTest,
|
|
64
|
+
/**
|
|
65
|
+
* @TODO: fix test for TriStateInput
|
|
66
|
+
*/
|
|
67
|
+
[AdminComponent.TriStateInput]: () => undefined,
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Plain wrappers
|
|
71
|
+
*/
|
|
72
|
+
[AdminComponent.ButtonGroup]: runPlainWrapperTest,
|
|
73
|
+
[AdminComponent.ConceptBoxWrapper]: runPlainWrapperTest,
|
|
74
|
+
[AdminComponent.PluginSettingsWrapper]: runPlainWrapperTest,
|
|
75
|
+
[AdminComponent.ShipmentLabelWrapper]: runPlainWrapperTest,
|
|
76
|
+
[AdminComponent.TabNavButtonWrapper]: runPlainWrapperTest,
|
|
77
|
+
[AdminComponent.TabNavContentWrapper]: runPlainWrapperTest,
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Layout
|
|
81
|
+
*/
|
|
82
|
+
[AdminComponent.Box]: runBoxTest,
|
|
83
|
+
[AdminComponent.Col]: runColTest,
|
|
84
|
+
[AdminComponent.Row]: runRowTest,
|
|
85
|
+
|
|
86
|
+
[AdminComponent.Table]: runTableTest,
|
|
87
|
+
[AdminComponent.TableCol]: runTableColTest,
|
|
88
|
+
[AdminComponent.TableRow]: runTableRowTest,
|
|
89
|
+
|
|
90
|
+
[AdminComponent.FormGroup]: runFormGroupTest,
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Interactive components
|
|
94
|
+
*/
|
|
95
|
+
[AdminComponent.Button]: runButtonTest,
|
|
96
|
+
[AdminComponent.DropdownButton]: runDropDownButtonTest,
|
|
97
|
+
[AdminComponent.Link]: runLinkTest,
|
|
98
|
+
[AdminComponent.Modal]: runModalTest,
|
|
99
|
+
[AdminComponent.TabNavButton]: runTabNavButtonTest,
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Other
|
|
103
|
+
*/
|
|
104
|
+
[AdminComponent.Badge]: runBadgeTest,
|
|
105
|
+
[AdminComponent.Heading]: runHeadingTest,
|
|
106
|
+
[AdminComponent.Icon]: runIconTest,
|
|
107
|
+
[AdminComponent.Image]: runImageTest,
|
|
108
|
+
[AdminComponent.Loader]: runLoaderTest,
|
|
109
|
+
[AdminComponent.Notification]: runNotificationTest,
|
|
110
|
+
[AdminComponent.SettingsDivider]: runSettingsDividerTest,
|
|
111
|
+
});
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {type Component as ComponentType, type Component} from 'vue';
|
|
2
|
+
import {type ComponentMountingOptions} from '@vue/test-utils';
|
|
3
|
+
|
|
4
|
+
export type ComponentTestOptions = {
|
|
5
|
+
$slots?: Record<string, unknown>;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/ban-types
|
|
9
|
+
export type PartialComponentTest<Args extends unknown[] = unknown[]> = <
|
|
10
|
+
T extends ComponentTestOptions = ComponentTestOptions,
|
|
11
|
+
>(
|
|
12
|
+
component: Component,
|
|
13
|
+
options?: ComponentMountingOptions<T>,
|
|
14
|
+
...args: Args
|
|
15
|
+
) => void;
|
|
16
|
+
|
|
17
|
+
export interface AdditionalOptions {
|
|
18
|
+
value?: unknown;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type TestComponentMountingOptions<
|
|
22
|
+
Component extends ComponentType = ComponentType,
|
|
23
|
+
Options extends ComponentTestOptions = ComponentTestOptions,
|
|
24
|
+
> = ComponentMountingOptions<Component> & Options;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/* eslint-disable import/consistent-type-specifier-style,@typescript-eslint/no-explicit-any,@typescript-eslint/ban-types,@typescript-eslint/naming-convention,no-underscore-dangle */
|
|
2
|
+
|
|
3
|
+
import type {DOMWrapper} from '@vue/test-utils';
|
|
4
|
+
|
|
5
|
+
declare module '*.vue' {
|
|
6
|
+
import type {DefineComponent} from 'vue';
|
|
7
|
+
|
|
8
|
+
const component: DefineComponent<{}, {}, any>;
|
|
9
|
+
export default component;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
declare const __VUE_PROD_DEVTOOLS__: boolean;
|
|
13
|
+
|
|
14
|
+
declare module '@vue/test-utils' {
|
|
15
|
+
export class VueWrapper {
|
|
16
|
+
public findByTestId<K extends keyof HTMLElementTagNameMap>(
|
|
17
|
+
selector: string | string[],
|
|
18
|
+
): DOMWrapper<HTMLElementTagNameMap[K]>;
|
|
19
|
+
|
|
20
|
+
public findByTestId<K extends keyof SVGElementTagNameMap>(
|
|
21
|
+
selector: string | string[],
|
|
22
|
+
): DOMWrapper<SVGElementTagNameMap[K]>;
|
|
23
|
+
|
|
24
|
+
public findByTestId<T extends Element | Node = Node>(selector: string | string[]): DOMWrapper<T>;
|
|
25
|
+
}
|
|
26
|
+
}
|