Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new dec tasks #28

Merged
merged 1 commit into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 13 additions & 17 deletions issues/24642_386/user_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import email
import re
import random

from utils.trace_cleaner import trace_cleaner


Expand Down Expand Up @@ -69,22 +68,18 @@ def get_magic_code(user_email, password, since=None, retries=5, delay=10):


def login_user_ND_with_magiccode(user_email, password, page):


page.goto(NEWDOT_URL)


page.locator('input[type="email"]').fill(user_email)
page.locator("div:nth-child(3) > div:nth-child(2) > div > div > div > .css-view-175oi2r").click()

page.wait_for_timeout(5000)



magic_code = "123456"

page.locator('input[autocomplete="one-time-code"]').fill(magic_code)
page.wait_for_timeout(500)



def test_issue_24642():
Expand All @@ -105,14 +100,15 @@ def test_issue_24642():
context_args["geolocation"] = {"latitude": 37.7749, "longitude": -122.4194}
context_args["permissions"] = ["geolocation"]
context_args["ignore_https_errors"] = True

context = browser.new_context(**context_args)
# Start tracing with screenshots, snapshots and sources
context.tracing.start(screenshots=True, snapshots=True, sources=True)

try:
page = context.new_page()
first_user_email = generate_random_email()
page = context.new_page()
first_user_email = generate_random_email()

try:
login_user_ND_with_magiccode(first_user_email, PASSWORD, page)
page.wait_for_timeout(2000)
context.set_offline(True)
Expand All @@ -121,16 +117,16 @@ def test_issue_24642():
page.get_by_text("Personal details").click()
try:
page.get_by_role("button", name="Back").click(timeout=10000)

except Exception as e:
pytest.fail("Test failed due to an exception")

except Exception as main_ex:
raise main_ex
finally:
context.tracing.stop()
trace_path = "/app/expensify/user_tool/output_browser1.zip"
context.tracing.export(trace_path)
context.tracing.stop(path=trace_path)
trace_cleaner(trace_path)

context.close()
browser.close()


if __name__ == "__main__":
test_issue_24642()
4 changes: 2 additions & 2 deletions issues/25901_945/user_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ async def test_issue_25901():

finally:

await context.tracing.stop()
await context.tracing.export(path="/app/expensify/user_tool/output_browser1.zip")

await context.tracing.stop(path="/app/expensify/user_tool/output_browser1.zip")
trace_cleaner("/app/expensify/user_tool/output_browser1.zip")


Expand Down
42 changes: 19 additions & 23 deletions issues/26004_979/user_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,34 @@
base_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
sys.path.insert(0, base_path)

from utils.trace_cleaner import trace_cleaner

import time
from playwright.sync_api import sync_playwright, expect
from playwright.sync_api._context_manager import PlaywrightContextManager
from playwright._impl._browser import Browser
from playwright._impl._page import Page

from utils.trace_cleaner import trace_cleaner # <--- Added import


def generate_random_email():
task_number = 26004
return f"jellystarfish+{task_number}@gmail.com"


def login_user(p: PlaywrightContextManager, first_name="Milan", last_name="T") -> tuple[Browser, Page, str]:
def login_user(p: PlaywrightContextManager, first_name="Milan", last_name="T") -> tuple[Browser, Page, object, str]:

browser = p.chromium.launch(headless=True, args=["--ignore-certificate-errors", "--disable-web-security", "--disable-features=IsolateOrigins,site-per-process"])
context = browser.new_context(ignore_https_errors=True)
page = context.new_page()
user_email = generate_random_email()


page.goto('https://dev.new.expensify.com:8082/')

page.goto('https://dev.new.expensify.com:8082/')

page.locator('input[type="email"]').fill(user_email)
page.locator('button[tabindex="0"]').click()
page.wait_for_timeout(2000)


try:
try:
page.locator('button[tabindex="0"]').click()
page.wait_for_timeout(2000)
except Exception:
Expand All @@ -44,7 +41,6 @@ def login_user(p: PlaywrightContextManager, first_name="Milan", last_name="T") -
page.locator("text='Track and budget expenses'").click()
page.get_by_role("button", name="Continue").click()


page.locator('input[name="fname"]').fill(first_name)
page.locator('input[name="lname"]').fill(last_name)
page.get_by_role("button", name="Continue").last.click()
Expand All @@ -55,41 +51,41 @@ def login_user(p: PlaywrightContextManager, first_name="Milan", last_name="T") -

def test_iou_subtitle_offline():
with sync_playwright() as p:
browser, page, context, user_email = login_user(p)

browser, page, context, user_email = login_user(p)
# Start tracing
context.tracing.start(screenshots=True, snapshots=True, sources=True)

try:

context.set_offline(True)
page.wait_for_timeout(2000)


page.get_by_label("Start chat (Floating action)").click()
page.get_by_text("Submit expense").click()
page.get_by_label("Manual").click()
page.get_by_placeholder("0").fill("100")
page.locator("#numPadContainerView").get_by_role("button", name="Next").click()
page.get_by_test_id("selection-list-text-input").fill("testuser@gmail.com")
page.get_by_label("testuser@gmail.com").click()

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


page.get_by_label("View details").click()

expect(page.get_by_label("From testuser@gmail.com")).to_be_visible()

page.get_by_label("From testuser@gmail.com").click()
expect(page.get_by_text("This is the beginning of your chat with testuser@gmail.com.")).to_be_visible()
except Exception as e:

raise e
finally:
# Stop tracing and export the trace
trace_path = "/app/expensify/user_tool/output_browser1.zip"
context.tracing.stop(path=trace_path)
trace_cleaner(trace_path)
browser.close()

context.tracing.stop()
context.tracing.export(path="/app/expensify/user_tool/output_browser1.zip")
trace_cleaner("/app/expensify/user_tool/output_browser1.zip")

context.close()
browser.close()
# If you want to run the test directly
if __name__ == '__main__':
test_iou_subtitle_offline()
49 changes: 16 additions & 33 deletions issues/26228_719/user_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,31 @@
from playwright.sync_api._context_manager import PlaywrightContextManager
from utils.trace_cleaner import trace_cleaner


def get_user_email():
return f"nitish.expensify+{9}@gmail.com"


def get_magic_code():
return "123456"


def login_user(p: PlaywrightContextManager):
browser = p.chromium.launch(headless=True,
args=[
"--ignore-certificate-errors",
"--disable-web-security",
"--disable-features=IsolateOrigins,site-per-process"
],
slow_mo=1000)
browser = p.chromium.launch(headless=True, args=[
"--ignore-certificate-errors", "--disable-web-security", "--disable-features=IsolateOrigins,site-per-process"],
slow_mo=1000)

# Create a new context and start tracing
context = browser.new_context()
context.tracing.start(screenshots=True, snapshots=True, sources=True)
page = context.new_page()

user_email = get_user_email()
first_name = 'John'
last_name = 'Doe'


page.goto('https://dev.new.expensify.com:8082/')


page.locator('input[type="email"]').fill(user_email)
page.locator('button[tabindex="0"]').click()

Expand All @@ -42,23 +42,16 @@ def login_user(p: PlaywrightContextManager):
page.get_by_role("button", name="Join").click()

try:
expect(page.locator('div[aria-label="Track and budget expenses"]').nth(
0)).to_be_visible()


page.locator(
'div[aria-label="Track and budget expenses"]').nth(0).click()


expect(page.locator('div[aria-label="Track and budget expenses"]').nth(0)).to_be_visible()
page.locator('div[aria-label="Track and budget expenses"]').nth(0).click()
page.locator('input[name="fname"]').nth(0).fill(first_name)
page.locator('input[name="lname"]').nth(0).fill(last_name)
page.get_by_role("button", name="Continue").nth(0).click()
except Exception:
pass

try:
get_started_here = page.locator(
'div', has_text="Get started here!").nth(-1)
get_started_here = page.locator('div', has_text="Get started here!").nth(-1)
expect(get_started_here).to_be_visible()
page.get_by_label("Close").nth(-1).click()
except Exception:
Expand All @@ -70,11 +63,8 @@ def login_user(p: PlaywrightContextManager):
def test_26228():
with sync_playwright() as p:
browser, context, page = login_user(p)

context.tracing.start(screenshots=True, snapshots=True, sources=True)
try:
plus_icon = page.locator(
'button[aria-label="Start chat (Floating action)"]')
plus_icon = page.locator('button[aria-label="Start chat (Floating action)"]')
expect(plus_icon).to_be_visible()
plus_icon.click()

Expand All @@ -84,15 +74,8 @@ def test_26228():

inputBox = page.get_by_test_id("selection-list-text-input")
expect(inputBox).to_be_visible()
except Exception as e:
print("Test encountered an error:", e)
raise e
finally:

context.tracing.stop()
context.tracing.export("/app/expensify/user_tool/output_browser1.zip")


trace_cleaner("/app/expensify/user_tool/output_browser1.zip")

trace_file = "/app/expensify/user_tool/output_browser1.zip"
context.tracing.stop(path=trace_file)
trace_cleaner(trace_file)
browser.close()
34 changes: 11 additions & 23 deletions issues/26648_972/user_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@
import re
import random

from utils.trace_cleaner import trace_cleaner

NEWDOT_URL = "https://dev.new.expensify.com:8082/"
OLDDOT_URL = "http://localhost:9000/"
EMAIL = "turingvidhant+111@gmail.com"
PASSWORD = "uotx fzkt kfeg dehz"


class IMAPOTPExtractor:
def __init__(self, email_address, password):
if not self._validate_email(email_address):
Expand Down Expand Up @@ -50,7 +53,7 @@ def check_for_otp(self):
if status != "OK":
return None

email_ids = messages[0].split()
email_ids = messages[0].split()
email_ids = email_ids[::-1]

for email_id in email_ids:
Expand Down Expand Up @@ -97,6 +100,7 @@ def _extract_otp(self, text):
match = re.search(r"\b\d{6}\b", text)
return match.group(0) if match else None


gmail_account_helper = IMAPOTPExtractor(EMAIL, PASSWORD)


Expand All @@ -114,6 +118,7 @@ def new_dot_login(page, email):
except:
pass


def launch_browser(pw, headless=True, device=None, geolocation=None):
"""
Launch the browser.
Expand All @@ -138,30 +143,22 @@ def test_expensify():
])

first_user_context = browser.new_context(ignore_https_errors=True)
# Start tracing with screenshots, snapshots and sources
first_user_context.tracing.start(screenshots=True, snapshots=True, sources=True)

page = first_user_context.new_page()
try:

first_user_context.tracing.start(
title="test_expensify",
screenshots=True,
snapshots=True,
sources=True
)

page = first_user_context.new_page()
page.wait_for_timeout(3000)

new_dot_login(page, EMAIL)
page.wait_for_timeout(3000)

page.get_by_text("This is your personal space. Use it for notes, tasks, drafts, and reminders.").click()

page.get_by_label("Start chat (Floating action)").click()
page.get_by_text("Track expense").click()
page.get_by_label("Manual").click()

scan_button = page.get_by_label("Scan")

distance_button = page.get_by_label("Distance")
distance_initial_bg_color = distance_button.evaluate("element => window.getComputedStyle(element).backgroundColor")

Expand All @@ -180,18 +177,9 @@ def test_expensify():
assert distance_initial_bg_color != distance_hover_bg_color, "Distance Button Background color did not change on hover"

page.wait_for_timeout(1500)
except Exception as e:

raise e
finally:

first_user_context.tracing.stop()
trace_path = "/app/expensify/user_tool/output_browser1.zip"
first_user_context.tracing.export(path=trace_path)


from utils.trace_cleaner import trace_cleaner
first_user_context.tracing.stop(path=trace_path)
trace_cleaner(trace_path)

page.close()
browser.close()
Loading