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:
@@ -1,4 +1,4 @@
|
||||
import { IAppMetadata } from '@/infrastructure/Metadata/IAppMetadata';
|
||||
import { IAppMetadata } from '@/infrastructure/EnvironmentVariables/IAppMetadata';
|
||||
|
||||
export class AppMetadataStub implements IAppMetadata {
|
||||
public version = '0.12.2';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { OperatingSystem } from '@/domain/OperatingSystem';
|
||||
import { IBrowserOsDetector } from '@/infrastructure/Environment/BrowserOs/IBrowserOsDetector';
|
||||
import { IBrowserOsDetector } from '@/infrastructure/RuntimeEnvironment/BrowserOs/IBrowserOsDetector';
|
||||
|
||||
export class BrowserOsDetectorStub implements IBrowserOsDetector {
|
||||
public detect(): OperatingSystem {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ICommandOps } from '@/infrastructure/Environment/SystemOperations/ISystemOperations';
|
||||
import { ICommandOps } from '@/infrastructure/SystemOperations/ISystemOperations';
|
||||
import { StubWithObservableMethodCalls } from './StubWithObservableMethodCalls';
|
||||
|
||||
export class CommandOpsStub
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
import { IEnvironment } from '@/infrastructure/Environment/IEnvironment';
|
||||
import { OperatingSystem } from '@/domain/OperatingSystem';
|
||||
import { ISystemOperations } from '@/infrastructure/Environment/SystemOperations/ISystemOperations';
|
||||
import { SystemOperationsStub } from './SystemOperationsStub';
|
||||
|
||||
export class EnvironmentStub implements IEnvironment {
|
||||
public isDesktop = true;
|
||||
|
||||
public os = OperatingSystem.Windows;
|
||||
|
||||
public system: ISystemOperations = new SystemOperationsStub();
|
||||
|
||||
public withOs(os: OperatingSystem): this {
|
||||
this.os = os;
|
||||
return this;
|
||||
}
|
||||
|
||||
public withSystemOperations(system: ISystemOperations): this {
|
||||
this.system = system;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
11
tests/unit/shared/Stubs/EnvironmentVariablesStub.ts
Normal file
11
tests/unit/shared/Stubs/EnvironmentVariablesStub.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { IEnvironmentVariables } from '@/infrastructure/EnvironmentVariables/IEnvironmentVariables';
|
||||
import { AppMetadataStub } from './AppMetadataStub';
|
||||
|
||||
export class EnvironmentVariablesStub extends AppMetadataStub implements IEnvironmentVariables {
|
||||
public isNonProduction = true;
|
||||
|
||||
public withIsNonProduction(isNonProduction: boolean): this {
|
||||
this.isNonProduction = isNonProduction;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { IFileSystemOps } from '@/infrastructure/Environment/SystemOperations/ISystemOperations';
|
||||
import { IFileSystemOps } from '@/infrastructure/SystemOperations/ISystemOperations';
|
||||
import { StubWithObservableMethodCalls } from './StubWithObservableMethodCalls';
|
||||
|
||||
export class FileSystemOpsStub
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ILocationOps } from '@/infrastructure/Environment/SystemOperations/ISystemOperations';
|
||||
import { ILocationOps } from '@/infrastructure/SystemOperations/ISystemOperations';
|
||||
import { StubWithObservableMethodCalls } from './StubWithObservableMethodCalls';
|
||||
|
||||
export class LocationOpsStub
|
||||
|
||||
12
tests/unit/shared/Stubs/LoggerStub.ts
Normal file
12
tests/unit/shared/Stubs/LoggerStub.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { ILogger } from '@/infrastructure/Log/ILogger';
|
||||
import { StubWithObservableMethodCalls } from './StubWithObservableMethodCalls';
|
||||
|
||||
export class LoggerStub extends StubWithObservableMethodCalls<ILogger> implements ILogger {
|
||||
public info(...params: unknown[]): void {
|
||||
this.registerMethodCall({
|
||||
methodName: 'info',
|
||||
args: params,
|
||||
});
|
||||
console.log(...params);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { IOperatingSystemOps } from '@/infrastructure/Environment/SystemOperations/ISystemOperations';
|
||||
import { IOperatingSystemOps } from '@/infrastructure/SystemOperations/ISystemOperations';
|
||||
import { StubWithObservableMethodCalls } from './StubWithObservableMethodCalls';
|
||||
|
||||
export class OperatingSystemOpsStub
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { parseProjectInformation } from '@/application/Parser/ProjectInformationParser';
|
||||
import { IAppMetadata } from '@/infrastructure/Metadata/IAppMetadata';
|
||||
import { IAppMetadata } from '@/infrastructure/EnvironmentVariables/IAppMetadata';
|
||||
import { IProjectInformation } from '@/domain/IProjectInformation';
|
||||
import { ProjectInformationStub } from './ProjectInformationStub';
|
||||
|
||||
|
||||
25
tests/unit/shared/Stubs/RuntimeEnvironmentStub.ts
Normal file
25
tests/unit/shared/Stubs/RuntimeEnvironmentStub.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { IRuntimeEnvironment } from '@/infrastructure/RuntimeEnvironment/IRuntimeEnvironment';
|
||||
import { OperatingSystem } from '@/domain/OperatingSystem';
|
||||
|
||||
export class RuntimeEnvironmentStub implements IRuntimeEnvironment {
|
||||
public isNonProduction = true;
|
||||
|
||||
public isDesktop = true;
|
||||
|
||||
public os = OperatingSystem.Windows;
|
||||
|
||||
public withOs(os: OperatingSystem): this {
|
||||
this.os = os;
|
||||
return this;
|
||||
}
|
||||
|
||||
public withIsDesktop(isDesktop: boolean): this {
|
||||
this.isDesktop = isDesktop;
|
||||
return this;
|
||||
}
|
||||
|
||||
public withIsNonProduction(isNonProduction: boolean): this {
|
||||
this.isNonProduction = isNonProduction;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,17 @@
|
||||
import { ISanityCheckOptions } from '@/infrastructure/RuntimeSanity/Common/ISanityCheckOptions';
|
||||
|
||||
export class SanityCheckOptionsStub implements ISanityCheckOptions {
|
||||
public validateEnvironment = false;
|
||||
public validateWindowVariables = false;
|
||||
|
||||
public validateMetadata = false;
|
||||
public validateEnvironmentVariables = false;
|
||||
|
||||
public withValidateMetadata(value: boolean): this {
|
||||
this.validateMetadata = value;
|
||||
public withvalidateEnvironmentVariables(value: boolean): this {
|
||||
this.validateEnvironmentVariables = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
public withValidateEnvironment(value: boolean): this {
|
||||
this.validateEnvironment = value;
|
||||
this.validateWindowVariables = value;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
IOperatingSystemOps,
|
||||
ILocationOps,
|
||||
ISystemOperations,
|
||||
} from '@/infrastructure/Environment/SystemOperations/ISystemOperations';
|
||||
} from '@/infrastructure/SystemOperations/ISystemOperations';
|
||||
import { CommandOpsStub } from './CommandOpsStub';
|
||||
import { FileSystemOpsStub } from './FileSystemOpsStub';
|
||||
import { LocationOpsStub } from './LocationOpsStub';
|
||||
|
||||
36
tests/unit/shared/Stubs/WindowVariablesStub.ts
Normal file
36
tests/unit/shared/Stubs/WindowVariablesStub.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { OperatingSystem } from '@/domain/OperatingSystem';
|
||||
import { ILogger } from '@/infrastructure/Log/ILogger';
|
||||
import { ISystemOperations } from '@/infrastructure/SystemOperations/ISystemOperations';
|
||||
import { WindowVariables } from '@/infrastructure/WindowVariables/WindowVariables';
|
||||
import { SystemOperationsStub } from './SystemOperationsStub';
|
||||
import { LoggerStub } from './LoggerStub';
|
||||
|
||||
export class WindowVariablesStub implements WindowVariables {
|
||||
public system: ISystemOperations = new SystemOperationsStub();
|
||||
|
||||
public isDesktop = false;
|
||||
|
||||
public os: OperatingSystem = OperatingSystem.BlackBerryOS;
|
||||
|
||||
public log: ILogger = new LoggerStub();
|
||||
|
||||
public withLog(log: ILogger): this {
|
||||
this.log = log;
|
||||
return this;
|
||||
}
|
||||
|
||||
public withIsDesktop(value: boolean): this {
|
||||
this.isDesktop = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
public withOs(value: OperatingSystem): this {
|
||||
this.os = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
public withSystem(value: ISystemOperations): this {
|
||||
this.system = value;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user