|
1 | 1 | import { describe, it, expect } from 'vitest'; |
| 2 | +import os from 'os'; |
2 | 3 | import path from 'path'; |
3 | 4 | import { amazonQAdapter } from '../../../src/core/command-generation/adapters/amazon-q.js'; |
4 | 5 | import { antigravityAdapter } from '../../../src/core/command-generation/adapters/antigravity.js'; |
@@ -205,9 +206,43 @@ describe('command-generation/adapters', () => { |
205 | 206 | expect(codexAdapter.toolId).toBe('codex'); |
206 | 207 | }); |
207 | 208 |
|
208 | | - it('should generate correct file path', () => { |
| 209 | + it('should return an absolute path', () => { |
| 210 | + const filePath = codexAdapter.getFilePath('explore'); |
| 211 | + expect(path.isAbsolute(filePath)).toBe(true); |
| 212 | + }); |
| 213 | + |
| 214 | + it('should generate path ending with correct structure', () => { |
209 | 215 | const filePath = codexAdapter.getFilePath('explore'); |
210 | | - expect(filePath).toBe(path.join('.codex', 'prompts', 'opsx-explore.md')); |
| 216 | + expect(filePath).toMatch(/prompts[/\\]opsx-explore\.md$/); |
| 217 | + }); |
| 218 | + |
| 219 | + it('should default to homedir/.codex', () => { |
| 220 | + const original = process.env.CODEX_HOME; |
| 221 | + delete process.env.CODEX_HOME; |
| 222 | + try { |
| 223 | + const filePath = codexAdapter.getFilePath('explore'); |
| 224 | + const expected = path.join(os.homedir(), '.codex', 'prompts', 'opsx-explore.md'); |
| 225 | + expect(filePath).toBe(expected); |
| 226 | + } finally { |
| 227 | + if (original !== undefined) { |
| 228 | + process.env.CODEX_HOME = original; |
| 229 | + } |
| 230 | + } |
| 231 | + }); |
| 232 | + |
| 233 | + it('should respect CODEX_HOME env var', () => { |
| 234 | + const original = process.env.CODEX_HOME; |
| 235 | + process.env.CODEX_HOME = '/custom/codex-home'; |
| 236 | + try { |
| 237 | + const filePath = codexAdapter.getFilePath('explore'); |
| 238 | + expect(filePath).toBe(path.join('/custom/codex-home', 'prompts', 'opsx-explore.md')); |
| 239 | + } finally { |
| 240 | + if (original !== undefined) { |
| 241 | + process.env.CODEX_HOME = original; |
| 242 | + } else { |
| 243 | + delete process.env.CODEX_HOME; |
| 244 | + } |
| 245 | + } |
211 | 246 | }); |
212 | 247 |
|
213 | 248 | it('should format file with description and argument-hint', () => { |
|
0 commit comments