8000 TINY-9219: Fix broken tests on Firefox (#8158) · tinymce/tinymce@5421ec9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5421ec9

Browse files
MitchC1999spocke
andauthored
TINY-9219: Fix broken tests on Firefox (#8158)
* TINY-9200: Fix broken tests on Firefox (#8155) * TINY-9200: excluded source from style checking * TINY-9200: switched table tests to use inline block over text * TINY-9200: added check for linux firefox scrollbar widths * TINY-9200: increased the fuzzy assert from 2 to 4 on table widths * TINY-9200: cleanup * TINY-9200: added check for Win 11 * TINY-9200: firefox check for Win11 scrollbars * TINY-9200: added comment about source being hidden * TINY-9200: added comment about Firefox being of by 4 pixels * TINY-9200: Add fix to `TableTestUtils` * TINY-9200: Remove Windows version check * TINY-9200: Revert flaking test only for IE Co-authored-by: spocke <spocke@moxiecode.com>
1 parent f058ea7 commit 5421ec9

File tree

5 files changed

+12
-6
lines changed

5 files changed

+12
-6
lines changed

modules/snooker/src/test/ts/browser/ResizeTest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ describe('ResizeTest', () => {
220220
const table = SugarElement.fromHtml<HTMLTableElement>(`<table style="border-collapse: collapse; width: 800px;">
221221
<tbody>
222222
<tr>
223-
<td style="width: 400px;">thisisareallylongsentencewithoutspacesthatcausescontenttooverflow</td>
223+
<td style="width: 400px;"><span style="display: inline-block; width: 483px"></span></td>
224224
<td style="width: 400px;">B</td>
225225
</tr>
226226
<tr>

modules/snooker/src/test/ts/browser/TableSizeTest.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ const tOptional = OptionalInstances.tOptional;
1111

1212
describe('TableSizeTest', () => {
1313
const pixelTableHtml = '<table style="width: 400px; border-collapse: collapse;"><tbody><tr><td style="width: 200px"></td><td style="width: 200px"></td></tr></tbody></table>';
14-
const overflowingPixelTableHtml = '<table style="width: 400px; border-collapse: collapse;"><tbody><tr><td style="width: 200px">thisisareallylongsentencewithoutspacesthatcausescontenttooverflow</td><td style="width: 200px"></td></tr></tbody></table>';
14+
const overflowingPixelTableHtml = '<table style="width: 400px; border-collapse: collapse;"><tbody><tr><td style="width: 200px"><span style="display: inline-block; width: 483px"></span></td><td style="width: 200px"></td></tr></tbody></table>';
1515
const percentTableHtml = '<table style="width: 80%; border-collapse: collapse;"><tbody><tr><td style="width: 50%"></td><td style="width: 50%"></td></tr></tbody></table>';
16-
const overflowingPercentTableHtml = '<table style="width: 80%; border-collapse: collapse;"><tbody><tr><td style="width: 50%">thisisareallylongsentencewithoutspacesthatcausescontenttooverflow</td><td style="width: 50%"></td></tr></tbody></table>';
16+
const overflowingPercentTableHtml = '<table style="width: 80%; border-collapse: collapse;"><tbody><tr><td style="width: 50%"><span style="display: inline-block; width: 483px"></span></td><td style="width: 50%"></td></tr></tbody></table>';
1717
const noneTableHtml = '<table><tbody><tr><td></td><td></td></tr></tbody></table>';
1818

1919
context('getTableSize', () => {

modules/sugar/src/test/ts/browser/LocationTest.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ UnitTest.asynctest('LocationTest', (success, failure) => {
136136
pos = SugarLocation.viewport(body);
137137
assert.eq(0, pos.top);
138138
assert.eq(0, pos.left);
139-
assert.eq(true, scrollBarWidth > 5 && scrollBarWidth < 50 || (platform.os.isOSX() && scrollBarWidth === 0), 'scroll bar width, got=' + scrollBarWidth);
139+
const noVisibleScrollbarBrowser = platform.os.isOSX() || (platform.browser.isFirefox() && platform.os.isLinux());
140+
assert.eq(true, scrollBarWidth > 5 && scrollBarWidth < 50 || (noVisibleScrollbarBrowser && scrollBarWidth === 0), 'scroll bar width, got=' + scrollBarWidth);
140141
};
141142

142143
const disconnectedChecks = () => {

modules/sugar/src/test/ts/browser/ScrollTest.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ UnitTest.asynctest('ScrollTest', (success, failure) => {
135135
const cX = Math.round(center.left);
136136
const cY = Math.round(center.top);
137137

138-
assert.eq(true, scrollBarWidth > 5 && scrollBarWidth < 50 || (platform.os.isOSX() && scrollBarWidth === 0), 'scroll bar width, got=' + scrollBarWidth);
138+
const noVisibleScrollbarBrowser = platform.os.isOSX() || (platform.browser.isFirefox() && platform.os.isLinux());
139+
assert.eq(true, scrollBarWidth > 5 && scrollBarWidth < 50 || (noVisibleScrollbarBrowser && scrollBarWidth === 0), 'scroll bar width, got=' + scrollBarWidth);
139140

140141
scrollCheck(0, 0, 0, 0, doc, 'start pos');
141142

modules/tinymce/src/plugins/table/test/ts/module/test/TableTestUtils.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { ApproxStructure, Assertions, Cursors, Mouse, StructAssert, UiFinder, Waiter } from '@ephox/agar';
22
import { Arr, Obj } from '@ephox/katamari';
3+
import { PlatformDetection } from '@ephox/sand';
34
import { Attribute, Checked, Class, Html, SelectorFilter, SelectorFind, SugarBody, SugarElement, Value } from '@ephox/sugar';
45
import { TinyAssertions, TinyContentActions, TinyDom, TinySelections, TinyUiActions } from '@ephox/wrap-mcagar';
56
import { assert } from 'chai';
@@ -52,7 +53,10 @@ const assertWidth = (editor: Editor, elm: HTMLElement, expectedWidth: number | n
5253
if (expectedWidth === null) {
5354
assert.isNull(widthData.raw, `${nodeName} width should not be set`);
5455
} else {
55-
assert.approximately(widthData.raw, expectedWidth, 2, `${nodeName} width is ${expectedWidth} ~= ${widthData.raw}`);
56+
const platform = PlatformDetection.detect();
57+
// This does a approximately check with a delta of 4 to compensate for Firefox sometimes being off by 4 pixels depending on version and platform see TINY-9200 for details
58+
const delta = platform.browser.isFirefox() ? 4 : 2;
59+
assert.approximately(widthData.raw ?? -1, expectedWidth, delta, `${nodeName} width is ${expectedWidth} ~= ${widthData.raw}`);
5660
}
5761
assert.equal(widthData.unit, expectedUnit, `${nodeName} unit is ${expectedUnit}`);
5862
};

0 commit comments

Comments
 (0)
0