Skip to content

Commit

Permalink
V1.3.0
Browse files Browse the repository at this point in the history
- vitest for quasar
  • Loading branch information
fakoua committed Mar 3, 2024
1 parent 7073fab commit 4317ae6
Show file tree
Hide file tree
Showing 37 changed files with 7,161 additions and 5,297 deletions.
10 changes: 10 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,20 @@ module.exports = function (grunt) {
setVersion: {
command: 'deno run -A prepare-spa.ts --action set-version --version <%= grunt.config.get("version") %>',
},
testQuasar: {
cwd: './q-manui',
command: 'yarn cov',
},
buildQuasar: {
cwd: './q-manui',
command: 'quasar build',
},
spa: {
command: 'deno run -A prepare-spa.ts --action spa',
},
sonar: {
command: 'sonar-scanner.bat -D"sonar.organization=fakoua" -D"sonar.projectKey=fakoua_denoman" -D"sonar.sources=." -D"sonar.host.url=https://sonarcloud.io"',
},
},
});

Expand All @@ -36,12 +43,15 @@ module.exports = function (grunt) {
done();
});
});

grunt.registerTask("publish", [
"prompt",
"exec:fmt",
"exec:lint",
"exec:setVersion",
"exec:testQuasar",
"exec:buildQuasar",
"exec:spa",
"exec:sonar",
]);
};
20 changes: 14 additions & 6 deletions q-manui/package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
{
"name": "q-manui",
"version": "1.2.1",
"description": "DenoMan 1.2.1",
"version": "1.3.0",
"description": "DenoMan 1.3.0",
"productName": "DenoMan",
"author": "Sameh Fakoua <s.fakoua@gmail.com>",
"private": true,
"scripts": {
"lint": "eslint --ext .js,.ts,.vue ./",
"format": "prettier --write \"**/*.{js,ts,vue,css,html,md,json}\" --ignore-path .gitignore",
"test": "vitest",
"test": "echo \"See package.json => scripts for available tests.\" && exit 0",
"dev": "quasar dev",
"build": "quasar build"
"build": "quasar build",
"test:unit:ui": "vitest --ui",
"test:unit": "vitest",
"test:unit:ci": "vitest run",
"cov": "vitest run --coverage"
},
"dependencies": {
"@quasar/extras": "^1.16.9",
Expand All @@ -28,19 +32,23 @@
"devDependencies": {
"@babel/preset-typescript": "^7.23.3",
"@quasar/app-vite": "^1.7.3",
"@quasar/quasar-app-extension-testing-unit-vitest": "^0.4.0",
"@types/lodash": "^4.14.202",
"@types/node": "^20.11.22",
"@types/uuid": "^9.0.8",
"@typescript-eslint/eslint-plugin": "^7.1.0",
"@typescript-eslint/parser": "^7.1.0",
"@vue/test-utils": "^2.4.4",
"@vitest/coverage-v8": "^1.3.1",
"@vitest/ui": "^1.3.1",
"@vue/test-utils": "^2.4.1",
"autoprefixer": "^10.4.17",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-vue": "^9.22.0",
"prettier": "^3.2.5",
"typescript": "^5.3.3",
"vitest": "^1.3.1"
"vitest": "^1.3.1",
"@pinia/testing": "^0.1.3"
},
"engines": {
"node": "^20 || ^18 || ^16",
Expand Down
7 changes: 7 additions & 0 deletions q-manui/quasar.extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"@quasar/testing-unit-vitest": {
"options": [
"ui"
]
}
}
2 changes: 1 addition & 1 deletion q-manui/src/components/ServerComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ export default defineComponent({
selectedService: selectedService,
doubleClickedService,
splitterModel: ref(15),
services: ref<Array<ServiceModel>>([]),
services: ref<ServiceModel[]>([]),
isDialogOpen: isDialogOpen,
serviceWindow,
tab: ref('dashboard'),
Expand Down
5 changes: 1 addition & 4 deletions q-manui/src/components/dashboard/DashboardComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ export default defineComponent({
const processDependencies = (
services: ServiceModel[],
dependencies: DependenciesModel[]
dependencies: DependenciesModel[],
) => {
const grp = _groupBy(dependencies, (s) => {
return s.antecedent;
Expand Down Expand Up @@ -243,13 +243,10 @@ export default defineComponent({
}
model.value.system = await loadSystem();
const deps = await loadDependencies();
if (deps && services) {
processDependencies(services, deps);
}
isLoading.value = false;
});
Expand Down
3 changes: 0 additions & 3 deletions q-manui/src/components/devices/DevicesComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,6 @@ export default defineComponent({
data.value = await serviceApi.getDevices(props.host);
const res = _orderBy(data.value, ['class', 'caption'], ['asc', 'asc']);
const sam = data.value.filter((d) => d.status !== 'OK');
console.log(sam);
const grouped = _groupBy(res, 'class');
for (const key in grouped) {
const hasError =
Expand Down
4 changes: 1 addition & 3 deletions q-manui/src/components/processes/ProcessesComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ export default defineComponent({
setup(props) {
const data = ref<ParentProcessModel[]>([]);
const isLoading = ref(false);
const isLoading = ref(true);
const filter = ref('');
const pagination = ref({ sortBy: 'processName', descending: false });
const selected = ref([] as ProcessModel[]);
Expand All @@ -193,9 +193,7 @@ export default defineComponent({
});
onMounted(async () => {
isLoading.value = true;
const response = await serviceApi.getProcesses(props.host);
data.value = _.chain(response)
.groupBy('processName')
.map((value, key) => {
Expand Down
50 changes: 50 additions & 0 deletions q-manui/src/components/service-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ import {
WinRMPayload,
} from './models';

/**
* Retrieves services from the API based on the provided parameters.
*
* @param params - The parameters to be sent with the API request.
* @returns A promise that resolves to an array of ServiceModel objects if the request is successful, otherwise undefined.
*/
export async function getServices(params: WinRMPayload): Promise<ServiceModel[] | undefined> {
try {
const res = await api.get('http://localhost:8001/api/service', { params });
Expand All @@ -23,6 +29,12 @@ export async function getServices(params: WinRMPayload): Promise<ServiceModel[]
return undefined;
}

/**
* Retrieves the dependencies based on the provided parameters.
*
* @param params - The payload containing the parameters for the request.
* @returns A promise that resolves to an array of `DependenciesModel` or `undefined`.
*/
export async function getDependencies(params: WinRMPayload): Promise<
DependenciesModel[] | undefined
> {
Expand All @@ -39,6 +51,13 @@ export async function getDependencies(params: WinRMPayload): Promise<
return undefined;
}

/**
* Controls a service by sending an API request to the server.
* @param params - The payload to be sent with the API request.
* @param action - The control action to be performed on the service.
* @param name - The name of the service.
* @returns A Promise that resolves to a ServiceModel object if the API request is successful, otherwise undefined.
*/
export async function controlService(
params: WinRMPayload,
action: ControlAction,
Expand All @@ -62,31 +81,62 @@ export async function controlService(
return undefined;
}

/**
* Retrieves system information using the specified WinRMPayload.
* @param params - The WinRMPayload object containing the necessary parameters.
* @returns A Promise that resolves to a SystemModel object representing the system information.
*/
export async function getSystemInformation(params: WinRMPayload): Promise<SystemModel> {
const res = await api.get('http://localhost:8001/api/system', { params });
return res.data as SystemModel;
}

/**
* Retrieves performance monitor data using the specified WinRMPayload.
* @param params - The WinRMPayload object containing the parameters for the request.
* @returns A Promise that resolves to a PerfmonModel object representing the performance monitor data.
*/
export async function getPerfmon(params: WinRMPayload): Promise<PerfmonModel> {
const res = await api.get('http://localhost:8001/api/perfmon', { params });
return res.data as PerfmonModel;
}

/**
* Retrieves a list of processes based on the provided parameters.
*
* @param params - The payload containing the parameters for the request.
* @returns A promise that resolves to an array of ProcessModel objects.
*/
export async function getProcesses(params: WinRMPayload): Promise<ProcessModel[]> {
const res = await api.get('http://localhost:8001/api/process', { params });
return res.data as ProcessModel[];
}

/**
* Executes a command on the server using WinRM.
* @param params - The WinRM payload.
* @param command - The command to execute.
* @param isPowerShell - Indicates whether the command is a PowerShell command.
* @returns A promise that resolves to the response from the server.
*/
export async function execCommand(params: WinRMPayload, command: string, isPowerShell: boolean): Promise<ShellResponse> {
const res = await api.post('http://localhost:8001/api/command', { command, isPowerShell }, { params });
return res.data as ShellResponse;
}

/**
* Retrieves a list of devices based on the provided parameters.
* @param params - The payload containing the parameters for the request.
* @returns A promise that resolves to an array of DeviceModel objects.
*/
export async function getDevices(params: WinRMPayload): Promise<DeviceModel[]> {
const res = await api.get('http://localhost:8001/api/device', { params });
return res.data as DeviceModel[];
}

/**
* Sends a request to the server to exit the application.
*/
export function exitApp() {
api.get('http://localhost:8001/api/exit').catch(() => {
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export default defineComponent({
);
return dependsOn.map((v) => {
const svr = (services).find(
const svr = services.find(
(s: ServiceModel) => s.name == v.antecedent,
);
return {
Expand All @@ -209,9 +209,7 @@ export default defineComponent({
);
return antecedentsOn.map((v) => {
const svr = (services).find(
(s: ServiceModel) => s.name == v.dependent,
);
const svr = services.find((s: ServiceModel) => s.name == v.dependent);
return {
caption: svr?.caption,
name: v.dependent,
Expand Down Expand Up @@ -244,9 +242,7 @@ export default defineComponent({
if (!props.service) {
return true;
}
return !(
props.service.state === 'Running' && props.service.acceptPause
);
return !(props.service.state === 'Running' && props.service.acceptPause);
});
const disableResume = computed(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ export default defineComponent({
setup() {
return {
tab: ref('general'),
text: ref('asdfasdf'),
};
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,12 @@
{{ col.value }}
</q-td>
</q-tr>
<q-tr v-if="props.expand" v-show="props.expand" :props="props">
<q-tr
v-if="props.expand"
v-show="props.expand"
:props="props"
:key="props.row.caption"
>
<q-td colspan="100%" style="padding-left: 6px; background-color: white">
<div class="text-left">
<dependencies-row-component
Expand Down
14 changes: 9 additions & 5 deletions q-manui/src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@ import routes from './routes';

export default route(function () {
//NOSONAR
const createHistory = process.env.SERVER
? createMemoryHistory
: process.env.VUE_ROUTER_MODE === 'history'
? createWebHistory
: createWebHashHistory;
let createHistory;

if (process.env.SERVER) {
createHistory = createMemoryHistory;
} else if (process.env.VUE_ROUTER_MODE === 'history') {
createHistory = createWebHistory;
} else {
createHistory = createWebHashHistory;
}

const Router = createRouter({
scrollBehavior: () => ({ left: 0, top: 0 }),
Expand Down
15 changes: 0 additions & 15 deletions q-manui/src/stores/example-store.ts

This file was deleted.

15 changes: 15 additions & 0 deletions q-manui/test/vitest/__tests__/App.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { installQuasarPlugin } from '@quasar/quasar-app-extension-testing-unit-vitest';
import { mount } from '@vue/test-utils';
import { Notify } from 'quasar';
import { describe, expect, it } from 'vitest';
import App from 'src/App.vue';

installQuasarPlugin({ plugins: { Notify } });

describe('app component', () => {
it('should load [loading]', async () => {
expect(App).toBeTruthy();
const wrapper = mount(App);
expect(wrapper.html()).toContain('router-view');
});
});
Loading

0 comments on commit 4317ae6

Please sign in to comment.