Improve desktop runtime execution tests
Test improvements: - Capture titles for all macOS windows, not just the frontmost. - Incorporate missing application log files. - Improve log clarity with enriched context. - Improve application termination on macOS by reducing grace period. - Ensure complete application termination on macOS. - Validate Vue application loading through an initial log. - Support ignoring environment-specific `stderr` errors. - Do not fail the test if working directory cannot be deleted. - Use retry pattern when installing dependencies due to network errors. Refactorings: - Migrate the test code to TypeScript. - Replace deprecated `rmdir` with `rm` for error-resistant directory removal. - Improve sanity checking by shifting from App.vue to Vue bootstrapper. - Centralize environment variable management with `EnvironmentVariables` construct. - Rename infrastructure/Environment to RuntimeEnvironment for clarity. - Isolate WindowVariables and SystemOperations from RuntimeEnvironment. - Inject logging via preloader. - Correct mislabeled RuntimeSanity tests. Configuration: - Introduce `npm run check:desktop` for simplified execution. - Omit `console.log` override due to `nodeIntegration` restrictions and reveal logging functionality using context-bridging.
This commit is contained in:
@@ -3,6 +3,8 @@ import { IconBootstrapper } from './Modules/IconBootstrapper';
|
||||
import { VueConstructor, IVueBootstrapper } from './IVueBootstrapper';
|
||||
import { VueBootstrapper } from './Modules/VueBootstrapper';
|
||||
import { TooltipBootstrapper } from './Modules/TooltipBootstrapper';
|
||||
import { RuntimeSanityValidator } from './Modules/RuntimeSanityValidator';
|
||||
import { AppInitializationLogger } from './Modules/AppInitializationLogger';
|
||||
|
||||
export class ApplicationBootstrapper implements IVueBootstrapper {
|
||||
public bootstrap(vue: VueConstructor): void {
|
||||
@@ -18,6 +20,8 @@ export class ApplicationBootstrapper implements IVueBootstrapper {
|
||||
new TreeBootstrapper(),
|
||||
new VueBootstrapper(),
|
||||
new TooltipBootstrapper(),
|
||||
new RuntimeSanityValidator(),
|
||||
new AppInitializationLogger(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
25
src/presentation/bootstrapping/ClientLoggerFactory.ts
Normal file
25
src/presentation/bootstrapping/ClientLoggerFactory.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { RuntimeEnvironment } from '@/infrastructure/RuntimeEnvironment/RuntimeEnvironment';
|
||||
import { IRuntimeEnvironment } from '@/infrastructure/RuntimeEnvironment/IRuntimeEnvironment';
|
||||
import { ConsoleLogger } from '@/infrastructure/Log/ConsoleLogger';
|
||||
import { ILogger } from '@/infrastructure/Log/ILogger';
|
||||
import { ILoggerFactory } from '@/infrastructure/Log/ILoggerFactory';
|
||||
import { NoopLogger } from '@/infrastructure/Log/NoopLogger';
|
||||
import { WindowInjectedLogger } from '@/infrastructure/Log/WindowInjectedLogger';
|
||||
|
||||
export class ClientLoggerFactory implements ILoggerFactory {
|
||||
public static readonly Current: ILoggerFactory = new ClientLoggerFactory();
|
||||
|
||||
public readonly logger: ILogger;
|
||||
|
||||
protected constructor(environment: IRuntimeEnvironment = RuntimeEnvironment.CurrentEnvironment) {
|
||||
if (environment.isDesktop) {
|
||||
this.logger = new WindowInjectedLogger();
|
||||
return;
|
||||
}
|
||||
if (environment.isNonProduction) {
|
||||
this.logger = new ConsoleLogger();
|
||||
return;
|
||||
}
|
||||
this.logger = new NoopLogger();
|
||||
}
|
||||
}
|
||||
@@ -2,15 +2,15 @@ import { InjectionKey, provide } from 'vue';
|
||||
import { useCollectionState } from '@/presentation/components/Shared/Hooks/UseCollectionState';
|
||||
import { useApplication } from '@/presentation/components/Shared/Hooks/UseApplication';
|
||||
import {
|
||||
useCollectionStateKey, useApplicationKey, useEnvironmentKey,
|
||||
useCollectionStateKey, useApplicationKey, useRuntimeEnvironmentKey,
|
||||
} from '@/presentation/injectionSymbols';
|
||||
import { IApplicationContext } from '@/application/Context/IApplicationContext';
|
||||
import { Environment } from '@/infrastructure/Environment/Environment';
|
||||
import { RuntimeEnvironment } from '@/infrastructure/RuntimeEnvironment/RuntimeEnvironment';
|
||||
|
||||
export function provideDependencies(context: IApplicationContext) {
|
||||
registerSingleton(useApplicationKey, useApplication(context.app));
|
||||
registerTransient(useCollectionStateKey, () => useCollectionState(context));
|
||||
registerSingleton(useEnvironmentKey, Environment.CurrentEnvironment);
|
||||
registerSingleton(useRuntimeEnvironmentKey, RuntimeEnvironment.CurrentEnvironment);
|
||||
}
|
||||
|
||||
function registerSingleton<T>(
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import { ILogger } from '@/infrastructure/Log/ILogger';
|
||||
import { IVueBootstrapper } from '../IVueBootstrapper';
|
||||
import { ClientLoggerFactory } from '../ClientLoggerFactory';
|
||||
|
||||
export class AppInitializationLogger implements IVueBootstrapper {
|
||||
constructor(
|
||||
private readonly logger: ILogger = ClientLoggerFactory.Current.logger,
|
||||
) { }
|
||||
|
||||
public bootstrap(): void {
|
||||
// Do not remove [APP_INIT]; it's a marker used in tests.
|
||||
this.logger.info('[APP_INIT] Application is initialized.');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import { validateRuntimeSanity } from '@/infrastructure/RuntimeSanity/SanityChecks';
|
||||
import { IVueBootstrapper } from '../IVueBootstrapper';
|
||||
|
||||
export class RuntimeSanityValidator implements IVueBootstrapper {
|
||||
constructor(private readonly validator = validateRuntimeSanity) {
|
||||
|
||||
}
|
||||
|
||||
public bootstrap(): void {
|
||||
this.validator({
|
||||
validateEnvironmentVariables: true,
|
||||
validateWindowVariables: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user