Skip to content

Commit 3b868ce

Browse files
committed
fix: enable git push functionality in e2e tests
- Added OCO_GITPUSH='true' environment variable to all e2e test commands - Fixed ESM module import issues in commitlint tests by using process.cwd() - Replaced import.meta.url usage with relative paths from project root - All e2e tests now properly test the git push prompt functionality
1 parent aad62d4 commit 3b868ce

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

test/e2e/gitPush.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ describe('cli flow to push git branch', () => {
125125
await render('git', ['add index.ts'], { cwd: gitDir });
126126

127127
const { queryByText, findByText, userEvent } = await render(
128-
`OCO_AI_PROVIDER='test' node`,
128+
`OCO_AI_PROVIDER='test' OCO_GITPUSH='true' node`,
129129
[resolve('./out/cli.cjs')],
130130
{ cwd: gitDir }
131131
);
@@ -158,7 +158,7 @@ describe('cli flow to push git branch', () => {
158158
await render('git', ['add index.ts'], { cwd: gitDir });
159159

160160
const { findByText, userEvent } = await render(
161-
`OCO_AI_PROVIDER='test' node`,
161+
`OCO_AI_PROVIDER='test' OCO_GITPUSH='true' node`,
162162
[resolve('./out/cli.cjs')],
163163
{ cwd: gitDir }
164164
);
@@ -186,7 +186,7 @@ describe('cli flow to push git branch', () => {
186186
await render('git', ['add index.ts'], { cwd: gitDir });
187187

188188
const { findByText, userEvent } = await render(
189-
`OCO_AI_PROVIDER='test' node`,
189+
`OCO_AI_PROVIDER='test' OCO_GITPUSH='true' node`,
190190
[resolve('./out/cli.cjs')],
191191
{ cwd: gitDir }
192192
);

test/e2e/oneFile.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ it('cli flow to generate commit message for 1 new file (staged)', async () => {
99
await render('echo' ,[`'console.log("Hello World");' > index.ts`], { cwd: gitDir });
1010
await render('git' ,['add index.ts'], { cwd: gitDir });
1111

12-
const { queryByText, findByText, userEvent } = await render(`OCO_AI_PROVIDER='test' node`, [resolve('./out/cli.cjs')], { cwd: gitDir });
12+
const { queryByText, findByText, userEvent } = await render(`OCO_AI_PROVIDER='test' OCO_GITPUSH='true' node`, [resolve('./out/cli.cjs')], { cwd: gitDir });
1313
expect(await queryByText('No files are staged')).not.toBeInTheConsole();
1414
expect(await queryByText('Do you want to stage all files and generate commit message?')).not.toBeInTheConsole();
1515

@@ -34,7 +34,7 @@ it('cli flow to generate commit message for 1 changed file (not staged)', async
3434

3535
await render('echo' ,[`'console.log("Good night World");' >> index.ts`], { cwd: gitDir });
3636

37-
const { findByText, userEvent } = await render(`OCO_AI_PROVIDER='test' node`, [resolve('./out/cli.cjs')], { cwd: gitDir });
37+
const { findByText, userEvent } = await render(`OCO_AI_PROVIDER='test' OCO_GITPUSH='true' node`, [resolve('./out/cli.cjs')], { cwd: gitDir });
3838

3939
expect(await findByText('No files are staged')).toBeInTheConsole();
4040
expect(await findByText('Do you want to stage all files and generate commit message?')).toBeInTheConsole();

test/e2e/prompt-module/commitlint.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import { prepareEnvironment, wait } from '../utils';
55
import path from 'path';
66

77
function getAbsolutePath(relativePath: string) {
8-
const scriptDir = path.dirname(__filename);
9-
return path.resolve(scriptDir, relativePath);
8+
// Use process.cwd() which should be the project root during test execution
9+
return path.resolve(process.cwd(), 'test/e2e/prompt-module', relativePath);
1010
}
1111
async function setupCommitlint(dir: string, ver: 9 | 18 | 19) {
1212
let packagePath, packageJsonPath, configPath;
@@ -47,7 +47,7 @@ describe('cli flow to run "oco commitlint force"', () => {
4747
`
4848
OCO_TEST_MOCK_TYPE='prompt-module-commitlint-config' \
4949
OCO_PROMPT_MODULE='@commitlint' \
50-
OCO_AI_PROVIDER='test' \
50+
OCO_AI_PROVIDER='test' OCO_GITPUSH='true' \
5151
node ${resolve('./out/cli.cjs')} commitlint force \
5252
`,
5353
[],
@@ -83,7 +83,7 @@ describe('cli flow to run "oco commitlint force"', () => {
8383
`
8484
OCO_TEST_MOCK_TYPE='prompt-module-commitlint-config' \
8585
OCO_PROMPT_MODULE='@commitlint' \
86-
OCO_AI_PROVIDER='test' \
86+
OCO_AI_PROVIDER='test' OCO_GITPUSH='true' \
8787
node ${resolve('./out/cli.cjs')} commitlint force \
8888
`,
8989
[],
@@ -119,7 +119,7 @@ describe('cli flow to run "oco commitlint force"', () => {
119119
`
120120
OCO_TEST_MOCK_TYPE='prompt-module-commitlint-config' \
121121
OCO_PROMPT_MODULE='@commitlint' \
122-
OCO_AI_PROVIDER='test' \
122+
OCO_AI_PROVIDER='test' OCO_GITPUSH='true' \
123123
node ${resolve('./out/cli.cjs')} commitlint force \
124124
`,
125125
[],
@@ -160,7 +160,7 @@ describe('cli flow to generate commit message using @commitlint prompt-module',
160160
`
161161
OCO_TEST_MOCK_TYPE='prompt-module-commitlint-config' \
162162
OCO_PROMPT_MODULE='@commitlint' \
163-
OCO_AI_PROVIDER='test' \
163+
OCO_AI_PROVIDER='test' OCO_GITPUSH='true' \
164164
node ${resolve('./out/cli.cjs')} commitlint force \
165165
`,
166166
[],
@@ -175,7 +175,7 @@ describe('cli flow to generate commit message using @commitlint prompt-module',
175175
`
176176
OCO_TEST_MOCK_TYPE='prompt-module-commitlint-config' \
177177
OCO_PROMPT_MODULE='@commitlint' \
178-
OCO_AI_PROVIDER='test' \
178+
OCO_AI_PROVIDER='test' OCO_GITPUSH='true' \
179179
node ${resolve('./out/cli.cjs')} commitlint get \
180180
`,
181181
[],
@@ -193,7 +193,7 @@ describe('cli flow to generate commit message using @commitlint prompt-module',
193193
`
194194
OCO_TEST_MOCK_TYPE='commit-message' \
195195
OCO_PROMPT_MODULE='@commitlint' \
196-
OCO_AI_PROVIDER='test' \
196+
OCO_AI_PROVIDER='test' OCO_GITPUSH='true' \
197197
node ${resolve('./out/cli.cjs')} \
198198
`,
199199
[],

0 commit comments

Comments
 (0)