mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-05-06 07:07:12 -04:00
Ported more tests to playwright.
This commit is contained in:
parent
d8e0975f97
commit
0d7bca27c1
11 changed files with 282 additions and 231 deletions
39
src/tests/frontend-new/specs/font_type.spec.ts
Normal file
39
src/tests/frontend-new/specs/font_type.spec.ts
Normal file
|
@ -0,0 +1,39 @@
|
|||
import {expect, test} from "@playwright/test";
|
||||
import {getPadBody, goToNewPad} from "../helper/padHelper";
|
||||
import {showSettings} from "../helper/settingsHelper";
|
||||
|
||||
test.beforeEach(async ({ page })=>{
|
||||
// create a new pad before each test run
|
||||
await goToNewPad(page);
|
||||
})
|
||||
|
||||
|
||||
test.describe('font select', function () {
|
||||
// create a new pad before each test run
|
||||
|
||||
test('makes text RobotoMono', async function ({page}) {
|
||||
// click on the settings button to make settings visible
|
||||
await showSettings(page);
|
||||
|
||||
// get the font menu and RobotoMono option
|
||||
const viewFontMenu = page.locator('#viewfontmenu');
|
||||
|
||||
// select RobotoMono and fire change event
|
||||
// $RobotoMonooption.attr('selected','selected');
|
||||
// commenting out above will break safari test
|
||||
const dropdown = page.locator('.dropdowns-container .dropdown-line .current').nth(0)
|
||||
await dropdown.click()
|
||||
await page.locator('li:text("RobotoMono")').click()
|
||||
|
||||
await viewFontMenu.dispatchEvent('change');
|
||||
const padBody = await getPadBody(page)
|
||||
const color = await padBody.evaluate((e) => {
|
||||
return window.getComputedStyle(e).getPropertyValue("font-family")
|
||||
})
|
||||
|
||||
|
||||
// check if font changed to RobotoMono
|
||||
const containsStr = color.toLowerCase().indexOf('robotomono');
|
||||
expect(containsStr).not.toBe(-1);
|
||||
});
|
||||
});
|
56
src/tests/frontend-new/specs/inner_height.spec.ts
Normal file
56
src/tests/frontend-new/specs/inner_height.spec.ts
Normal file
|
@ -0,0 +1,56 @@
|
|||
'use strict';
|
||||
|
||||
import {expect, test} from "@playwright/test";
|
||||
import {clearPadContent, getPadBody, goToNewPad, writeToPad} from "../helper/padHelper";
|
||||
|
||||
test.beforeEach(async ({ page })=>{
|
||||
await goToNewPad(page);
|
||||
})
|
||||
|
||||
test.describe('height regression after ace.js refactoring', function () {
|
||||
|
||||
test('clientHeight should equal scrollHeight with few lines', async function ({page}) {
|
||||
const padBody = await getPadBody(page);
|
||||
await padBody.click()
|
||||
await clearPadContent(page)
|
||||
|
||||
const iframe = page.locator('iframe').first()
|
||||
const scrollHeight = await iframe.evaluate((element) => {
|
||||
return element.scrollHeight;
|
||||
})
|
||||
|
||||
const clientHeight = await iframe.evaluate((element) => {
|
||||
return element.clientHeight;
|
||||
})
|
||||
|
||||
|
||||
expect(clientHeight).toEqual(scrollHeight);
|
||||
});
|
||||
|
||||
test('client height should be less than scrollHeight with many lines', async function ({page}) {
|
||||
const padBody = await getPadBody(page);
|
||||
await padBody.click()
|
||||
await clearPadContent(page)
|
||||
|
||||
await writeToPad(page,'Test line\n' +
|
||||
'\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' +
|
||||
'\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' +
|
||||
'\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' +
|
||||
'\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' +
|
||||
'\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' +
|
||||
'\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' +
|
||||
'\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n');
|
||||
|
||||
const iframe = page.locator('iframe').first()
|
||||
const scrollHeight = await iframe.evaluate((element) => {
|
||||
return element.scrollHeight;
|
||||
})
|
||||
|
||||
const clientHeight = await iframe.evaluate((element) => {
|
||||
return element.clientHeight;
|
||||
})
|
||||
|
||||
// Need to poll because the heights take some time to settle.
|
||||
expect(clientHeight).toBeLessThanOrEqual(scrollHeight);
|
||||
});
|
||||
});
|
65
src/tests/frontend-new/specs/italic.spec.ts
Normal file
65
src/tests/frontend-new/specs/italic.spec.ts
Normal file
|
@ -0,0 +1,65 @@
|
|||
import {expect, test} from "@playwright/test";
|
||||
import {clearPadContent, getPadBody, goToNewPad, writeToPad} from "../helper/padHelper";
|
||||
|
||||
test.beforeEach(async ({ page })=>{
|
||||
await goToNewPad(page);
|
||||
})
|
||||
|
||||
test.describe('italic some text', function () {
|
||||
|
||||
test('makes text italic using button', async function ({page}) {
|
||||
const padBody = await getPadBody(page);
|
||||
await padBody.click()
|
||||
await clearPadContent(page)
|
||||
|
||||
// get the first text element out of the inner iframe
|
||||
const $firstTextElement = padBody.locator('div').first();
|
||||
await $firstTextElement.click()
|
||||
await writeToPad(page, 'Foo')
|
||||
|
||||
// select this text element
|
||||
await padBody.click()
|
||||
await page.keyboard.press('Control+A');
|
||||
|
||||
// get the bold button and click it
|
||||
const $boldButton = page.locator('.buttonicon-italic');
|
||||
await $boldButton.click();
|
||||
|
||||
// ace creates a new dom element when you press a button, just get the first text element again
|
||||
const $newFirstTextElement = padBody.locator('div').first();
|
||||
|
||||
// is there a <i> element now?
|
||||
// expect it to be italic
|
||||
await expect($newFirstTextElement.locator('i')).toHaveCount(1);
|
||||
|
||||
|
||||
// make sure the text hasn't changed
|
||||
expect(await $newFirstTextElement.textContent()).toEqual(await $firstTextElement.textContent());
|
||||
});
|
||||
|
||||
test('makes text italic using keypress', async function ({page}) {
|
||||
const padBody = await getPadBody(page);
|
||||
await padBody.click()
|
||||
await clearPadContent(page)
|
||||
|
||||
// get the first text element out of the inner iframe
|
||||
const $firstTextElement = padBody.locator('div').first();
|
||||
|
||||
// select this text element
|
||||
await writeToPad(page, 'Foo')
|
||||
|
||||
await page.keyboard.press('Control+A');
|
||||
|
||||
await page.keyboard.press('Control+I');
|
||||
|
||||
// ace creates a new dom element when you press a button, just get the first text element again
|
||||
const $newFirstTextElement = padBody.locator('div').first();
|
||||
|
||||
// is there a <i> element now?
|
||||
// expect it to be italic
|
||||
await expect($newFirstTextElement.locator('i')).toHaveCount(1);
|
||||
|
||||
// make sure the text hasn't changed
|
||||
expect(await $newFirstTextElement.textContent()).toBe(await $firstTextElement.textContent());
|
||||
});
|
||||
});
|
65
src/tests/frontend-new/specs/redo.spec.ts
Normal file
65
src/tests/frontend-new/specs/redo.spec.ts
Normal file
|
@ -0,0 +1,65 @@
|
|||
import {expect, test} from "@playwright/test";
|
||||
import {clearPadContent, getPadBody, goToNewPad, writeToPad} from "../helper/padHelper";
|
||||
|
||||
test.beforeEach(async ({ page })=>{
|
||||
await goToNewPad(page);
|
||||
})
|
||||
|
||||
|
||||
test.describe('undo button then redo button', function () {
|
||||
|
||||
|
||||
test('redo some typing with button', async function ({page}) {
|
||||
const padBody = await getPadBody(page);
|
||||
|
||||
// get the first text element inside the editable space
|
||||
const $firstTextElement = padBody.locator('div span').first();
|
||||
const originalValue = await $firstTextElement.textContent(); // get the original value
|
||||
const newString = 'Foo';
|
||||
|
||||
await $firstTextElement.focus()
|
||||
expect(await $firstTextElement.textContent()).toContain(originalValue);
|
||||
await padBody.click()
|
||||
await clearPadContent(page)
|
||||
await writeToPad(page, newString); // send line 1 to the pad
|
||||
|
||||
const modifiedValue = await $firstTextElement.textContent(); // get the modified value
|
||||
expect(modifiedValue).not.toBe(originalValue); // expect the value to change
|
||||
|
||||
// get undo and redo buttons // click the buttons
|
||||
await page.locator('.buttonicon-undo').click() // removes foo
|
||||
await page.locator('.buttonicon-redo').click() // resends foo
|
||||
|
||||
await expect($firstTextElement).toHaveText(newString);
|
||||
|
||||
const finalValue = await padBody.locator('div').first().textContent();
|
||||
expect(finalValue).toBe(modifiedValue); // expect the value to change
|
||||
});
|
||||
|
||||
test('redo some typing with keypress', async function ({page}) {
|
||||
const padBody = await getPadBody(page);
|
||||
|
||||
// get the first text element inside the editable space
|
||||
const $firstTextElement = padBody.locator('div span').first();
|
||||
const originalValue = await $firstTextElement.textContent(); // get the original value
|
||||
const newString = 'Foo';
|
||||
|
||||
await padBody.click()
|
||||
await clearPadContent(page)
|
||||
await writeToPad(page, newString); // send line 1 to the pad
|
||||
const modifiedValue = await $firstTextElement.textContent(); // get the modified value
|
||||
expect(modifiedValue).not.toBe(originalValue); // expect the value to change
|
||||
|
||||
// undo the change
|
||||
await padBody.click()
|
||||
await page.keyboard.press('Control+Z');
|
||||
|
||||
await page.keyboard.press('Control+Y'); // redo the change
|
||||
|
||||
|
||||
await expect($firstTextElement).toHaveText(newString);
|
||||
|
||||
const finalValue = await padBody.locator('div').first().textContent();
|
||||
expect(finalValue).toBe(modifiedValue); // expect the value to change
|
||||
});
|
||||
});
|
55
src/tests/frontend-new/specs/undo.spec.ts
Normal file
55
src/tests/frontend-new/specs/undo.spec.ts
Normal file
|
@ -0,0 +1,55 @@
|
|||
'use strict';
|
||||
|
||||
import {expect, test} from "@playwright/test";
|
||||
import {clearPadContent, getPadBody, goToNewPad, writeToPad} from "../helper/padHelper";
|
||||
|
||||
test.beforeEach(async ({ page })=>{
|
||||
await goToNewPad(page);
|
||||
})
|
||||
|
||||
|
||||
test.describe('undo button', function () {
|
||||
|
||||
test('undo some typing by clicking undo button', async function ({page}) {
|
||||
const padBody = await getPadBody(page);
|
||||
await padBody.click()
|
||||
await clearPadContent(page)
|
||||
|
||||
|
||||
// get the first text element inside the editable space
|
||||
const firstTextElement = padBody.locator('div').first()
|
||||
const originalValue = await firstTextElement.textContent(); // get the original value
|
||||
await firstTextElement.focus()
|
||||
|
||||
await writeToPad(page, 'foo'); // send line 1 to the pad
|
||||
|
||||
const modifiedValue = await firstTextElement.textContent(); // get the modified value
|
||||
expect(modifiedValue).not.toBe(originalValue); // expect the value to change
|
||||
|
||||
// get clear authorship button as a variable
|
||||
const undoButton = page.locator('.buttonicon-undo')
|
||||
await undoButton.click() // click the button
|
||||
|
||||
await expect(firstTextElement).toHaveText(originalValue!);
|
||||
});
|
||||
|
||||
test('undo some typing using a keypress', async function ({page}) {
|
||||
const padBody = await getPadBody(page);
|
||||
await padBody.click()
|
||||
await clearPadContent(page)
|
||||
|
||||
// get the first text element inside the editable space
|
||||
const firstTextElement = padBody.locator('div').first()
|
||||
const originalValue = await firstTextElement.textContent(); // get the original value
|
||||
|
||||
await firstTextElement.focus()
|
||||
await writeToPad(page, 'foo'); // send line 1 to the pad
|
||||
const modifiedValue = await firstTextElement.textContent(); // get the modified value
|
||||
expect(modifiedValue).not.toBe(originalValue); // expect the value to change
|
||||
|
||||
// undo the change
|
||||
await page.keyboard.press('Control+Z');
|
||||
|
||||
await expect(firstTextElement).toHaveText(originalValue!);
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue