Skip to content

Commit 3961701

Browse files
authored
Merge branch 'publiclab:main' into main
2 parents ebda258 + 6e10b32 commit 3961701

5 files changed

Lines changed: 88 additions & 17 deletions

File tree

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"crossvent": "1.5.5",
4141
"domador": "2.4.4",
4242
"font-awesome": "~4.7.0",
43-
"grow-textarea": "git://github.com/jywarren/grow.git#d54141c9456343f14cc6c935faa0915af09eb669",
43+
"grow-textarea": "https://github.com/jywarren/grow.git#d54141c9456343f14cc6c935faa0915af09eb669",
4444
"http-server": "^0.12.3",
4545
"jquery": "^3.6.0",
4646
"leaflet": "^1.6.0",
@@ -50,7 +50,7 @@
5050
"popper.js": "1.16.1",
5151
"resig-class": "~1.0.0",
5252
"typeahead.js-browserify": "~1.0.7",
53-
"woofmark": "git://github.com/jywarren/woofmark.git#plots2",
53+
"woofmark": "https://github.com/jywarren/woofmark.git#plots2",
5454
"xhr": "~2.5.0"
5555
},
5656
"devDependencies": {

spec/javascripts/formatter_spec.js

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/modules/PublicLab.CustomInsert.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,12 @@ module.exports = function CustomInsert(_module, wysiwyg) {
6767
}
6868
});
6969
const builder = require("./PublicLab.CustomInsert.Template.js");
70-
$('.wk-commands').append('<a class="woofmark-command-insert btn btn-outline-secondary" data-toggle="Insert" title="Custom Insert"><i class="fa fa-tags"></i></a>');
70+
$('.wk-commands').append('<button class="woofmark-command-insert btn btn-outline-secondary" data-toggle="insert" title="Custom Insert"><i class="fa fa-tags"></i></button>');
71+
72+
$(document).ready(function() {
73+
$('[data-toggle="insert"]').tooltip();
74+
});
75+
7176
var Option1 = "Notes";
7277
var Option2 = "List";
7378
$('.woofmark-command-insert').attr('data-content', builder);

test/ui-testing/editor.test.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
const timeout = process.env.SLOWMO ? 60000 : 10000;
2+
const fs = require('fs');
3+
let editor;
4+
5+
beforeAll(async () => {
6+
path = fs.realpathSync('file://../examples/index.html');
7+
// scriptPath = fs.realpathSync('file://../node_modules/jquery/dist/jquery.min.js');
8+
// await page.addScriptTag({path: scriptPath});
9+
await page.goto('file://' + path, {waitUntil: 'domcontentloaded'});
10+
await page.evaluate(() => {
11+
editor = new PL.Editor({
12+
textarea: document.querySelector('.ple-textarea')
13+
});
14+
});
15+
});
16+
17+
describe('Errors', () => {
18+
test('Editor exists and has a textarea', async () => {
19+
expect( await page.evaluate(() => document.querySelector('.ple-textarea')) ).toBeDefined();
20+
expect( await page.evaluateHandle(() => editor) ).toBeDefined();
21+
expect( await page.evaluateHandle(() => editor.options.textarea) ).toBeDefined();
22+
expect( await page.evaluateHandle(() => editor.options.textarea.innerHTML) ).toEqual(await page.evaluateHandle(() => document.querySelector('.ple-textarea').innerHTML));
23+
});
24+
25+
test('counts valid modules and enables publish button', async () => {
26+
expect( await page.evaluate(() => editor.titleModule.el.find('input')[0].value) ).toBe("");
27+
expect( await page.evaluate(() => editor.titleModule.valid()) ).toBe(false);
28+
29+
expect( await page.evaluate(() => editor.validate()) ).toBe(false);
30+
31+
await page.evaluate(() => editor.richTextModule.wysiwyg.setMode('markdown')); // set editor mode to markdown
32+
await page.evaluate(() => editor.richTextModule.value("")); // empty editor content on
33+
expect( await page.evaluate(() => editor.richTextModule.valid()) ).toBe(false);
34+
35+
await page.evaluate(() => editor.titleModule.value("My Title")); // set sample title
36+
await page.evaluate(() => editor.richTextModule.value("My Content")); // set sample content
37+
expect( await page.evaluate(() => editor.validate()) ).toBe(true);
38+
});
39+
40+
test('Sends AJAX request on editor.publish()', async () => {
41+
await page.evaluate(() => editor.options.destination = '/post');
42+
const spy = jest.fn().mockImplementation(async (options) => {
43+
await page.evaluate(() => {
44+
if (options === editor.options.destination) {
45+
const d = $.Deferred();
46+
d.resolve(options);
47+
d.reject(options);
48+
return d.promise();
49+
}
50+
});
51+
52+
function onPublish(response) {
53+
expect(response).toBeDefined();
54+
}
55+
56+
editor.publish(onPublish);
57+
});
58+
});
59+
});

test/ui-testing/formatter.test.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
const timeout = process.env.SLOWMO ? 60000 : 10000;
2+
const fs = require('fs');
3+
let formatted;
4+
beforeAll(async () => {
5+
path = fs.realpathSync('file://../examples/index.html');
6+
await page.goto('file://' + path, {waitUntil: 'domcontentloaded'});
7+
await page.evaluate(() => {
8+
formatted = new PL.Formatter().convert({
9+
title: 'My title',
10+
body: 'My body'
11+
}, 'publiclab');
12+
});
13+
});
14+
15+
describe('Formatter', () => {
16+
test('converts basic post data into a given format', async () => {
17+
expect(await page.evaluate(() => formatted)).toBeDefined();
18+
expect(await page.evaluate(() => formatted.title)).toBeDefined();
19+
expect(await page.evaluate(() => formatted.body)).toBeDefined();
20+
});
21+
}, timeout);

0 commit comments

Comments
 (0)