Skip to content

Commit

Permalink
Added a (skipped) test for boo#1177145, wrong item is selected
Browse files Browse the repository at this point in the history
  • Loading branch information
mvidner committed Oct 21, 2020
1 parent 7c7d193 commit 50ba537
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 9 deletions.
21 changes: 16 additions & 5 deletions tests/libyui/table_sort.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#! /usr/bin/env ruby

# See table_sort_wrong_cell_1165388.test

require_relative "../test_helper"
require "yast"

Expand All @@ -16,9 +14,9 @@ def main

# notice that neither the ids nor the values are sorted here
contents = [
Item(Id("id-zzz-1"), "name-bbb", "value-bbb"),
Item(Id("id-yyy-2"), "name-ccc", "value-ccc"),
Item(Id("id-xxx-3"), "name-aaa", "value-aaa"),
Item(Id("id-zzz-1-bbb"), "name-bbb", "value-bbb"),
Item(Id("id-yyy-2-ccc"), "name-ccc", "value-ccc"),
Item(Id("id-xxx-3-aaa"), "name-aaa", "value-aaa"),
]
keep_sorting = WFM.Args()[0] == "no-sort"
opts = keep_sorting ? Opt(:keepSorting, :notify) : Opt(:notify)
Expand All @@ -30,12 +28,25 @@ def main
Table(Id(:table), opts, Header("Name", "Value"), contents)
),
Label("Enter/Double-click any item to uppercase the value"),
HBox(
HSquash(Label("Current Item: ")),
Label(Id(:current_item), Opt(:outputField, :hstretch), "...")
),
PushButton(Id(:cancel), "&Close")
)
)

if WFM.Args()[0] == "change-current-item"
# test boo#1177145, wrong item is selected
UI.ChangeWidget(Id(:table), :CurrentItem, "id-yyy-2-ccc")
current_item_id = UI.QueryWidget(Id(:table), :CurrentItem)
UI.ChangeWidget(Id(:current_item), :Value, current_item_id.inspect)
end

while UI.UserInput != :cancel
current_item_id = UI.QueryWidget(Id(:table), :CurrentItem)
UI.ChangeWidget(Id(:current_item), :Value, current_item_id.inspect)

value = UI.QueryWidget(:table, Cell(current_item_id, 1))
UI.ChangeWidget(Id(:table), Cell(current_item_id, 1), value.upcase)
end
Expand Down
26 changes: 22 additions & 4 deletions tests/libyui/table_sort_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,43 @@
around(:each) do |ex|
yast_ncurses = "#{__dir__}/yast_ncurses"
@base = "table_sort"
@tui = TmuxTui.new_session "#{yast_ncurses} #{__dir__}/#{@base}.rb"
@tui = TmuxTui.new_session "#{yast_ncurses} #{__dir__}/#{@base}.rb change-current-item"
ex.run
@tui.kill_session if @tui.has_session?
end

bug = "1165388"
it "ChangeWidget(_, Cell(row, col)) changes the correct cell, boo##{bug}" do
base = @base + "_cell"
@tui.await(/Table sorting test/)
@tui.capture_pane_to("#{@base}-1-initial")
@tui.capture_pane_to("#{base}-1-initial")

@tui.send_keys "Home" # go to first table row
@tui.capture_pane_to("#{@base}-2-first-row-selected")
@tui.capture_pane_to("#{base}-2-first-row-selected")

@tui.send_keys "Enter" # activate first table row
@tui.capture_pane_to("#{@base}-3-first-row-activated")
@tui.capture_pane_to("#{base}-3-first-row-activated")

expect(@tui.capture_pane).to match(/name-aaa.VALUE-AAA/)

@tui.send_keys "M-C" # &Close
end

bug = "1177145"
it "ChangeWidget(_, :CurrentItem) activates the correct line, boo##{bug}" do
skip "not fixed yet"

base = @base + "_current_item"
@tui.await(/Table sorting test/)
@tui.capture_pane_to("#{base}-1-ccc-selected")
# the UI code performs a
# UI.ChangeWidget(Id(:table), :CurrentItem, "id-yyy-2-ccc")
# then
# UI.QueryWidget(Id(:table), :CurrentItem)
@tui.send_keys "Enter" # activate the current item to produce an event
expect(@tui.capture_pane).to match(/Current Item: "id-yyy-2-ccc"/)

@tui.send_keys "M-C" # &Close
end
end
end

0 comments on commit 50ba537

Please sign in to comment.