From c195df4f3c91092e4664c6b0f808dfeec6c300c2 Mon Sep 17 00:00:00 2001 From: shreyaa-sharmaa Date: Sat, 4 Jul 2020 14:14:17 +0530 Subject: [PATCH 1/2] bold jest test --- test/ui-testing/bold.test.js | 37 ++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 test/ui-testing/bold.test.js diff --git a/test/ui-testing/bold.test.js b/test/ui-testing/bold.test.js new file mode 100644 index 00000000..e69b8385 --- /dev/null +++ b/test/ui-testing/bold.test.js @@ -0,0 +1,37 @@ +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 () => { + 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); + await page.keyboard.press("Backspace"); + + }, timeout); + + test('Adds strong text in markdown mode', async () => { + 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); + + 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); + + await page.keyboard.press("Backspace"); + await page.waitForSelector('.woofmark-mode-wysiwyg'); + + }, timeout); +}); From 78e31ea9c3bce4bda858043ac5f74aab2b7b7a62 Mon Sep 17 00:00:00 2001 From: shreyaa-sharmaa Date: Sat, 4 Jul 2020 14:50:53 +0530 Subject: [PATCH 2/2] error fixes --- dist/PublicLab.Editor.js | 2 +- src/PublicLab.Editor.js | 2 +- test/ui-testing/bold.test.js | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) 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 index e69b8385..76c9b79a 100644 --- a/test/ui-testing/bold.test.js +++ b/test/ui-testing/bold.test.js @@ -31,7 +31,8 @@ describe('Bold Text', () => { expect(stringIsIncluded).toBe(false); await page.keyboard.press("Backspace"); - await page.waitForSelector('.woofmark-mode-wysiwyg'); + await page.click('.woofmark-mode-wysiwyg'); }, timeout); + });