From 3707847ec23fae7bb3b0e2e5e7014887aa262c41 Mon Sep 17 00:00:00 2001 From: robbertuittenbroek Date: Thu, 11 Jul 2024 22:05:06 +0200 Subject: [PATCH] Fix for duplicating task cards on drag --- tests/api/routes/test_status.py | 4 ++-- tests/api/routes/test_tasks_move.py | 2 +- tests/e2e/test_move_task.py | 20 +++++++++---------- .../static/templates/test_task_template.py | 6 +++--- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/api/routes/test_status.py b/tests/api/routes/test_status.py index 2992a300..e199e101 100644 --- a/tests/api/routes/test_status.py +++ b/tests/api/routes/test_status.py @@ -14,7 +14,7 @@ def test_post_move_task(client: TestClient, db: DatabaseTestUtils) -> None: response = client.patch("/tasks/", json=move_task.model_dump(by_alias=True)) assert response.status_code == 200 assert response.headers["content-type"] == "text/html; charset=utf-8" - assert b'class="progress_card_container"' in response.content + assert b'id="card-content-' in response.content def test_post_move_task_no_siblings(client: TestClient, db: DatabaseTestUtils) -> None: @@ -26,4 +26,4 @@ def test_post_move_task_no_siblings(client: TestClient, db: DatabaseTestUtils) - assert response.status_code == 200 assert response.headers["content-type"] == "text/html; charset=utf-8" - assert b'class="progress_card_container"' in response.content + assert b'id="card-content-' in response.content diff --git a/tests/api/routes/test_tasks_move.py b/tests/api/routes/test_tasks_move.py index 2b9a5d71..70dafb60 100644 --- a/tests/api/routes/test_tasks_move.py +++ b/tests/api/routes/test_tasks_move.py @@ -13,7 +13,7 @@ def test_post_task_move(client: TestClient, db: DatabaseTestUtils) -> None: ) assert response.status_code == 200 assert response.headers["content-type"] == "text/html; charset=utf-8" - assert b'id="card-1"' in response.content + assert b'id="card-content-1"' in response.content def test_task_move_error(client: TestClient) -> None: diff --git a/tests/e2e/test_move_task.py b/tests/e2e/test_move_task.py index e796b76b..0a3dda04 100644 --- a/tests/e2e/test_move_task.py +++ b/tests/e2e/test_move_task.py @@ -17,17 +17,17 @@ def test_move_task_to_column(browser: Page, db: DatabaseTestUtils) -> None: browser.goto("/pages/") - expect(browser.locator("#column-1 #card-1")).to_be_visible() + expect(browser.locator("#column-1 #card-container-1")).to_be_visible() expect(browser.locator("#column-3")).to_be_visible() # todo (Robbert) action below is performed twice, because once does not work, we need find out why and fix it - browser.locator("#card-1").drag_to(browser.locator("#column-3")) - browser.locator("#card-1").drag_to(browser.locator("#column-3")) + browser.locator("#card-container-1").drag_to(browser.locator("#column-3")) + browser.locator("#card-container-1").drag_to(browser.locator("#column-3")) browser.reload() - card = browser.locator("#column-3 #card-1") - expect(card).to_have_id("card-1") + card = browser.locator("#column-3 #card-container-1") + expect(card).to_have_id("card-container-1") expect(card).to_be_visible() @@ -48,11 +48,11 @@ def test_move_task_order_in_same_column(browser: Page, db: DatabaseTestUtils) -> browser.goto("/pages/") - expect(browser.locator("#column-1 #card-1")).to_be_visible() + expect(browser.locator("#column-1 #card-container-1")).to_be_visible() expect(browser.locator("#column-1")).to_be_visible() # todo (robbert) code below doesn't do what it should do, card is not moved - task = browser.locator("#card-1") + task = browser.locator("#card-container-1") task.hover() browser.mouse.down() browser.mouse.move(0, 50) @@ -62,6 +62,6 @@ def test_move_task_order_in_same_column(browser: Page, db: DatabaseTestUtils) -> tasks_in_column = browser.locator("#column-1").locator(".progress_card_container").all() # todo (robbert) this order should be changed if code above works correctly - expect(tasks_in_column[0]).to_have_id("card-1") - expect(tasks_in_column[1]).to_have_id("card-2") - expect(tasks_in_column[2]).to_have_id("card-3") + expect(tasks_in_column[0]).to_have_id("card-container-1") + expect(tasks_in_column[1]).to_have_id("card-container-2") + expect(tasks_in_column[2]).to_have_id("card-container-3") diff --git a/tests/site/static/templates/test_task_template.py b/tests/site/static/templates/test_task_template.py index 513b48dd..590618a7 100644 --- a/tests/site/static/templates/test_task_template.py +++ b/tests/site/static/templates/test_task_template.py @@ -9,9 +9,9 @@ def test_template_rendering(): task = Task(id=1, title="Test Task", description="Test Description", sort_order=1) result = env.get_template(name="task.html.jinja").render(task=task) expected_result = """ -
-

Test Task

-
Test Description
+
+

Test Task

+
Test Description
""" # todo (robbert) there is probably a better way to clean results than replacing newlines and spaces