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

fix email wait #3295

Merged
merged 11 commits into from
Aug 18, 2024
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
3 changes: 3 additions & 0 deletions packages/playground/tests/frontend_selenium/pages/bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
from selenium.webdriver.common.alert import Alert
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import StaleElementReferenceException
import time

class BridgePage:

"""
Expand Down Expand Up @@ -44,6 +46,7 @@ def navigate_to_bridge(self):

def twin_address(self):
self.browser.find_element(*self.deposit_close_button).click()
WebDriverWait(self.browser, 30).until(EC.visibility_of_element_located(self.twin_page))
self.browser.find_element(*self.twin_page).click()
return self.browser.find_element(*self.twin_address_text).text

Expand Down
12 changes: 10 additions & 2 deletions packages/playground/tests/frontend_selenium/pages/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from selenium.webdriver.common.alert import Alert
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import StaleElementReferenceException
from utils.base import Base
import time

Expand Down Expand Up @@ -64,10 +65,12 @@ def open_and_load(self):
def press_esc_key(self):
webdriver.ActionChains(self.browser).send_keys(Keys.ESCAPE).perform()

def import_account(self, seed):
def import_account(self, seed, validation=True):
self.browser.find_element(*self.mnemonic_input).send_keys(Keys.CONTROL + "a")
self.browser.find_element(*self.mnemonic_input).send_keys(Keys.DELETE)
self.browser.find_element(*self.mnemonic_input).send_keys(seed)
if(validation):
WebDriverWait(self.browser, 30).until(EC.element_to_be_clickable(self.email_input))

def connect_your_wallet(self, email, password):
self.browser.find_element(*self.email_input).send_keys(Keys.CONTROL + "a")
Expand All @@ -83,7 +86,12 @@ def connect_your_wallet(self, email, password):

def logout_account(self):
time.sleep(3)
self.wait_for_button(self.browser.find_element(*self.logout_button)).click()
while True:
try:
self.wait_for_button(self.browser.find_element(*self.logout_button)).click()
break # Exit the loop if interaction is successful
except StaleElementReferenceException:
time.sleep(0.5)
WebDriverWait(self.browser, 30).until(EC.visibility_of_element_located(self.find_more_button))
self.browser.refresh()
# alert = Alert(self.browser)
Expand Down
3 changes: 2 additions & 1 deletion packages/playground/tests/frontend_selenium/pages/farm.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ def create_farm(self, farm_name):
def create_farm_invalid_name(self, data):
self.browser.find_element(*self.farm_name_text_field).send_keys(Keys.CONTROL + "a")
self.browser.find_element(*self.farm_name_text_field).send_keys(Keys.DELETE)
self.browser.find_element(*self.farm_name_text_field).send_keys(data)
for char in data:
self.browser.find_element(*self.farm_name_text_field).send_keys(char)

def search_functionality(self, farm_name):
tries = 3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import StaleElementReferenceException
import time

class TransferPage:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ def test_create_farm(browser):
You should see "No data available " on the table of farms.
"""
farm_page, farm_name = before_test_setup(browser)
table = farm_page.search_functionality_invalid_name(generate_string())
assert 'No data available' in table
farm_page.create_farm(farm_name)
assert farm_page.wait_for('Farm created successfully')
farm_page.search_functionality(farm_name)
assert farm_page.wait_for_farm_name(farm_name)
table = farm_page.search_functionality_invalid_name(generate_string())
assert 'No data available' in table
farm_page.open_create()
farm_page.create_farm_invalid_name(farm_name)
assert farm_page.wait_for('Farm name already exists!')
Expand Down Expand Up @@ -77,7 +77,7 @@ def test_create_farm_invalid_name(browser):
for case in cases:
farm_page.create_farm_invalid_name(case)
assert farm_page.wait_for("Farm name can only contain alphabetic letters, numbers,")
farm_page.create_farm_invalid_name(generate_string()+generate_string()+'_'+generate_string()+generate_string())
farm_page.create_farm_invalid_name('f'+generate_string()+generate_string()+'_'+generate_string()+generate_string())
assert farm_page.wait_for('Farm name maximum length is 40 chars')


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def test_config_validation(browser):
nodes = grid_proxy.get_twin_node(str(node_page.twin_id))
node_id = nodes[random.randint(0,len(nodes)-1)]['nodeId']
node_page.setup_config(node_id)
cases = [generate_inavalid_ip(), '1.0.0.0/66', '239.255.255/17', '239.15.35.78.5/25', '239.15.35.78.5', ' ', '*.#.@.!|+-']
cases = [generate_string(), '1.0.0.0/66', '239.255.255/17', '239.15.35.78.5/25', '239.15.35.78.5', ' ', '*.#.@.!|+-']
assert node_page.add_config_input( "1.1.1.1/16", '1.1.1.2', '::2/16', '::1', 'tf.grid').is_enabled() == True
for case in cases:
node_page.add_config_input(case, 0, 0, 0, 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ def test_account_validation(browser):
grid_proxy = GridProxy(browser)
cases = [generate_string(), '123456', '!)$%&@#(+?', '0x123456ae7be88dc11f7', 'wrong hat egg gospel crowd foster lonely control cat recipe mean spoon']
for case in cases:
dashboard_page.import_account(case)
dashboard_page.import_account(case, False)
assert dashboard_page.wait_for('seem to be valid')
dashboard_page.import_account('')
dashboard_page.import_account('', False)
assert dashboard_page.wait_for('Mnemonic or Hex Seed is required.')
dashboard_page.import_account(get_seed())
cases = [generate_string(), '123456', '!)$%&@#(+?', '1@c@vva.ca', '1f@test,com', '@test.com', 'test@.com', 'test@com']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ def test_get_tft(browser):
Result: Assert that it should go to the correct link.
"""
twin_page = before_test_setup(browser)
twin_page.get_tft()
assert '/html' in browser.page_source
# twin_page.get_tft() # Get TFT button was removed from dashboard
# assert '/html' in browser.page_source
# NO checking as devnet don't direct to TF Connect page https://gettft.com/auth/login?next_url=/gettft/shop/#/buy
assert twin_page.press_locked_info() == 'https://www.manual.grid.tf/documentation/developers/tfchain/tfchain.html#contract-locking'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ def generate_gateway():
return gateway

def generate_gateway_from_ip(ipv4):
cryptogen = SystemRandom()
ip, mask = ipv4.split('/')
network = ipaddress.ip_network(f"{ip}/{mask}", strict=False)
if network.num_addresses <= 2:
Expand Down
Loading