diff --git a/pilot/main.py b/pilot/main.py index 0fb7ceb..14ed573 100644 --- a/pilot/main.py +++ b/pilot/main.py @@ -70,14 +70,20 @@ def get_custom_print(args): else: return local_print, ipc_client_instance + if __name__ == "__main__": try: + # sys.argv.append('--ux-test=' + 'run_command_until_success') args = init() + builtins.print, ipc_client_instance = get_custom_print(args) if '--api-key' in args: - os.environ["OPENAI_API_KEY"] = args['--api-key'] + os.environ["OPENAI_API_KEY"] = args['--api-key'] if '--get-created-apps-with-steps' in args: print({ 'db_data': get_created_apps_with_steps() }, type='info') + elif '--ux-test' in args: + from test.ux_tests import run_test + run_test(args['--ux-test']) else: # TODO get checkpoint from database and fill the project with it project = Project(args, ipc_client_instance=ipc_client_instance) diff --git a/pilot/test/ux_tests/README.md b/pilot/test/ux_tests/README.md new file mode 100644 index 0000000..cb0f00a --- /dev/null +++ b/pilot/test/ux_tests/README.md @@ -0,0 +1 @@ +The functions in this directory are used to test specific scenarios of the user experience. diff --git a/pilot/test/ux_tests/__init__.py b/pilot/test/ux_tests/__init__.py new file mode 100644 index 0000000..104f87f --- /dev/null +++ b/pilot/test/ux_tests/__init__.py @@ -0,0 +1,10 @@ +from .run_command_until_success import run_command_until_success + + +def run_test(test_name: str): + print(f'Running UX test "{test_name}"...') + + if test_name == 'run_command_until_success': + return run_command_until_success() + + print(f'UX test "{test_name}" not found') diff --git a/pilot/test/ux_tests/run_command_until_success.py b/pilot/test/ux_tests/run_command_until_success.py new file mode 100644 index 0000000..8b67612 --- /dev/null +++ b/pilot/test/ux_tests/run_command_until_success.py @@ -0,0 +1,41 @@ +import os +from helpers.agents import Developer, ENVIRONMENT_SETUP_STEP +from helpers import AgentConvo, Project +from helpers.files import update_file +from database import save_app + + +def run_command_until_success(): + name = 'run_command_until_success' + project = Project({ + 'app_id': '84c2c532-e07c-4694-bcb0-70767c348b07', + 'name': name, + 'app_type': '', + 'user_id': '97510ce7-dbca-44b6-973c-d27346ce4009', + 'email': '7ed2f578-c791-4719-959c-dedf94394ad3', + 'password': 'secret', + }, + name=name, + architecture=[], + user_stories=[] + ) + + project.root_path = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), + '../../../workspace/TestDeveloper')) + project.technologies = [] + project.current_step = ENVIRONMENT_SETUP_STEP + project.app = save_app(project) + + update_file(f'{project.root_path}/package.json', + '{"dependencies": {"axios": "^1.5.0", "express": "^4.18.2", "mongoose": "^7.5.0"}}') + + developer = Developer(project) + developer.run_command = 'npm install' + + convo = AgentConvo(developer) + step = { + 'type': 'human_intervention', + 'human_intervention_description': 'I want you to test that this process works from the CLI _and_ from the UI.', + } + + result = developer.step_human_intervention(convo, step)