-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start adding December tasks, update tooling API (#28)
- Loading branch information
1 parent
dc59971
commit 59187b3
Showing
53 changed files
with
1,118 additions
and
1,124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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: | ||
|
@@ -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() | ||
|
@@ -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("[email protected]") | ||
page.get_by_label("[email protected]").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 [email protected]")).to_be_visible() | ||
|
||
page.get_by_label("From [email protected]").click() | ||
expect(page.get_by_text("This is the beginning of your chat with [email protected].")).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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 = "[email protected]" | ||
PASSWORD = "uotx fzkt kfeg dehz" | ||
|
||
|
||
class IMAPOTPExtractor: | ||
def __init__(self, email_address, password): | ||
if not self._validate_email(email_address): | ||
|
@@ -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: | ||
|
@@ -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) | ||
|
||
|
||
|
@@ -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. | ||
|
@@ -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") | ||
|
||
|
@@ -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() |
Oops, something went wrong.