Skip to content

Commit c9292fd

Browse files
authored
Various small codebase clean-ups (directus#20977)
1 parent 8a314a8 commit c9292fd

34 files changed

+76
-284
lines changed

.eslintignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
dist/
22
/packages/extensions-sdk/templates/
33
/api/extensions/
4-
!/app/.storybook/
54
!/docs/.vitepress/
65
!/docs/.typedocs/
76
/docs/.vitepress/cache/

.eslintrc.js

+7
Original file line numberDiff line numberDiff line change
@@ -124,5 +124,12 @@ module.exports = {
124124
...vueRules,
125125
},
126126
},
127+
// Test files
128+
{
129+
files: ['*.test.ts'],
130+
rules: {
131+
'vue/one-component-per-file': 'off',
132+
},
133+
},
127134
],
128135
};

.gitignore

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@ node_modules/
66

77
# Builds / Caches
88
dist/
9-
storybook-static/
109
coverage/
10+
.histoire/
1111
*.tsbuildinfo
1212
**/.vitepress/cache/
1313
**/.vitepress/.temp/
14-
.thumbsmith/
1514
.eslintcache
1615

1716
# Dotenv configs

.prettierignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
dist/
22
coverage/
33
pnpm-lock.yaml
4+
.histoire/
45
**/.vitepress/cache/
56
/.changeset/pre.json
67
/.changeset/*.md
78
/app/src/lang/translations/*.yaml
89
!/app/src/lang/translations/en-US.yaml
910
/docs/packages/
10-
storybook-static/
1111
/api/uploads/
1212
/api/extensions/
File renamed without changes.

api/tsconfig.prod.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"extends": "./tsconfig.json",
3-
"exclude": ["**/*.test.ts"]
3+
"exclude": ["**/*.test.ts", "src/__utils__", "src/__setup__"]
44
}

api/vitest.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ import { defineConfig } from 'vitest/config';
22

33
export default defineConfig({
44
test: {
5-
globalSetup: ['./globalSetup.js'],
5+
globalSetup: ['./src/__setup__/global.js'],
66
},
77
});

app/histoire.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { defineConfig } from 'histoire';
33

44
export default defineConfig({
55
plugins: [HstVue()],
6-
setupFile: './src/histoire/setup.ts',
6+
setupFile: './src/__histoire__/setup.ts',
77
theme: {
88
title: 'Directus Components',
99
favicon: './public/favicon.ico',
File renamed without changes.
File renamed without changes.
File renamed without changes.

app/src/__setup__/mock-globals.ts

-21
This file was deleted.

app/src/__utils__/router.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1+
import { h } from 'vue';
12
import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router';
23

3-
export function generateRouter(routes: RouteRecordRaw[]) {
4+
export function generateRouter(routes?: RouteRecordRaw[]) {
45
const router = createRouter({
56
history: createWebHistory(),
6-
routes,
7+
routes: routes ?? [
8+
{
9+
path: '/',
10+
component: h('div'),
11+
},
12+
],
713
});
814

915
return router;

app/src/components/v-button.test.ts

+8-31
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,18 @@
1-
import { test, expect, beforeEach } from 'vitest';
21
import { mount } from '@vue/test-utils';
3-
4-
import VButton from './v-button.vue';
5-
import { h } from 'vue';
6-
import { generateRouter } from '@/__utils__/router';
2+
import { beforeEach, expect, test } from 'vitest';
73
import { Router } from 'vue-router';
8-
import { GlobalMountOptions } from '@vue/test-utils/dist/types';
4+
95
import { Focus } from '@/__utils__/focus';
6+
import { generateRouter } from '@/__utils__/router';
7+
import { Tooltip } from '@/__utils__/tooltip';
8+
import { GlobalMountOptions } from '@/__utils__/types';
9+
import VButton from './v-button.vue';
1010

1111
let router: Router;
12-
1312
let global: GlobalMountOptions;
1413

1514
beforeEach(async () => {
16-
router = generateRouter([
17-
{
18-
path: '/',
19-
component: h('div', VButton),
20-
},
21-
{
22-
path: '/test',
23-
component: h('div', 'empty'),
24-
},
25-
]);
15+
router = generateRouter();
2616

2717
router.push('/');
2818
await router.isReady();
@@ -31,6 +21,7 @@ beforeEach(async () => {
3121
stubs: ['v-progress-circular'],
3222
directives: {
3323
focus: Focus,
24+
tooltip: Tooltip,
3425
},
3526
plugins: [router],
3627
};
@@ -45,17 +36,3 @@ test('Mount component', () => {
4536

4637
expect(wrapper.html()).toMatchSnapshot();
4738
});
48-
49-
// test('Click on link', async () => {
50-
// const wrapper = mount(VButton, {
51-
// props: {
52-
// to: '/test'
53-
// },
54-
// global
55-
// });
56-
57-
// await wrapper.get('a').trigger('click')
58-
59-
// expect(router.currentRoute.value.path).toBe('/test')
60-
61-
// });
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,22 @@
1-
import { test, expect, beforeEach } from 'vitest';
21
import { mount } from '@vue/test-utils';
2+
import { beforeEach, expect, test } from 'vitest';
3+
import { Router } from 'vue-router';
34

4-
import VCheckboxTree from './v-checkbox-tree.vue';
5-
import VCheckboxTreeCheckbox from './v-checkbox-tree-checkbox.vue';
6-
import VListItem from '../v-list-item.vue';
5+
import { generateRouter } from '@/__utils__/router';
6+
import type { GlobalMountOptions } from '@/__utils__/types';
7+
import VCheckbox from '../v-checkbox.vue';
8+
import VListGroup from '../v-list-group.vue';
79
import VListItemIcon from '../v-list-item-icon.vue';
10+
import VListItem from '../v-list-item.vue';
811
import VList from '../v-list.vue';
9-
import VListGroup from '../v-list-group.vue';
10-
import VCheckbox from '../v-checkbox.vue';
11-
import { h } from 'vue';
12-
import type { GlobalMountOptions } from '@/__utils__/types';
13-
import { Router } from 'vue-router';
14-
import { generateRouter } from '@/__utils__/router';
12+
import VCheckboxTreeCheckbox from './v-checkbox-tree-checkbox.vue';
13+
import VCheckboxTree from './v-checkbox-tree.vue';
1514

1615
let router: Router;
1716
let global: GlobalMountOptions;
1817

1918
beforeEach(async () => {
20-
router = generateRouter([
21-
{
22-
path: '/',
23-
component: h('div', 'test'),
24-
},
25-
{
26-
path: '/test',
27-
component: h('div', 'empty'),
28-
},
29-
]);
19+
router = generateRouter();
3020

3121
router.push('/');
3222
await router.isReady();
@@ -54,39 +44,3 @@ test('Mount component', () => {
5444

5545
expect(wrapper.html()).toMatchSnapshot();
5646
});
57-
58-
// test('Choices prop', async () => {
59-
// const wrapper = mount(VCheckboxTree, {
60-
// props: {
61-
// modelValue: ['p1', 'c1'],
62-
// showSelectionOnly: true,
63-
// choices: [
64-
// {
65-
// text: 'Parent 1',
66-
// value: 'p1',
67-
// },
68-
// {
69-
// text: 'Parent 2',
70-
// value: 'p2',
71-
// children: [
72-
// {
73-
// text: 'Child 1',
74-
// value: 'c1',
75-
// },
76-
// ],
77-
// },
78-
// ],
79-
// },
80-
// global,
81-
// });
82-
83-
// expect(wrapper.getComponent('.v-checkbox:nth-child(1)').classes()).toContain('checked');
84-
// expect(wrapper.getComponent('.v-checkbox:nth-child(1)').props().label).toBe('Parent 1');
85-
// expect(wrapper.getComponent('.v-checkbox:nth-child(2)').classes()).not.toContain('checked');
86-
87-
// await wrapper.get('.v-checkbox:nth-child(2)').trigger('click');
88-
89-
// const child1 = wrapper.get('.v-checkbox:nth-child(2)').find('.v-checkbox');
90-
// expect(child1.exists()).toBeTruthy();
91-
// expect(child1.props().label).toBe('Child 1');
92-
// });

app/src/components/v-error-boundary.test.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable vue/one-component-per-file */
2-
31
import { mount } from '@vue/test-utils';
42
import { afterAll, beforeAll, expect, test, vi } from 'vitest';
53
import { defineComponent, h, nextTick } from 'vue';

app/src/components/v-form/__snapshots__/form-field-raw-editor.test.ts.snap

-16
This file was deleted.

app/src/components/v-form/form-field-raw-editor.test.ts

-92
This file was deleted.

0 commit comments

Comments
 (0)