Migrate to electron-vite and electron-builder
- Switch from deprecated Vue CLI plugin to `electron-vite` (see nklayman/vue-cli-plugin-electron-builder#1982) - Update main/preload scripts to use `index.cjs` filenames to support `"type": "module"`, resolving crash issue (#233). This crash was related to Electron not supporting ESM (see electron/asar#249, electron/electron#21457). - This commit completes migration to Vite from Vue CLI (#230). Structure changes: - Introduce separate folders for Electron's main and preload processes. - Move TypeHelpers to `src/` to mark tit as accessible by the rest of the code. Config changes: - Make `vite.config.ts` reusable by Electron configuration. - On electron-builder, use `--publish` flag instead of `-p` for clarity. Tests: - Add log for preload script loading verification. - Implement runtime environment sanity checks. - Enhance logging in `check-desktop-runtime-errors`.
This commit is contained in:
40
tests/unit/shared/Stubs/CategoryCollectionParserStub.ts
Normal file
40
tests/unit/shared/Stubs/CategoryCollectionParserStub.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { IProjectInformation } from '@/domain/IProjectInformation';
|
||||
import { ProjectInformation } from '@/domain/ProjectInformation';
|
||||
import { ICategoryCollection } from '@/domain/ICategoryCollection';
|
||||
import { getEnumValues } from '@/application/Common/Enum';
|
||||
import type { CollectionData } from '@/application/collections/';
|
||||
import { CategoryCollectionParserType } from '@/application/Parser/ApplicationParser';
|
||||
import { OperatingSystem } from '@/domain/OperatingSystem';
|
||||
import { CategoryCollectionStub } from './CategoryCollectionStub';
|
||||
|
||||
export class CategoryCollectionParserStub {
|
||||
public readonly arguments = new Array<{
|
||||
data: CollectionData,
|
||||
info: ProjectInformation,
|
||||
}>();
|
||||
|
||||
private readonly returnValues = new Map<CollectionData, ICategoryCollection>();
|
||||
|
||||
public withReturnValue(
|
||||
data: CollectionData,
|
||||
collection: ICategoryCollection,
|
||||
): this {
|
||||
this.returnValues.set(data, collection);
|
||||
return this;
|
||||
}
|
||||
|
||||
public getStub(): CategoryCollectionParserType {
|
||||
return (data: CollectionData, info: IProjectInformation) => {
|
||||
this.arguments.push({ data, info });
|
||||
if (this.returnValues.has(data)) {
|
||||
return this.returnValues.get(data);
|
||||
}
|
||||
// Get next OS with a unique OS so mock does not result in an invalid app due to duplicated OS
|
||||
// collections.
|
||||
const currentRun = this.arguments.length - 1;
|
||||
const nextOs = getEnumValues(OperatingSystem)[currentRun];
|
||||
return new CategoryCollectionStub()
|
||||
.withOs(nextOs);
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { expect } from 'vitest';
|
||||
import { Constructible } from '@tests/shared/TypeHelpers';
|
||||
import { Constructible } from '@/TypeHelpers';
|
||||
import { ICodeValidationRule } from '@/application/Parser/Script/Validation/ICodeValidationRule';
|
||||
import { ICodeValidator } from '@/application/Parser/Script/Validation/ICodeValidator';
|
||||
|
||||
|
||||
22
tests/unit/shared/Stubs/ProjectInformationParserStub.ts
Normal file
22
tests/unit/shared/Stubs/ProjectInformationParserStub.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { parseProjectInformation } from '@/application/Parser/ProjectInformationParser';
|
||||
import { IAppMetadata } from '@/infrastructure/Metadata/IAppMetadata';
|
||||
import { IProjectInformation } from '@/domain/IProjectInformation';
|
||||
import { ProjectInformationStub } from './ProjectInformationStub';
|
||||
|
||||
export class ProjectInformationParserStub {
|
||||
public readonly arguments = new Array<IAppMetadata>();
|
||||
|
||||
private returnValue: IProjectInformation = new ProjectInformationStub();
|
||||
|
||||
public withReturnValue(value: IProjectInformation): this {
|
||||
this.returnValue = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
public getStub(): typeof parseProjectInformation {
|
||||
return (metadata) => {
|
||||
this.arguments.push(metadata);
|
||||
return this.returnValue;
|
||||
};
|
||||
}
|
||||
}
|
||||
10
tests/unit/shared/Stubs/SanityCheckOptionsStub.ts
Normal file
10
tests/unit/shared/Stubs/SanityCheckOptionsStub.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { ISanityCheckOptions } from '@/infrastructure/RuntimeSanity/ISanityCheckOptions';
|
||||
|
||||
export class SanityCheckOptionsStub implements ISanityCheckOptions {
|
||||
public validateMetadata = false;
|
||||
|
||||
public withValidateMetadata(value: boolean): this {
|
||||
this.validateMetadata = value;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
29
tests/unit/shared/Stubs/SanityValidatorStub.ts
Normal file
29
tests/unit/shared/Stubs/SanityValidatorStub.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { ISanityCheckOptions } from '@/infrastructure/RuntimeSanity/ISanityCheckOptions';
|
||||
import { ISanityValidator } from '@/infrastructure/RuntimeSanity/ISanityValidator';
|
||||
|
||||
export class SanityValidatorStub implements ISanityValidator {
|
||||
public shouldValidateArgs = new Array<ISanityCheckOptions>();
|
||||
|
||||
private errors: readonly string[] = [];
|
||||
|
||||
private shouldValidateResult = true;
|
||||
|
||||
public shouldValidate(options: ISanityCheckOptions): boolean {
|
||||
this.shouldValidateArgs.push(options);
|
||||
return this.shouldValidateResult;
|
||||
}
|
||||
|
||||
public collectErrors(): Iterable<string> {
|
||||
return this.errors;
|
||||
}
|
||||
|
||||
public withErrorsResult(errors: readonly string[]): this {
|
||||
this.errors = errors;
|
||||
return this;
|
||||
}
|
||||
|
||||
public withShouldValidateResult(shouldValidate: boolean): this {
|
||||
this.shouldValidateResult = shouldValidate;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { it, expect } from 'vitest';
|
||||
import { Constructible } from '@tests/shared/TypeHelpers';
|
||||
import { Constructible } from '@/TypeHelpers';
|
||||
|
||||
interface ISingletonTestData<T> {
|
||||
getter: () => T;
|
||||
|
||||
Reference in New Issue
Block a user