Skip to content

Commit

Permalink
Merge pull request #871 from nistormihai/rp-image-issues
Browse files Browse the repository at this point in the history
Rp image issues
  • Loading branch information
nistormihai committed Jan 7, 2015
2 parents c65e499 + 4763e4a commit ef6bdd2
Show file tree
Hide file tree
Showing 10 changed files with 301 additions and 65 deletions.
1 change: 1 addition & 0 deletions plugins/embed/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ config.json
logs/**
server-test-results.xml
client-test-results.xml
e2e-test-results/
docs/docco/test/**
docs/docco/scripts/**
!docs/docco/scripts/index.html
Expand Down

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions plugins/embed/gui-resources/scripts/js/plugins/image-fix.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
'use strict';

define([
'lib/utils',
'plugins'
], function (utils, plugins) {
plugins.imageFix = function (config) {
utils.dispatcher.on('before-render.post-view', function (view) {
if (view.model.get('item') !== 'posttype/image' &&
view.model.get('item') !== 'posttype/normal') {
return;
}
var Content = view.model.get('Content');
// remove 'null' with or without   trailing.
Content = Content.replace(/null(\n )?/, '');
// replace all links that have images with the actuall image.
Content = Content.replace(new RegExp('<a([^>]*)>(.*?)</a>', 'gi'), function(all, attr) {
attr.replace(/"(.*?)content\/media_archive\/image([^"]*)"/, function(link) {
all = '<img src=' + link + '>';
});
return all;
});
// add a class for all local images.
Content = Content.replace(/"(.*?)content\/media_archive\/image([^"]*)"/, function(link) {
return link + ' class="liveblog-local"';
});
view.model.set({Content: Content}, {silent: true});
});

};
return plugins.imageFix;
});
4 changes: 3 additions & 1 deletion plugins/embed/gui-themes/themes/rp/desktop.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ define([
'plugins/pending-messages',
'plugins/stop-auto-render',
'plugins/ivw-refresh',
'plugins/image-fix',
'tmpl!theme/container',
'tmpl!theme/item/base'
], function() {
Expand All @@ -24,7 +25,8 @@ define([
'status',
'pending-messages',
'stop-auto-render',
'ivw-refresh'
'ivw-refresh',
'image-fix'
]
};
});
5 changes: 5 additions & 0 deletions plugins/embed/gui-themes/themes/rp/desktop/liveblog.css
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@
padding: 0;
}

#livedesk-root .liveblog-local
{
width: 100%;
}

#livedesk-root blockquote {
border: none;
padding-bottom: 0px;
Expand Down
1 change: 1 addition & 0 deletions plugins/embed/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"grunt-karma-coveralls": "^2.5.1",
"grunt-mocha-test": "^0.10.2",
"grunt-open": "^0.2.3",
"jasmine-reporters": "^1.0.0",
"jssha": "^1.5.0",
"karma": "^0.12.9",
"karma-chrome-launcher": "^0.1.3",
Expand Down
4 changes: 4 additions & 0 deletions plugins/embed/protractor-conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,9 @@ exports.config = {
},
takeScreenShotsOnlyForFailedSpecs: true
}));
require('jasmine-reporters');
jasmine.getEnv().addReporter(
new jasmine.JUnitXmlReporter('e2e-test-results', true, true)
);
}
};
261 changes: 206 additions & 55 deletions plugins/embed/spec/embed_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,89 +6,240 @@ var uploadFixtures = require('./helpers/liveblog_fixtures').uploadFixtures;
var liveblogBackend = require('./helpers/liveblog_posts.js');
var postCreateAndPublish = liveblogBackend.postCreateAndPublish;
var postEdit = liveblogBackend.postEdit;
var postDelete = liveblogBackend.postDelete;
var postUnpublish = liveblogBackend.postUnpublish;
var postsReorder = liveblogBackend.postsReorder;

// Protractor Params:
var pp = protractor.getInstance().params;

describe('Embed', function() {
'use strict';

describe(' (when have one post)', function() {
beforeEach(function(done) {
uploadFixtures('posts', 1, function(e, r, j) {
gotoUri('/', function() {
done();
});
beforeEach(function(done) {
uploadFixtures('posts', 0, function(e, r, j) {
gotoUri('/', function() {
done();
});
});
});

it(' is rendered serverside', function() {
expect(
element(by.css('div[data-gimme="liveblog-layout"]'))
.isDisplayed()
).toBe(true);
});

it(' is rendered serverside', function() {
expect(
element(by.css('div[data-gimme="liveblog-layout"]'))
.isDisplayed()
).toBe(true);
});

describe(' (when blank)', function() {
beforeEach(function(done) {
uploadFixtures('posts', 0, function(e, r, j) {
gotoUri('/', function() {
done();
});
});
it(' is updating to show just added post', function() {
var postContent = randomText();
postCreateAndPublish({
postContent: postContent
});

it(' is updating to show just added post', function() {
var postContent = randomText();
postCreateAndPublish({
postContent: postContent
});
browser.wait(function() {
browser.wait(
function() {
return browser.isElementPresent(
by.cssContainingText(
'div.liveblog-content p.post-text',
postContent
)
);
}, pp.maxTimeout);
expect(true).toBe(true);
}, pp.maxTimeout);
));
},
pp.maxTimeout,
'Just added post should appear on page.'
);
},
//it
pp.maxTimeout);

it(' is updating to show just edited post', function() {
var postContent = randomText(),
newContent = randomText(),
postId;
postCreateAndPublish({
postContent: postContent
}, function(e, r, j, id) {
postId = id;
});
browser.wait(function() {
it(' is updating to show just edited post', function() {
var postContent = randomText(),
newContent = randomText(),
postId;
postCreateAndPublish({
postContent: postContent
}, function(e, r, j, id) {
postId = id;
});
browser.wait(
function() {
return browser.isElementPresent(
by.cssContainingText(
'div.liveblog-content p.post-text',
postContent
)
);
}, pp.maxTimeout)
.then(function() {
postEdit({
postId: postId,
newContent: newContent
});
browser.wait(function() {
));
},
pp.maxTimeout,
'Just added post should appear on page.'
).then(function() {
postEdit({
postId: postId,
newContent: newContent
});
browser.wait(
function() {
return browser.isElementPresent(
by.cssContainingText(
'div.liveblog-content p.post-text',
newContent
)
);
}, pp.maxTimeout);
expect(true).toBe(true);
},
pp.maxTimeout,
'Just edited post should be updated on page.'
);
});
},
//it
pp.maxTimeout * 2);

it(' is updating to show what post was just deleted', function() {
var postContent = randomText(),
postId;
postCreateAndPublish({
postContent: postContent
}, function(e, r, j, id) {
postId = id;
});
browser.wait(
function() {
return browser.isElementPresent(
by.cssContainingText(
'div.liveblog-content p.post-text',
postContent
));
},
pp.maxTimeout,
'Just added post should appear on page.'
).then(function() {
postDelete({
postId: postId
});
}, pp.maxTimeout * 2);
});
browser.wait(
function() {
return element.all(
by.cssContainingText(
'div.liveblog-content p.post-text',
postContent
)
).count().then(
function(count) {
return count === 0;
}
);
}, pp.maxTimeout,
'Just deleted post should disappear from page.'
);
});
},
//it
pp.maxTimeout * 2);

it(' is updating to show what post was just ubpublished', function() {
var postContent = randomText(),
postId;
postCreateAndPublish({
postContent: postContent
}, function(e, r, j, id) {
postId = id;
});
browser.wait(
function() {
return browser.isElementPresent(
by.cssContainingText(
'div.liveblog-content p.post-text',
postContent
));
},
pp.maxTimeout,
'Just added post should appear on page.'
).then(function() {
postUnpublish({
postId: postId
});
browser.wait(
function() {
return element.all(
by.cssContainingText(
'div.liveblog-content p.post-text',
postContent
)
).count().then(
function(count) {
return count === 0;
}
);
}, pp.maxTimeout,
'Just unpublished post should disappear from page.'
);
});
},
//it
pp.maxTimeout * 2);

it(' is updating to show what posts were reordered', function() {
var firstPostContent = randomText(),
secondPostContent = randomText(),
firstPostId,
secondPostId;
postCreateAndPublish({
postContent: firstPostContent
}, function(e, r, j, id) {
firstPostId = id;
});
browser.wait(
function() {
return browser.isElementPresent(
by.cssContainingText(
'div.liveblog-content p.post-text',
firstPostContent
));
},
pp.maxTimeout,
'First added post should appear on page.'
).then(function() {
postCreateAndPublish({
postContent: secondPostContent
}, function(e, r, j, id) {
secondPostId = id;
});
browser.wait(
function() {
return browser.isElementPresent(
by.cssContainingText(
'div.liveblog-content p.post-text',
secondPostContent
));
},
pp.maxTimeout,
'Second added post should appear on page.'
).then(function() {
postsReorder({
postId: firstPostId,
otherPostId: secondPostId,
before: true
});
browser.wait(
function() {
var posts = element.all(
by.css('div.liveblog-content p.post-text')
);
return posts.get(0).getText().then(function(text) {
if (text === firstPostContent) {
return posts.get(1).getText().then(function (text) {
if (text === secondPostContent) {
return true;
}
});
}
});
}, pp.maxTimeout,
'Just reordered posts should update on embed.'
);
});
});
},
//it
pp.maxTimeout * 3);

//describe Embed
});
2 changes: 1 addition & 1 deletion plugins/embed/spec/helpers/liveblog_backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function backendRequest(params, callback) {
throw new Error(error);
}
if (
(response.statusCode !== 200) && (response.statusCode !== 201)
(response.statusCode < 200) && (response.statusCode >= 300)
) {
console.log('Request:');
console.log(response.request.href);
Expand Down
Loading

0 comments on commit ef6bdd2

Please sign in to comment.