test_loading_analysis.rb 7.26 KB
Newer Older
1 2 3
load 'vidjil_browser.rb'
load 'browser_test.rb'

4
class TestLoadingAnalysis < BrowserTest
5 6 7 8 9

  def setup
    super
    if not defined? $b
      set_browser("/doc/analysis-example2.vidjil", "/doc/analysis-example2.analysis")
Mikaël Salson's avatar
Mikaël Salson committed
10
      $b.clone_in_scatterplot('0').wait_until(&:present?)
11 12 13
      if $b.div(id: 'tip-container').present?
        $b.div(:id => 'tip-container').div(:class => 'tip_1').element(:class => 'icon-cancel').click
      end
14 15 16
    end
  end

17
  def test_001_name
18 19 20 21
    # change current sample to start on sample 0 (second in loaded order)
    $b.send_keys :arrow_right
    $b.update_icon.wait_while(&:present?)

22 23
    assert ($b.graph_x_legend('0').text == '2019-12-17')
    assert ($b.graph_x_legend('1').text == '+10')
24 25 26 27 28

    # It should be selected
    assert ($b.graph_x_legend('0', :class => 'graph_time2').exists?)
  end

29
  def test_002_order
30 31 32 33
    # fu1 should be before diag
    assert ($b.graph_x_legend('0').attribute_value('x') > $b.graph_x_legend('1').attribute_value('x'))
  end

34
  def test_003_custom_clone
35 36 37
    assert ($b.clone_info('0')[:name].text == 'Main ALL clone')

    $b.select_tag('0').click
marc's avatar
marc committed
38
    $b.update_icon.wait_while(&:present?)
39

Mikaël Salson's avatar
Mikaël Salson committed
40 41 42
    assert (not $b.clone_in_list('0').present?)
    assert (not $b.clone_in_scatterplot('0').present?)
    assert (not $b.clone_in_graph('0').present?)
43 44

    $b.select_tag('0').click
marc's avatar
marc committed
45
    $b.update_icon.wait_while(&:present?)
46 47
  end

48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
  def test_01_data_loaded
    qpcr = $b.external_data('qPCR')
    assert (qpcr[:name] == 'qPCR' and qpcr[:value] == 0.83), "qPCR external data not as expected"

    spike = $b.external_data('spikeZ')
    assert (spike[:name] == 'spikeZ' and spike[:value] == 0.01), "spikeZ external data not as expected"
  end

  def test_02_tag_names
    # Open tag selector
    $b.clone_info('1')[:star].click

    assert($b.tag_item('0')[:name].text == 'main clone')
    assert($b.tag_item('3')[:name].text == 'spike')
    assert($b.tag_item('5')[:name].text == 'custom tag')
  end

  def test_03_hidden_tags
    # Test that the two tags are hidden
    assert ($b.select_tag('4', :class => 'inactiveTag').exists?)
    assert ($b.select_tag('5', :class => 'inactiveTag').exists?)
  end

  def test_04_hide_clone
Mikaël Salson's avatar
Mikaël Salson committed
72 73 74
    assert ($b.clone_in_list('0').present?)
    assert ($b.clone_in_scatterplot('0').present?)
    assert ($b.clone_in_graph('0').present?)
75 76 77 78

    # Hide the clone by affecting it to a hidden tag
    $b.clone_info('0')[:star].click
    $b.tag_item('4')[:name].click
marc's avatar
marc committed
79
    $b.update_icon.wait_while(&:present?)
80

marc's avatar
marc committed
81
    $b.clone_in_list('0').wait_while(&:present?)
Mikaël Salson's avatar
Mikaël Salson committed
82
    assert (not $b.clone_in_list('0').present?)
marc's avatar
marc committed
83
    $b.clone_in_scatterplot('0').wait_while(&:present?)
Mikaël Salson's avatar
Mikaël Salson committed
84
    assert (not $b.clone_in_scatterplot('0').present?)
marc's avatar
marc committed
85
    $b.clone_in_graph('0').wait_while(&:present?)
Mikaël Salson's avatar
Mikaël Salson committed
86
    assert (not $b.clone_in_graph('0').present?)
87 88 89

    # Unhide clone
    $b.element(:id => 'fastTag4', :class => 'inactiveTag').click
marc's avatar
marc committed
90
    $b.update_icon.wait_while(&:present?)
91
    assert (not $b.element(:id => 'fastTag4', :class => 'inactiveTag').exists?)
Mikaël Salson's avatar
Mikaël Salson committed
92 93 94
    assert ($b.clone_in_list('0').present?)
    assert ($b.clone_in_scatterplot('0').present?)
    assert ($b.clone_in_graph('0').present?)
95 96
  end

97 98 99
  def test_05_check_cluster
    clustered = $b.clone_info('1')
    assert (clustered[:name].text == 'clone2'), "First clone of cluster should be clone2"
Mikaël Salson's avatar
Mikaël Salson committed
100 101
    assert ($b.clone_in_scatterplot('1').present?)
    assert (not $b.clone_in_scatterplot('2').present?)
102

103
    clustered[:cluster].click
marc's avatar
marc committed
104
    $b.update_icon.wait_while(&:present?)
105

Mikaël Salson's avatar
Mikaël Salson committed
106 107
    assert ($b.clone_in_scatterplot('1').present?), "First clone should still be present"
    $b.clone_in_scatterplot('2').wait_until(&:present?)
108 109 110 111 112 113 114 115 116 117 118 119 120 121

    first_in_cluster = $b.clone_in_cluster('1', '1')
    second_in_cluster = $b.clone_in_cluster('1', '2')

    assert (first_in_cluster[:name].text == 'clone2')
    assert (second_in_cluster[:name].text == 'clone3')

    # Close the cluster
    clustered[:cluster].click
end

  def test_06_remove_cluster
    clustered = $b.clone_info('1')
    clustered[:cluster].click
122
    $b.until { $b.clone_in_cluster('1', '2')[:delete].present? }
123
    $b.clone_in_cluster('1', '2')[:delete].click
marc's avatar
marc committed
124
    $b.update_icon.wait_while(&:present?)
marc's avatar
marc committed
125

Mikaël Salson's avatar
Mikaël Salson committed
126
    assert (not $b.clone_cluster('1').present?)
127
    
Mikaël Salson's avatar
Mikaël Salson committed
128 129
    assert ($b.clone_in_scatterplot('1').present?)
    assert ($b.clone_in_scatterplot('2').present?)
130 131 132 133 134 135 136 137 138 139 140

    clone3 = $b.clone_info('2')
    assert (clone3[:name].text == "clone3")
    assert (clone3[:system].text == "G")
  end

  def test_07_create_cluster
    $b.clone_in_scatterplot('1').click
    $b.clone_in_scatterplot('2').click(:control)

    $b.merge.click
marc's avatar
marc committed
141
    $b.update_icon.wait_while(&:present?)
142 143 144

    clustered = $b.clone_info('1')
    assert (clustered[:name].text == 'clone2')
Mikaël Salson's avatar
Mikaël Salson committed
145
    assert ($b.clone_in_scatterplot('1').present?)
146
    $b.until{ not $b.clone_in_scatterplot('2').present? }
147 148
  end

149 150
  def test_08_select_cluster
    $b.clone_in_scatterplot('1').click
marc's avatar
marc committed
151
    $b.update_icon.wait_while(&:present?)
152 153 154 155

    clustered = $b.clone_info('1')
    assert ($b.clone_in_scatterplot('1', :class => "circle_select").exists?)
    assert ($b.clone_in_graph('1', :class=> "graph_select").exists?)
marc duez's avatar
marc duez committed
156
    assert ($b.clone_in_segmenter('1').present? ), ">> fail to add clone to segmenter by clicking on the list or scatterplot"
157 158
    assert ( not $b.clone_in_scatterplot('2', :class => "circle_select").exists?)
    assert ( not $b.clone_in_graph('2', :class=> "graph_select").exists?)
marc duez's avatar
marc duez committed
159
    assert ( not $b.clone_in_segmenter('2').present? ), ">> fail to add clone to segmenter by clicking on the list or scatterplot"
160 161 162 163 164

    clustered[:cluster].click

    assert ($b.clone_in_scatterplot('1', :class => "circle_select").exists?)
    assert ($b.clone_in_graph('1', :class=> "graph_select").exists?)
marc duez's avatar
marc duez committed
165
    assert ($b.clone_in_segmenter('1').present? ), ">> fail to add clone to segmenter by clicking on the list or scatterplot"
166
    $b.until { $b.clone_in_scatterplot('2', :class => "circle_select").exists? }
167
    assert ( $b.clone_in_graph('2', :class=> "graph_select").exists?)
marc duez's avatar
marc duez committed
168
    assert ( $b.clone_in_segmenter('2').present? ), ">> fail to add clone to segmenter by clicking on the list or scatterplot"
169 170

    clustered[:cluster].click
marc's avatar
marc committed
171
    $b.update_icon.wait_while(&:present?)
172 173 174
    $b.unselect
  end

175
  def test_09_select_other
176 177
    # Click on first point
    $b.graph_x_legend('1').click
marc's avatar
marc committed
178
    $b.update_icon.wait_while(&:present?)
179 180 181 182 183 184 185 186
    assert ($b.graph_x_legend('1', :class => 'graph_time2').exists?)
    assert ($b.graph_x_legend('0', :class => 'graph_time').exists?)

    qpcr = $b.external_data('qPCR')
    assert (qpcr[:name] == 'qPCR' and qpcr[:value] == 0.024), "qPCR external data not as expected"

  end

187 188 189
  def test_10_clone_segedited_from_analysis
    # Click on first point
    $b.clone_in_scatterplot('3').click
190
    sleep 1
191 192
    # If cdr3 checked, the sequence will be split in mutiple dom element with highlight or not
    check = $b.checkbox(:id => "vdj_input_check")
193 194 195
    if check.set? # by default, in chromium based browser, the checkbox is set to true
      check.click
    end
196
    assert ( not check.set? ), "CDR3 checkbox is not checked"
197
    assert ( $b.clone_in_segmenter('3').exists? ), ">> clone 3 is correctly present in the segmenter, without infinite loop"
198
    assert ( $b.span(:id => 'sequence-clone-3').text.include? 'GGGGGCCCCCGGGGGCCCCCGGGGGCCCCCGGGGGCCCCCAAAAATTTTTAAAAATTTTTAAAAATTTTT'), "sequence of analysis loaded replace sequence of vidjil file"
199 200
  end

201 202 203 204
  def test_zz_close
    close_everything
  end
end