Skip to content
Open
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
4 changes: 2 additions & 2 deletions packages/cli/__tests__/commands/mcp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ describe('--dir', () => {

await run(['mcp', 'status', '--ide', 'claude', '--dir', '/tmp/my-project', '--json']);

expect(mockIntegration.detectMcpStatuses).toHaveBeenCalledWith('/tmp/my-project');
expect(mockIntegration.detectMcpStatuses).toHaveBeenCalledWith(resolve('/tmp/my-project'));
});

it('passes --dir through to auth refresh', async () => {
Expand All @@ -239,7 +239,7 @@ describe('--dir', () => {
await run(['mcp', 'auth', '--ide', 'claude', '--dir', '/tmp/my-project']);

expect(mockIntegration.connectMcpServer).toHaveBeenCalledWith(
expect.objectContaining({ projectDir: '/tmp/my-project' }),
expect.objectContaining({ projectDir: resolve('/tmp/my-project') }),
);
});
});
8 changes: 6 additions & 2 deletions packages/cli/__tests__/commands/plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ describe('plugin update', () => {

await run(['plugin', 'update', '--ide', 'claude', '--dir', '/tmp/my-project']);

expect(mockUpdatePlugin).toHaveBeenCalledWith('claude', '/tmp/my-project', 'project');
expect(mockUpdatePlugin).toHaveBeenCalledWith('claude', resolve('/tmp/my-project'), 'project');
});

it('passes --scope to the updater', async () => {
Expand Down Expand Up @@ -163,7 +163,11 @@ describe('plugin uninstall', () => {

await run(['plugin', 'uninstall', '--ide', 'claude', '--dir', '/tmp/my-project']);

expect(mockUninstallPlugin).toHaveBeenCalledWith('claude', '/tmp/my-project', 'project');
expect(mockUninstallPlugin).toHaveBeenCalledWith(
'claude',
resolve('/tmp/my-project'),
'project',
);
});

it('passes --scope to the uninstaller', async () => {
Expand Down
5 changes: 3 additions & 2 deletions packages/core/__tests__/auth/credentials/store.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { existsSync, statSync, writeFileSync } from 'node:fs';
import { join } from 'node:path';
import { isWindows } from '@spotify-confidence/shared-kernel';
import { prepareAuthTokens } from '@spotify-confidence/testing/auth';
import { getConfigDir } from '@config/index.js';
import {
Expand All @@ -20,7 +21,7 @@ describe('writeCredentials / readCredentials', () => {
expect(sut).toEqual(creds);
});

it('creates the config directory with 0700 permissions', () => {
it.skipIf(isWindows)('creates the config directory with 0700 permissions', () => {
using _auth = prepareAuthTokens('none');

writeCredentials({ accessToken: 'tok' });
Expand All @@ -30,7 +31,7 @@ describe('writeCredentials / readCredentials', () => {
expect(mode).toBe(0o700);
});

it('writes the credentials file with 0600 permissions', () => {
it.skipIf(isWindows)('writes the credentials file with 0600 permissions', () => {
using _auth = prepareAuthTokens('none');

writeCredentials({ accessToken: 'tok' });
Expand Down
26 changes: 26 additions & 0 deletions packages/testing/__tests__/home-scaffold.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { homedir } from 'node:os';
import { describe, it, expect } from 'vitest';
import { isolateHome } from '../src/scaffold/home-scaffold.js';

describe('isolateHome', () => {
it('stubs both HOME and USERPROFILE to isolate os.homedir() across platforms', () => {
const fakeDir = process.platform === 'win32' ? 'C:\\fake\\home' : '/fake/home';
{
using _home = isolateHome(fakeDir);
expect(process.env.HOME).toBe(fakeDir);
expect(process.env.USERPROFILE).toBe(fakeDir);
expect(homedir()).toBe(fakeDir);
}
});

it('restores previous environment when disposed', () => {
const origHome = process.env.HOME;
const origUserProfile = process.env.USERPROFILE;
{
using _home = isolateHome('/temporary/test/dir');
expect(process.env.HOME).toBe('/temporary/test/dir');
}
expect(process.env.HOME).toBe(origHome);
expect(process.env.USERPROFILE).toBe(origUserProfile);
});
});
1 change: 1 addition & 0 deletions packages/testing/__tests__/overlay-env.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest';
import { overlayEnv } from '../src/env/overlay-env.js';

describe('overlayEnv', () => {
Expand Down
1 change: 1 addition & 0 deletions packages/testing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"node-pty": "1.2.0-beta.14"
},
"scripts": {
"test": "vitest run",
"typecheck": "tsc --noEmit"
},
"devDependencies": {
Expand Down
5 changes: 3 additions & 2 deletions packages/testing/src/scaffold/home-scaffold.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { vi } from 'vitest';

/**
* Stubs the `HOME` environment variable to `dir`, isolating the test
* from real user config files (`~/.cursor/`, `~/.claude.json`, etc.).
* Stubs `HOME` and `USERPROFILE` environment variables to `dir`, isolating the test
* from real user config files (`~/.cursor/`, `~/.claude.json`, etc.) across platforms.
* Supports `Symbol.dispose` for automatic cleanup via `vi.unstubAllEnvs`.
*
* @example
Expand All @@ -13,6 +13,7 @@ import { vi } from 'vitest';
*/
export function isolateHome(dir: string) {
vi.stubEnv('HOME', dir);
vi.stubEnv('USERPROFILE', dir);

return {
[Symbol.dispose]() {
Expand Down