Skip to content

Commit

Permalink
Test that the removal of columns work
Browse files Browse the repository at this point in the history
- Needed adjustments in the template, but it is now possible to specify
  a bare minimum set of attributes with just Title and getURL being
  available.
  • Loading branch information
metatoaster committed Dec 18, 2015
1 parent 326ec67 commit 884767d
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 1 deletion.
1 change: 1 addition & 0 deletions mockup/patterns/structure/js/views/tablerow.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ define([
data.attributes = self.model.attributes;
data.activeColumns = self.app.activeColumns;
data.availableColumns = self.app.availableColumns;
data.contenttype = data.portal_type ? data.portal_type.toLowerCase() : '';
data._authenticator = utils.getAuthenticator();
data._t = _t;
self.$el.html(self.template(data));
Expand Down
2 changes: 1 addition & 1 deletion mockup/patterns/structure/templates/tablerow.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<td class="selection"><input type="checkbox" <% if(selected){ %> checked="checked" <% } %>/></td>
<td class="title">
<a href="<%- getURL %>" class="manage state-<%- review_state %> contenttype-<%- portal_type.toLowerCase() %>"><%- Title %></a>
<a href="<%- getURL %>" class="manage state-<%- review_state %> contenttype-<%- contenttype %>"><%- Title %></a>
<div class="icon-group-right">
<a href="<%- getURL %>/view" title="<%- _t('View') %>"><span class="glyphicon glyphicon-new-window"></span></a>
</div>
Expand Down
111 changes: 111 additions & 0 deletions mockup/tests/pattern-structure-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -602,4 +602,115 @@ define([
});


/* ==========================
TEST: Structure barebone columns
========================== */
describe('Structure barebone columns', function() {
beforeEach(function() {
// clear cookie setting
$.removeCookie('_fc_perPage');
$.removeCookie('_fc_activeColumnsCustom');

var structure = {
"vocabularyUrl": "/data.json",
"indexOptionsUrl": "/tests/json/queryStringCriteria.json",
"contextInfoUrl": "{path}/contextInfo",
"activeColumnsCookie": "activeColumnsCustom",
"activeColumns": [],
"availableColumns": {
"getURL": "URL",
},
"buttons": [],
"attributes": [
'Title', 'getURL'
]
};

this.$el = $('<div class="pat-structure"></div>').attr(
'data-pat-structure', JSON.stringify(structure)).appendTo('body');

this.server = sinon.fakeServer.create();
this.server.autoRespond = true;

this.server.respondWith('GET', /data.json/, function (xhr, id) {
var batch = JSON.parse(getQueryVariable(xhr.url, 'batch'));
var start = 0;
var end = 15;
if (batch) {
start = (batch.page - 1) * batch.size;
end = start + batch.size;
}
var items = [];
items.push({
/*
getURL: 'http://localhost:8081/folder',
Title: 'Folder',
id: 'folder'
*/
// 'portal_type', 'review_state', 'getURL'

getURL: 'http://localhost:8081/folder',
Title: 'Folder',
});
for (var i = start; i < end; i = i + 1) {
items.push({
/*
getURL: 'http://localhost:8081/item' + i,
Title: 'Document ' + i,
id: 'item' + i
*/

getURL: 'http://localhost:8081/item' + i,
Title: 'Document ' + i,
});
}

xhr.respond(200, { 'Content-Type': 'application/json' }, JSON.stringify({
total: 100,
results: items
}));
});
this.server.respondWith('GET', /contextInfo/, function (xhr, id) {
var data = {
addButtons: []
};
if (xhr.url.indexOf('folder') !== -1){
data.object = {
UID: '123sdfasdfFolder',
getURL: 'http://localhost:8081/folder',
path: '/folder',
portal_type: 'Folder',
Description: 'folder',
Title: 'Folder',
'review_state': 'published',
'is_folderish': true,
Subject: [],
id: 'folder'
};
}
xhr.respond(200, { 'Content-Type': 'application/json' }, JSON.stringify(data));
});

this.clock = sinon.useFakeTimers();
});

afterEach(function() {
this.server.restore();
this.clock.restore();
});

it('per page', function() {
registry.scan(this.$el);
this.clock.tick(1000);
this.$el.find('.serverhowmany15 a').trigger('click');
this.clock.tick(1000);
expect(this.$el.find('.itemRow').length).to.equal(16);
this.$el.find('.serverhowmany30 a').trigger('click');
this.clock.tick(1000);
expect(this.$el.find('.itemRow').length).to.equal(31);
});

});


});

0 comments on commit 884767d

Please sign in to comment.