From 8f99e5c91736d0394044109e4cd48647f44ecad9 Mon Sep 17 00:00:00 2001 From: Marek Libra Date: Fri, 1 Jun 2018 08:06:39 +0200 Subject: [PATCH] check-storage-luks: Fixes for React Element nesting structure has changed ( is followed by instead of ). Workaround for not-emitted onChange event when setting "value" attribute of element directly. Works fine now but would be better to introduce a generic solution for that in a later patch. --- test/verify/check-storage-luks | 12 ++++++------ test/verify/storagelib.py | 32 +++++++++++++++++++++++++++----- 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/test/verify/check-storage-luks b/test/verify/check-storage-luks index 90e9ddebb235..71d21ce0ab76 100755 --- a/test/verify/check-storage-luks +++ b/test/verify/check-storage-luks @@ -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") @@ -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") @@ -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()) @@ -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") diff --git a/test/verify/storagelib.py b/test/verify/storagelib.py index 3567149f9f8f..e26602cddc83 100644 --- a/test/verify/storagelib.py +++ b/test/verify/storagelib.py @@ -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) @@ -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) @@ -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): + 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) {