diff --git a/agent/cli.py b/agent/cli.py index 4b95da5..ae94eb7 100644 --- a/agent/cli.py +++ b/agent/cli.py @@ -281,6 +281,39 @@ def assign(test_id): click.echo(f"\nāœ… TC '{test_id}' assigned to '{new_assignee}'!\n") +# Command: delete a test case +@cli.command() +@click.argument("test_id") +def delete_test(test_id): + """Delete a test case from the database. Ex: python agent/cli.py delete-test TC-001""" + with open(TEST_CASES_PATH, "r") as f: + data = json.load(f) + + test = next((tc for tc in data["test_cases"] if tc["id"] == test_id), None) + + if test is None: + click.echo(f"\nāŒ Test case '{test_id}' not found.\n") + return + + click.echo(f"\nšŸ—‘ļø You are about to delete the following test case:") + click.echo(f" {test['id']} | {test['title']} | {test['state']} | {test['assigned_to']}\n") + + confirm = click.confirm(" Are you sure you want to delete this test case?", default=False) + + if not confirm: + click.echo(f"\nāŒ Deletion cancelled.\n") + return + + data["test_cases"] = [tc for tc in data["test_cases"] if tc["id"] != test_id] + + with open(TEST_CASES_PATH, "w") as f: + json.dump(data, f, indent=2, ensure_ascii=False) + + log_event("test_deleted", test_id, f"Test case '{test['title']}' deleted") + + click.echo(f"\nāœ… Test case '{test_id}' successfully deleted!\n") + + # Command: run a playwright test @cli.command() @click.argument("test_id") diff --git a/agent/menu.py b/agent/menu.py index 7623c80..62c9eaa 100644 --- a/agent/menu.py +++ b/agent/menu.py @@ -25,6 +25,7 @@ def test_cases_menu(): "āœļø Update Test Case", "šŸ‘¤ Assign Test Case", "šŸŽ­ Run Playwright Test", + "šŸ—‘ļø Delete Test Case", "šŸ“Š Stats", "šŸ“¤ Export Test Cases History", "ā¬…ļø Back" @@ -96,6 +97,11 @@ def test_cases_menu(): else: run_command(["run-test", test_id]) wait_for_menu() + + elif choice == "šŸ—‘ļø Delete Test Case": + test_id = questionary.text("Test Case ID (e.g. TC-001):").ask() + run_command(["delete-test", test_id]) + wait_for_menu() elif choice == "šŸ“Š Stats": run_command(["stats"]) diff --git a/knowledge_base/history.json b/knowledge_base/history.json index db15140..9003811 100644 --- a/knowledge_base/history.json +++ b/knowledge_base/history.json @@ -53,6 +53,30 @@ "type": "test_run", "test_id": "TC-001", "details": "Playwright test ran — result: Passed" + }, + { + "timestamp": "2026-08-11 09:57", + "type": "test_deleted", + "test_id": "TC-001", + "details": "Test case 'new title' deleted" + }, + { + "timestamp": "2026-08-11 10:00", + "type": "test_created", + "test_id": "TC-001 log in", + "details": "Test case 'log in' created" + }, + { + "timestamp": "2026-08-11 10:11", + "type": "test_created", + "test_id": "TC-001", + "details": "Test case 'Log in' created" + }, + { + "timestamp": "2026-08-11 10:12", + "type": "test_deleted", + "test_id": "TC-001", + "details": "Test case 'Log in' deleted" } ] } \ No newline at end of file diff --git a/knowledge_base/test_cases/test_cases.json b/knowledge_base/test_cases/test_cases.json index 88a9f08..699a655 100644 --- a/knowledge_base/test_cases/test_cases.json +++ b/knowledge_base/test_cases/test_cases.json @@ -3,13 +3,13 @@ "last_updated": "2026-06-30", "test_cases": [ { - "id": "TC-001", + "id": "TC-002", "work_item_type": "Test Case", - "title": "new title", - "area_path": "Login/logout", - "assigned_to": "Tester", - "state": "Passed", - "playwright_file": "tests/test_login.py::test_login_valid_credentials", + "title": "Login with invalid credentials", + "area_path": "Project/Login", + "assigned_to": "Diogo", + "state": "Active", + "playwright_file": "tests/test_login.py::test_login_invalid_credentials", "steps": [ { "step": 1, @@ -18,39 +18,29 @@ }, { "step": 2, - "action": "Enter valid email and password", - "expected": "Fields are filled correctly" + "action": "Enter invalid email and wrong password", + "expected": "Fields are filled" }, { "step": 3, "action": "Click 'Login'", - "expected": "User is redirected to the dashboard" + "expected": "Error message is displayed" } ] }, { - "id": "TC-002", + "id": "TC-001 log in", "work_item_type": "Test Case", - "title": "Login with invalid credentials", - "area_path": "Project/Login", + "title": "log in", + "area_path": "Log in", "assigned_to": "Diogo", "state": "Active", - "playwright_file": "tests/test_login.py::test_login_invalid_credentials", + "playwright_file": "", "steps": [ { "step": 1, - "action": "Open the login page", - "expected": "Login page is displayed" - }, - { - "step": 2, - "action": "Enter invalid email and wrong password", - "expected": "Fields are filled" - }, - { - "step": 3, - "action": "Click 'Login'", - "expected": "Error message is displayed" + "action": "Log in to account", + "expected": "it loggins" } ] }