Skip to content

Commit

Permalink
Fix for duplicating task cards on drag
Browse files Browse the repository at this point in the history
  • Loading branch information
uittenbroekrobbert committed Jul 11, 2024
1 parent 0faa762 commit 3707847
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions tests/api/routes/test_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
2 changes: 1 addition & 1 deletion tests/api/routes/test_tasks_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
20 changes: 10 additions & 10 deletions tests/e2e/test_move_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()


Expand All @@ -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)
Expand All @@ -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")
6 changes: 3 additions & 3 deletions tests/site/static/templates/test_task_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = """
<div class="progress_card_container" id="card-1" data-id="1">
<h4 class="margin-bottom--extra-small">Test Task</h4>
<div>Test Description</div>
<div id="card-content-1" data-id="1">
<h4 class="margin-bottom--extra-small">Test Task</h4>
<div>Test Description</div>
</div>
"""
# todo (robbert) there is probably a better way to clean results than replacing newlines and spaces
Expand Down

0 comments on commit 3707847

Please sign in to comment.