Skip to content

Commit 0da6931

Browse files
committed
fix: make transform playwright tests resilient
- Fix merchant row IDs to use underscore format (Apple_Purchases) - Click chevron instead of row for reliable expansion - Use correct CSS class for popup (.match-info-popup.visible) - Use .txn-row instead of .transaction-row - Run fixture from tmp_dir so relative paths work - Use expect().to_be_visible() for reliable element waiting
1 parent 5b49222 commit 0da6931

File tree

1 file changed

+30
-24
lines changed

1 file changed

+30
-24
lines changed

tests/test_report_html.py

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2033,7 +2033,7 @@ def transform_report_path(tmp_path_factory):
20332033
["uv", "run", "tally", "run", "-o", str(report_file), str(config_dir)],
20342034
capture_output=True,
20352035
text=True,
2036-
cwd=os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
2036+
cwd=str(tmp_dir) # Run from tmp_dir so relative paths in settings work
20372037
)
20382038

20392039
if result.returncode != 0:
@@ -2053,29 +2053,31 @@ def test_transformed_description_displayed(self, page: Page, transform_report_pa
20532053
"""Transaction with transform shows transformed description."""
20542054
page.goto(f"file://{transform_report_path}")
20552055

2056-
# Expand Apple Purchases merchant
2057-
apple_row = page.get_by_test_id("merchant-row-Apple Purchases")
2058-
apple_row.click()
2056+
# Wait for Vue to mount and render merchant rows
2057+
apple_row = page.get_by_test_id("merchant-row-Apple_Purchases")
2058+
expect(apple_row).to_be_visible()
20592059

2060-
# Wait for expansion
2061-
page.wait_for_timeout(200)
2060+
# Expand Apple Purchases merchant by clicking the chevron
2061+
apple_row.locator(".chevron").click()
20622062

20632063
# The transformed description should show "App Store Purchase"
2064-
txn_row = page.locator(".transaction-row", has_text="App Store Purchase")
2064+
txn_row = page.locator(".txn-row", has_text="App Store Purchase")
20652065
expect(txn_row).to_be_visible()
20662066

20672067
def test_extra_fields_badge_includes_original_description(self, page: Page, transform_report_path):
20682068
"""The +N badge count includes original_description."""
20692069
page.goto(f"file://{transform_report_path}")
20702070

2071-
# Expand Apple Purchases merchant
2072-
apple_row = page.get_by_test_id("merchant-row-Apple Purchases")
2073-
apple_row.click()
2071+
# Wait for Vue to mount and render merchant rows
2072+
apple_row = page.get_by_test_id("merchant-row-Apple_Purchases")
2073+
expect(apple_row).to_be_visible()
20742074

2075-
page.wait_for_timeout(200)
2075+
# Expand Apple Purchases merchant by clicking the chevron
2076+
apple_row.locator(".chevron").click()
20762077

20772078
# Find the transaction row with extra fields badge
2078-
txn_row = page.locator(".transaction-row", has_text="App Store Purchase")
2079+
txn_row = page.locator(".txn-row", has_text="App Store Purchase")
2080+
expect(txn_row).to_be_visible()
20792081

20802082
# Should have +2 badge (original_description + store field)
20812083
badge = txn_row.locator(".extra-fields-trigger")
@@ -2086,21 +2088,22 @@ def test_popup_shows_original_description(self, page: Page, transform_report_pat
20862088
"""Clicking +N badge shows original description in popup."""
20872089
page.goto(f"file://{transform_report_path}")
20882090

2089-
# Expand Apple Purchases merchant
2090-
apple_row = page.get_by_test_id("merchant-row-Apple Purchases")
2091-
apple_row.click()
2091+
# Wait for Vue to mount and render merchant rows
2092+
apple_row = page.get_by_test_id("merchant-row-Apple_Purchases")
2093+
expect(apple_row).to_be_visible()
20922094

2093-
page.wait_for_timeout(200)
2095+
# Expand Apple Purchases merchant by clicking the chevron
2096+
apple_row.locator(".chevron").click()
20942097

20952098
# Click the extra fields badge
2096-
txn_row = page.locator(".transaction-row", has_text="App Store Purchase")
2099+
txn_row = page.locator(".txn-row", has_text="App Store Purchase")
2100+
expect(txn_row).to_be_visible()
2101+
20972102
badge = txn_row.locator(".extra-fields-trigger")
20982103
badge.click()
20992104

2100-
page.wait_for_timeout(100)
2101-
21022105
# Popup should show "Original" label with raw description
2103-
popup = page.locator(".extra-fields-popup")
2106+
popup = txn_row.locator(".match-info-popup.visible")
21042107
expect(popup).to_be_visible()
21052108
expect(popup).to_contain_text("Original")
21062109
expect(popup).to_contain_text("APPLE.COM/BILL")
@@ -2109,13 +2112,16 @@ def test_untransformed_transaction_no_original_field(self, page: Page, transform
21092112
"""Transaction without transform has no original_description in badge."""
21102113
page.goto(f"file://{transform_report_path}")
21112114

2112-
# Expand Amazon merchant (no transform directive)
2115+
# Wait for Vue to mount and render merchant rows
21132116
amazon_row = page.get_by_test_id("merchant-row-Amazon")
2114-
amazon_row.click()
2117+
expect(amazon_row).to_be_visible()
21152118

2116-
page.wait_for_timeout(200)
2119+
# Expand Amazon merchant by clicking the chevron
2120+
amazon_row.locator(".chevron").click()
21172121

21182122
# Amazon transaction should not have extra fields badge
2119-
txn_row = page.locator(".transaction-row", has_text="AMAZON")
2123+
txn_row = page.locator(".txn-row", has_text="AMAZON")
2124+
expect(txn_row).to_be_visible()
2125+
21202126
badge = txn_row.locator(".extra-fields-trigger")
21212127
expect(badge).not_to_be_visible()

0 commit comments

Comments
 (0)