diff --git a/test/e2e/gitPush.test.ts b/test/e2e/gitPush.test.ts index 611f8d0..7062ef0 100644 --- a/test/e2e/gitPush.test.ts +++ b/test/e2e/gitPush.test.ts @@ -125,7 +125,7 @@ describe('cli flow to push git branch', () => { await render('git', ['add index.ts'], { cwd: gitDir }); const { queryByText, findByText, userEvent } = await render( - `OCO_AI_PROVIDER='test' node`, + `OCO_AI_PROVIDER='test' OCO_GITPUSH='true' node`, [resolve('./out/cli.cjs')], { cwd: gitDir } ); @@ -158,7 +158,7 @@ describe('cli flow to push git branch', () => { await render('git', ['add index.ts'], { cwd: gitDir }); const { findByText, userEvent } = await render( - `OCO_AI_PROVIDER='test' node`, + `OCO_AI_PROVIDER='test' OCO_GITPUSH='true' node`, [resolve('./out/cli.cjs')], { cwd: gitDir } ); @@ -186,7 +186,7 @@ describe('cli flow to push git branch', () => { await render('git', ['add index.ts'], { cwd: gitDir }); const { findByText, userEvent } = await render( - `OCO_AI_PROVIDER='test' node`, + `OCO_AI_PROVIDER='test' OCO_GITPUSH='true' node`, [resolve('./out/cli.cjs')], { cwd: gitDir } ); diff --git a/test/e2e/oneFile.test.ts b/test/e2e/oneFile.test.ts index b3e25f9..1e6c4d4 100644 --- a/test/e2e/oneFile.test.ts +++ b/test/e2e/oneFile.test.ts @@ -9,7 +9,7 @@ it('cli flow to generate commit message for 1 new file (staged)', async () => { await render('echo' ,[`'console.log("Hello World");' > index.ts`], { cwd: gitDir }); await render('git' ,['add index.ts'], { cwd: gitDir }); - const { queryByText, findByText, userEvent } = await render(`OCO_AI_PROVIDER='test' node`, [resolve('./out/cli.cjs')], { cwd: gitDir }); + const { queryByText, findByText, userEvent } = await render(`OCO_AI_PROVIDER='test' OCO_GITPUSH='true' node`, [resolve('./out/cli.cjs')], { cwd: gitDir }); expect(await queryByText('No files are staged')).not.toBeInTheConsole(); expect(await queryByText('Do you want to stage all files and generate commit message?')).not.toBeInTheConsole(); @@ -34,7 +34,7 @@ it('cli flow to generate commit message for 1 changed file (not staged)', async await render('echo' ,[`'console.log("Good night World");' >> index.ts`], { cwd: gitDir }); - const { findByText, userEvent } = await render(`OCO_AI_PROVIDER='test' node`, [resolve('./out/cli.cjs')], { cwd: gitDir }); + const { findByText, userEvent } = await render(`OCO_AI_PROVIDER='test' OCO_GITPUSH='true' node`, [resolve('./out/cli.cjs')], { cwd: gitDir }); expect(await findByText('No files are staged')).toBeInTheConsole(); expect(await findByText('Do you want to stage all files and generate commit message?')).toBeInTheConsole(); diff --git a/test/e2e/prompt-module/commitlint.test.ts b/test/e2e/prompt-module/commitlint.test.ts index ab84999..643db37 100644 --- a/test/e2e/prompt-module/commitlint.test.ts +++ b/test/e2e/prompt-module/commitlint.test.ts @@ -5,8 +5,8 @@ import { prepareEnvironment, wait } from '../utils'; import path from 'path'; function getAbsolutePath(relativePath: string) { - const scriptDir = path.dirname(__filename); - return path.resolve(scriptDir, relativePath); + // Use process.cwd() which should be the project root during test execution + return path.resolve(process.cwd(), 'test/e2e/prompt-module', relativePath); } async function setupCommitlint(dir: string, ver: 9 | 18 | 19) { let packagePath, packageJsonPath, configPath; @@ -47,7 +47,7 @@ describe('cli flow to run "oco commitlint force"', () => { ` OCO_TEST_MOCK_TYPE='prompt-module-commitlint-config' \ OCO_PROMPT_MODULE='@commitlint' \ - OCO_AI_PROVIDER='test' \ + OCO_AI_PROVIDER='test' OCO_GITPUSH='true' \ node ${resolve('./out/cli.cjs')} commitlint force \ `, [], @@ -83,7 +83,7 @@ describe('cli flow to run "oco commitlint force"', () => { ` OCO_TEST_MOCK_TYPE='prompt-module-commitlint-config' \ OCO_PROMPT_MODULE='@commitlint' \ - OCO_AI_PROVIDER='test' \ + OCO_AI_PROVIDER='test' OCO_GITPUSH='true' \ node ${resolve('./out/cli.cjs')} commitlint force \ `, [], @@ -119,7 +119,7 @@ describe('cli flow to run "oco commitlint force"', () => { ` OCO_TEST_MOCK_TYPE='prompt-module-commitlint-config' \ OCO_PROMPT_MODULE='@commitlint' \ - OCO_AI_PROVIDER='test' \ + OCO_AI_PROVIDER='test' OCO_GITPUSH='true' \ node ${resolve('./out/cli.cjs')} commitlint force \ `, [], @@ -160,7 +160,7 @@ describe('cli flow to generate commit message using @commitlint prompt-module', ` OCO_TEST_MOCK_TYPE='prompt-module-commitlint-config' \ OCO_PROMPT_MODULE='@commitlint' \ - OCO_AI_PROVIDER='test' \ + OCO_AI_PROVIDER='test' OCO_GITPUSH='true' \ node ${resolve('./out/cli.cjs')} commitlint force \ `, [], @@ -175,7 +175,7 @@ describe('cli flow to generate commit message using @commitlint prompt-module', ` OCO_TEST_MOCK_TYPE='prompt-module-commitlint-config' \ OCO_PROMPT_MODULE='@commitlint' \ - OCO_AI_PROVIDER='test' \ + OCO_AI_PROVIDER='test' OCO_GITPUSH='true' \ node ${resolve('./out/cli.cjs')} commitlint get \ `, [], @@ -193,7 +193,7 @@ describe('cli flow to generate commit message using @commitlint prompt-module', ` OCO_TEST_MOCK_TYPE='commit-message' \ OCO_PROMPT_MODULE='@commitlint' \ - OCO_AI_PROVIDER='test' \ + OCO_AI_PROVIDER='test' OCO_GITPUSH='true' \ node ${resolve('./out/cli.cjs')} \ `, [],