Implemented vite test to make sure blocks.js maintains it's integrity and validates
This commit is contained in:
parent
4ae0edad49
commit
27032c098a
819
package-lock.json
generated
819
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -17,10 +17,12 @@
|
|||||||
"eslint-config-prettier": "^10.0.1",
|
"eslint-config-prettier": "^10.0.1",
|
||||||
"eslint-plugin-vue": "^9.32.0",
|
"eslint-plugin-vue": "^9.32.0",
|
||||||
"flowbite": "^1.8.1",
|
"flowbite": "^1.8.1",
|
||||||
|
"jsdom": "^26.1.0",
|
||||||
"prettier": "^3.4.2",
|
"prettier": "^3.4.2",
|
||||||
"prettier-plugin-organize-imports": "^4.1.0",
|
"prettier-plugin-organize-imports": "^4.1.0",
|
||||||
"prettier-plugin-tailwindcss": "^0.6.11",
|
"prettier-plugin-tailwindcss": "^0.6.11",
|
||||||
"typescript-eslint": "^8.23.0",
|
"typescript-eslint": "^8.23.0",
|
||||||
|
"vitest": "^3.1.3",
|
||||||
"vue-tsc": "^2.2.4"
|
"vue-tsc": "^2.2.4"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
65
resources/js/__tests__/Utils/blocks.test.js
Normal file
65
resources/js/__tests__/Utils/blocks.test.js
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
import blocks from '@/Utils/blocks';
|
||||||
|
import path from 'path';
|
||||||
|
import fs from 'fs';
|
||||||
|
import { expect } from 'vitest';
|
||||||
|
|
||||||
|
describe('blocks.js structure', () => {
|
||||||
|
it('should contain uuid, componentName, renderComponentName and description for every block', () => {
|
||||||
|
blocks.groups.forEach(group => {
|
||||||
|
group.blocks.forEach(block => {
|
||||||
|
expect(block).toHaveProperty('uuid');
|
||||||
|
expect(typeof block.uuid).toBe('string');
|
||||||
|
|
||||||
|
expect(block).toHaveProperty('componentName');
|
||||||
|
expect(typeof block.componentName).toBe('string');
|
||||||
|
|
||||||
|
expect(block).toHaveProperty('renderComponentName');
|
||||||
|
expect(typeof block.renderComponentName).toBe('string');
|
||||||
|
|
||||||
|
expect(block).toHaveProperty('description');
|
||||||
|
expect(typeof block.description).toBe('string');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should contain optionsComponentName if block is not static', () => {
|
||||||
|
blocks.groups.forEach(group => {
|
||||||
|
group.blocks.forEach(block => {
|
||||||
|
if (!block.static) {
|
||||||
|
expect(block).toHaveProperty('optionsComponentName');
|
||||||
|
expect(typeof block.optionsComponentName).toBe('string');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not require optionsComponentName if block is static', () => {
|
||||||
|
blocks.groups.forEach(group => {
|
||||||
|
group.blocks.forEach(block => {
|
||||||
|
if (block.static) {
|
||||||
|
if (block.hasOwnProperty('optionsComponentName')) {
|
||||||
|
expect(typeof block.optionsComponentName).toBe('string');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should contain a valid thumbUrl that points to an existing file, for each block', () => {
|
||||||
|
const publicDir = path.resolve(__dirname, '../../../../public');
|
||||||
|
|
||||||
|
blocks.groups.forEach(group => {
|
||||||
|
group.blocks.forEach(block => {
|
||||||
|
expect(block).toHaveProperty('thumbUrl');
|
||||||
|
expect(typeof block.thumbUrl).toBe('string');
|
||||||
|
|
||||||
|
const isValid = /^\/img\/blocks\/[^\/]+\.(jpg|png)$/.test(block.thumbUrl);
|
||||||
|
expect(isValid).toBe(true);
|
||||||
|
|
||||||
|
const fullPath = path.join(publicDir, block.thumbUrl);
|
||||||
|
const exists = fs.existsSync(fullPath);
|
||||||
|
expect(exists).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
@ -41,7 +41,7 @@ const activeItemStyles = computed(
|
|||||||
const mainNavItems: NavItem[] = [
|
const mainNavItems: NavItem[] = [
|
||||||
{
|
{
|
||||||
title: 'Dashboard',
|
title: 'Dashboard',
|
||||||
href: '/dashboard',
|
href: '/dashboard/page-admin',
|
||||||
icon: LayoutGrid,
|
icon: LayoutGrid,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
@ -11,7 +11,7 @@ import AppLogo from './AppLogo.vue';
|
|||||||
const mainNavItems: NavItem[] = [
|
const mainNavItems: NavItem[] = [
|
||||||
{
|
{
|
||||||
title: 'Dashboard',
|
title: 'Dashboard',
|
||||||
href: '/dashboard',
|
href: '/dashboard/page-admin',
|
||||||
icon: LayoutGrid,
|
icon: LayoutGrid,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
@ -3,9 +3,14 @@ import laravel from 'laravel-vite-plugin';
|
|||||||
import path from 'path';
|
import path from 'path';
|
||||||
import tailwindcss from "@tailwindcss/vite";
|
import tailwindcss from "@tailwindcss/vite";
|
||||||
import { resolve } from 'node:path';
|
import { resolve } from 'node:path';
|
||||||
import { defineConfig } from 'vite';
|
import { defineConfig } from 'vitest/config';
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
|
test: {
|
||||||
|
globals: true,
|
||||||
|
environment: 'jsdom',
|
||||||
|
include: ['resources/js/__tests__/**/*.test.js'],
|
||||||
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
laravel({
|
laravel({
|
||||||
input: ['resources/js/app.ts'],
|
input: ['resources/js/app.ts'],
|
||||||
|
Loading…
Reference in New Issue
Block a user