added manual test for discourse-onebox.js.

This commit is contained in:
Atul Varma 2015-02-02 15:15:22 -05:00
Родитель 85c175352a
Коммит 8edaff4697
3 изменённых файлов: 49 добавлений и 9 удалений

9
app.js
Просмотреть файл

@ -13,6 +13,7 @@ var IS_TESTING = 'IS_TESTING' in process.env;
var PORT = process.env.PORT || 3000;
var bundlejs;
var discoursejs;
var screenshotConfig = new ScreenshotConfig();
var redisCache = new RedisCache(process.env.REDIS_URL ||
process.env.REDISTOGO_URL,
@ -48,6 +49,14 @@ app.get('/healthcheck', function(req, res, next) {
});
});
app.get('/js/discourse-onebox.js', function(req, res, next) {
if (!discoursejs || DEBUG) {
discoursejs = require('fs')
.readFileSync(__dirname + '/contrib/discourse-onebox.js');
}
return res.type('text/javascript').send(discoursejs);
});
app.get('/js/bundle.js', function(req, res, next) {
if (!bundlejs || DEBUG) {
var b = browserify();

Просмотреть файл

@ -5,17 +5,16 @@
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
<link rel="stylesheet" href="/css/makerstrap.min.css">
<style>
.screenshot {
-moz-box-sizing: border-box;
width: 320px;
height: 240px;
border: 1px solid gray;
margin: 10px;
/* Simulate Discourse style. */
.onebox-result {
background: lightgray;
padding: 10px;
border-left: 4px solid darkgray;
}
.screenshot.loading {
padding: 100px;
opacity: 0.5;
.onebox-result-body img {
float: left;
margin-right: 10px;
}
</style>
<title>Manual Tests for Webmaker Screenshot</title>
@ -38,5 +37,28 @@
show the changes you made earlier.</p>
</li>
</ol>
<h2>Manual Test for Discourse Onebox</h2>
<blockquote id="fake-post">
<p>Hi, I am a fake Discourse post. Here is a Webmaker link, which should look roughly like a Discourse onebox.</p>
<p><a href="https://toolness.makes.org/thimble/hey-french-toast-refactored">https://toolness.makes.org/thimble/hey-french-toast-refactored</a></p>
<p>Here is a non-Webmaker link, which should <em>not</em> look like a Discourse onebox.</p>
<p><a href="http://mozilla.org/">http://mozilla.org/</a></p>
</blockquote>
</div>
<script src="//code.jquery.com/jquery-2.1.3.min.js"></script>
<script>
var Discourse = {
PostView: {
reopen: function(options) {
var post = $('#fake-post');
var self = {
_super: function() {},
$: post.find.bind(post)
};
options.didInsertElement.call(self)
}
}
};
</script>
<script src="/js/discourse-onebox.js"></script>
</body>

Просмотреть файл

@ -228,4 +228,13 @@ describe("app", function() {
.expect(200)
.end(done);
});
it("should generate /js/discourse-onebox.js", function(done) {
request(app)
.get('/js/discourse-onebox.js')
.expect('Content-Type', 'text/javascript; charset=utf-8')
.expect(200)
.end(done);
});
});