Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JASPER-176/253: Testing Framework and Components #116

Merged
merged 3 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,099 changes: 2,018 additions & 81 deletions web/package-lock.json

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"build": "vite build",
"dev": "vite",
"clean": "",
"lint": "eslint --ext .ts,.vue --ignore-path .gitignore --fix src"
"lint": "eslint --ext .ts,.vue --ignore-path .gitignore --fix src",
"test": "vitest"
},
"resolutions": {
"glob-parent": "^5.1.2",
Expand Down Expand Up @@ -54,16 +55,19 @@
"@vitejs/plugin-vue": "^5.2.1",
"@vue/compiler-sfc": "^3.5.13",
"@vue/eslint-config-typescript": "^14.1.4",
"@vue/test-utils": "^2.4.6",
"buffer": "^6.0.3",
"eslint": "^9.16.0",
"eslint-plugin-vue": "^9.32.0",
"happy-dom": "^15.11.7",
"prettier": "^3.4.2",
"process": "^0.11.10",
"ts-loader": "^9.5.1",
"tslib": "^2.8.1",
"typescript": "^5.7.2",
"unplugin-vue-components": "^0.27.5",
"vite": "^6.0.2"
"vite": "^6.0.2",
"vitest": "^2.1.8"
},
"eslintConfig": {
"root": true,
Expand Down
88 changes: 0 additions & 88 deletions web/src/components/NavigationFooter.vue

This file was deleted.

106 changes: 0 additions & 106 deletions web/src/components/NavigationTopbar.vue

This file was deleted.

2 changes: 0 additions & 2 deletions web/src/components/dashboard/Dashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -545,13 +545,11 @@
</style>
<script lang="ts">
import { HttpService } from '@/services/HttpService';
import NavigationTopbar from '@components/NavigationTopbar.vue';
import Calendar from '@components/calendar/Calendar.vue';
import { defineComponent, inject, onMounted, reactive, ref } from 'vue';

export default defineComponent({
components: {
NavigationTopbar,
Calendar,
},
setup() {
Expand Down
19 changes: 19 additions & 0 deletions web/src/components/shared/Form/ActionButtons.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<template>
<v-btn-tertiary v-if="showSearch" type="submit" size="large" class="mr-2" text="Search" />
<v-btn v-if="showReset" size="large" text="Reset" @click="() => emit('reset')" />
</template>

<script setup>
const emit = defineEmits(['reset']);

const props = defineProps({
showSearch: {
type: Boolean,
default: true,
},
showReset: {
type: Boolean,
default: true,
},
});
</script>
39 changes: 39 additions & 0 deletions web/tests/components/shared/Form/ActionButtons.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { mount } from '@vue/test-utils';
import { describe, it, expect } from 'vitest';
import ActionButtons from 'CMP/shared/Form/ActionButtons.vue';

describe('ActionButtons.vue', () => {
it('renders search button when showSearch is true', () => {
const wrapper = mount(ActionButtons, {
props: { showSearch: true }
});
expect(wrapper.find('v-btn-tertiary').exists()).toBe(true);
});

it('does not render search button when showSearch is false', () => {
const wrapper = mount(ActionButtons, {
props: { showSearch: false }
});
expect(wrapper.find('v-btn-tertiary').exists()).toBe(false);
});

it('renders reset button when showReset is true', () => {
const wrapper = mount(ActionButtons, {
props: { showReset: true }
});
expect(wrapper.find('v-btn').exists()).toBe(true);
});

it('does not render reset button when showReset is false', () => {
const wrapper = mount(ActionButtons, {
props: { showReset: false }
});
expect(wrapper.find('v-btn').exists()).toBe(false);
});

it('emits "reset" event when reset button is clicked', async () => {
const wrapper = mount(ActionButtons);
await wrapper.find('v-btn').trigger('click');
expect(wrapper.emitted()).toHaveProperty('reset');
});
});
26 changes: 26 additions & 0 deletions web/vitest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import Vue from '@vitejs/plugin-vue';
import { dirname, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
import { defineConfig } from 'vitest/config';

const basePath = dirname(fileURLToPath(import.meta.url));

export default defineConfig({
plugins: [Vue()],
resolve: {
extensions: ['.ts', '.vue']
},
test: {
alias: [
{ find: 'SRC', replacement: resolve(basePath, './src') },
{ find: 'CMP', replacement: resolve(basePath, './src/components') }
],
css: true,
environment: 'happy-dom',
globals: true,
logHeapUsage: true,
reporters: ['default', 'junit'],
outputFile: './coverage/junit.xml',
mockReset: true
}
});
2 changes: 0 additions & 2 deletions web/web.njsproj
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,6 @@
<Content Include="src\components\criminal\CriminalWitnesses.vue" />
<Content Include="src\components\Home.vue" />
<Content Include="src\components\LoadingSpinner.vue" />
<Content Include="src\components\NavigationFooter.vue" />
<Content Include="src\components\NavigationTopbar.vue" />
<Content Include="tsconfig.json" />
<Content Include="package.json" />
<Content Include="README.md" />
Expand Down
Loading