Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add tft price test case #642

Merged
merged 2 commits into from
Jul 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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

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
A-Harby marked this conversation as resolved.
Show resolved Hide resolved