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

check-storage-luks: Fixes for React #9355

Closed
Closed
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
12 changes: 6 additions & 6 deletions test/verify/check-storage-luks
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class TestStorage(StorageCase):
"mounting": "custom",
"mount_point": mount_point_secret,
"crypto_extra_options": CheckBoxText("crypto,options") })

self.content_row_wait_in_col(1, 1, "Encrypted data")
self.content_row_wait_in_col(2, 1, "ext4 File System")

Expand All @@ -69,7 +70,6 @@ class TestStorage(StorageCase):
b.wait_not_in_text("#detail-content", "ext4 File System")

if not self.storaged_is_old_udisks:

# Unlock, this uses the stored passphrase
self.content_head_action(1, "Unlock")
self.content_row_wait_in_col(2, 1, "ext4 File System")
Expand Down Expand Up @@ -187,8 +187,8 @@ class TestStorage(StorageCase):
self.content_tab_action(1, 1, "Add")
self.dialog_wait_open()
self.dialog_set_val("method", "tang")
self.dialog_set_val("tang_url", "127.0.0.1")
self.dialog_set_val("passphrase", "vainu-reku-toma-rolle-kaja")
self.dialog_type_val("tang_url", "127.0.0.1")
self.dialog_type_val("passphrase", "vainu-reku-toma-rolle-kaja")
self.dialog_apply()
b.wait_in_text("#dialog", "The output should match this text")
b.wait_in_text("#dialog", m.execute("jose jwk thp -i /var/db/tang/sig1.jwk").strip())
Expand Down Expand Up @@ -301,11 +301,11 @@ class TestStorage(StorageCase):
self.content_tab_action(1, 1, "Add")
self.dialog_wait_open()
self.dialog_set_val("method", "http")
self.dialog_set_val("http_url", "http://127.0.0.1:88")
self.dialog_set_val("allow_plain_http", True)
self.dialog_type_val("http_url", "http://127.0.0.1:88")
self.dialog_click_checkbox("allow_plain_http")
self.dialog_set_val("http_method", "PUT")
self.dialog_set_val("key_type", "octet-stream")
self.dialog_set_val("passphrase", "vainu-reku-toma-rolle-kaja")
self.dialog_type_val("passphrase", "vainu-reku-toma-rolle-kaja")
self.dialog_apply()
self.dialog_wait_close()
self.content_tab_wait_in_info(1, 1, "Network keys", "http://127.0.0.1:88")
Expand Down
32 changes: 27 additions & 5 deletions test/verify/storagelib.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@ def step():

def content_row_expand(self, index):
b = self.browser
tbody = "#detail-content tbody:nth-of-type(%d)" % index
tbody = "#detail-content > table > tbody:nth-of-type(%d)" % index # consider nested tables
b.wait_present(tbody)
if not "open" in (b.attr(tbody, "class") or ""):
b.click(tbody + " tr.listing-ct-item")
b.wait_present(tbody + ".open")

def content_row_action(self, index, title):
btn = "#detail-content tbody:nth-of-type(%d) .listing-ct-item .listing-ct-actions button:contains(%s)" % (index, title)
btn = "#detail-content > table > tbody:nth-of-type(%d) .listing-ct-item .listing-ct-actions button:contains(%s)" % (index, title)
self.browser.wait_present(btn)
self.browser.click(btn)

Expand All @@ -88,18 +88,18 @@ def content_row_action(self, index, title):
# temporarily disappearing element, so we use self.retry.

def content_row_wait_in_col(self, row_index, col_index, val):
col = "#detail-content tbody:nth-of-type(%d) .listing-ct-item :nth-child(%d)" % (row_index, col_index+1)
col = "#detail-content > table > tbody:nth-of-type(%d) .listing-ct-item :nth-child(%d)" % (row_index, col_index+1)
self.retry(None, lambda: self.browser.is_present(col) and val in self.browser.text(col), None)

def content_head_action(self, index, title):
self.content_row_expand(index)
btn = "#detail-content tbody:nth-of-type(%d) .listing-ct-head .listing-ct-actions button:contains(%s)" % (index, title)
btn = "#detail-content > table > tbody:nth-of-type(%d) .listing-ct-head .listing-ct-actions button:contains(%s)" % (index, title)
self.browser.wait_present(btn)
self.browser.click(btn)

def content_tab_expand(self, row_index, tab_index):
tab_btn = "#detail-content tbody:nth-of-type(%d) .listing-ct-head li:nth-child(%d) a" % (row_index, tab_index)
tab = "#detail-content tbody:nth-of-type(%d) .listing-ct-body:nth-child(%d)" % (row_index, tab_index + 1)
tab = "#detail-content > table > tbody:nth-of-type(%d) .listing-ct-body:nth-child(%d)" % (row_index, tab_index + 1)
self.content_row_expand(row_index)
self.browser.wait_present(tab_btn)
self.browser.click(tab_btn)
Expand Down Expand Up @@ -217,6 +217,28 @@ def dialog_set_val(self, field, val):
else:
self.browser.set_val(self.dialog_field(field), val)

# Workaround: React does not fire onChange event when setting input.value attribute directly
# https://github.com/facebook/react/issues/8971
# potential fix: https://codepen.io/pudgereyem/live/OWBrdv
def dialog_type_val(self, field, val):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dialog_set_val function needs to be able to handle all types of fields, as it is used also by the high-level dialog and dialog_with_retry functions. And unfortunately, it needs to handle both React and the old Mustache dialogs at the same time... Right now only check-storage-luks runs into React dialogs, but the goal is to change all dialogs to be implemented with React, and thus dialog and dialog_with_retry should be ready to work with them.

Does using React really change the behavior of the <input> element so much? Could we maybe synthesize the onChange event?

val = str(val)
selector = self.dialog_field(field)

self.browser.wait_present(selector)
self.browser.wait_visible(selector)
self.browser.click(selector)
self.browser.focus(selector)
self.browser.set_val(selector, '') # clear value
self.browser.key_press(val)
self.browser.wait_val(selector, val)

# Workaround as the dialog_type_val()
def dialog_click_checkbox(self, field):
selector = self.dialog_field(field)
self.browser.wait_present(selector)
self.browser.wait_visible(selector)
self.browser.click(selector)

def dialog_set_expander(self, field, val):
self.browser.call_js_func(
"""(function (sel, val) {
Expand Down