def test_expensify()

in issues/364/user_tool.py [0:0]


def test_expensify():
     with sync_playwright() as p:
        browser = p.chromium.launch(headless=True, args=[
            "--disable-web-security",
            "--disable-features=IsolateOrigins,site-per-process"
        ])

        first_user_context = browser.new_context(ignore_https_errors=True)
        # Start tracing immediately after creating the context
        first_user_context.tracing.start(screenshots=True, snapshots=True, sources=True)
        page = first_user_context.new_page()
        page.wait_for_timeout(3000)

        try:
            new_dot_login(page, EMAIL)
            page.wait_for_timeout(3000)
            amount = "100"

            workspace_chat = page.locator('button[aria-label="Navigates to a chat"]', has_text="Turing Vidhant+114's Workspace")
            expect(workspace_chat).to_be_visible()
            workspace_chat.click()
            page.wait_for_timeout(2000)

            plus_create_icon = page.locator('button[aria-label="Create"]').last
            expect(plus_create_icon).to_be_visible()
            plus_create_icon.click()
            page.wait_for_timeout(2000)

            submit_expense_button = page.locator('div[aria-label="Submit expense"]')
            expect(submit_expense_button).to_be_visible()
            submit_expense_button.click()
            page.wait_for_timeout(2000)

            manual_button = page.locator('button[aria-label="Manual"]').
            expect(manual_button).to_be_visible()
            manual_button.click()
            page.wait_for_timeout(2000)

            page.locator('input[role="presentation"]').fill(amount)

            next_button = page.locator('button[data-listener="Enter"]', has_text="Next").first
            expect(next_button).to_be_visible()
            next_button.click()
            page.wait_for_timeout(2000)

            merchant_field = page.locator('div[role="menuitem"]', has_text="Merchant")
            expect(merchant_field).to_be_visible()
            merchant_field.click()
            page.wait_for_timeout(2000)

            page.locator('input[aria-label="Merchant"]').fill("Test Merchant")

            save_button = page.locator('button', has_text="Save")
            expect(save_button).to_be_visible()
            save_button.click()
            page.wait_for_timeout(2000)

            save_button = page.locator('button[data-listener="Enter"]', has_text="Submit")
            expect(save_button).to_be_visible()
            save_button.click()
            page.wait_for_timeout(2000)

            new_workspace_chat = page.locator('button[aria-label="Navigates to a chat"]', has_text="Turing Vidhant+114's Workspace")
            expect(new_workspace_chat).to_be_visible()
            new_workspace_chat.click()
            page.wait_for_timeout(2000)
    
            view_details = page.locator('button[aria-label="View details"]').last
            expect(view_details).to_be_visible()
            view_details.click()
            
            page.get_by_role("textbox").type(':eye:', delay=100)
            page.wait_for_timeout(2000)
            
            smile_emoji = page.locator('div[aria-label="smile+1}"]')
            page.wait_for_timeout(2000)
    
            if smile_emoji.is_visible():
                assert False, "Emoji suggestion does not auto close after inserting emoji."
            else:
                assert True, "Emoji suggestion auto close after inserting emoji."
            
            page.wait_for_timeout(1500)

        finally:
            # Ensure that tracing is stopped and the trace file is exported
            trace_path = "/app/expensify/user_tool/output_browser1.zip"
            first_user_context.tracing.stop(path=trace_path)
            trace_cleaner(trace_path)
            page.close()
            browser.close()