--ux-test arg provides short-cuts to defined scenarios for testing

This commit is contained in:
Nicholas Albion
2023-10-02 19:06:01 +11:00
parent 5fdc853768
commit 05a0358d39
4 changed files with 59 additions and 1 deletions

View File

@@ -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)

View File

@@ -0,0 +1 @@
The functions in this directory are used to test specific scenarios of the user experience.

View File

@@ -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')

View File

@@ -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)