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 UI testing and client explorer #1943

Closed
wants to merge 42 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
f61622c
packages frontend tests
Dina-Abd-Elrahman Nov 15, 2020
4ca4fdf
Merge branch 'development' of https://github.com/threefoldtech/js-sdk…
Dina-Abd-Elrahman Nov 15, 2020
fe1bfec
Merge branch 'development' of https://github.com/threefoldtech/js-sdk…
Dina-Abd-Elrahman Nov 16, 2020
ee43929
Merge branch 'development' of https://github.com/threefoldtech/js-sdk…
Dina-Abd-Elrahman Nov 24, 2020
6bd7e74
Merge branch 'development' of https://github.com/threefoldtech/js-sdk…
Dina-Abd-Elrahman Nov 28, 2020
6a50729
Merge branch 'development' of https://github.com/threefoldtech/js-sdk…
Dina-Abd-Elrahman Dec 2, 2020
dbe2b8c
Merge branch 'development' of https://github.com/threefoldtech/js-sdk…
Dina-Abd-Elrahman Dec 2, 2020
1816196
threebot deployer selenium
Dina-Abd-Elrahman Dec 6, 2020
d99de2d
threebot deployer selenium
Dina-Abd-Elrahman Dec 6, 2020
bff8163
workloads testcases
Dina-Abd-Elrahman Dec 9, 2020
05369d2
workloads testcases
Dina-Abd-Elrahman Dec 9, 2020
fbbe336
Merge branch 'development' of https://github.com/threefoldtech/js-sdk…
Dina-Abd-Elrahman Dec 13, 2020
0be32cc
workloads testcases
Dina-Abd-Elrahman Dec 15, 2020
e5268a2
workloads testcases
Dina-Abd-Elrahman Dec 15, 2020
77ab582
threebot deployer selenium
Dina-Abd-Elrahman Dec 16, 2020
bbf59a8
Merge branch 'development' of https://github.com/threefoldtech/js-sdk…
Dina-Abd-Elrahman Dec 17, 2020
536b2e7
add settings UI tests
mhost39 Dec 23, 2020
71c4cb9
add developer options
mhost39 Dec 24, 2020
aac5eac
modify workloads testcases
Dina-Abd-Elrahman Dec 29, 2020
a5005e0
Merge branch 'development' of https://github.com/threefoldtech/js-sdk…
Dina-Abd-Elrahman Dec 29, 2020
3e8fdf6
modify workloads testcases
Dina-Abd-Elrahman Dec 29, 2020
130cfac
explorer client testcases
Dina-Abd-Elrahman Dec 29, 2020
d345b19
remove package files
Dina-Abd-Elrahman Dec 30, 2020
dc4a990
Merge branch 'development_test_frontend_threebot_deployer' into devel…
mhost39 Jan 11, 2021
dc1da4b
Merge branch 'development_test_client_explorer' into development_test…
mhost39 Jan 11, 2021
dfdf382
Merge branch 'development_test_frontend_workloads' into development_t…
mhost39 Jan 11, 2021
9ed1d6e
Merge branch 'development' into development_testing_frontend_setting
mhost39 Jan 14, 2021
192af46
handel comments
mhost39 Jan 18, 2021
b524ef3
handle comments
mhost39 Jan 31, 2021
b583f1a
add ssh file
mhost39 Feb 10, 2021
1d0d7e7
Merge branch 'development' into development_testing_frontend_setting
mhost39 Feb 10, 2021
4654c0a
cover 3bot actions
mhost39 Feb 11, 2021
337b9bf
Merge branch 'development' into development_testing_frontend_setting
mhost39 Feb 15, 2021
8c129c4
handle comments
mhost39 Feb 17, 2021
3938fed
add tests docs
mhost39 Feb 17, 2021
5d3fe17
fix explorer test
mhost39 Mar 1, 2021
6e7349e
update 3bot tests
mhost39 Mar 1, 2021
9a83b7f
add Initializing your 3Bot wait
mhost39 Mar 3, 2021
fba9121
Merge branch 'development' into development_testing_frontend_setting
mhost39 Mar 7, 2021
bafece2
update setup
mhost39 Mar 8, 2021
2c524e6
Merge branch 'development' into development_testing_frontend_setting
mhost39 Mar 8, 2021
5f41ffa
add wait
mhost39 Mar 10, 2021
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
4 changes: 4 additions & 0 deletions docs/tests/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
### Clients

- [test_digitalocean](clients/digitalocean/test_digitalocean.md)
- [test_explorer](clients/explorer/test_explorer.md)
- [test_github](clients/github/test_github.md)
- [test_sendgrid](clients/sendgrid/test_sendgrid.md)

Expand All @@ -12,7 +13,10 @@

- [test_packages](frontend/tests/test_packages.md)
- [test_pools](frontend/tests/test_pools.md)
- [test_settings](frontend/tests/test_settings.md)
- [test_threebot_deployer](frontend/tests/test_threebot_deployer.md)
- [test_wallets](frontend/tests/test_wallets.md)
- [test_workloads](frontend/tests/test_workloads.md)

### Sals

Expand Down
26 changes: 26 additions & 0 deletions docs/tests/clients/explorer/test_explorer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
### test01_check_nodes

Check the node lists in explorer client.

**Test Scenario**

- List all nodes.
- Check that node list contains the node_id, farm_id, resources.

### test02_check_explorer_url

Check the explorer URL.

**Test Scenario**

- Check the explorer url.
- Make sure explorer_url "https://explorer.testnet.grid.tf/api/v1"

### test03_check_farms

Check the farms lists in explorer client.

**Test Scenario**

- List all farms.
- Check that farm list contains the wallet_addresses, id, location.
92 changes: 92 additions & 0 deletions docs/tests/frontend/tests/test_settings.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
### test01_add_admins

Test case for adding an admin and deleting it.

**Test Scenario**

- Add an admin.
- Check that the admin has been added in the admins.
- Delete the admin.
- Check that the admin has been deleted from the admins.

### test02_add_identity

Test case for adding an identity and deleting it.

**Test Scenario**

- Add an identity.
- Check that the identity has been added in the identities.
- Delete the identity.
- Check that the identity has been deleted from the identities.

### test03_add_escalation_emails

Test case for adding an email and deleting it.

**Test Scenario**

- Add an email.
- Check that the email has been added in the escalation emails.
- Delete the email.
- Check that the email has been deleted from the escalation emails.

### test04_allow_staging_ssl

Test case for changing developer options (Allow staging ssl certificate).

**Test Scenario**

- Get the config for staging ssl certificate option.
- Change this config.
- Check that the config has been changed.

### test05_allow_over_provisioning

Test case for changing developer options (Allow over provisioning).

**Test Scenario**

- Get the config for over provisioning.
- Change this config.
- Check that the config has been changed.

### test06_enable_explorer_logs

Test case for changing developer options (Enable explorer logs).

**Test Scenario**

- Get the config for explorer logs.
- Change this config.
- Check that the config has been changed.

### test07_enable_sending_escalation_emails

Test case for changing developer options (Enable sending escalation emails).

**Test Scenario**

- Get the config for sending escalation emails.
- Change this config.
- Check that the config has been changed.

### test08_pools_auto_extension

Test case for changing developer options (Pools auto extension).

**Test Scenario**

- Get the config for pools auto extension.
- Change this config.
- Check that the config has been changed.

### test09_sort_nodes_by_SRU

Test case for changing developer options (Sort nodes by SRU).

**Test Scenario**

- Get the config for sort nodes by SRU.
- Change this config.
- Check that the config has been changed.
34 changes: 34 additions & 0 deletions docs/tests/frontend/tests/test_threebot_deployer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
### test01_deploy_3bot

Test case to test deploy and delete a 3bot instance

**Test Scenario**

- Create a threebot instance.
- Check that the threebot instance has been created successfully.
- Delete the threebot instance.

### test02_start_and_stop_my_3bot_instance

Test case to test start and stop a 3bot instance

**Test Scenario**

- Create a threebot instance.
- Stopped the new created 3bot instance.
- Check that the 3bot instance has been stopped successfully.
- Start the 3bot instance.
- Check that the 3bot instance has been started successfully.
- Delete the 3bot instance.

### test03_change_deployed_threebot_location

Test case for changing a threebot location.

**Test Scenario**

- Create a threebot instance.
- Stopped the new created 3bot instance.
- Change the stopped threebot location.
- Check that threebot is reachable.
- Delete the 3bot instance.
9 changes: 9 additions & 0 deletions docs/tests/frontend/tests/test_workloads.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
### test01_delete_selected_workloads

Check that selected workload has been deleted correctly.

**Test Scenario**

- Create a workload.
- Delete selected workload.
- Check that selected workload has been deleted correctly.
84 changes: 84 additions & 0 deletions tests/clients/explorer/test_explorer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
from os import environ
from random import randint, choice

from jumpscale.loader import j
from tests.base_tests import BaseTests


class Explorer(BaseTests):

tname = environ.get("TNAME")
email = environ.get("EMAIL")
words = environ.get("WORDS")
explorer_url = "https://explorer.testnet.grid.tf/api/v1"
MYID_NAME = "identity_{}".format(randint(1, 1000))
explorer = j.core.identity.me.explorer

@classmethod
def setUpClass(cls):
if not all([cls.tname, cls.email, cls.words]):
raise Exception("Please add (TNAME, EMAIL, WORDS) of your 3bot identity as environment variables")
cls.me = None
if j.core.identity.list_all() and hasattr(j.core.identity, "me"):
cls.me = j.core.identity.me
myid = j.core.identity.new(
cls.MYID_NAME, tname=cls.tname, email=cls.email, words=cls.words, explorer_url=cls.explorer_url
)
myid.register()
myid.set_default()
myid.save()

@classmethod
def tearDownClass(cls):
j.core.identity.delete(cls.MYID_NAME)
if cls.me:
cls.me.set_default()

def test01_check_nodes(self):
"""Check the node lists in explorer client.

**Test Scenario**

- List all nodes.
- Check that node list contains the node_id, farm_id, resources.
"""

self.info("List all nodes")
nodes = self.explorer.nodes.list()
node = choice(nodes)

self.info("Check that node list contains the node_id, farm_id, resources")

self.assertIn("node_id", str(node))
self.assertIn("farm_id", str(node))
self.assertIn("total_resources", str(node))

def test02_check_explorer_url(self):
"""Check the explorer URL.

**Test Scenario**

- Check the explorer url.
- Make sure explorer_url "https://explorer.testnet.grid.tf/api/v1"
"""

self.info("Check the explorer url")
self.assertEquals(self.explorer.url, "https://explorer.testnet.grid.tf/api/v1")

def test03_check_farms(self):
"""Check the farms lists in explorer client.

**Test Scenario**

- List all farms.
- Check that farm list contains the wallet_addresses, id, location.
"""

self.info("List all farms")
farms = self.explorer.farms.list()
farm = choice(farms)

self.info("Check that farm list contains the wallet_addresses, id, location")
self.assertTrue(hasattr(farm, "wallet_addresses"))
self.assertTrue(hasattr(farm, "id"))
self.assertTrue(hasattr(farm, "location"))
3 changes: 2 additions & 1 deletion tests/frontend/pages/base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common import exceptions


class Base:
Expand All @@ -10,7 +11,7 @@ def __init__(self, *args, **kwargs):
pass

def wait(self, driver, class_name):
wait = WebDriverWait(driver, 360)
wait = WebDriverWait(driver, 600)
wait.until(EC.invisibility_of_element_located((By.CLASS_NAME, class_name)))

def click_button(self, driver, text):
Expand Down
Empty file.
100 changes: 100 additions & 0 deletions tests/frontend/pages/settings/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
from tests.frontend.pages.base import Base
from urllib.parse import urljoin
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC


class Settings(Base):
def __init__(self, driver, *args, **kwargs):
super().__init__(self, *args, **kwargs)
self.driver = driver
self.endpoint = "/admin/#/settings"

def load(self):
url = urljoin(self.base_url, self.endpoint)
self.driver.get(url)

def add_admin(self, name):
self.select_card("Admins")

admin_card = self.driver.find_element_by_class_name("v-dialog--active")
input = admin_card.find_element_by_tag_name("input")
input.send_keys(name)
add_button = admin_card.find_elements_by_tag_name("button")
add_button[1].click()
self.wait(self.driver, "v-card__progress")

def delete_admin(self, admin):
admins = self.list("Admins")
deleted_admin = [admins[a] for a in admins.keys() if a == admin][0]
delete_button = deleted_admin.find_element_by_tag_name("button")
delete_button.click()
self.wait(self.driver, "progressbar")
buttons = self.driver.find_elements_by_class_name("v-btn")
next_button = [button for button in buttons if button.text == "CONFIRM"][1]
next_button.click()
self.wait(self.driver, "v-card__progress")

def add_escalation_emails(self, email):
self.select_card("Escalation Emails")
escale_card = self.driver.find_element_by_class_name("v-dialog--active")
input = escale_card.find_element_by_tag_name("input")
input.send_keys(email)
add_button = escale_card.find_elements_by_tag_name("button")
add_button[1].click()
self.wait(self.driver, "v-card__progress")

def delete_escalation_emails(self, email):
emails = self.list("Escalation Emails")
deleted_email = [emails[e] for e in emails.keys() if e == email][0]
delete_button = deleted_email.find_element_by_tag_name("button")
delete_button.click()

def add_identities(self, name, tname, email, words):
self.select_card("Identities")
v_cards = self.driver.find_elements_by_class_name("v-card")
identity_card = [card for card in v_cards if "Add identity" in card.text][0]
form = identity_card.find_element_by_tag_name("form")
inputs_div = form.find_elements_by_class_name("v-text-field__slot")
inputs = {"Display name": name, "3Bot name": tname, "Email": email, "Words": words}
for input in inputs_div:
if input.text in inputs.keys():
input.find_element_by_tag_name("input").send_keys(inputs[input.text])

self.click_button(self.driver, "ADD")
self.wait(self.driver, "v-card__progress")

def delete_identity(self, name):
identities = self.list("Identities")
identity = [identities[i] for i in identities.keys() if i == name][0]
identity.click()
v_cards = self.driver.find_elements_by_class_name("v-card")
identity_details = [identity for identity in v_cards if identity == "Identity details"]
buttons = identity_details.find_element_by_tag_name("button")
buttons[0].click()

def developer_options(self, label):
self.wait(self.driver, "progressbar")
cards = self.driver.find_elements_by_class_name("mt-0")
developer_card = [card for card in cards if "Developer options" in card.text][0]
options = developer_card.find_elements_by_class_name("v-input__slot")
button = [option for option in options if option.text == label][0]
button.click()

def list(self, name):
self.wait(self.driver, "progressbar")
names = {}
v_cards = self.driver.find_elements_by_class_name("v-card")
card = [card for card in v_cards if name in card.text][0]
admins = card.find_elements_by_class_name("ma-2")
for a in admins:
names[a.text] = a
return names

def select_card(self, name):
self.wait(self.driver, "progressbar")
v_cards = self.driver.find_elements_by_class_name("v-card")
card = [card for card in v_cards if name in card.text][0]
button = card.find_element_by_tag_name("button")
button.click()
Empty file.
Loading