41 lines
2.9 KiB
JavaScript
41 lines
2.9 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
const path_1 = require("path");
|
|
const cli_testing_library_1 = require("cli-testing-library");
|
|
require("cli-testing-library/extend-expect");
|
|
const utils_1 = require("./utils");
|
|
it('cli flow to generate commit message for 1 new file (staged)', async () => {
|
|
const { gitDir, cleanup } = await (0, utils_1.prepareEnvironment)();
|
|
await (0, cli_testing_library_1.render)('echo', [`'console.log("Hello World");' > index.ts`], { cwd: gitDir });
|
|
await (0, cli_testing_library_1.render)('git', ['add index.ts'], { cwd: gitDir });
|
|
const { queryByText, findByText, userEvent } = await (0, cli_testing_library_1.render)(`OCO_AI_PROVIDER='test' OCO_GITPUSH='true' node`, [(0, path_1.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();
|
|
expect(await findByText('Generating the commit message')).toBeInTheConsole();
|
|
expect(await findByText('Confirm the commit message?')).toBeInTheConsole();
|
|
userEvent.keyboard('[Enter]');
|
|
expect(await findByText('Do you want to run `git push`?')).toBeInTheConsole();
|
|
userEvent.keyboard('[Enter]');
|
|
expect(await findByText('Successfully pushed all commits to origin')).toBeInTheConsole();
|
|
await cleanup();
|
|
});
|
|
it('cli flow to generate commit message for 1 changed file (not staged)', async () => {
|
|
const { gitDir, cleanup } = await (0, utils_1.prepareEnvironment)();
|
|
await (0, cli_testing_library_1.render)('echo', [`'console.log("Hello World");' > index.ts`], { cwd: gitDir });
|
|
await (0, cli_testing_library_1.render)('git', ['add index.ts'], { cwd: gitDir });
|
|
await (0, cli_testing_library_1.render)('git', [`commit -m 'add new file'`], { cwd: gitDir });
|
|
await (0, cli_testing_library_1.render)('echo', [`'console.log("Good night World");' >> index.ts`], { cwd: gitDir });
|
|
const { findByText, userEvent } = await (0, cli_testing_library_1.render)(`OCO_AI_PROVIDER='test' OCO_GITPUSH='true' node`, [(0, path_1.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();
|
|
userEvent.keyboard('[Enter]');
|
|
expect(await findByText('Generating the commit message')).toBeInTheConsole();
|
|
expect(await findByText('Confirm the commit message?')).toBeInTheConsole();
|
|
userEvent.keyboard('[Enter]');
|
|
expect(await findByText('Successfully committed')).toBeInTheConsole();
|
|
expect(await findByText('Do you want to run `git push`?')).toBeInTheConsole();
|
|
userEvent.keyboard('[Enter]');
|
|
expect(await findByText('Successfully pushed all commits to origin')).toBeInTheConsole();
|
|
await cleanup();
|
|
});
|