Compare commits

...
Author SHA1 Message Date
Tabish Bidiwale 92c6f1f729 refactor: use ENOTDIR approach for cross-platform install error tests
Instead of platform-specific invalid paths (Z:\ or /root), create a
temporary file and use it as homeDir. This guarantees deterministic
ENOTDIR failures when trying to create subdirectories on all platforms.
2026-01-09 16:22:40 -08:00
Tabish Bidiwale 11c50ab4d1 fix: skip additional Windows-specific tests
- fish-installer: skip uninstall permission test (chmod on directory)
- powershell-installer: skip "skip configuration when script line exists"
  test (Windows has dual profile paths so the second profile gets configured)
2026-01-09 16:20:02 -08:00
3 changed files with 16 additions and 14 deletions
@@ -139,12 +139,11 @@ describe('BashInstaller', () => {
});
it('should handle installation errors gracefully', async () => {
// Create installer with non-existent/invalid home directory
// Use a path that will fail on both Unix and Windows
const invalidPath = process.platform === 'win32'
? 'Z:\\nonexistent\\invalid\\path' // Non-existent drive letter on Windows
: '/root/invalid/nonexistent/path'; // Permission-denied path on Unix
const invalidInstaller = new BashInstaller(invalidPath);
// Create a temporary file and use its path as homeDir
// This guarantees ENOTDIR when trying to create subdirectories (cross-platform)
const blockingFile = path.join(testHomeDir, 'blocking-file');
await fs.writeFile(blockingFile, 'blocking content');
const invalidInstaller = new BashInstaller(blockingFile);
const result = await invalidInstaller.install(testScript);
@@ -377,12 +376,11 @@ describe('BashInstaller', () => {
});
it('should handle write permission errors gracefully', async () => {
// Create installer with path that can't be written
// Use a path that will fail on both Unix and Windows
const invalidPath = process.platform === 'win32'
? 'Z:\\nonexistent\\invalid\\path' // Non-existent drive letter on Windows
: '/root/invalid/path'; // Permission-denied path on Unix
const invalidInstaller = new BashInstaller(invalidPath);
// Create a temporary file and use its path as homeDir
// This guarantees ENOTDIR when trying to write .bashrc (cross-platform)
const blockingFile = path.join(testHomeDir, 'blocking-file');
await fs.writeFile(blockingFile, 'blocking content');
const invalidInstaller = new BashInstaller(blockingFile);
const result = await invalidInstaller.configureBashrc(completionsDir);
@@ -286,7 +286,9 @@ complete -c openspec -a 'init'
expect(result.message).toBe('Completion script uninstalled successfully');
});
it('should return failure on permission error', async () => {
// Skip on Windows: fs.chmod() on directories doesn't restrict write access on Windows
// Windows uses ACLs which Node.js chmod doesn't control
it.skipIf(process.platform === 'win32')('should return failure on permission error', async () => {
await installer.install(mockCompletionScript);
const targetPath = path.join(testHomeDir, '.config', 'fish', 'completions', 'openspec.fish');
const parentDir = path.dirname(targetPath);
@@ -171,7 +171,9 @@ describe('PowerShellInstaller', () => {
expect(content).toContain('Write-Host "Hello"');
});
it('should skip configuration when script line already exists', async () => {
// Skip on Windows: Windows has dual profile paths (PowerShell Core + Windows PowerShell 5.1),
// so even if one profile is already configured, the second one will be configured and return true
it.skipIf(process.platform === 'win32')('should skip configuration when script line already exists', async () => {
delete process.env.OPENSPEC_NO_AUTO_CONFIG;
const profilePath = installer.getProfilePath();
await fs.mkdir(path.dirname(profilePath), { recursive: true });