Conversation
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The new
check_disk_row/check_disk_row_not_presentimplementations rely on substring matches intextContentacross the entire row, which is looser than the previous cell-based selectors and may produce false positives when multiple disks share similar values; consider tightening the matching (e.g., per-cell checks or stricter delimiters) if that is important for these tests. - The inline JavaScript snippets for
wait_js_condincheck_disk_rowandcheck_disk_row_not_presentare very similar; consider factoring the common logic into a small helper to keep the test helpers easier to maintain.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new `check_disk_row`/`check_disk_row_not_present` implementations rely on substring matches in `textContent` across the entire row, which is looser than the previous cell-based selectors and may produce false positives when multiple disks share similar values; consider tightening the matching (e.g., per-cell checks or stricter delimiters) if that is important for these tests.
- The inline JavaScript snippets for `wait_js_cond` in `check_disk_row` and `check_disk_row_not_present` are very similar; consider factoring the common logic into a small helper to keep the test helpers easier to maintain.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Code Review
This pull request removes the Sizzle dependency, updates the Cockpit repository commit, and refactors test helpers to eliminate Sizzle-based selectors. In test/helpers/network.py, methods now use NetworkCase via a shim, while test/helpers/review.py replaces CSS selectors with custom JavaScript conditions. Feedback indicates a potential bug in the construction of search fragments where None values could be incorrectly processed as strings. Additionally, the new JavaScript-based row validation is less precise than the original column-specific selectors, which may lead to false positives in tests.
| fragments = [] | ||
| for part in (parent, str(size) if size != "" else "", action, encrypt_text, mount_point): | ||
| if part is not None and str(part) != "": | ||
| fragments.append(str(part)) |
There was a problem hiding this comment.
The logic for building the fragments list is redundant and contains a potential bug. The ternary expression str(size) if size != "" else "" will convert None to the string "None", which then passes the subsequent check and is added to the search fragments. Since the loop already handles string conversion and filters out empty values, this can be simplified into a list comprehension.
fragments = [str(p) for p in (parent, size, action, encrypt_text, mount_point)
if p is not None and str(p) != ""]| cond = """(() => { | ||
| const table = document.querySelector(%s); | ||
| if (!table) return false; | ||
| const frags = %s; | ||
| const rows = table.querySelectorAll("tbody tr"); | ||
| for (let i = 0; i < rows.length; i++) { | ||
| const t = rows[i].textContent; | ||
| if (frags.every(f => t.includes(f))) return true; | ||
| } | ||
| return false; | ||
| })()""" % (sel_json, frag_json) | ||
| else: | ||
| idx = int(rowIndex) - 1 | ||
| cond = """(() => { | ||
| const table = document.querySelector(%s); | ||
| if (!table) return false; | ||
| const frags = %s; | ||
| const rows = table.querySelectorAll("tbody tr"); | ||
| const tr = rows[%d]; | ||
| if (!tr) return false; | ||
| const t = tr.textContent; | ||
| return frags.every(f => t.includes(f)); | ||
| })()""" % (sel_json, frag_json, idx) | ||
| self.browser.wait_js_cond(cond) |
There was a problem hiding this comment.
The new implementation using textContent.includes() is significantly less precise than the original Sizzle-based selector. The original code used the adjacent sibling combinator (+) to ensure that the expected values appeared in specific columns and in a specific order. The current JavaScript logic will match if the fragments appear anywhere in the row in any order, which increases the risk of false positives in tests. Consider implementing a check that validates the order of fragments within the row text or checks individual cells.
361f8d9 to
c3bd0bb
Compare
KKoukiou
left a comment
There was a problem hiding this comment.
I think the last commit might not be needed?
I see cockpit supports it's own contains:
test/common/test-functions.js: // Best effort support :contains()
c3bd0bb to
9e3a5fa
Compare
9e3a5fa to
2373936
Compare
76af1a1 to
433dd68
Compare
433dd68 to
4bb8dda
Compare
6a88bfc to
cc834ac
Compare
|
I don't think the declining test scores have anything to do with the change. |
f926447 to
fbbcde8
Compare
fbbcde8 to
df55545
Compare
Remove the unused Sizzle devDependency and refresh the node_modules cache. Cockpit test-functions only supports a single :contains() per selector when Sizzle is absent. Chained td:contains in check_disk_row therefore fails with "Unsupported multiple ':contains'". - review: assert disk table rows via wait_js_cond over #storage-review-table-<disk> tbody tr text; fix rowIndex as nth data row (tbody tr), not tbody:nth-child. - network: call NetworkCase.configure_iface_setting / wait_for_iface_setting through a SimpleNamespace(browser=...) so behaviour matches netlib without duplicating [data-label] selectors. Made-with: Cursor
Rewrite StorageReclaimDialog to use wait_js_cond and button matching by aria-label instead of chained tr/td :contains selectors (Cockpit testlib without Sizzle). Made-with: Cursor
544fc0e to
a46ebed
Compare
Rewrite StorageReclaimDialog to use wait_js_cond and button matching by aria-label instead of chained tr/td :contains selectors (Cockpit testlib without Sizzle).
No description provided.