mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-06 02:51:34 +00:00
Make TableMatcher match exactly, not part of row
Reverts dbf3a7aaaf9d458f99e14983ca9db2d4cbe4b564. The reverted commit tried to avoid a 30 second delay by using have_selector. While that was successful in reducing test time, it made the matcher find rows that where not exactly the wanted row, but contained text of the wanted row. This wasn't a problem until we experimented with Chrome as test browser returns text on select boxes. This commit makes the matcher precise again. We still have to deal with the 30 second delay.
This commit is contained in:
@@ -2,19 +2,11 @@ RSpec::Matchers.define :have_table_row do |row|
|
||||
|
||||
match do |node|
|
||||
@row = row
|
||||
|
||||
text_without_blanks = row.select(&:present?).join(" ").strip
|
||||
return false unless node.has_selector? "tr", text: text_without_blanks # Check for appearance
|
||||
|
||||
rows_under(node).include? row # Robust check of columns
|
||||
end
|
||||
|
||||
match_when_negated do |node|
|
||||
@row = row
|
||||
|
||||
text_without_blanks = row.select(&:present?).join(" ").strip
|
||||
return false unless node.has_no_selector? "tr", text: text_without_blanks # Check for appearance
|
||||
|
||||
!rows_under(node).include? row # Robust check of columns
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user