Skip to content

Commit 23d1367

Browse files
ktranDevtools-frontend LUCI CQ
authored andcommitted
Unflake navigator-view_test.ts
This is an attempt to unflake the test "which can scroll the navigator element into view on source file change" Bug: none Change-Id: I35d073ff785c3a215cfd86e29b9c0f15ad96e590 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/5975524 Commit-Queue: Ergün Erdoğmuş <[email protected]> Reviewed-by: Ergün Erdoğmuş <[email protected]> Auto-Submit: Kim-Anh Tran <[email protected]>
1 parent 90bdbd2 commit 23d1367

File tree

1 file changed

+12
-27
lines changed

1 file changed

+12
-27
lines changed

test/e2e/sources/navigator-view_test.ts

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,18 @@
55
import {assert} from 'chai';
66

77
import {
8+
click,
89
getBrowserAndPages,
910
waitFor,
10-
waitForElementWithTextContent,
1111
waitForFunction,
1212
waitForNone,
1313
} from '../../shared/helper.js';
1414
import {openSoftContextMenuAndClickOnItem} from '../helpers/context-menu-helpers.js';
1515
import {
16-
getMenuItemAtPosition,
17-
openFileQuickOpen,
1816
openFileWithQuickOpen,
1917
runCommandWithQuickOpen,
20-
typeIntoQuickOpen,
2118
} from '../helpers/quick_open-helpers.js';
2219
import {
23-
createNewSnippet,
2420
openFileInSourcesPanel,
2521
openSnippetsSubPane,
2622
openSourceCodeEditorForFile,
@@ -154,43 +150,32 @@ describe('The Sources panel', () => {
154150
});
155151

156152
it('which can scroll the navigator element into view on source file change', async () => {
157-
async function openSnippet(snippet: string) {
158-
await openFileQuickOpen();
159-
await typeIntoQuickOpen(snippet);
160-
const firstItem = await getMenuItemAtPosition(0);
161-
await firstItem.click();
162-
}
163-
164-
async function assertSnippetIsSelected(snippet: string) {
165-
const selectedItem = await waitFor('.navigator-file-tree-item.selected');
166-
const selectedItemName = await selectedItem.evaluate(node => node.textContent);
167-
assert.strictEqual(selectedItemName, snippet);
153+
async function openFirstSnippetInList() {
154+
const sourcesView = await waitFor('#sources-panel-sources-view');
155+
await click('[aria-label="More tabs"]', {root: sourcesView});
156+
await click('[aria-label="Script snippet #1"]');
168157
}
169158

170159
await openSourcesPanel();
171160
await openSnippetsSubPane();
172161

173162
const numSnippets = 50;
174163
for (let i = 0; i < numSnippets; ++i) {
175-
await createNewSnippet(`Snippet${i}`);
164+
await click('[aria-label="New snippet"]');
165+
await waitFor(`[aria-label="Script snippet #${i + 1}"]`);
176166
}
177-
const firstSnippetName = 'Snippet0';
178-
const lastSnippetName = `Snippet${numSnippets - 1}`;
179-
180-
await waitForElementWithTextContent(lastSnippetName);
181-
await assertSnippetIsSelected(lastSnippetName);
182167

183168
const snippetsPanel = await waitFor('[aria-label="Snippets panel"]');
184169
const scrollTopBeforeFileChange = await snippetsPanel.evaluate(panel => panel.scrollTop);
185170

186-
await openSnippet(firstSnippetName);
187-
await assertSnippetIsSelected(firstSnippetName);
171+
await openFirstSnippetInList();
172+
188173
await waitForFunction(async () => {
189-
return await snippetsPanel.evaluate(panel => panel.scrollTop) === 0;
174+
const scrollTopAfterFileChange = await snippetsPanel.evaluate(panel => panel.scrollTop);
175+
return scrollTopBeforeFileChange !== scrollTopAfterFileChange;
190176
});
191177

192-
const scrollTopAfterFileChange = await snippetsPanel.evaluate(panel => panel.scrollTop);
193-
assert.notStrictEqual(scrollTopBeforeFileChange, scrollTopAfterFileChange);
178+
assert.notStrictEqual(scrollTopBeforeFileChange, await snippetsPanel.evaluate(panel => panel.scrollTop));
194179
});
195180
});
196181
});

0 commit comments

Comments
 (0)