diff --git a/.travis.yml b/.travis.yml index e691b329..344c84e5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,4 +8,4 @@ before_script: - grunt build script: - grunt jasmine --force - - npm run test-ui \ No newline at end of file + - npm run test-ui diff --git a/dist/PublicLab.Editor.js b/dist/PublicLab.Editor.js index 8e1307f3..c0422640 100644 --- a/dist/PublicLab.Editor.js +++ b/dist/PublicLab.Editor.js @@ -20479,7 +20479,7 @@ PL.MapModule = require('./modules/PublicLab.MapModule.js'); $(document).ready(function() { PL.Util.preventModalScrollToTop(); - PL.Util.enableRichTextModeKeyboardShortcut(); + PL.Util.enableTextModeKeyboardShortcut(); PL.Util.preventUploadedImagesDragging(); }); diff --git a/src/PublicLab.Editor.js b/src/PublicLab.Editor.js index 2df20fc3..3becf8be 100644 --- a/src/PublicLab.Editor.js +++ b/src/PublicLab.Editor.js @@ -18,7 +18,7 @@ PL.MapModule = require('./modules/PublicLab.MapModule.js'); $(document).ready(function() { PL.Util.preventModalScrollToTop(); - PL.Util.enableRichTextModeKeyboardShortcut(); + PL.Util.enableTextModeKeyboardShortcut(); PL.Util.preventUploadedImagesDragging(); }); diff --git a/test/ui-testing/bold.test.js b/test/ui-testing/bold.test.js new file mode 100644 index 00000000..10940a6c --- /dev/null +++ b/test/ui-testing/bold.test.js @@ -0,0 +1,43 @@ +const timeout = process.env.SLOWMO ? 60000 : 10000; +const fs = require('fs'); +beforeAll(async () => { + path = fs.realpathSync('file://../examples/index.html'); + await page.goto('file://' + path, {waitUntil: 'domcontentloaded'}); +}); + +describe('Bold Text', () => { + test('Adds strong text in rich text mode', async () => { + // clicks on bold button and checks if 'strong text' is added in the editor + await page.waitForSelector('.ple-module-body'); + await page.click('.woofmark-command-bold'); + const stringIsIncluded = await page.evaluate(() => document.querySelector('.wk-wysiwyg').textContent.includes('strong text')); + expect(stringIsIncluded).toBe(true); + + // resets the changes by removing the added text + await page.keyboard.press("Backspace"); + + }, timeout); + + test('Adds strong text in markdown mode', async () => { + // clicks on bold button and checks if '**strong text**' is added in the editor + await page.waitForSelector('.woofmark-mode-markdown'); + await page.click('.woofmark-mode-markdown'); + await page.evaluate(() => document.querySelector('.ple-textarea').value += ' '); + await page.click('.woofmark-command-bold'); + let stringIsIncluded = await page.evaluate(() => document.querySelector('.ple-textarea').value.includes('**strong text**')); + expect(stringIsIncluded).toBe(true); + + // clicks bold button again to un-bolden the text but retains the text value 'strong text' + await page.click('.woofmark-command-bold'); + stringIsIncluded = await page.evaluate(() => document.querySelector('.ple-textarea').value.includes('strong text')); + expect(stringIsIncluded).toBe(true); + stringIsIncluded = await page.evaluate(() => document.querySelector('.ple-textarea').value.includes('**strong text**')); + expect(stringIsIncluded).toBe(false); + + // resets changes by removing the added text and changes back to wysiwyg mode + await page.keyboard.press("Backspace"); + await page.click('.woofmark-mode-wysiwyg'); + + }, timeout); + +}); \ No newline at end of file diff --git a/test/ui-testing/italic.test.js b/test/ui-testing/italic.test.js new file mode 100644 index 00000000..e04df013 --- /dev/null +++ b/test/ui-testing/italic.test.js @@ -0,0 +1,43 @@ +const timeout = process.env.SLOWMO ? 60000 : 10000; +const fs = require('fs'); +beforeAll(async () => { + path = fs.realpathSync('file://../examples/index.html'); + await page.goto('file://' + path, {waitUntil: 'domcontentloaded'}); +}); + +describe('Italic Text', () => { + test('Adds emphasized text in rich text mode', async () => { + // clicks on italic button and checks if 'emphasized text' is added in the editor + await page.waitForSelector('.ple-module-body'); + await page.click('.woofmark-command-italic'); + const stringIsIncluded = await page.evaluate(() => document.querySelector('.wk-wysiwyg').textContent.includes('emphasized text')); + expect(stringIsIncluded).toBe(true); + + // resets the changes by removing the added text + await page.keyboard.press("Backspace"); + + }, timeout); + + test('Adds emphasized text in markdown mode', async () => { + // clicks on italic button and checks if '*emphasized text*' is added in the editor + await page.waitForSelector('.woofmark-mode-markdown'); + await page.click('.woofmark-mode-markdown'); + await page.evaluate(() => document.querySelector('.ple-textarea').value += ' '); + await page.click('.woofmark-command-italic'); + let stringIsIncluded = await page.evaluate(() => document.querySelector('.ple-textarea').value.includes('*emphasized text*')); + expect(stringIsIncluded).toBe(true); + + // clicks italic button again to un-emphasize the text but retains the text value 'emphasized text' + await page.click('.woofmark-command-italic'); + stringIsIncluded = await page.evaluate(() => document.querySelector('.ple-textarea').value.includes('emphasized text')); + expect(stringIsIncluded).toBe(true); + stringIsIncluded = await page.evaluate(() => document.querySelector('.ple-textarea').value.includes('*emphasized text*')); + expect(stringIsIncluded).toBe(false); + + // resets changes by removing the added text and changes back to wysiwyg mode + await page.keyboard.press("Backspace"); + await page.click('.woofmark-mode-wysiwyg'); + + }, timeout); + +});