test_list.rb 4.94 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
# coding: utf-8
load 'vidjil_browser.rb'
load 'browser_test.rb'

#browser test suite
class TestList < BrowserTest

  def setup
    super
    if not defined? $b
      set_browser("/doc/analysis-example2.vidjil", "/doc/analysis-example2.analysis")
      if $b.div(id: 'tip-container').present?
        $b.div(:id => 'tip-container').div(:class => 'tip_1').element(:class => 'icon-cancel').click
      end
    end
  end


  def after_tests
  end
  
  def test_00_list_clones
23 24 25 26 27
    $b.update_icon.wait_while(&:present?)
    # declare variables
    $lock      = $b.listLock()
    $listClone = $b.list()

28
    # tester la presence du lock
29
    assert ( $lock.attribute_value("class") == "icon-lock-1 list_lock_on"), "lock start in good state (locked)"
30 31 32 33 34 35 36 37 38
    assert ( $lock.attribute_value("title") == "Release sort as '-' on sample diag"), "lock title start by showing 'release xxx'"
    # print $lock.attribute_value("title")   #     Release sort as '-' on sample diag

    # change order by 'size'
    $b.select(:id => 'list_sort_select').click
    $b.send_keys :arrow_down
    $b.send_keys :enter
    $b.update_icon.wait_while(&:present?)

39
    assert ( $lock.attribute_value("title") == "Release sort as 'size' on sample diag"), "lock title start by showing 'release xxx'"
40 41

    # tester l'ordre des clones
42
    l0 = $listClone.div(index: 0)
43
    assert ( l0.id == "listElem_0" ), "opening; correct id of the first element"
44
    $b.div(:id => "left-container").click # get out of the select list
45 46 47 48
  end


  def test_01_xxx
49
    # Change sample (-> fu1); order should still the same
50
    $b.send_keys :arrow_right
51 52 53
    $b.update_icon.wait_while(&:present?)
    # list should show '-' as sort option
    # todo !!!
54
    l0 = $listClone.div(index: 0)
55
    assert ( l0.id == "listElem_0" ), "opening; correct id of the first element"
56
    assert ( $lock.attribute_value("title") == "Release sort as 'size' on sample diag"), "lock title still showsame message"
57 58 59
  end

  def test_02_xxx
60 61 62
    # Lock off
    $lock.click
    assert ( $lock.attribute_value("class") == "icon-lock-open list_lock_off"), "lock in good state after click (unlocked)"
63 64 65 66 67 68 69 70 71 72 73 74
    # print "\n"+$lock.attribute_value("title")+"\n"
    assert ( $lock.attribute_value("title") == "Freeze list as '-' on sample fu1"), "lock title show correct effet if click in icon (freeze, size, fu1)"
    # Clone order should NOT have changed (as sort is now '-')
    l0 = $listClone.div(index: 0)
    assert ( l0.id == "listElem_0" ), "opening; correct id of the first element"

    # change order by 'size'
    $b.select(:id => 'list_sort_select').click
    $b.send_keys :arrow_down
    $b.send_keys :enter
    $b.update_icon.wait_while(&:present?)
    # Clone order should have changed (sort 'size')
75
    l0 = $listClone.div(index: 0)
76
    assert ( l0.id == "listElem_5" ), "opening; correct id of the first element (clone other)"
77
    
78 79 80 81
    $lock.click # remove lock
    l0 = $listClone.div(index: 0)
    assert ( l0.id == "listElem_5" ), "opening; correct id of the first element (clone other)"
    $b.div(:id => "left-container").click # get out of the select list
82 83 84 85 86
  end


  def test_03_xxx
    
87
    # Change sample (-> diag)
88
    $b.send_keys :arrow_right
89 90 91
    $b.update_icon.wait_while(&:present?)
    # clone order
    l0 = $listClone.div(index: 0)
92
    assert ( l0.id == "listElem_0" ), "opening; correct id of the first element"
93
    assert ( $lock.attribute_value("title") == "Freeze list as 'size' on sample diag"), "lock title show correct effet if click in icon (freeze, size, diag)"
94 95 96 97 98
    
  end


  def test_04_xxx
99 100 101 102 103 104
    # Lock again
    $lock.click
    $b.update_icon.wait_while(&:present?)
    assert ( $lock.attribute_value("class") == "icon-lock-1 list_lock_on"), "lock in good state after second click (locked)"
    assert ( $lock.attribute_value("title") == "Release sort as 'size' on sample diag"), "lock title showing 'release ...'size' ... diag'"
    # Change sample (-> fu1)
105
    $b.send_keys :arrow_right
106 107 108 109 110
    $b.update_icon.wait_while(&:present?)
    assert ( $lock.attribute_value("title") == "Release sort as 'size' on sample diag"), "lock title showing 'release ...'size' ... diag'"

    # Clone order should be as in case 1
    l0 = $listClone.div(index: 0)
111 112 113 114 115
    assert ( l0.id == "listElem_0" ), "opening; correct id of the first element"
    
  end

  def test_05_xxx
116
    # Change sort method (size => V/5')
117 118 119 120
    $b.select(:id => 'list_sort_select').click
    $b.send_keys :arrow_down
    $b.send_keys :arrow_down
    $b.send_keys :enter
121
    $b.update_icon.wait_while(&:present?)
122

123 124 125
    # Lock should be open
    assert ( $lock.attribute_value("class") == "icon-lock-1 list_lock_on"), "lock in good state after change of sort method (locked)"
    assert ( $lock.attribute_value("title") == "Release sort as 'V/5'' on sample fu1"), "lock title showing 'release ...'V/5'' ... diag'"
126
    
127 128
    # clone list should be cha
    l0 = $listClone.div(index: 0)
129 130 131 132 133 134 135
    assert ( l0.id == "listElem_0" ), "opening; correct id of the first element"
    
  end


  # Not really a test
  def test_zz_close
flothoni's avatar
flothoni committed
136
    close_everything
137 138
  end
end