in issues/294/user_tool.py [0:0]
def test_task_preview():
with sync_playwright() as p:
browser = p.chromium.launch(headless=True, slow_mo=1000,
proxy={"server": "http://127.0.0.1:8080/"},
args=[
"--ignore-certificate-errors",
"--disable-web-security",
"--disable-features=IsolateOrigins,site-per-process"
])
context_args = {}
context_args["geolocation"] = {"latitude": 37.7749, "longitude": 122.4194}
context_args["permissions"] = ["geolocation"]
context_args["viewport"] = {"width": 1280, "height": 800}
context_args["user_agent"] = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.61 Safari/537.36"
context_args["ignore_https_errors"] = True
# Create first context and start tracing
context = browser.new_context(**context_args)
context.tracing.start(screenshots=True, snapshots=True, sources=True)
# Initialize context1 outside the try block
context1 = None
try:
page = context.new_page()
page.wait_for_timeout(5000)
page.goto("https://127.0.0.1:8082/")
email1 = create_user(page, "Test", "User1", "t1533148+1734358702@gmail.com")
# Create a second context and start tracing for it
context1 = browser.new_context(**context_args)
context1.tracing.start(screenshots=True, snapshots=True, sources=True)
page1 = context1.new_page()
page1.wait_for_timeout(5000)
page1.goto("https://127.0.0.1:8082/")
email2 = create_user(page1, "Test", "User2", "t1533148+1734358725@gmail.com")
page.wait_for_timeout(2000)
page.get_by_label("My settings").click()
page.get_by_test_id("InitialSettingsPage").get_by_label("Workspaces").click()
page.get_by_label("New workspace").last.click()
page.get_by_label("Members").click()
page.get_by_role("button", name="Invite member").click()
page.get_by_test_id("selection-list-text-input").fill(email2)
page.get_by_label("Test User2").last.click()
page.get_by_role("button", name="Next").click()
page.get_by_test_id("WorkspaceInviteMessagePage").get_by_role("button", name="Invite").click()
page.get_by_label("More features").click()
page.get_by_label("Configure how spend is").click()
page.get_by_label("Workflows").click()
page.get_by_label("Require additional approval").click()
page.get_by_label("Back").click()
page.get_by_label("Inbox").click()
page1.wait_for_timeout(2000)
page1.reload()
page1.locator('button[aria-label="Navigates to a chat"]', has_text="Test User1's Workspace").last.click()
page1.get_by_label("Create").nth(-1).click()
page1.get_by_label("Submit expense").click()
page1.get_by_label("Manual").click()
page1.get_by_placeholder("0").fill("100")
page1.locator("#numPadContainerView").get_by_role("button", name="Next").click()
page1.locator('div[role="menuitem"]', has_text="Merchant").click()
page1.locator('input[aria-label="Merchant"]').fill("Test Merchant")
page1.locator('button', has_text="Save").click()
page1.locator("button", has_text="Submit ₹").last.click()
page1.get_by_label("View details").click()
page1.wait_for_timeout(2000)
current_page_url = page1.url
page1.goto(f'{current_page_url}/details')
page1.get_by_role("button", name="Hold").click()
page1.get_by_role("textbox", name="Reason").fill("NA")
page1.get_by_role("button", name="Hold expense").click()
page1.get_by_role("button", name="Got it").click()
page.wait_for_timeout(2000)
page.reload()
page.locator('button[aria-label="Navigates to a chat"]', has_text="Test User2").last.click()
page.wait_for_timeout(2000)
page.get_by_role("button", name="Approve").click()
page.wait_for_timeout(5000)
expect(page.locator("text=Approve what's not on hold, or approve the entire report.")).not_to_be_visible()
finally:
# Stop tracing and export trace files for each context if available
if context1 is not None:
context1.tracing.stop(path="/app/expensify/user_tool/output_browser2.zip")
trace_cleaner("/app/expensify/user_tool/output_browser2.zip")
try:
context1.close()
except Exception:
pass
context.tracing.stop(path="/app/expensify/user_tool/output_browser1.zip")
trace_cleaner("/app/expensify/user_tool/output_browser1.zip")
try:
# Attempt to close pages if they exist
page1.close()
except Exception:
pass
try:
page.close()
except Exception:
pass
context.close()
browser.close()