in issues/363/user_tool.py [0:0]
def reproduce_scenario(page: Page) -> None:
mile_rate = 100000
start_chat_element = page.get_by_label("Start chat (Floating action)")
start_chat_element .click()
new_workspace_element = page.get_by_text("New workspace")
new_workspace_element .click()
default_currency_element = page.get_by_text("Default currency")
default_currency_element .click()
page.get_by_test_id("selection-list-text-input").fill("usd")
currency_input_element = page.get_by_label("USD - $")
currency_input_element .click()
more_features_element = page.locator('div[dir="auto"]').get_by_text("More features")
more_features_element.click()
add_update_enforce_element = page.get_by_label("Add, update, and enforce")
add_update_enforce_element .click()
distance_rates_element = page.get_by_test_id("WorkspaceInitialPage").get_by_text("Distance rates")
distance_rates_element .click()
enabled_element = page.locator('div[dir="auto"]').get_by_text("Enabled")
enabled_element.click()
rate_element = page.locator('div[dir="auto"]').get_by_text("Rate").last
rate_element.click()
page.get_by_placeholder("0").fill(str(mile_rate))
save_element = page.get_by_role("button", name="Save")
save_element.click()
back_element = page.get_by_test_id("PolicyDistanceRateDetailsPage").get_by_label("Back")
back_element.click()
page.get_by_label("Back").first.click()
inbox_element = page.get_by_label("Inbox")
inbox_element.click()
workspace_name = str(first_name + " " + last_name + "'s Workspace")
collaboration_text = f"Collaboration between {first_name} {last_name} and {workspace_name} starts here!"
collaboration_element = page.locator('div[dir="auto"]').get_by_text(collaboration_text)
collaboration_element.click()
create_button = page.get_by_role("button", name="Create")
create_button.click()
page.get_by_text("Track expense").click()
page.get_by_label("Distance").click()
page.get_by_test_id("IOURequestStartPage").get_by_role("button", name="Start").click()
page.get_by_test_id("IOURequestStepWaypoint").get_by_role("textbox").fill("saray")
page.wait_for_timeout(2000)
page.get_by_text("Saray", exact=True).first.click()
page.get_by_role("button", name="Stop").click()
page.get_by_test_id("IOURequestStepWaypoint").get_by_role("textbox").fill("ergene")
page.get_by_text("Ergene", exact=True).first.click()
page.get_by_role("button", name="Next").nth(1).click()
miles_element = page.locator('div[dir="auto"]').get_by_text("miles")
text_content = miles_element.text_content()
miles_value = float(text_content.split()[0])
amount_element = page.locator('div[dir="auto"][data-selection-scrapper-hidden-element="false"]').get_by_text("$").first
text_content = amount_element.text_content()
actual_value = float(text_content.replace('$', '').replace(',', ''))
expected_value = miles_value * mile_rate
tolerance = 0.001
dif = abs(actual_value - expected_value)
assert dif < tolerance, f"Values do not match. Actual: {actual_value}, Expected: {expected_value}, Tolerance: {tolerance} Difference:{dif}"