Commit 88aee9d7 authored by Robert Knight's avatar Robert Knight

Make HTML side-by-side tests tolerate more variation in window size

The tests previously assumed a window width of 800px. This changed recently and
in Chrome 130, is 1200px. Revise two tests that were failing locally to tolerate
more variation in the window size.
parent eeba7ec5
...@@ -215,9 +215,14 @@ describe('HTMLIntegration', () => { ...@@ -215,9 +215,14 @@ describe('HTMLIntegration', () => {
it('does not set left and right margins if there is not enough room to enable', () => { it('does not set left and right margins if there is not enough room to enable', () => {
const integration = createIntegration(); const integration = createIntegration();
// Minimum available content width for side-by-side is 480 // Minimum content width for side-by-side to activate.
// window.innerWidth (800) - 321 = 479 --> too small const minSideBySideWidth = 480;
integration.fitSideBySide({ expanded: true, width: 321 });
// Create a sidebar width which leaves less than `minSideBySideWidth` px
// available for the content.
const sidebarWidth = window.innerWidth - minSideBySideWidth + 1;
assert.isAbove(sidebarWidth, 1);
integration.fitSideBySide({ expanded: true, width: sidebarWidth });
assert.isFalse(integration.sideBySideActive()); assert.isFalse(integration.sideBySideActive());
assert.deepEqual(getMargins(), [null, null]); assert.deepEqual(getMargins(), [null, null]);
...@@ -339,19 +344,19 @@ describe('HTMLIntegration', () => { ...@@ -339,19 +344,19 @@ describe('HTMLIntegration', () => {
it('may move the main content to the left to make room for sidebar', () => { it('may move the main content to the left to make room for sidebar', () => {
const integration = createIntegration(); const integration = createIntegration();
const [leftMargin, rightMargin] = getComputedMargins(document.body);
// Will result in right margin of 262 (250 + 12 padding) // Choose a sidebar width that doesn't require moving the main content.
integration.fitSideBySide({ expanded: true, width: 250 }); assert.isAbove(rightMargin, 100);
integration.fitSideBySide({ expanded: true, width: 100 });
let [newLeftMargin] = getComputedMargins(document.body);
assert.equal(newLeftMargin, leftMargin);
// The amount of space available to the left of the body is now _less_ // Choose a sidebar width that does require moving the main content.
// than the original auto-left-margin. This is fine: let the auto integration.fitSideBySide({ expanded: true, width: rightMargin });
// margin re-adjust to the available amount of space (move to the left):
const updatedMargins = getComputedMargins(document.body); [newLeftMargin] = getComputedMargins(document.body);
const expectedLeftMargin = Math.floor( assert.isBelow(newLeftMargin, leftMargin);
window.innerWidth - bodyWidth - 262,
);
assert.equal(updatedMargins[0], expectedLeftMargin);
assert.isBelow(updatedMargins[0], autoMargin);
}); });
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment