external_test_segmenter-page.rb 4.15 KB
Newer Older
1
load 'segmenter_browser.rb'
2
load 'segmenter_test.rb'
3

4
class TestSegmenterPage < SegmenterTest
5
6
7
8
9
10
11
12
13
14
15

  def test_00_launch_query
    sequences = $b.textarea(:id => 'form_sequences')

    sequences.set ">seq1
CGTCTTCTGTACTATGACGTCTCCAACTCAAAGGATGTGTTGGAATCAGGACTCAGTCCAGGAAAGTATTATACTCATACACCCAGGAGGTGGAGCTGGATATTGATACTACGAAATCTAATTGAAAATGATTCTGGGGTCTATTACTGTGCCACCTGGGGGGCCAGATTATAAGAAACTCTTTGGCAGTGGAACAACAC

>seq2
GGGGGAGGCTTGGTACAGCCTGGGGGGTCCCTGAGACTCTCCTGTGCAGCCTCTGGATTCACCTTCAGTAGCTACGACATGCACTGGGTCCGCCAAGCTACAGGAAAAGGTCTGGAGTGGGTCTCAGCTATTGGTACTGCTGGTGACACATACTATCCAGGCTCCGTGAAGGGCCGATTCACCATCTCCAGAGAAAATGCCAAGAACTCCTTGTATCTTCAAATGAACAGCCTGAGAGCCGGGGACACGGCTGTGTATTACTGTGCAAGAGTGAGGCGGAGAGATCGGGGGATTGTAGTGGTGGTAGCTGCTACTCAACGGTAAGTTGGTTCGACCCCTGGGGCCAGGGAACCCTGGTCACCGTCTCCTCAGGT"

    assert (not $b.element(:class => 'segmenter').present?), "Segmenter should not be present yet"
16
    assert (not $b.element(:class => 'scatterplot').present?), "Scatterplot should not be present yet"
17
18
19

    $b.button(:id => 'form_submit').click

Mikaël Salson's avatar
Mikaël Salson committed
20
21
    $b.element(:class => 'imgAjaxLoading').wait_until(&:present?)
    $b.clone_in_scatterplot('0').wait_until(&:present?)
22
23
    
    assert ($b.element(:class => 'segmenter').present?), "Segmenter should be present"
24
    assert ($b.element(:class => 'scatterplot').present?), "Scatterplot should be present"
25
26
27
  end

  def test_01_segmenter
Mikaël Salson's avatar
Mikaël Salson committed
28
29
    assert ($b.clone_in_segmenter('0').present?), "Clone 0 should be in segmenter"
    assert ($b.clone_in_segmenter('1').present?), "Clone 1 should be in segmenter"
marc duez's avatar
marc duez committed
30
    assert (not $b.clone_in_segmenter('2').present?), "Clone 2 should not be visible"
31
32
33
  end

  def test_02_scatterplot
Mikaël Salson's avatar
Mikaël Salson committed
34
35
36
    assert ($b.clone_in_scatterplot('0').present?), "Clone 0 should be in scatterplot"
    assert ($b.clone_in_scatterplot('1').present?), "Clone 1 should be in scatterplot"
    assert (not $b.clone_in_scatterplot('2').present?), "Clone 2 should not be visible"
37
38
39
40
41
42
43
44
45
46
  end

  def test_03_change_color
    $b.clone_in_segmenter('0').hover
    $b.clone_info_segmenter('0')[:star].click
    tagColor = $b.tag_item('3')[:color].style('background-color')
    check_segmenter_on_the_right
    $b.tag_item('3')[:name].click
    $b.clone_in_segmenter('1').hover # Change clone to hover: on hover color doesn't change

47
    $b.until { $b.clone_info_segmenter('0')[:name].style('color') == tagColor }
48
49
50
51
52
53
54
55
56
57
58
59
60

    # Must remove rgb from the start of the fill style, and the closing parentheses at the end,
    # as tagColor is a rgba color with four components, and not just a rgb as the fill color.
    assert (tagColor.index($b.clone_in_scatterplot('0').style('fill')[4..-2]) > 0), "Clone has not changed color in scatterplot"

    # Check that scatterplot is still on the right
    check_segmenter_on_the_right
  end

  def test_04_segmenter_highlights
    for i in ['0', '1']
      for gene in ['V', 'J']
        span = $b.clone_in_segmenter(i).span(:class => gene)
Mikaël Salson's avatar
Mikaël Salson committed
61
        assert (span.present?), "#{gene} span should be visible"
62
63
64
65
66
67
      end
    end
  end

  def test_06_scatterplot_change_preset
    $b.scatterplot_select_preset(/CDR3 length/)
68
69
70
    $b.update_icon.wait_while(&:present?)   
    text = $b.scatterplot_x_label.text
    assert (text == "CDR3 length (nt)"), "X scatterplot label should now be CDR3 length (nt) (was %s)" % text
71
72
73
74
75
76
    assert ($b.clone_in_scatterplot('1').tag_name == 'rect'), "Clone should be a rectangle now (was %s)" % $b.clone_in_scatterplot('1').tag_name
  end

  def test_07_export_fasta
    $b.element(:id => 'btn_exportfasta').click
    
77
78
    assert ( $b.window(:url => /about:blank/).exists? ) , ">> fail opening fasta export "
    $b.window(:url => /about:blank/).use do
79
80
      assert ($b.text.index(/TRGV5.*200 nt/) > 0), "header name"
      assert ($b.text.index(/IGHV3-13.*374 nt/) > 0), "header name"
81
      assert ($b.text.include? "CCTGGG\nGGGCCAG\nATT"), "sequence"
82
83
84
85
86
87
88
89
90
91
92
    end
  end
  
  def check_segmenter_on_the_right
    
    right_coord_of_textarea = $b.sequences_area.wd.location.x \
                              + $b.sequences_area.wd.size.width
    left_coord_of_scatterplot = $b.scatterplot.wd.location.x

    assert (right_coord_of_textarea < left_coord_of_scatterplot), "Textarea should be left of scatterplot"
  end
93

94
95
96
97
  def test_zz_close
    close_everything
  end
end