Skip to content

Commit

Permalink
Merge pull request #642 from threefoldtech/development_add_tft_price_…
Browse files Browse the repository at this point in the history
…test_case
  • Loading branch information
xmonader authored Jul 2, 2023
2 parents 30c00b3 + 39ab34d commit 29a1d37
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
22 changes: 21 additions & 1 deletion packages/dashboard/tests/frontend_selenium/pages/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:])
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

18 changes: 18 additions & 0 deletions packages/dashboard/tests/frontend_selenium/tests/test_homepage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 29a1d37

Please sign in to comment.