MAJ terminée. Nous sommes passés en version 14.6.2 . Pour consulter les "releases notes" associées c'est ici :

https://about.gitlab.com/releases/2022/01/11/security-release-gitlab-14-6-2-released/
https://about.gitlab.com/releases/2022/01/04/gitlab-14-6-1-released/

test_browser.rb 11.9 KB
Newer Older
Marc Duez's avatar
Marc Duez committed
1
2
require 'rubygems'
require 'watir-webdriver'
Marc Duez's avatar
Marc Duez committed
3
4
require 'test/unit'
require "minitest/autorun"
Marc Duez's avatar
Marc Duez committed
5

Marc Duez's avatar
Marc Duez committed
6
7
include Test::Unit::Assertions
MiniTest::Unit.autorun
Marc Duez's avatar
Marc Duez committed
8

Marc Duez's avatar
Marc Duez committed
9
10
11
12
13
14
15
16
17
#custom runner
class MyMiniTest
    class Unit < MiniTest::Unit

        #open browser and load default data
        def before_suites
            folder_path = Dir.pwd
            index_path = 'file://' + folder_path + '/../index.html'
            data_path = folder_path + '/test.data'
Marc Duez's avatar
Marc Duez committed
18
            analysis_path = folder_path + '/test.analysis'
Marc Duez's avatar
Marc Duez committed
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
            
            $b = Watir::Browser.new :firefox
            #$b = Watir::Browser.new :chrome
            $b.goto index_path

            # close the welcoming popup
            $b.div(:id => 'popup-msg').button(:text => 'start').click 

            # select data file
            $b.div(:id => 'file_menu').file_field(:name,"json").set(data_path)
            $b.div(:id => 'file_menu').button(:text => 'start').click 
            
            sleep 2
        end

        #close browser
        def after_suites
36
            $b.close
Marc Duez's avatar
Marc Duez committed
37
38
39
40
        end

        #test suite launcher
        def _run_suites(suites, type)
41
            begin
Marc Duez's avatar
Marc Duez committed
42
43
44
45
46
47
                before_suites
                super(suites, type)
            ensure
                after_suites
            end
        end
Marc Duez's avatar
Marc Duez committed
48

Marc Duez's avatar
Marc Duez committed
49
50
51
52
53
54
        def _run_suite(suite, type)
            begin
                suite.before_suite if suite.respond_to?(:before_suite)
                super(suite, type)
            ensure
                suite.after_suite if suite.respond_to?(:after_suite)
55
            end
Marc Duez's avatar
Marc Duez committed
56
        end
Marc Duez's avatar
Marc Duez committed
57
58
59
60
61
62
63
64
65
66
67
68

    end
end


MiniTest::Unit.runner = MyMiniTest::Unit.new

#browser test suite
class BrowserTest < MiniTest::Unit::TestCase

    #before all tests
    def self.before_suite
69
        
Marc Duez's avatar
Marc Duez committed
70
    end
71

Marc Duez's avatar
Marc Duez committed
72
73
74
75
76
77
78
79
80
81
82
83
    #after all tests
    def self.after_suite
        
    end
    
    #after each tests
    def teardown
        $b.window(:title => "Vidjil").use do
            $b.execute_script("m.resetClones()")
            $b.element(:id => "visu_back" ).click 
        end
    end
84
    
Marc Duez's avatar
Marc Duez committed
85

86
    def test_01_init
Marc Duez's avatar
Marc Duez committed
87
        begin
Marc Duez's avatar
Marc Duez committed
88
            list = $b.div(:id => 'list_clones')
Marc Duez's avatar
Marc Duez committed
89
90
91
92
            
            assert ( list.li(:id => '0' ).exists?), ">>fail init : clone 0 missing in list"
            assert ( $b.element(:id => "circle0" ).exists?), ">>fail init : clone 0 missing in scatterplot"
            assert ( $b.element(:id => "polyline0" ).exists?), ">>fail init : clone 0 missing in graph"
Marc Duez's avatar
Marc Duez committed
93
            assert ( list.li(:id => '0' ).span(:class => 'sizeBox').text == '64.75%' ) , ">>fail init : wrong clone size "
Marc Duez's avatar
Marc Duez committed
94
        rescue
95
            assert (false), "missing element to run test_01_init \n" 
Marc Duez's avatar
Marc Duez committed
96
97
98
99
        end
    end
    
    
100
    def test_02_focus
Marc Duez's avatar
Marc Duez committed
101
102
103
        begin
            
            #test hover a clone in the list
Marc Duez's avatar
Marc Duez committed
104
            list = $b.div(:id => 'list_clones')
Marc Duez's avatar
Marc Duez committed
105
106
107
108
109
110
111
112
113
114
115
116
117
118
            list.li(:id => '0' ).hover
            
            assert ( $b.element(:id => "circle0" ).class_name == "circle_focus"), ">> fail to focus correct plot after hovering a clone in the list"
            assert ( $b.element(:id => "polyline0" ).class_name == "graph_focus"), ">> fail to focus correct graphLine after hovering a clone in the list"
            
            #test hover a clone in the scatterplot
            $b.element(:id => "circle1" ).hover
            
            assert ( $b.element(:id => "circle1" ).class_name == "circle_focus"), ">> fail to focus correct plot after hovering a clone in the scatterplot"
            assert ( $b.element(:id => "polyline1" ).class_name == "graph_focus"), ">> fail to focus correct graphLine after hovering a clone in the scatterplot"
            
            #watir unable to do hover/click on svg path
            
        rescue
119
            assert (false), "missing element to run test_02_focus \n" 
Marc Duez's avatar
Marc Duez committed
120
121
122
123
        end
    end
    
    
124
    def test_03_select
Marc Duez's avatar
Marc Duez committed
125
126
127
        begin
            
            #test select a clone in the list
Marc Duez's avatar
Marc Duez committed
128
            list = $b.div(:id => 'list_clones')
Marc Duez's avatar
Marc Duez committed
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
            
            #list.li(:id => '0' ).div(:class => 'nameBox2').click 
            # ".click" work with chrome but not with firefox so direct call with javascript ( a bit hadrcore ...) 
            $b.execute_script("document.getElementById('0').getElementsByClassName('nameBox2')[0].click()")
            
            assert ( list.li(:id => '0' ).class_name == "list list_select" )
            assert ( $b.element(:id => "circle0" ).class_name == "circle_select")
            assert ( $b.element(:id => "polyline0" ).class_name == "graph_select")
            assert ( $b.element(:id => "seq0" ).exists? ), ">> fail to add clone to segmenter by clicking on the list"
            
            #test select a clone in the scatteplot
            $b.element(:id => "circle1" ).click
            
            assert ( list.li(:id => '1' ).class_name == "list list_select" )
            assert ( $b.element(:id => "circle1" ).class_name == "circle_select")
            assert ( $b.element(:id => "polyline1" ).class_name == "graph_select")
            assert ( $b.element(:id => "seq1" ).exists? ), ">> fail to add clone to segmenter by clicking on the scatterplot"
            
            #watir unable to hover/click svg path
            
            #unselect
            $b.element(:id => "visu_back" ).click
            
            assert ( list.li(:id => '0' ).class_name == "list" )
            
        rescue
155
            assert (false), "missing element to run test_03_select \n" 
Marc Duez's avatar
Marc Duez committed
156
157
158
159
        end
    end
    
    
160
    def test_04_cluster
Marc Duez's avatar
Marc Duez committed
161
        begin
Marc Duez's avatar
Marc Duez committed
162
            list = $b.div(:id => 'list_clones')
Marc Duez's avatar
Marc Duez committed
163
            $b.execute_script("m.clusterBy('V')")
Marc Duez's avatar
Marc Duez committed
164
            assert ( list.li(:id => '0' ).span(:class => 'sizeBox').text == '78.65%' ) , ">> fail cluster by V : wrong clone size "
Marc Duez's avatar
Marc Duez committed
165
166
            
            $b.execute_script("m.clusterBy('J')")
Marc Duez's avatar
Marc Duez committed
167
            assert ( list.li(:id => '0' ).span(:class => 'sizeBox').text == '69.92%' ) , ">> fail cluster by J : wrong clone size "
Marc Duez's avatar
Marc Duez committed
168
169
            
            $b.execute_script("m.resetClones()")
Marc Duez's avatar
Marc Duez committed
170
            assert ( list.li(:id => '0' ).span(:class => 'sizeBox').text == '64.75%' ) , ">> fail reset cluster : wrong clone size "
Marc Duez's avatar
Marc Duez committed
171
172
            
        rescue
173
            assert (false), "missing element to run test_04_cluster \n" 
Marc Duez's avatar
Marc Duez committed
174
175
176
177
        end
    end
    
    
178
    def test_05_normalize
Marc Duez's avatar
Marc Duez committed
179
        begin
Marc Duez's avatar
Marc Duez committed
180
            list = $b.div(:id => 'list_clones')
Marc Duez's avatar
Marc Duez committed
181
182
183
184
            $b.execute_script("m.normalization_switch(true)")
            assert ( list.li(:id => '0' ).span(:class => 'sizeBox').text == '6.625%' ) , ">> fail normalize on : wrong clone size "
            
            $b.execute_script("m.normalization_switch(false)")
Marc Duez's avatar
Marc Duez committed
185
            assert ( list.li(:id => '0' ).span(:class => 'sizeBox').text == '64.75%' ) , ">> fail normalize off : wrong clone size "
Marc Duez's avatar
Marc Duez committed
186
        rescue
187
            assert (false), "missing element to run test_05_normalize \n" 
Marc Duez's avatar
Marc Duez committed
188
189
190
191
        end
    end
    
    
192
    def test_06_displayTop
Marc Duez's avatar
Marc Duez committed
193
        begin
Marc Duez's avatar
Marc Duez committed
194
            list = $b.div(:id => 'list_clones')
Marc Duez's avatar
Marc Duez committed
195
196
197
198
199
200
201
            $b.execute_script("m.displayTop(100)")
            assert ( list.li(:id => '120' ).visible? ) , ">> fail display : this clone should be visible"

            $b.execute_script("m.displayTop(20)")
            assert ( not list.li(:id => '120' ).visible? ) , ">> fail display : this clone shouldn't be visible"

        rescue
202
            assert (false), "missing element to run test_06_displayTop \n" 
Marc Duez's avatar
Marc Duez committed
203
204
205
206
        end
    end
    
    
207
    def test_07_merge
Marc Duez's avatar
Marc Duez committed
208
        begin
Marc Duez's avatar
Marc Duez committed
209
            list = $b.div(:id => 'list_clones')
Marc Duez's avatar
Marc Duez committed
210
211
212
213
214
215
            #select 3 clones
            $b.element(:id => "circle0" ).click
            $b.element(:id => "circle1" ).click
            $b.element(:id => "circle2" ).click
            
            #merge
216
            #$b.span(:id => "merge" ).click
Marc Duez's avatar
Marc Duez committed
217
            $b.execute_script("m.merge()")
Marc Duez's avatar
Marc Duez committed
218
            assert ( list.li(:id => '0' ).span(:class => 'sizeBox').text == '75.55%' ) , ">> fail clustering : wrong clone size "
Marc Duez's avatar
Marc Duez committed
219
220
221
            
            #unmerge
            $b.execute_script("m.resetClones()")
Marc Duez's avatar
Marc Duez committed
222
            assert ( list.li(:id => '0' ).span(:class => 'sizeBox').text == '64.75%' ) , ">> fail unclustering : wrong clone size "
Marc Duez's avatar
Marc Duez committed
223
224
            
        rescue
225
            assert (false), "missing element to run test_07_merge \n" 
Marc Duez's avatar
Marc Duez committed
226
227
228
229
        end
    end
    
    
230
    def test_08_imgt
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
        begin
            #select 3 clones
            $b.element(:id => "circle0" ).click
            $b.element(:id => "circle1" ).click
            $b.element(:id => "circle2" ).click
            
            $b.span(:id => "toIMGT" ).click
            
            assert ( $b.window(:title => "IMGT/V-QUEST").exists? ) , ">> fail opening IMGT "
            $b.window(:title => "IMGT/V-QUEST").use do
                assert ($b.text.include? "Number of analysed sequences: 3"), ">> fail IMGT analysis" 
            end
 
            $b.window(:title => "Vidjil").use
            
        rescue
247
            assert (false), "missing element to run test_08_imgt \n" 
248
249
250
251
        end
    end
    
    
252
    def test_09_igBlast
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
        begin
            #select 3 clones
            $b.element(:id => "circle5" ).click
            $b.element(:id => "circle8" ).click
            $b.element(:id => "circle12" ).click
            
            $b.span(:id => "toIgBlast" ).click
            
            assert ( $b.window(:title => "IgBLAST Search Results").exists? ) , ">> fail opening igblast "
            $b.window(:title => "IgBLAST Search Results").use do
                assert ($b.text.include? "Index for multiple query sequences (total = 3)"), ">> fail igblast analysis" 
            end
 
            $b.window(:title => "Vidjil").use
            
        rescue
269
            assert (false), "missing element to run test_09_igBlast \n" 
270
271
272
273
        end
    end
    
    
Marc Duez's avatar
Marc Duez committed
274
    def test_10_align
Marc Duez's avatar
Marc Duez committed
275
276
277
        #TODO find a way to use local cgi
        skip 
        
Marc Duez's avatar
Marc Duez committed
278
279
280
281
282
283
284
285
286
287
288
289
290
        begin
            #select 2 clones
            $b.element(:id => "circle1" ).click
            $b.element(:id => "circle0" ).click
            
            assert ($b.text.include? "GGTCTATTACTGTGCCACCTTCTGACATAAGAAACTCTTTGGCAGTGGA"), ">> fail to display sequence"
            
            $b.span(:id => "align" ).click
            
            assert ($b.text.include? "CTT---CTG-AC-AT--AAGAAACT--CTTT-GG--C-A-G-TG---G-AA"), ">> fail to align sequences" 
            
        rescue
            assert (false), "missing element to run test_10_align \n" 
Marc Duez's avatar
Marc Duez committed
291
292
        end
    end
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335

    
    def test_11_load_analysis
        begin
            analysis_path = Dir.pwd + '/test.analysis'
            data_path = Dir.pwd + '/test.data'
            
            $b.div(:id => 'logo').click 
            $b.div(:id => 'popup-msg').button(:text => 'start').click 
            $b.div(:id => 'file_menu').file_field(:name,"json").set(data_path)
            $b.div(:id => 'file_menu').file_field(:name,"pref").set(analysis_path)
            $b.div(:id => 'file_menu').button(:text => 'start').click 
            
            assert ( $b.div(:id => 'info').text.include? "plop") , ">> fail load analysis: wrong selected time point "
            
        rescue
            assert (false), "missing element to run test_11_load_analysis \n" 
        end
    end
    
    
    def test_12_drag_time
        begin
            time=$b.element(:id => "time6" )
            target=$b.element(:id => "time0" )

            time.fire_event("onmousedown")
            $b.driver.action.click_and_hold(time.wd).perform

            sleep 2
            $b.driver.action.move_to(target.wd).perform

            sleep 2
            target.fire_event("onmouseup")
            
            list = $b.div(:id => 'list_clones')
            assert ( list.li(:id => '0' ).span(:class => 'sizeBox').text == '0.0005%' ) , ">> fail drag/drop : wrong clone size "
            assert ( $b.div(:id => 'info').text.include? "Fu6.data") , ">> fail drag/drop : wrong selected time point "
            
        rescue
    
        end
    end
Marc Duez's avatar
Marc Duez committed
336
    
Marc Duez's avatar
Marc Duez committed
337
338
end

Marc Duez's avatar
Marc Duez committed
339
340
341
342
343
344
345
346
347
348
349
350
351
352
=begin
    TODO
    save_analysis
    clipboard
    change tag
    edit tag
    change axis scatterplot
    edit name
    change color method
    change color palette
    change scatterplot/graph size
    
    check x/y clone position on scatterplot
    check clone path 
Marc Duez's avatar
Marc Duez committed
353
=end