Repository navigation
test: boost CI coverage to 68% threshold #648
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import { describe, expect, test } from 'bun:test'; | ||
| import { shortcutsShowCommand } from './shortcuts.js'; | ||
|
|
||
| describe('shortcutsShowCommand', () => { | ||
| test('does not throw', async () => { | ||
| // shortcutsShowCommand prints to console — just verify it doesn't crash | ||
| await expect(shortcutsShowCommand()).resolves.toBeUndefined(); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| import { describe, expect, test } from 'bun:test'; | ||
| import { homedir } from 'node:os'; | ||
| import { contractClaudePath, getClaudeSettingsPath, hookScriptExists, removeHookScript } from './claude-settings.js'; | ||
|
|
||
| describe('getClaudeSettingsPath', () => { | ||
| test('returns path under ~/.claude', () => { | ||
| const path = getClaudeSettingsPath(); | ||
| expect(path).toContain('.claude'); | ||
| expect(path).toEndWith('settings.json'); | ||
| }); | ||
| }); | ||
|
|
||
| describe('hookScriptExists', () => { | ||
| test('returns a boolean', () => { | ||
| const result = hookScriptExists(); | ||
| expect(typeof result).toBe('boolean'); | ||
| }); | ||
| }); | ||
|
|
||
| describe('removeHookScript', () => { | ||
| test('does not throw when hook script does not exist', () => { | ||
| // In a clean test env, the hook script likely doesn't exist | ||
| // This just verifies it doesn't crash | ||
| expect(() => removeHookScript()).not.toThrow(); | ||
| }); | ||
| }); | ||
|
|
||
| describe('contractClaudePath', () => { | ||
| test('contracts home directory to ~', () => { | ||
| const home = homedir(); | ||
| expect(contractClaudePath(`${home}/foo/bar`)).toBe('~/foo/bar'); | ||
| }); | ||
|
|
||
| test('contracts exact home to ~', () => { | ||
| const home = homedir(); | ||
| expect(contractClaudePath(home)).toBe('~'); | ||
| }); | ||
|
|
||
| test('returns non-home paths unchanged', () => { | ||
| expect(contractClaudePath('/tmp/foo')).toBe('/tmp/foo'); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import { describe, expect, test } from 'bun:test'; | ||
| import { OTEL_RELAY_PORT, getCodexConfigPath, isCodexConfigured } from './codex-config.js'; | ||
|
|
||
| describe('OTEL_RELAY_PORT', () => { | ||
| test('is a valid port number', () => { | ||
| expect(OTEL_RELAY_PORT).toBe(14318); | ||
| }); | ||
| }); | ||
|
|
||
| describe('getCodexConfigPath', () => { | ||
| test('returns a path ending with config.toml', () => { | ||
| const path = getCodexConfigPath(); | ||
| expect(path).toEndWith('config.toml'); | ||
| expect(path).toContain('.codex'); | ||
| }); | ||
| }); | ||
|
|
||
| describe('isCodexConfigured', () => { | ||
| test('returns a boolean', () => { | ||
| const result = isCodexConfigured(); | ||
| expect(typeof result).toBe('boolean'); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| import { describe, expect, test } from 'bun:test'; | ||
|
|
||
| // genie-config.ts uses module-level constants that read homedir() at import time. | ||
| // We can't override GENIE_DIR/GENIE_CONFIG_FILE. Instead we test the pure functions | ||
| // and verify the ones that use the filesystem work without crashing. | ||
|
|
||
| import { | ||
| contractPath, | ||
| genieConfigExists, | ||
| getGenieConfigPath, | ||
| getGenieDir, | ||
| getTerminalConfig, | ||
| isSetupComplete, | ||
| loadGenieConfig, | ||
| loadGenieConfigSync, | ||
| } from './genie-config.js'; | ||
|
|
||
| describe('getGenieDir', () => { | ||
| test('returns a path containing .genie', () => { | ||
| const dir = getGenieDir(); | ||
| expect(dir).toContain('.genie'); | ||
| }); | ||
| }); | ||
|
|
||
| describe('getGenieConfigPath', () => { | ||
| test('returns a path ending with config.json', () => { | ||
| const path = getGenieConfigPath(); | ||
| expect(path).toEndWith('config.json'); | ||
| }); | ||
| }); | ||
|
|
||
| describe('genieConfigExists', () => { | ||
| test('returns a boolean', () => { | ||
| const result = genieConfigExists(); | ||
| expect(typeof result).toBe('boolean'); | ||
| }); | ||
| }); | ||
|
|
||
| describe('contractPath', () => { | ||
| test('contracts home directory to ~', () => { | ||
| const { homedir } = require('node:os'); | ||
| const home = homedir(); | ||
| expect(contractPath(`${home}/projects/test`)).toBe('~/projects/test'); | ||
| }); | ||
|
|
||
| test('contracts exact home to ~', () => { | ||
| const { homedir } = require('node:os'); | ||
| expect(contractPath(homedir())).toBe('~'); | ||
| }); | ||
|
Comment on lines
+40
to
+49
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For consistency and best practice, it's better to use a top-level test('contracts home directory to ~', () => {
const home = homedir();
expect(contractPath(`${home}/projects/test`)).toBe('~/projects/test');
});
test('contracts exact home to ~', () => {
expect(contractPath(homedir())).toBe('~');
}); |
||
|
|
||
| test('returns non-home paths unchanged', () => { | ||
| expect(contractPath('/tmp/foo')).toBe('/tmp/foo'); | ||
| }); | ||
|
|
||
| test('returns relative paths unchanged', () => { | ||
| expect(contractPath('relative/path')).toBe('relative/path'); | ||
| }); | ||
| }); | ||
|
|
||
| describe('loadGenieConfig', () => { | ||
| test('returns a valid config object', async () => { | ||
| const config = await loadGenieConfig(); | ||
| expect(config).toBeDefined(); | ||
| expect(typeof config).toBe('object'); | ||
| }); | ||
| }); | ||
|
|
||
| describe('loadGenieConfigSync', () => { | ||
| test('returns a valid config object', () => { | ||
| const config = loadGenieConfigSync(); | ||
| expect(config).toBeDefined(); | ||
| expect(typeof config).toBe('object'); | ||
| }); | ||
| }); | ||
|
|
||
| describe('getTerminalConfig', () => { | ||
| test('returns terminal config with expected shape', () => { | ||
| const config = getTerminalConfig(); | ||
| expect(config).toBeDefined(); | ||
| expect(typeof config).toBe('object'); | ||
| }); | ||
| }); | ||
|
|
||
| describe('isSetupComplete', () => { | ||
| test('returns a boolean', () => { | ||
| const result = isSetupComplete(); | ||
| expect(typeof result).toBe('boolean'); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import { describe, expect, test } from 'bun:test'; | ||
| import { getRepoGenieDir } from './genie-dir.js'; | ||
|
|
||
| describe('getRepoGenieDir', () => { | ||
| test('returns .genie path under the given repo path', () => { | ||
| const dir = getRepoGenieDir('/tmp/some-repo'); | ||
| expect(dir).toEndWith('.genie'); | ||
| }); | ||
|
|
||
| test('returns path for current repo', () => { | ||
| const dir = getRepoGenieDir(process.cwd()); | ||
| expect(dir).toContain('.genie'); | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test calls
removeHookScript()against the default path under the current user's home directory, so running the suite on a machine where Genie/Claude hooks are installed will delete~/.claude/hooks/genie-bash-hook.shas a side effect. That makes the test destructive and can silently break a developer’s local setup; it should run against an isolated temp HOME (or a mocked filesystem path) instead.Useful? React with 👍 / 👎.