Dotclear


Ignore:
Timestamp:
09/04/13 21:55:21 (12 years ago)
Author:
Nicolas <nikrou77@…>
Branch:
default
Message:

[Tests] Add tests for media uploader
Refactoring of _media.js : put all code in a jquery plugin to make
it easy to test and to avoid polluting global namespace.
Use same jquery for tests and for admin

Need to add more tests for media uploader
Fix indentation for all js

Location:
tests/functional/spec
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • tests/functional/spec/common.js

    r1703 r1724  
    11describe("Others common methods (admin/js/common.js)", function() { 
    2     describe("postsActionsHelper", function() { 
    3      it("A confirm popup must appear if action is \"delete\" and at least on checkbox is checked", function() { 
    4          loadFixtures('posts_list.html'); 
    5          dotclear.postsActionsHelper(); 
    6           
    7          spyOn(window, 'confirm').andReturn(false); 
    8          var submitCallback = jasmine.createSpy().andReturn(false); 
    9          $('#form-entries').submit(submitCallback); 
     2     describe("postsActionsHelper", function() { 
     3          it("A confirm popup must appear if action is \"delete\" and at least on checkbox is checked", function() { 
     4               loadFixtures('posts_list.html'); 
     5               dotclear.postsActionsHelper(); 
     6                
     7               spyOn(window, 'confirm').andReturn(false); 
     8               var submitCallback = jasmine.createSpy().andReturn(false); 
     9               $('#form-entries').submit(submitCallback); 
    1010 
    11          $('select[name="action"] option[value="delete"]').attr('selected', 'selected'); 
    12          $('input[type="checkbox"][name="entries[]"][value="2"]').attr('checked', 'checked'); 
     11               $('select[name="action"] option[value="delete"]').attr('selected', 'selected'); 
     12               $('input[type="checkbox"][name="entries[]"][value="2"]').attr('checked', 'checked'); 
    1313 
    14          $('#form-entries').trigger('submit'); 
    15          expect(window.confirm).toHaveBeenCalled(); 
     14               $('#form-entries').trigger('submit'); 
     15               expect(window.confirm).toHaveBeenCalled(); 
     16          }); 
     17          it("Confirm popup doesn't appear if action is \"delete\" but no checkbox is checked", function() { 
     18               loadFixtures('posts_list.html'); 
     19               dotclear.postsActionsHelper(); 
     20                
     21               spyOn(window, 'confirm').andReturn(false); 
     22               var submitCallback = jasmine.createSpy().andReturn(false); 
     23               $('#form-entries').submit(submitCallback); 
     24 
     25               $('select[name="action"] option[value="delete"]').attr('selected', 'selected'); 
     26               $('#form-entries').trigger('submit'); 
     27               expect(window.confirm).not.toHaveBeenCalled(); 
     28          }); 
     29          it("Others actions don't show confirm popup", function() { 
     30               loadFixtures('posts_list.html'); 
     31               dotclear.postsActionsHelper(); 
     32                
     33               spyOn(window, 'confirm').andReturn(false); 
     34               var submitCallback = jasmine.createSpy().andReturn(false); 
     35               $('#form-entries').submit(submitCallback); 
     36 
     37               $('select[name="action"] option[value="publish"]').attr('selected', 'selected'); 
     38               $('#form-entries').trigger('submit'); 
     39               expect(window.confirm).not.toHaveBeenCalled(); 
     40          }); 
    1641     }); 
    17      it("Confirm popup doesn't appear if action is \"delete\" but no checkbox is checked", function() { 
    18          loadFixtures('posts_list.html'); 
    19          dotclear.postsActionsHelper(); 
    20           
    21          spyOn(window, 'confirm').andReturn(false); 
    22          var submitCallback = jasmine.createSpy().andReturn(false); 
    23          $('#form-entries').submit(submitCallback); 
    2442 
    25          $('select[name="action"] option[value="delete"]').attr('selected', 'selected'); 
    26          $('#form-entries').trigger('submit'); 
    27          expect(window.confirm).not.toHaveBeenCalled(); 
     43     describe("commentsActionsHelper", function() { 
     44          it("A confirm popup must appear if action is \"delete\" and at least on checkbox is checked", function() { 
     45               loadFixtures('comments_list.html'); 
     46               dotclear.commentsActionsHelper(); 
     47                
     48               spyOn(window, 'confirm').andReturn(false); 
     49               var submitCallback = jasmine.createSpy().andReturn(false); 
     50               $('#form-comments').submit(submitCallback); 
     51 
     52               $('select[name="action"] option[value="delete"]').attr('selected', 'selected'); 
     53               $('input[type="checkbox"][name="comments[]"][value="2"]').attr('checked', 'checked'); 
     54 
     55               $('#form-comments').trigger('submit'); 
     56               expect(window.confirm).toHaveBeenCalled(); 
     57          }); 
     58          it("Confirm popup doesn't appear if action is \"delete\" but no checkbox is checked", function() { 
     59               loadFixtures('comments_list.html'); 
     60               dotclear.commentsActionsHelper(); 
     61                
     62               spyOn(window, 'confirm').andReturn(false); 
     63               var submitCallback = jasmine.createSpy().andReturn(false); 
     64               $('#form-comments').submit(submitCallback); 
     65 
     66               $('select[name="action"] option[value="delete"]').attr('selected', 'selected'); 
     67               $('#form-comments').trigger('submit'); 
     68               expect(window.confirm).not.toHaveBeenCalled(); 
     69          }); 
     70          it("Others actions don't show confirm popup", function() { 
     71               loadFixtures('comments_list.html'); 
     72               dotclear.commentsActionsHelper(); 
     73                
     74               spyOn(window, 'confirm').andReturn(false); 
     75               var submitCallback = jasmine.createSpy().andReturn(false); 
     76               $('#form-comments').submit(submitCallback); 
     77 
     78               $('select[name="action"] option[value="publish"]').attr('selected', 'selected'); 
     79               $('#form-comments').trigger('submit'); 
     80               expect(window.confirm).not.toHaveBeenCalled(); 
     81          }); 
    2882     }); 
    29      it("Others actions don't show confirm popup", function() { 
    30          loadFixtures('posts_list.html'); 
    31          dotclear.postsActionsHelper(); 
    32           
    33          spyOn(window, 'confirm').andReturn(false); 
    34          var submitCallback = jasmine.createSpy().andReturn(false); 
    35          $('#form-entries').submit(submitCallback); 
    36  
    37          $('select[name="action"] option[value="publish"]').attr('selected', 'selected'); 
    38          $('#form-entries').trigger('submit'); 
    39          expect(window.confirm).not.toHaveBeenCalled(); 
    40      }); 
    41     }); 
    42  
    43     describe("commentsActionsHelper", function() { 
    44      it("A confirm popup must appear if action is \"delete\" and at least on checkbox is checked", function() { 
    45          loadFixtures('comments_list.html'); 
    46          dotclear.commentsActionsHelper(); 
    47           
    48          spyOn(window, 'confirm').andReturn(false); 
    49          var submitCallback = jasmine.createSpy().andReturn(false); 
    50          $('#form-comments').submit(submitCallback); 
    51  
    52          $('select[name="action"] option[value="delete"]').attr('selected', 'selected'); 
    53          $('input[type="checkbox"][name="comments[]"][value="2"]').attr('checked', 'checked'); 
    54  
    55          $('#form-comments').trigger('submit'); 
    56          expect(window.confirm).toHaveBeenCalled(); 
    57      }); 
    58      it("Confirm popup doesn't appear if action is \"delete\" but no checkbox is checked", function() { 
    59          loadFixtures('comments_list.html'); 
    60          dotclear.commentsActionsHelper(); 
    61           
    62          spyOn(window, 'confirm').andReturn(false); 
    63          var submitCallback = jasmine.createSpy().andReturn(false); 
    64          $('#form-comments').submit(submitCallback); 
    65  
    66          $('select[name="action"] option[value="delete"]').attr('selected', 'selected'); 
    67          $('#form-comments').trigger('submit'); 
    68          expect(window.confirm).not.toHaveBeenCalled(); 
    69      }); 
    70      it("Others actions don't show confirm popup", function() { 
    71          loadFixtures('comments_list.html'); 
    72          dotclear.commentsActionsHelper(); 
    73           
    74          spyOn(window, 'confirm').andReturn(false); 
    75          var submitCallback = jasmine.createSpy().andReturn(false); 
    76          $('#form-comments').submit(submitCallback); 
    77  
    78          $('select[name="action"] option[value="publish"]').attr('selected', 'selected'); 
    79          $('#form-comments').trigger('submit'); 
    80          expect(window.confirm).not.toHaveBeenCalled(); 
    81      }); 
    82     }); 
    8383}); 
  • tests/functional/spec/toggle_with_legend.js

    r1703 r1724  
    11describe("toggleWithLegend method (admin/js/common.js)", function() { 
    2     it("Click arrow must make target visible", function() { 
    3      loadFixtures('menu.html'); 
    4      $('#post_status').parent().toggleWithLegend($('#post_status'),{  }); 
     2     it("Click arrow must make target visible", function() { 
     3          loadFixtures('menu.html'); 
     4          $('#post_status').parent().toggleWithLegend($('#post_status'),{  }); 
    55 
    6      var $arrow = $('#post_status').parent().find('img'); 
    7      $arrow.click(); 
    8      expect($('#post_status')).toBeVisible(); 
    9     }); 
    10     it("Click arrow twice,must make target visible and after second click hidden", function() { 
    11      loadFixtures('menu.html'); 
    12      $('#post_status').parent().toggleWithLegend($('#post_status'),{  }); 
     6          var $arrow = $('#post_status').parent().find('img'); 
     7          $arrow.click(); 
     8          expect($('#post_status')).toBeVisible(); 
     9     }); 
     10     it("Click arrow twice,must make target visible and after second click hidden", function() { 
     11          loadFixtures('menu.html'); 
     12          $('#post_status').parent().toggleWithLegend($('#post_status'),{  }); 
    1313 
    14      var $arrow = $('#post_status').parent().find('img'); 
    15      $arrow.click(); 
    16      expect($('#post_status')).toBeVisible(); 
     14          var $arrow = $('#post_status').parent().find('img'); 
     15          $arrow.click(); 
     16          expect($('#post_status')).toBeVisible(); 
    1717 
    18      $arrow.click(); 
    19      expect($('#post_status')).toBeHidden(); 
    20     }); 
    21     it("Chick target must not hide target", function() { 
    22      loadFixtures('menu.html'); 
    23      $('#post_status').parent().toggleWithLegend($('#post_status'),{  }); 
     18          $arrow.click(); 
     19          expect($('#post_status')).toBeHidden(); 
     20     }); 
     21     it("Chick target must not hide target", function() { 
     22          loadFixtures('menu.html'); 
     23          $('#post_status').parent().toggleWithLegend($('#post_status'),{  }); 
    2424 
    25      var $arrow = $('#post_status').parent().find('img'); 
    26      $arrow.click(); 
    27      expect($('#post_status')).toBeVisible(); 
     25          var $arrow = $('#post_status').parent().find('img'); 
     26          $arrow.click(); 
     27          expect($('#post_status')).toBeVisible(); 
    2828 
    29      $('#post_status option[value="-2"]').attr('selected', 'selected'); 
    30      expect($('#post_status')).toBeVisible(); 
    31     }); 
    32     it("Chick target must not hide target, when legend_click is true", function() { 
    33      loadFixtures('menu.html'); 
    34      var $label = $('#post_status').parent().children('label'); 
    35      $label.toggleWithLegend($('#post_status'),{'legend_click':true, a_container:false}); 
     29          $('#post_status option[value="-2"]').attr('selected', 'selected'); 
     30          expect($('#post_status')).toBeVisible(); 
     31     }); 
     32     it("Chick target must not hide target, when legend_click is true", function() { 
     33          loadFixtures('menu.html'); 
     34          var $label = $('#post_status').parent().children('label'); 
     35          $label.toggleWithLegend($('#post_status'),{'legend_click':true, a_container:false}); 
    3636 
    37      $label.click(); 
    38      expect($('#post_status')).toBeVisible(); 
     37          $label.click(); 
     38          expect($('#post_status')).toBeVisible(); 
    3939 
    40      var $arrow = $('#post_status').parent().find('img'); 
    41      $arrow.click(); 
    42      expect($('#post_status')).toBeVisible(); 
     40          var $arrow = $('#post_status').parent().find('img'); 
     41          $arrow.click(); 
     42          expect($('#post_status')).toBeVisible(); 
    4343 
    44      $('#post_status').val(-2).trigger('change'); 
    45      expect($('#post_status')).toBeVisible(); 
    46     }); 
     44          $('#post_status').val(-2).trigger('change'); 
     45          expect($('#post_status')).toBeVisible(); 
     46     }); 
    4747}); 
  • tests/functional/spec/users_actions.js

    r1703 r1724  
    11describe("updatePermissionsForm method (admin/js/_users_actions.js)", function() { 
    2     it("Click admin persmission must checked all associated permissions", function() { 
    3      loadFixtures('normal.html'); 
    4      $('#permissions-form').updatePermissionsForm(); 
    5      var permissions = ['usage','publish','delete','contentadmin','categories']; 
     2     it("Click admin persmission must checked all associated permissions", function() { 
     3          loadFixtures('normal.html'); 
     4          $('#permissions-form').updatePermissionsForm(); 
     5          var permissions = ['usage','publish','delete','contentadmin','categories']; 
    66 
    7      $('input[name="perm[default][admin]"]').click(); 
    8      for (var _i=0,_len=permissions.length;_i<_len;_i++) { 
    9          expect($('input[name="perm[default]['+permissions[_i]+']"]')).toBeChecked(); 
    10          expect($('input[name="perm[default]['+permissions[_i]+']"]')).toBeDisabled(); 
    11      } 
    12     }); 
     7          $('input[name="perm[default][admin]"]').click(); 
     8          for (var _i=0,_len=permissions.length;_i<_len;_i++) { 
     9               expect($('input[name="perm\\[default\\]\\['+permissions[_i]+'\\]"]')).toBeChecked(); 
     10               expect($('input[name="perm\\[default\\]\\['+permissions[_i]+'\\]"]')).toBeDisabled(); 
     11          } 
     12     }); 
    1313 
    14     it("Click contentadmin persmission must checked all associated permissions", function() { 
    15      loadFixtures('normal.html'); 
    16      $('#permissions-form').updatePermissionsForm(); 
    17      var permissions = ['usage','publish','delete']; 
     14     it("Click contentadmin persmission must checked all associated permissions", function() { 
     15          loadFixtures('normal.html'); 
     16          $('#permissions-form').updatePermissionsForm(); 
     17          var permissions = ['usage','publish','delete']; 
    1818 
    19      $('input[name="perm[default][contentadmin]"]').click(); 
    20      for (var _i=0,_len=permissions.length;_i<_len;_i++) { 
    21          expect($('input[name="perm[default]['+permissions[_i]+']"]')).toBeChecked(); 
    22          expect($('input[name="perm[default]['+permissions[_i]+']"]')).toBeDisabled(); 
    23      } 
    24     }); 
     19          $('input[name="perm[default][contentadmin]"]').click(); 
     20          for (var _i=0,_len=permissions.length;_i<_len;_i++) { 
     21               expect($('input[name="perm[default]['+permissions[_i]+']"]')).toBeChecked(); 
     22               expect($('input[name="perm[default]['+permissions[_i]+']"]')).toBeDisabled(); 
     23          } 
     24     }); 
    2525}); 
Note: See TracChangeset for help on using the changeset viewer.

Sites map