diff --git a/packages/dashboard/tests/frontend_selenium/pages/dashboard.py b/packages/dashboard/tests/frontend_selenium/pages/dashboard.py index 5871b7f573..7ac571d4e6 100644 --- a/packages/dashboard/tests/frontend_selenium/pages/dashboard.py +++ b/packages/dashboard/tests/frontend_selenium/pages/dashboard.py @@ -22,6 +22,10 @@ class DashboardPage: decentralized_cloud_img = (By.XPATH, '//*[@id="app"]/div[1]/div[3]/div/div/div/div[1]/div/div/div/div/div/div[1]/div[3]') explorer_map = (By.XPATH,'//*[@id="app"]/div[1]/div[3]/div/div[2]/section') threefold_guide_img = (By.XPATH, "//*[contains(text(), 'Your Guide to The ThreeFold Grid')]") + tft_swap = (By.XPATH, '//*[@id="app"]/div[1]/div[1]/header/div/div[2]/div/div/div/button/span/i') + tft_price = (By.XPATH, '//*[@id="app"]/div[1]/div[1]/header/div/div[2]/div/div/div/p[2]') + tft_info = (By.XPATH, '//*[@id="app"]/div[1]/div[1]/header/div/div[2]/div/div/div/button[2]/span/i') + stellar_tft_price = (By.XPATH, '/html/body/div/div/div[3]/div/div/div[3]/div[1]/div[1]/dl/dd[9]/span') def __init__(self, browser): self.browser = browser @@ -70,4 +74,20 @@ def accounts_list(self): return self.browser.find_element(*self.account_list).text def get_address(self, account): - return str(account[13:]) \ No newline at end of file + return str(account[13:]) + + def tft_price_result(self): + return self.browser.find_element(*self.tft_price).text + + def tft_price_swap(self): + price = self.browser.find_element(*self.tft_price).text + self.browser.find_element(*self.tft_swap).click() + while (price == self.browser.find_element(*self.tft_price).text): + WebDriverWait(self.browser, 30).until(EC.visibility_of_element_located((By.XPATH, "//*[contains(text(), '1 USD')]"))) + + def get_tft_price(self): + self.browser.find_element(*self.tft_info).click() + WebDriverWait(self.browser, 30).until(EC.number_of_windows_to_be(2)) + self.browser.switch_to.window(self.browser.window_handles[1]) + return self.browser.find_element(*self.stellar_tft_price).text + \ No newline at end of file diff --git a/packages/dashboard/tests/frontend_selenium/tests/test_homepage.py b/packages/dashboard/tests/frontend_selenium/tests/test_homepage.py index a0720ab872..b2f63fabc0 100644 --- a/packages/dashboard/tests/frontend_selenium/tests/test_homepage.py +++ b/packages/dashboard/tests/frontend_selenium/tests/test_homepage.py @@ -206,3 +206,21 @@ def test_search_by_invalid_name_address(browser, cases): dashboard_page.search_accounts(cases.lower()) assert address not in address_list and address not in dashboard_page.accounts_list() assert len(account_list) == 0 and len(dashboard_page.accounts_list()) == 0 + + +def test_tft_price(browser): + """ + Test Case: TC1674 - TFT price + Steps: + - Navigate to dashboard. + - Authenticate polkadot. + - Click on TFT swap icon. + - Get TFT price from stellar site. + Result: Assert TFT in USD and vice versa. + """ + dashboard_page, _ = before_test_setup(browser) + tft_in_usd = float(dashboard_page.tft_price_result()[:-4]) + dashboard_page.tft_price_swap() + usd_in_tft = float(dashboard_page.tft_price_result()[:-4]) + assert str(tft_in_usd) in dashboard_page.get_tft_price() + assert 0.99 < tft_in_usd * usd_in_tft < 1.1 \ No newline at end of file