ep_font_size 0.4.103 → 0.4.104

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "description": "Apply sizes to fonts",
3
3
  "name": "ep_font_size",
4
- "version": "0.4.103",
4
+ "version": "0.4.104",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
7
7
  "name": "John McLear",
@@ -0,0 +1,73 @@
1
+ import {expect, test} from '@playwright/test';
2
+ import {clearPadContent, getPadBody, goToNewPad, selectAllText, writeToPad}
3
+ from 'ep_etherpad-lite/tests/frontend-new/helper/padHelper';
4
+
5
+ test.beforeEach(async ({page}) => {
6
+ await goToNewPad(page);
7
+ });
8
+
9
+ test.describe('ep_font_size', () => {
10
+ // The #font-size <select> is wrapped by niceSelect, which intercepts
11
+ // native change events. Mirror the legacy spec by setting .value on
12
+ // the underlying <select> and dispatching change manually.
13
+ const setFontSizeIndex = (page: any, index: string) => page.evaluate((i: string) => {
14
+ const sel = document.querySelector<HTMLSelectElement>('#font-size')!;
15
+ sel.value = i;
16
+ sel.dispatchEvent(new Event('change', {bubbles: true}));
17
+ }, index);
18
+
19
+ test('Changes from size 8 to 9 and back to 8', async ({page}) => {
20
+ const padBody = await getPadBody(page);
21
+ await padBody.click();
22
+ await clearPadContent(page);
23
+ await writeToPad(page, 'foo');
24
+ await selectAllText(page);
25
+
26
+ // Index 1 → font-size:9
27
+ await setFontSizeIndex(page, '1');
28
+ await expect(
29
+ padBody.locator('div').first().locator('span').first()
30
+ ).toHaveClass(/font-size:9/);
31
+
32
+ await selectAllText(page);
33
+
34
+ // Index 0 → font-size:8
35
+ await setFontSizeIndex(page, '0');
36
+ await expect(
37
+ padBody.locator('div').first().locator('span').first()
38
+ ).toHaveClass(/font-size:8/);
39
+ });
40
+
41
+ // Regression test for ep_font_size#4914: applying very large font to
42
+ // ~120 lines should grow ace_inner past 2000px (the legacy bug pinned
43
+ // the iframe to a smaller height regardless of content).
44
+ test('iframe height grows under very large font (regression #4914)', async ({page}) => {
45
+ const padBody = await getPadBody(page);
46
+ await padBody.click();
47
+ await clearPadContent(page);
48
+
49
+ // Build content quickly via the inner DOM rather than typing 120 lines.
50
+ const numLines = 120;
51
+ const innerFrame = page.frame('ace_inner')!;
52
+ await innerFrame.evaluate((n: number) => {
53
+ const body = document.getElementById('innerdocbody')!;
54
+ body.innerHTML = '';
55
+ for (let i = 0; i < n - 1; i++) body.appendChild(document.createElement('div'));
56
+ const last = document.createElement('div');
57
+ last.textContent = 'Very large text that ideally spans across multiple lines';
58
+ body.appendChild(last);
59
+ }, numLines);
60
+
61
+ await page.waitForTimeout(800);
62
+ await selectAllText(page);
63
+
64
+ // Index 22 → font-size:60 (largest published option in the legacy spec).
65
+ await setFontSizeIndex(page, '22');
66
+
67
+ const heightOf = () => page.evaluate(() => {
68
+ const f = document.querySelector<HTMLIFrameElement>('iframe[name="ace_inner"]')!;
69
+ return parseInt(window.getComputedStyle(f).height || '0', 10);
70
+ });
71
+ await expect.poll(heightOf, {timeout: 10_000}).toBeGreaterThan(2000);
72
+ });
73
+ });
@@ -1,48 +0,0 @@
1
- 'use strict';
2
-
3
- describe('ep_font_size - Select font-size dropdown localization', function () {
4
- const changeEtherpadLanguageTo = async (lang) => {
5
- const boldTitles = {
6
- en: 'Bold (Ctrl+B)',
7
- fr: 'Gras (Ctrl + B)',
8
- };
9
- const chrome$ = helper.padChrome$;
10
-
11
- // click on the settings button to make settings visible
12
- const $settingsButton = chrome$('.buttonicon-settings');
13
- $settingsButton.click();
14
-
15
- // select the language
16
- const $language = chrome$('#languagemenu');
17
- $language.val(lang);
18
- $language.change();
19
-
20
- // hide settings again
21
- $settingsButton.click();
22
-
23
- await helper.waitForPromise(
24
- () => chrome$('.buttonicon-bold').parent()[0].title === boldTitles[lang]);
25
- };
26
-
27
- // create a new pad with comment before each test run
28
- beforeEach(async function () {
29
- this.timeout(60000);
30
- await helper.aNewPad();
31
- await changeEtherpadLanguageTo('fr');
32
- });
33
-
34
- // ensure we go back to English to avoid breaking other tests:
35
- after(async function () {
36
- await changeEtherpadLanguageTo('en');
37
- });
38
-
39
- it('Localizes dropdown when Etherpad language is changed', async function () {
40
- const optionTranslations = {
41
- 'ep_font_size.size': 'Taille de police',
42
- };
43
- const chrome$ = helper.padChrome$;
44
- const $option = chrome$('#editbar').find('#font-size').find('option').first();
45
-
46
- expect($option.text()).to.be(optionTranslations[$option.attr('data-l10n-id')]);
47
- });
48
- });
@@ -1,74 +0,0 @@
1
- 'use strict';
2
-
3
- describe('ep_font_size - Set Font size and ensure its removed properly', function () {
4
- // Tests still to do
5
- // Ensure additional chars keep the same formatting
6
- // Ensure heading value is properly set when caret is placed on font size changed content
7
-
8
- // create a new pad before each test run
9
- beforeEach(async function () {
10
- this.timeout(60000);
11
- await helper.aNewPad();
12
- });
13
-
14
- // Create Pad
15
- // Select all text
16
- // Set it to size 9
17
- // Select all text
18
- // Set it to size 8
19
-
20
- it('Changes from size 8 to 9 and back to 8', async function () {
21
- this.timeout(60000);
22
- const chrome$ = helper.padChrome$;
23
- const inner$ = helper.padInner$;
24
-
25
- let $firstTextElement = inner$('div').first();
26
-
27
- $firstTextElement.sendkeys('foo');
28
- $firstTextElement.sendkeys('{selectall}');
29
-
30
- // sets first line to Font size 9
31
- chrome$('#font-size').val('1');
32
- chrome$('#font-size').change();
33
-
34
- let fElement = inner$('div').first();
35
- await helper.waitForPromise(() => {
36
- const elementHasClass = fElement.children().first().hasClass('font-size:9');
37
- return expect(elementHasClass).to.be(true);
38
- });
39
- $firstTextElement = inner$('div').first();
40
- $firstTextElement.sendkeys('{selectall}');
41
- // sets first line to Font size 8
42
- chrome$('#font-size').val('0');
43
- chrome$('#font-size').change();
44
- await helper.waitForPromise(() => {
45
- fElement = inner$('div').first();
46
- const elementHasClass = fElement.children().first().hasClass('font-size:8');
47
- return expect(elementHasClass).to.be(true);
48
- });
49
- });
50
-
51
- it('iframe height is correct using very large font, regression for #4914', async function () {
52
- await helper.clearPad();
53
- const height = () => parseInt(window.getComputedStyle(
54
- helper.padOuter$("iframe[name='ace_inner']").get(0)).height);
55
- expect(height()).to.not.be.above(2000);
56
-
57
- const numLines = 120;
58
- await helper.edit('\n'.repeat(numLines - 1));
59
- await helper.edit('Very large text that ideally spans across multiple lines');
60
- await helper.edit('Another very large text that should span across multiple lines', 80);
61
-
62
- const lines = helper.linesDiv();
63
- expect(lines.length).to.be(numLines);
64
- helper.selectLines(lines[0], lines[lines.length - 1]);
65
- await helper.waitForPromise(() => !helper.padInner$.document.getSelection().isCollapsed);
66
-
67
- // font size 60
68
- helper.padChrome$('#font-size').val('22');
69
- helper.padChrome$('#font-size').change();
70
-
71
- // ace_inner should be above 2000px now
72
- await helper.waitForPromise(() => height() > 2000);
73
- });
74
- });