mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-20 10:34:30 +00:00
functional-tests: Avoid unnecessary trips to Home
Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net> [sunil: Check fo '/plinth/' instead of 'plinth' in URL checking for UI] Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
parent
8b4ccceb6b
commit
26100b50c1
@ -37,7 +37,9 @@ default_url = config['DEFAULT']['url']
|
|||||||
|
|
||||||
def login(browser, url, username, password):
|
def login(browser, url, username, password):
|
||||||
|
|
||||||
browser.visit(url)
|
if '/plinth/' not in browser.url:
|
||||||
|
browser.visit(url)
|
||||||
|
|
||||||
apps_link = browser.find_link_by_href('/plinth/apps/')
|
apps_link = browser.find_link_by_href('/plinth/apps/')
|
||||||
if len(apps_link):
|
if len(apps_link):
|
||||||
return
|
return
|
||||||
@ -64,7 +66,7 @@ def is_login_prompt(browser):
|
|||||||
def nav_to_module(browser, module):
|
def nav_to_module(browser, module):
|
||||||
sys_or_apps = 'sys' if module in sys_modules else 'apps'
|
sys_or_apps = 'sys' if module in sys_modules else 'apps'
|
||||||
required_url = default_url + f'/plinth/{sys_or_apps}/{module}/'
|
required_url = default_url + f'/plinth/{sys_or_apps}/{module}/'
|
||||||
if not (browser.url == required_url):
|
if browser.url != required_url:
|
||||||
browser.visit(required_url)
|
browser.visit(required_url)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -217,9 +217,7 @@ def backup_delete_root_archives(browser):
|
|||||||
|
|
||||||
|
|
||||||
def backup_create(browser, app_name):
|
def backup_create(browser, app_name):
|
||||||
browser.visit(default_url)
|
|
||||||
application.install(browser, 'backups')
|
application.install(browser, 'backups')
|
||||||
|
|
||||||
browser.find_link_by_href('/plinth/sys/backups/create/').first.click()
|
browser.find_link_by_href('/plinth/sys/backups/create/').first.click()
|
||||||
for app in browser.find_by_css('input[type=checkbox]'):
|
for app in browser.find_by_css('input[type=checkbox]'):
|
||||||
app.uncheck()
|
app.uncheck()
|
||||||
@ -231,7 +229,6 @@ def backup_create(browser, app_name):
|
|||||||
|
|
||||||
|
|
||||||
def backup_restore(browser, app_name):
|
def backup_restore(browser, app_name):
|
||||||
browser.visit(default_url)
|
|
||||||
nav_to_module(browser, 'backups')
|
nav_to_module(browser, 'backups')
|
||||||
path = "//a[starts-with(@href,'/plinth/sys/backups/root/restore-archive/')]"
|
path = "//a[starts-with(@href,'/plinth/sys/backups/root/restore-archive/')]"
|
||||||
# assume that want to restore the last (most recently created) backup
|
# assume that want to restore the last (most recently created) backup
|
||||||
@ -241,7 +238,6 @@ def backup_restore(browser, app_name):
|
|||||||
|
|
||||||
|
|
||||||
def backup_upload_and_restore(browser, app_name, downloaded_file_path):
|
def backup_upload_and_restore(browser, app_name, downloaded_file_path):
|
||||||
browser.visit(default_url)
|
|
||||||
nav_to_module(browser, 'backups')
|
nav_to_module(browser, 'backups')
|
||||||
browser.find_link_by_href('/plinth/sys/backups/upload/').first.click()
|
browser.find_link_by_href('/plinth/sys/backups/upload/').first.click()
|
||||||
fileinput = browser.driver.find_element_by_id('id_backups-file')
|
fileinput = browser.driver.find_element_by_id('id_backups-file')
|
||||||
@ -422,7 +418,8 @@ def open_main_page(browser):
|
|||||||
def networks_set_firewall_zone(browser, zone):
|
def networks_set_firewall_zone(browser, zone):
|
||||||
""""Set the network device firewall zone as internal or external."""
|
""""Set the network device firewall zone as internal or external."""
|
||||||
nav_to_module(browser, 'networks')
|
nav_to_module(browser, 'networks')
|
||||||
device = browser.find_by_xpath('//span[contains(@class, "label-success") '
|
device = browser.find_by_xpath(
|
||||||
|
'//span[contains(@class, "label-success") '
|
||||||
'and contains(@class, "connection-status-label")]/following::a').first
|
'and contains(@class, "connection-status-label")]/following::a').first
|
||||||
network_id = device['href'].split('/')[-3]
|
network_id = device['href'].split('/')[-3]
|
||||||
device.click()
|
device.click()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user