Wait for the layout in the Find width test
The documentFind smoke test failed about 1 run in 6 with "Find spans the document pane". It read two widths in separate steps while the outline closed after a resize. The app did not change. - The test waits for the outline to close. - The test reads both widths in one task.
This commit is contained in:
@@ -33,9 +33,9 @@ await runSmoke("find/documentFind", async ({ page }) => {
|
|||||||
async function onePanel() {
|
async function onePanel() {
|
||||||
assert.equal(await page.locator('.rs-find-bar:visible').count(), 1);
|
assert.equal(await page.locator('.rs-find-bar:visible').count(), 1);
|
||||||
assert.equal(await page.locator('.cm-search').count(), 0, 'No default CodeMirror search panel');
|
assert.equal(await page.locator('.cm-search').count(), 0, 'No default CodeMirror search panel');
|
||||||
const bar = await page.locator('.rs-find-bar:visible').boundingBox();
|
// Read both widths in one task. Two separate reads can cross a layout change.
|
||||||
const pane = await page.locator('.editor.pane-active').boundingBox();
|
const [bar, pane] = await page.locator('.rs-find-bar:visible').evaluate(node => [node, node.closest('.editor.pane-active')].map(element => element.getBoundingClientRect().width));
|
||||||
assert.ok(Math.abs(bar.width - pane.width) < 3, 'Find spans the document pane');
|
assert.ok(Math.abs(bar - pane) < 3, 'Find spans the document pane');
|
||||||
}
|
}
|
||||||
async function sourceEditor() {
|
async function sourceEditor() {
|
||||||
await page.waitForFunction(() => !!document.querySelector('.source-editor .cm-content'));
|
await page.waitForFunction(() => !!document.querySelector('.source-editor .cm-content'));
|
||||||
@@ -120,6 +120,8 @@ await runSmoke("find/documentFind", async ({ page }) => {
|
|||||||
await page.keyboard.press('F3');
|
await page.keyboard.press('F3');
|
||||||
await page.screenshot({ path: `${output}/source-replace-${theme}.png` });
|
await page.screenshot({ path: `${output}/source-replace-${theme}.png` });
|
||||||
await page.setViewportSize({ width: 800, height: 700 });
|
await page.setViewportSize({ width: 800, height: 700 });
|
||||||
|
// The outline closes in the resize event, one frame after the viewport changes. The pane width changes again at that point.
|
||||||
|
await page.locator('.shell.right-open').waitFor({ state: 'detached' });
|
||||||
await onePanel();
|
await onePanel();
|
||||||
assert.equal(await page.locator('.rs-find-bar').evaluate(node => node.scrollWidth <= node.clientWidth), true);
|
assert.equal(await page.locator('.rs-find-bar').evaluate(node => node.scrollWidth <= node.clientWidth), true);
|
||||||
await page.screenshot({ path: `${output}/source-narrow-${theme}.png` });
|
await page.screenshot({ path: `${output}/source-narrow-${theme}.png` });
|
||||||
|
|||||||
Reference in New Issue
Block a user