feat: add e2e tests for likes and fix like_count propagation in DTO mapping
All checks were successful
ci/woodpecker/pr/pipeline Pipeline was successful

- Write 3 e2e tests (TC-E2E-106-108): like/unlike flow, multi-user like, guest redirect
- Add get_like_count() and click_like() to PostDetailPage object
- Fix _map_to_dto in 5 use cases (create, get, list, publish, update) to include like_count
- Fix pre-existing mypy issues in page object (evaluate returns Any)
- Update FEATURE_LIKES.md with verified E2E status
This commit is contained in:
2026-05-10 21:11:28 +03:00
parent c8e19e3ce5
commit 30d9e287a7
8 changed files with 210 additions and 9 deletions

View File

@@ -107,7 +107,7 @@ class HomePage(BasePage):
tag = self.page.locator('[data-testid="pagination-next"]').evaluate(
"el => el.tagName.toLowerCase()"
)
return tag == "a"
return bool(tag == "a")
def can_go_prev(self) -> bool:
"""Check if the previous page link is enabled.
@@ -118,7 +118,7 @@ class HomePage(BasePage):
tag = self.page.locator('[data-testid="pagination-prev"]').evaluate(
"el => el.tagName.toLowerCase()"
)
return tag == "a"
return bool(tag == "a")
def go_to_next_page(self) -> None:
"""Click the next page pagination link."""
@@ -208,6 +208,7 @@ class PostDetailPage(BasePage):
self._content = SmartLocator.by_testid("post-detail-content")
self._edit_btn = SmartLocator.by_testid("btn-edit-post")
self._delete_btn = SmartLocator.by_testid("btn-delete-post")
self._like_button = SmartLocator.by_testid("like-button")
@property
def url(self) -> str:
@@ -275,3 +276,16 @@ class PostDetailPage(BasePage):
"""Click the delete button and accept the confirmation dialog."""
self.page.on("dialog", lambda dialog: dialog.accept())
self._delete_btn.click(self.page)
def get_like_count(self) -> int:
"""Get the current like count from the detail page.
Returns:
Current like count as integer.
"""
text = self.page.locator("#like-count").text_content()
return int(text.strip()) if text else 0
def click_like(self) -> None:
"""Click the like/unlike button to toggle the like state."""
self._like_button.click(self.page)