Skip to content

Commit

Permalink
don't try to checkout if CExp.ADD_TO_CART_JS_ERROR (#580)
Browse files Browse the repository at this point in the history
end the test at /cart (as no items were added and therefore checkout can't happen)
  • Loading branch information
ndmanvar authored Sep 26, 2024
1 parent 7e32190 commit 8118bad
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions tda/desktop_web/test_checkout.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,21 @@ def test_checkout(desktop_web_driver, endpoints, batch_size, backend, random, sl

time.sleep(sleep_length())

try:
desktop_web_driver.find_element(By.CSS_SELECTOR, 'a[href="/checkout"]').click()
except Exception as err:
sentry_sdk.metrics.incr(key="test_checkout.iteration.abandoned", value=1, tags=dict(query_string, reason=f"no_proceed_to_checkout_btn({err.__class__.__name__})"))
continue
if (ce != CExp.ADD_TO_CART_JS_ERROR):
try:
desktop_web_driver.find_element(By.CSS_SELECTOR, 'a[href="/checkout"]').click()
except Exception as err:
sentry_sdk.metrics.incr(key="test_checkout.iteration.abandoned", value=1, tags=dict(query_string, reason=f"no_proceed_to_checkout_btn({err.__class__.__name__})"))
continue

time.sleep(sleep_length())

desktop_web_driver.find_element(By.CSS_SELECTOR, '#email').send_keys("[email protected]")
time.sleep(sleep_length())
desktop_web_driver.find_element(By.CSS_SELECTOR, '#email').send_keys("[email protected]")

desktop_web_driver.find_element(By.CSS_SELECTOR, '.complete-checkout-btn').click()
time.sleep(sleep_length())
desktop_web_driver.find_element(By.CSS_SELECTOR, '.complete-checkout-btn').click()
time.sleep(sleep_length())

sentry_sdk.metrics.incr(key="test_checkout.iteration.completed", value=1, tags=query_string)
sentry_sdk.metrics.incr(key="test_checkout.iteration.completed", value=1, tags=query_string)

except Exception as err:
sentry_sdk.metrics.incr(key="test_checkout.iteration.abandoned", value=1, tags=dict(query_string, reason=f"other({err.__class__.__name__})"))
Expand Down

0 comments on commit 8118bad

Please sign in to comment.