Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I have changed const to let and changed #960

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
155 changes: 89 additions & 66 deletions test/ui-testing/CustomInsert.test.js
Original file line number Diff line number Diff line change
@@ -1,72 +1,95 @@
const timeout = process.env.SLOWMO ? 60000 : 10000;
const fs = require('fs');
let timeout = process.env.SLOWMO ? 60000 : 10000;
let fs = require("fs");

beforeAll(async () => {
path = fs.realpathSync('file://../examples/index.html');
await page.goto('file://' + path, {waitUntil: 'domcontentloaded'});
path = fs.realpathSync("file://../examples/index.html");
await page.goto("file://" + path, { waitUntil: "domcontentloaded" });
});

describe('Custom Insert text', () => {
test('Add Custom Insert text in rich text mode', async () => {
try {
if (await page.evaluate(() => $(".woofmark-mode-markdown").is(":disabled"))) {
await page.click('.woofmark-mode-wysiwyg');
}
await page.waitForSelector('.ple-module-body');
// Click on insert text button
await page.click('.woofmark-command-insert');
// Select the option 'Nodes' from Menu: What Do you want to insert?
await page.waitForSelector('.dropdownMenu1');
await page.click('.dropdownMenu1');
await page.waitForSelector('.Nodes');
await page.click('.Nodes');
// Select the option 'List' from Menu: Insert as a?
await page.waitForSelector('.dropdownMenu2');
await page.click('.dropdownMenu2');
await page.waitForSelector('.List');
await page.click('.List');
// Add input tag
await page.$eval('.inputText', (el) => el.value = 'tag');
// Press the Go! button
await page.click('.go1');
await page.click('.woofmark-command-insert');
// Evaluate the expression
await page.waitForSelector('.powertags');
const stringIsIncluded = await page.evaluate(() => document.querySelector('.wk-wysiwyg').textContent.includes("Power tag: nodes:tag"));
expect(stringIsIncluded).toBe(true);
describe("Custom Insert text", () => {
test(
"Add Custom Insert text in rich text mode",
async () => {
try {
if (
await page.evaluate(() =>
$(".woofmark-mode-markdown").is(":disabled")
)
) {
await page.click(".woofmark-mode-wysiwyg");
}
await page.waitForSelector(".ple-module-body");
// Click on insert text button
await page.click(".woofmark-command-insert");
// Select the option 'Nodes' from Menu: What Do you want to insert?
await page.waitForSelector(".dropdownMenu1");
await page.click(".dropdownMenu1");
await page.waitForSelector(".Nodes");
await page.click(".Nodes");
// Select the option 'List' from Menu: Insert as a?
await page.waitForSelector(".dropdownMenu2");
await page.click(".dropdownMenu2");
await page.waitForSelector(".List");
await page.click(".List");
// Add input tag
await page.$eval(".inputText", (el) => (el.value = "tag"));
// Press the Go! button
await page.click(".go1");
await page.click(".woofmark-command-insert");
// Evaluate the expression
await page.waitForSelector(".powertags");
const stringIsIncluded = await page.evaluate(() =>
document
.querySelector(".wk-wysiwyg")
.textContent.includes("Power tag: nodes:tag")
);
expect(stringIsIncluded).toBe(true);

await page.waitForSelector('.woofmark-mode-markdown');
await page.click('.woofmark-mode-markdown');
await page.screenshot({path: 'buddy-screenshot1.png', fullPage: true});
await page.waitForSelector('.ple-module-body');
// await page.evaluate(() => document.querySelector('.ple-textarea').value += ' ');
// Click on insert text button
await page.click('.woofmark-command-insert');
// Select the option 'Notes' from Menu: What Do you want to insert?
await page.waitForSelector('.dropdownMenu1');
await page.click('.dropdownMenu1');
await page.screenshot({path: 'buddy-screenshot11.png', fullPage: true});
await page.waitForSelector('.Notes');
await page.screenshot({path: 'buddy-screenshot2.png', fullPage: true});
await page.click('.Notes');
await page.screenshot({path: 'buddy-screenshot3.png'});
// Select the option 'List' from Menu: Insert as a?
await page.waitForSelector('.dropdownMenu2');
await page.click('.dropdownMenu2');
await page.waitForSelector('.List');
await page.click('.List');
await page.screenshot({path: 'buddy-screenshot4.png'});
// Add input tag
await page.$eval('.inputText', (el) => el.value = 'tag');
// Press the Go! button
await page.click('.go1');
await page.click('.woofmark-command-insert');
// Evaluate the expression
const stringIsIncluded2 = await page.evaluate(() => document.querySelector('.ple-textarea').value.includes('[notes:tag]'));
expect(stringIsIncluded2).toBe(true);
await page.click('.woofmark-mode-wysiwyg');
} catch (err) {
// console.log(err);
}
}, timeout);
await page.waitForSelector(".woofmark-mode-markdown");
await page.click(".woofmark-mode-markdown");
await page.screenshot({
path: "buddy-screenshot1.png",
fullPage: true,
});
await page.waitForSelector(".ple-module-body");
// await page.evaluate(() => document.querySelector('.ple-textarea').value += ' ');
// Click on insert text button
await page.click(".woofmark-command-insert");
// Select the option 'Notes' from Menu: What Do you want to insert?
await page.waitForSelector(".dropdownMenu1");
await page.click(".dropdownMenu1");
await page.screenshot({
path: "buddy-screenshot11.png",
fullPage: true,
});
await page.waitForSelector(".Notes");
await page.screenshot({
path: "buddy-screenshot2.png",
fullPage: true,
});
await page.click(".Notes");
await page.screenshot({ path: "buddy-screenshot3.png" });
// Select the option 'List' from Menu: Insert as a?
await page.waitForSelector(".dropdownMenu2");
await page.click(".dropdownMenu2");
await page.waitForSelector(".List");
await page.click(".List");
await page.screenshot({ path: "buddy-screenshot4.png" });
// Add input tag
await page.$eval(".inputText", (el) => (el.value = "tag"));
// Press the Go! button
await page.click(".go1");
await page.click(".woofmark-command-insert");
// Evaluate the expression
const stringIsIncluded2 = await page.evaluate(() =>
document.querySelector(".ple-textarea").value.includes("[notes:tag]")
);
expect(stringIsIncluded2).toBe(true);
await page.click(".woofmark-mode-wysiwyg");
} catch (err) {
// console.log(err);
}
},
timeout
);
});
102 changes: 64 additions & 38 deletions test/ui-testing/bold.test.js
Original file line number Diff line number Diff line change
@@ -1,47 +1,73 @@
const timeout = process.env.SLOWMO ? 60000 : 15000;
const fs = require('fs');
let timeout = process.env.SLOWMO ? 60000 : 15000;
let fs = require("fs");
beforeAll(async () => {
path = fs.realpathSync('file://../examples/index.html');
await page.goto('file://' + path, {waitUntil: 'domcontentloaded'});
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 () => {
// switches to wysiwyg mode if it is in markdown mode
if (await page.evaluate(() => $(".woofmark-mode-markdown").is(":disabled"))) {
await page.click('.woofmark-mode-wysiwyg');
}
describe("Bold Text", () => {
test(
"Adds strong text in rich text mode",
async () => {
// switches to wysiwyg mode if it is in markdown mode
if (
await page.evaluate(() => $(".woofmark-mode-markdown").is(":disabled"))
) {
await page.click(".woofmark-mode-wysiwyg");
}

// clicks on bold button and checks if 'strong text' is added in the editor
await page.waitForSelector('.ple-module-body');
await page.waitForSelector('.wk-wysiwyg');
await page.keyboard.press('Backspace');
await page.click('.woofmark-command-bold');
// clicks on bold button and checks if 'strong text' is added in the editor
await page.waitForSelector(".ple-module-body");
await page.waitForSelector(".wk-wysiwyg");
await page.keyboard.press("Backspace");
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);
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);
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);
// 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);
// 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
);
});
73 changes: 44 additions & 29 deletions test/ui-testing/center.test.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,50 @@
const timeout = process.env.SLOWMO ? 60000 : 15000;
const fs = require('fs');
let timeout = process.env.SLOWMO ? 60000 : 15000;
fs = require("fs");
beforeAll(async () => {
path = fs.realpathSync('file://../examples/index.html');
await page.goto('file://' + path, {waitUntil: 'domcontentloaded'});
path = fs.realpathSync("file://../examples/index.html");
await page.goto("file://" + path, { waitUntil: "domcontentloaded" });
});

describe('Center Text', () => {
test('Centering and decentering text', async () => {
// selects a string from textarea in md mode
await page.setViewport({width: 1920, height: 1080});
if (await page.evaluate(() => $(".woofmark-mode-wysiwyg").is(":disabled"))) {
await page.click('.woofmark-mode-markdown');
}
await page.waitForSelector('.ple-module-body');
await page.focus('.ple-textarea');
describe("Center Text", () => {
test(
"Centering and decentering text",
async () => {
// selects a string from textarea in md mode
await page.setViewport({ width: 1920, height: 1080 });
if (
await page.evaluate(() => $(".woofmark-mode-wysiwyg").is(":disabled"))
) {
await page.click(".woofmark-mode-markdown");
} else {
await page.waitForSelector(".ple-module-body");
await page.focus(".ple-textarea");
}

// center aligns the string and checks for presence of '->' and '<-'
await page.click('.woofmark-command-autocenter');
let opening = await page.evaluate(() => document.querySelector('.ple-textarea').value.includes('->'));
let closing = await page.evaluate(() => document.querySelector('.ple-textarea').value.includes('<-'));
expect(opening).toBe(true);
expect(closing).toBe(true);
// center aligns the string and checks for presence of '->' and '<-'
await page.click(".woofmark-command-autocenter");
let opening = await page.evaluate(() =>
document.querySelector(".ple-textarea").value.includes("->")
);
let closing = await page.evaluate(() =>
document.querySelector(".ple-textarea").value.includes("<-")
);
expect(opening).toBe(true);
expect(closing).toBe(true);

// the selection changes from '-> some text <-' to ->'some text'<-
await page.click('.woofmark-command-autocenter');
// clicking again removes the center alignment and tests for absence of '->' and '<-'
await page.click('.woofmark-command-autocenter');
opening = await page.evaluate(() => document.querySelector('.ple-textarea').value.includes('->'));
closing = await page.evaluate(() => document.querySelector('.ple-textarea').value.includes('<-'));
expect(opening).toBe(false);
expect(closing).toBe(false);
await page.click('.woofmark-mode-wysiwyg');
}, timeout);
// the selection changes from '-> some text <-' to ->'some text'<-
await page.click(".woofmark-command-autocenter");
// clicking again removes the center alignment and tests for absence of '->' and '<-'
await page.click(".woofmark-command-autocenter");
opening = await page.evaluate(() =>
document.querySelector(".ple-textarea").value.includes("->")
);
closing = await page.evaluate(() =>
document.querySelector(".ple-textarea").value.includes("<-")
);
expect(opening).toBe(false);
expect(closing).toBe(false);
await page.click(".woofmark-mode-wysiwyg");
},
timeout
);
});
Loading