Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions test/core/completions/installers/bash-installer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down
4 changes: 3 additions & 1 deletion test/core/completions/installers/fish-installer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down
Loading