From a5f6d4f334f131b79c690676f29d8afa831fb853 Mon Sep 17 00:00:00 2001 From: Tommy Yu Date: Thu, 11 Feb 2016 16:35:56 +1300 Subject: [PATCH 1/3] Change the comment to test skips - Rather than silently drop them, make a note of them to actually get that handled later. --- mockup/tests/pattern-relateditems-test.js | 52 ++++++++++------------- 1 file changed, 22 insertions(+), 30 deletions(-) diff --git a/mockup/tests/pattern-relateditems-test.js b/mockup/tests/pattern-relateditems-test.js index be79e3617..d58021021 100644 --- a/mockup/tests/pattern-relateditems-test.js +++ b/mockup/tests/pattern-relateditems-test.js @@ -170,8 +170,8 @@ define([ $el.remove(); $('.select2-sizer, .select2-drop').remove(); }); -/*fgrcon - it('select an item by clicking add button', function () { + + it.skip('select an item by clicking add button', function () { var $el = $('' + '
' + ' ' + ' ' + ' ' + ' ' + @@ -291,9 +288,8 @@ define([ $el.remove(); $('.select2-sizer, .select2-drop').remove(); }); -*/ -/*fgrcon - it('clicking folder button filters to that folder', function() { + + it.skip('clicking folder button filters to that folder', function() { var $el = $('' + '
' + ' ' + ' ' + ' ' + ' ' + @@ -419,8 +413,8 @@ define([ $el.remove(); $('.select2-sizer, .select2-drop, .select2-drop-mask').remove(); }); -/*fgrcon - it('test tree initialized', function() { + + it.skip('test tree initialized', function() { var $el = $('' + '
' + ' ' + ' ' + ' ' + @@ -536,8 +530,6 @@ define([ $('.select2-sizer, .select2-drop, .select2-drop-mask').remove(); }); - - }); }); From c17138a1e64aacd8a3139100e2f444cfd141c3da Mon Sep 17 00:00:00 2001 From: Tommy Yu Date: Thu, 11 Feb 2016 18:33:52 +1300 Subject: [PATCH 2/3] Patch test data with helper function, remove skip - This patches up the test data with a function to add in the expected fields to not cause rendering errors. - Also included is the patch to search helper function with the dummy json provider to restore the search by folder functionality as per upgrade in Products.CMFCore. - Remove the skip designation for all affected tests within the relateditems pattern. Side note: - These "attributes" need to be really documented somewhere to either ensure third-party users can use this, or tell them not to. --- mockup/tests/pattern-relateditems-test.js | 51 ++++++++++++++++------- 1 file changed, 35 insertions(+), 16 deletions(-) diff --git a/mockup/tests/pattern-relateditems-test.js b/mockup/tests/pattern-relateditems-test.js index d58021021..a027d621a 100644 --- a/mockup/tests/pattern-relateditems-test.js +++ b/mockup/tests/pattern-relateditems-test.js @@ -56,6 +56,17 @@ define([ {UID: 'asdfasdf9sdf', Title: 'Mike', path: '/about/staff/mike', portal_type: 'Document', getIcon: ""}, {UID: 'cvbcvb82345', Title: 'Joe', path: '/about/staff/joe', portal_type: 'Document', getIcon: ""} ]; + + var addMissingFields = function(item) { + item.getURL = 'http://localhost:8081' + item.path; + item.is_folderish = item.portal_type === 'Folder'; + item.review_state = 'published'; + }; + + _.each(root, addMissingFields); + _.each(about, addMissingFields); + _.each(staff, addMissingFields); + var searchables = about.concat(root).concat(staff); var addUrls = function(list) { @@ -91,6 +102,8 @@ define([ var criteria = query.criteria[i]; if (criteria.i === 'path') { path = criteria.v.split('::')[0]; + } else if (criteria.i === 'is_folderish') { + term = criteria; } else { term = criteria.v; } @@ -107,11 +120,17 @@ define([ var q; var keys = (item.UID + ' ' + item.Title + ' ' + item.path + ' ' + item.portal_type).toLowerCase(); if (typeof(term) === 'object') { - for (var i = 0; i < term.length; i = i + 1) { - q = term[i].toLowerCase(); - if (keys.indexOf(q) > -1) { + if (term.i === 'is_folderish') { + if (item.is_folderish) { results.push(item); - break; + } + } else { + for (var i = 0; i < term.length; i = i + 1) { + q = term[i].toLowerCase(); + if (keys.indexOf(q) > -1) { + results.push(item); + break; + } } } } else { @@ -171,7 +190,7 @@ define([ $('.select2-sizer, .select2-drop').remove(); }); - it.skip('select an item by clicking add button', function () { + it('select an item by clicking add button', function () { var $el = $('' + '
' + ' ' + ' ' + ' ' + ' ' + @@ -282,14 +301,14 @@ define([ $('.pattern-relateditems-result-select').first().click(); expect(pattern.$el.select2('data')).to.have.length(0); - $('.pattern-relateditems-type-Image .pattern-relateditems-result-select').first().click(); + $('.contenttype-image:parent').first().click(); expect(pattern.$el.select2('data')).to.have.length(1); $el.remove(); $('.select2-sizer, .select2-drop').remove(); }); - it.skip('clicking folder button filters to that folder', function() { + it('clicking folder button filters to that folder', function() { var $el = $('' + '
' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' Date: Thu, 11 Feb 2016 20:34:04 +1300 Subject: [PATCH 3/3] Better individual test isolation. --- mockup/tests/pattern-relateditems-test.js | 78 +++++++---------------- 1 file changed, 22 insertions(+), 56 deletions(-) diff --git a/mockup/tests/pattern-relateditems-test.js b/mockup/tests/pattern-relateditems-test.js index a027d621a..d99698976 100644 --- a/mockup/tests/pattern-relateditems-test.js +++ b/mockup/tests/pattern-relateditems-test.js @@ -11,6 +11,8 @@ define([ window.mocha.setup('bdd').globals(['jQuery*']); $.fx.off = true; + var $el; + /* ========================== TEST: Related Items ========================== */ @@ -173,8 +175,14 @@ define([ }); }); + afterEach(function() { + this.server.restore(); + $el.remove(); + $('.select2-sizer, .select2-drop').remove(); + }); + it('test initialize', function() { - var $el = $('' + + $el = $('' + '
' + ' ' + '
').appendTo('body'); @@ -303,13 +299,10 @@ define([ $('.contenttype-image:parent').first().click(); expect(pattern.$el.select2('data')).to.have.length(1); - - $el.remove(); - $('.select2-sizer, .select2-drop').remove(); }); it('clicking folder button filters to that folder', function() { - var $el = $('' + + $el = $('' + '
' + ' ' + ' ' + ' ' + ' ' + '