|
5 | 5 | import {assert} from 'chai'; |
6 | 6 |
|
7 | 7 | import { |
| 8 | + click, |
8 | 9 | getBrowserAndPages, |
9 | 10 | waitFor, |
10 | | - waitForElementWithTextContent, |
11 | 11 | waitForFunction, |
12 | 12 | waitForNone, |
13 | 13 | } from '../../shared/helper.js'; |
14 | 14 | import {openSoftContextMenuAndClickOnItem} from '../helpers/context-menu-helpers.js'; |
15 | 15 | import { |
16 | | - getMenuItemAtPosition, |
17 | | - openFileQuickOpen, |
18 | 16 | openFileWithQuickOpen, |
19 | 17 | runCommandWithQuickOpen, |
20 | | - typeIntoQuickOpen, |
21 | 18 | } from '../helpers/quick_open-helpers.js'; |
22 | 19 | import { |
23 | | - createNewSnippet, |
24 | 20 | openFileInSourcesPanel, |
25 | 21 | openSnippetsSubPane, |
26 | 22 | openSourceCodeEditorForFile, |
@@ -154,43 +150,32 @@ describe('The Sources panel', () => { |
154 | 150 | }); |
155 | 151 |
|
156 | 152 | 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"]'); |
168 | 157 | } |
169 | 158 |
|
170 | 159 | await openSourcesPanel(); |
171 | 160 | await openSnippetsSubPane(); |
172 | 161 |
|
173 | 162 | const numSnippets = 50; |
174 | 163 | 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}"]`); |
176 | 166 | } |
177 | | - const firstSnippetName = 'Snippet0'; |
178 | | - const lastSnippetName = `Snippet${numSnippets - 1}`; |
179 | | - |
180 | | - await waitForElementWithTextContent(lastSnippetName); |
181 | | - await assertSnippetIsSelected(lastSnippetName); |
182 | 167 |
|
183 | 168 | const snippetsPanel = await waitFor('[aria-label="Snippets panel"]'); |
184 | 169 | const scrollTopBeforeFileChange = await snippetsPanel.evaluate(panel => panel.scrollTop); |
185 | 170 |
|
186 | | - await openSnippet(firstSnippetName); |
187 | | - await assertSnippetIsSelected(firstSnippetName); |
| 171 | + await openFirstSnippetInList(); |
| 172 | + |
188 | 173 | 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; |
190 | 176 | }); |
191 | 177 |
|
192 | | - const scrollTopAfterFileChange = await snippetsPanel.evaluate(panel => panel.scrollTop); |
193 | | - assert.notStrictEqual(scrollTopBeforeFileChange, scrollTopAfterFileChange); |
| 178 | + assert.notStrictEqual(scrollTopBeforeFileChange, await snippetsPanel.evaluate(panel => panel.scrollTop)); |
194 | 179 | }); |
195 | 180 | }); |
196 | 181 | }); |
0 commit comments