chore: implement basic tests
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
23
.github/workflows/js-unit-tests.yml
vendored
Normal file
23
.github/workflows/js-unit-tests.yml
vendored
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
name: JS Unit Tests
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v6.0.2
|
||||||
|
|
||||||
|
- name: Set up Node.js
|
||||||
|
uses: actions/setup-node@v6.2.0
|
||||||
|
with:
|
||||||
|
node-version: '24'
|
||||||
|
cache: 'npm'
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: npm ci
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: npm run test:unit
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
name: PHP Tests
|
name: PHP Unit Tests
|
||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
@@ -11,7 +11,7 @@ jobs:
|
|||||||
uses: actions/checkout@v6.0.2
|
uses: actions/checkout@v6.0.2
|
||||||
|
|
||||||
- name: Set up PHP
|
- name: Set up PHP
|
||||||
uses: shivammathur/setup-php@v2
|
uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1
|
||||||
with:
|
with:
|
||||||
php-version: '8.5'
|
php-version: '8.5'
|
||||||
tools: composer:v2
|
tools: composer:v2
|
||||||
@@ -21,4 +21,4 @@ jobs:
|
|||||||
run: composer install --prefer-dist --no-progress
|
run: composer install --prefer-dist --no-progress
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: composer test
|
run: composer test:unit
|
||||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -15,9 +15,8 @@ node_modules/
|
|||||||
# Backend development
|
# Backend development
|
||||||
/vendor/
|
/vendor/
|
||||||
coverage/
|
coverage/
|
||||||
phpunit.xml.cache
|
|
||||||
.phpunit.cache
|
.phpunit.cache
|
||||||
.phpunit.result.cache
|
.phpunit.coverage
|
||||||
.php-cs-fixer.cache
|
.php-cs-fixer.cache
|
||||||
.phpstan.cache
|
.phpstan.cache
|
||||||
.phpactor/
|
.phpactor/
|
||||||
|
|||||||
@@ -38,6 +38,7 @@
|
|||||||
],
|
],
|
||||||
"post-update-cmd": [
|
"post-update-cmd": [
|
||||||
],
|
],
|
||||||
"test": "phpunit --colors=always --testdox"
|
"test:unit": "phpunit --configuration tests/php/phpunit.unit.xml --colors=always --testdox",
|
||||||
|
"test:coverage": "XDEBUG_MODE=coverage phpunit --configuration tests/php/phpunit.unit.xml --coverage-html .phpunit.coverage --coverage-text"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
1630
package-lock.json
generated
1630
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
17
package.json
17
package.json
@@ -7,14 +7,18 @@
|
|||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "vite build --mode production",
|
"build": "vite build --mode production",
|
||||||
|
"build:modules": "for dir in modules/*/; do if [ -f \"$dir/package.json\" ]; then echo \"Building $dir\" && npm run build --prefix \"$dir\"; fi; done",
|
||||||
|
"build:all": "npm run build && npm run build:modules",
|
||||||
"dev": "vite build --mode development",
|
"dev": "vite build --mode development",
|
||||||
|
"dev:modules": "for dir in modules/*/; do if [ -f \"$dir/package.json\" ]; then echo \"Building $dir\" && npm run dev --prefix \"$dir\"; fi; done",
|
||||||
|
"dev:all": "npm run dev && npm run dev:modules",
|
||||||
"watch": "vite build --mode development --watch",
|
"watch": "vite build --mode development --watch",
|
||||||
"typecheck": "vue-tsc --noEmit",
|
"typecheck": "vue-tsc --noEmit",
|
||||||
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
|
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
|
||||||
"build:modules": "for dir in modules/*/; do if [ -f \"$dir/package.json\" ]; then echo \"Building $dir\" && npm run build --prefix \"$dir\"; fi; done",
|
"test": "vitest run --config tests/js/vitest.config.ts",
|
||||||
"build:all": "npm run build && npm run build:modules",
|
"test:unit": "vitest run --config tests/js/vitest.config.ts",
|
||||||
"dev:modules": "for dir in modules/*/; do if [ -f \"$dir/package.json\" ]; then echo \"Building $dir\" && npm run dev --prefix \"$dir\"; fi; done",
|
"test:watch": "vitest watch --config tests/js/vitest.config.ts",
|
||||||
"dev:all": "npm run dev && npm run dev:modules"
|
"test:coverage": "vitest run --coverage --config tests/js/vitest.config.ts"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fontsource/inter": "5.2.8",
|
"@fontsource/inter": "5.2.8",
|
||||||
@@ -39,10 +43,14 @@
|
|||||||
"@types/dompurify": "^3.2.0",
|
"@types/dompurify": "^3.2.0",
|
||||||
"@types/node": "25.2.3",
|
"@types/node": "25.2.3",
|
||||||
"@vitejs/plugin-vue": "6.0.4",
|
"@vitejs/plugin-vue": "6.0.4",
|
||||||
|
"@vitest/coverage-v8": "^4.0.18",
|
||||||
|
"@vitest/ui": "^4.0.18",
|
||||||
"@vue/eslint-config-prettier": "10.2.0",
|
"@vue/eslint-config-prettier": "10.2.0",
|
||||||
|
"@vue/test-utils": "^2.4.6",
|
||||||
"@vue/tsconfig": "0.8.1",
|
"@vue/tsconfig": "0.8.1",
|
||||||
"eslint": "^9.18.0",
|
"eslint": "^9.18.0",
|
||||||
"eslint-plugin-vue": "10.7.0",
|
"eslint-plugin-vue": "10.7.0",
|
||||||
|
"jsdom": "^28.0.0",
|
||||||
"prettier": "3.8.1",
|
"prettier": "3.8.1",
|
||||||
"sass": "1.97.3",
|
"sass": "1.97.3",
|
||||||
"sass-loader": "16.0.7",
|
"sass-loader": "16.0.7",
|
||||||
@@ -50,6 +58,7 @@
|
|||||||
"typescript-eslint": "^8.55.0",
|
"typescript-eslint": "^8.55.0",
|
||||||
"vite": "7.3.1",
|
"vite": "7.3.1",
|
||||||
"vite-plugin-static-copy": "^3.2.0",
|
"vite-plugin-static-copy": "^3.2.0",
|
||||||
|
"vitest": "^4.0.18",
|
||||||
"vue-cli-plugin-vuetify": "2.5.8",
|
"vue-cli-plugin-vuetify": "2.5.8",
|
||||||
"vue-tsc": "^3.2.4"
|
"vue-tsc": "^3.2.4"
|
||||||
}
|
}
|
||||||
|
|||||||
30
tests/js/unit/base.test.ts
Normal file
30
tests/js/unit/base.test.ts
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
import { describe, it, expect } from 'vitest'
|
||||||
|
|
||||||
|
describe('Basic Tests', () => {
|
||||||
|
it('should perform basic assertion', () => {
|
||||||
|
expect(true).toBe(true)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should test array operations', () => {
|
||||||
|
const array = ['foo', 'bar', 'baz']
|
||||||
|
|
||||||
|
expect(array).toHaveLength(3)
|
||||||
|
expect(array).toContain('bar')
|
||||||
|
expect(array[0]).toBe('foo')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should test string operations', () => {
|
||||||
|
const string = 'Hello, World!'
|
||||||
|
|
||||||
|
expect(string).toContain('World')
|
||||||
|
expect(string.length).toBe(13)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should test object operations', () => {
|
||||||
|
const obj = { foo: 'bar', count: 42 }
|
||||||
|
|
||||||
|
expect(obj).toHaveProperty('foo')
|
||||||
|
expect(obj.foo).toBe('bar')
|
||||||
|
expect(obj.count).toBeGreaterThan(40)
|
||||||
|
})
|
||||||
|
})
|
||||||
33
tests/js/vitest.config.ts
Normal file
33
tests/js/vitest.config.ts
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
import { fileURLToPath } from 'node:url'
|
||||||
|
import { defineConfig, configDefaults } from 'vitest/config'
|
||||||
|
import vue from '@vitejs/plugin-vue'
|
||||||
|
import vuetify from 'vite-plugin-vuetify'
|
||||||
|
import path from 'path'
|
||||||
|
|
||||||
|
const __filename = fileURLToPath(import.meta.url)
|
||||||
|
const __dirname = path.dirname(__filename)
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
plugins: [vue(), vuetify()],
|
||||||
|
resolve: {
|
||||||
|
alias: {
|
||||||
|
'@KTXC': path.resolve(__dirname, '../../core/src'),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
test: {
|
||||||
|
environment: 'jsdom',
|
||||||
|
exclude: [...configDefaults.exclude, 'e2e/**'],
|
||||||
|
root: fileURLToPath(new URL('../../', import.meta.url)),
|
||||||
|
coverage: {
|
||||||
|
provider: 'v8',
|
||||||
|
reporter: ['text', 'json', 'html'],
|
||||||
|
exclude: [
|
||||||
|
'node_modules/',
|
||||||
|
'tests/',
|
||||||
|
'**/*.d.ts',
|
||||||
|
'**/*.config.*',
|
||||||
|
'**/dist/**',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
@@ -2,13 +2,13 @@
|
|||||||
|
|
||||||
<!-- https://phpunit.readthedocs.io/en/latest/configuration.html -->
|
<!-- https://phpunit.readthedocs.io/en/latest/configuration.html -->
|
||||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
|
xsi:noNamespaceSchemaLocation="../../vendor/phpunit/phpunit/phpunit.xsd"
|
||||||
colors="true"
|
colors="true"
|
||||||
failOnDeprecation="true"
|
failOnDeprecation="true"
|
||||||
failOnNotice="true"
|
failOnNotice="true"
|
||||||
failOnWarning="true"
|
failOnWarning="true"
|
||||||
bootstrap="tests/php/bootstrap.php"
|
bootstrap="bootstrap.php"
|
||||||
cacheDirectory=".phpunit.cache"
|
cacheDirectory="../../.phpunit.cache"
|
||||||
>
|
>
|
||||||
<php>
|
<php>
|
||||||
<ini name="display_errors" value="1" />
|
<ini name="display_errors" value="1" />
|
||||||
@@ -18,8 +18,8 @@
|
|||||||
</php>
|
</php>
|
||||||
|
|
||||||
<testsuites>
|
<testsuites>
|
||||||
<testsuite name="Project Test Suite">
|
<testsuite name="Unit Tests">
|
||||||
<directory>tests/php</directory>
|
<directory>unit</directory>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
</testsuites>
|
</testsuites>
|
||||||
|
|
||||||
@@ -29,7 +29,8 @@
|
|||||||
restrictWarnings="true"
|
restrictWarnings="true"
|
||||||
>
|
>
|
||||||
<include>
|
<include>
|
||||||
<directory>src</directory>
|
<directory>../../core/lib</directory>
|
||||||
|
<directory>../../shared/lib</directory>
|
||||||
</include>
|
</include>
|
||||||
|
|
||||||
<deprecationTrigger>
|
<deprecationTrigger>
|
||||||
Reference in New Issue
Block a user