in issues/88/user_tool.py [0:0]
def test_lhn_scrollable():
with sync_playwright() as p:
# Step 1: Login user
browser, page = login_user(p)
context = page.context
# Start tracing
context.tracing.start(screenshots=True, snapshots=True, sources=True)
try:
page.locator('span:has-text("Milan T (you)")').click()
# Step 2: Create multiple tracked expenses
create_expense(page, "usd", 10)
# Step 3: Navigate to Search
page.get_by_test_id("CustomBottomTabNavigator").get_by_label("Search").click()
# Step 4: Apply filters and save searches
# Each filter is applied differently based on its type
page.get_by_role("button", name="Filters").click()
# Filter by Currency (USD)
page.get_by_text("Currency").click()
page.get_by_test_id("selection-list-text-input").fill("usd")
page.locator("[id=\"USD\\ -\\ \\\"$\"]").click()
page.get_by_role("button", name="Save").click()
page.get_by_role("button", name="Save search").click()
page.wait_for_timeout(1000)
# Filter by Expense Type (Cash)
page.get_by_role("button", name="Filters").click()
page.get_by_role("link", name="Reset filters").click()
page.get_by_text("Expense type").click()
page.locator("#Cash").click()
page.get_by_role("button", name="Save").click()
page.get_by_role("button", name="Save search").click()
page.wait_for_timeout(1000)
# Filter by Total Amount (Between 10 and 1000)
page.get_by_role("button", name="Filters").click()
page.get_by_role("link", name="Reset filters").click()
page.get_by_test_id("SearchAdvancedFiltersPage").get_by_text("Total").click()
page.get_by_role("textbox", name="Greater than").fill("10")
page.get_by_role("textbox", name="Less than").click()
page.get_by_role("textbox", name="Less than").fill("1000")
page.get_by_role("button", name="Save").click()
page.get_by_role("button", name="Save search").click()
page.wait_for_timeout(1000)
# Filter by Currency (AED)
page.get_by_role("button", name="Filters").click()
page.get_by_role("link", name="Reset filters").click()
page.get_by_test_id("SearchAdvancedFiltersPage").get_by_text("Currency").click()
page.locator("[id=\"AED\\ -\\ Dhs\"]").get_by_label("AED - Dhs").click()
page.get_by_role("button", name="Save").click()
page.get_by_role("button", name="Save search").click()
page.wait_for_timeout(1000)
# Filter by Currency (JPY)
page.get_by_role("button", name="Filters").click()
page.get_by_role("link", name="Reset filters").click()
page.get_by_test_id("SearchAdvancedFiltersPage").get_by_text("Currency").click()
page.get_by_test_id("selection-list-text-input").fill("j")
page.locator("[id=\"JPY\\ -\\ ¥\"]").click()
page.get_by_role("button", name="Save").click()
page.get_by_role("button", name="Save search").click()
page.wait_for_timeout(1000)
# Filter by Currency (AOA)
page.get_by_role("button", name="Filters").click()
page.get_by_role("link", name="Reset filters").click()
page.get_by_test_id("SearchAdvancedFiltersPage").get_by_text("Currency").click()
page.locator("button").filter(has_text="AOA - Kz").click()
page.get_by_role("button", name="Save").click()
page.get_by_role("button", name="Save search").click()
page.wait_for_timeout(1000)
# Filter by Currency (AUD)
page.get_by_role("button", name="Filters").click()
page.get_by_test_id("SearchAdvancedFiltersPage").get_by_text("AOA").click()
page.locator("button").filter(has_text="AUD - A$").click()
page.locator("button").filter(has_text="AOA - Kz").get_by_label("AOA - Kz").click()
page.get_by_role("button", name="Save").click()
page.get_by_role("button", name="Save search").click()
page.wait_for_timeout(1000)
# Filter by Currency (ALL)
page.get_by_role("button", name="Filters").click()
page.get_by_role("link", name="Reset filters").click()
page.get_by_test_id("SearchAdvancedFiltersPage").get_by_text("Currency").click()
page.locator("[id=\"ALL\\ -\\ ALL\"]").click()
page.get_by_role("button", name="Save").click()
page.get_by_role("button", name="Save search").click()
# Step 5: Click "Expenses" in the bottom tab
expenses_tab = page.get_by_test_id("SearchPageBottomTab").get_by_text("Expenses")
expenses_tab.click()
page.wait_for_timeout(1000) # Allow UI to stabilize
page.set_viewport_size({"width": 1200, "height": 500})
# Step 6: Scroll the LHN to the bottom
aud_saved_search = page.get_by_text("type:expense status:all currency:AUD")
aud_saved_search.hover()
page.mouse.wheel(0, 600)
page.wait_for_timeout(1000)
# Step 7: Verify the "Expenses" tab is not visible after scrolling
locator = page.get_by_test_id("SearchPageBottomTab").get_by_text("Expenses")
expect(locator).to_be_visible()
# Get bounding box of the "Expenses" element
bounding_box = locator.bounding_box()
# Get current scroll position
scroll_y = page.evaluate("window.scrollY")
# Assert that the Expenses tab is not within the viewport
assert not bounding_box["y"] >= scroll_y, f"Expense tab should not be inside the viewport but is at {bounding_box['y']} while scrollY is {scroll_y}"
page.wait_for_timeout(2000)
finally:
# Stop tracing, export the trace file and run the trace cleaner
context.tracing.stop(path="/app/expensify/user_tool/output_browser1.zip")
trace_cleaner("/app/expensify/user_tool/output_browser1.zip")
browser.close()