Skip to content

Commit d4136f7

Browse files
committed
Fix integration tests
1 parent c383552 commit d4136f7

File tree

5 files changed

+22
-32
lines changed

5 files changed

+22
-32
lines changed

ui-tests/tests/commit-diff.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ test.describe('Commits diff', () => {
3939

4040
test('should display diff from single file history', async ({ page }) => {
4141
await page.sidebar.openTab('filebrowser');
42-
await page.click('#filebrowser >> text=example.ipynb', {
42+
await page.getByText('example.ipynb').click({
4343
button: 'right'
4444
});
45-
await page.hover('ul[role="menu"] >> text=Git');
45+
await page.getByRole('menu').getByText('Git').hover();
4646
await page.click('#jp-contextmenu-git >> text=History');
4747

4848
await page.waitForSelector('#jp-git-sessions >> ol >> text=example.ipynb');

ui-tests/tests/git-stash.spec.ts

+19-29
Original file line numberDiff line numberDiff line change
@@ -162,21 +162,19 @@ test.describe('Git Stash Commands', () => {
162162
// Show the stash entries and hover on the stash entry
163163
await page.getByText('Stash(2)').click();
164164
await page
165-
.locator('span')
166-
.filter({ hasText: 'stashy stash (on master)' })
165+
.locator('div').filter({ hasText: /^stashy stash \(on master\)$/ }).last()
167166
.hover();
168167

169-
const applyStashBtn = await page
170-
.locator('span')
171-
.filter({ hasText: 'stashy stash (on master)' })
168+
const applyStashBtn = page
169+
.locator('div').filter({ hasText: /^stashy stash \(on master\)$/ }).last()
172170
.getByRole('button', { name: 'Apply stash entry' });
173171

174172
await applyStashBtn.click();
175173

176174
// Check that the stash applies
177175
await expect
178-
.soft(await page.getByText('console.log("dirty changes");'))
179-
.toBeTruthy();
176+
.soft(page.getByText('console.log("dirty changes");'))
177+
.toHaveCount(1);
180178

181179
// open the second file has changes applied
182180
await page.getByRole('tab', { name: 'File Browser' }).click();
@@ -187,12 +185,12 @@ test.describe('Git Stash Commands', () => {
187185
.dblclick();
188186

189187
await expect
190-
.soft(await page.getByText('This is some dirty changes'))
191-
.toBeTruthy();
188+
.soft(page.getByText('This is some dirty changes'))
189+
.toHaveCount(1);
192190

193191
// See if the nStashes remains the same
194-
const numberOfStashes = await page.locator('[data-test-id="num-stashes"]');
195-
await expect(await numberOfStashes.innerText()).toBe('(2)');
192+
const numberOfStashes = page.locator('[data-test-id="num-stashes"]');
193+
await expect(numberOfStashes).toHaveText('(2)');
196194
});
197195

198196
test('should pop a stash entry when the `stash pop` button is clicked (apply stash then remove from list)', async ({
@@ -219,16 +217,12 @@ test.describe('Git Stash Commands', () => {
219217
await page.getByText('Stash', { exact: true }).click();
220218

221219
await page
222-
.locator('span')
223-
.filter({ hasText: 'stashy stash (on master)' })
220+
.locator('div').filter({ hasText: /^stashy stash \(on master\)$/ }).last()
224221
.hover();
225222

226-
const popStashBtn = await page
227-
.locator('span')
228-
.filter({ hasText: 'stashy stash (on master)' })
229-
.getByRole('button', { name: 'Pop stash entry' });
230-
231-
await popStashBtn.click();
223+
await page
224+
.locator('div').filter({ hasText: /^stashy stash \(on master\)$/ }).last()
225+
.getByRole('button', { name: 'Pop stash entry' }).click();
232226

233227
// Wait for the number of stashes to change
234228
await page.waitForFunction(() => {
@@ -237,11 +231,9 @@ test.describe('Git Stash Commands', () => {
237231
});
238232
await page.waitForTimeout(100);
239233
// Check that the stash applies
240-
const firstStashFileText = await page
241-
.locator('pre')
242-
.filter({ hasText: 'console.log("dirty changes");' });
234+
const firstStashFileText = page.getByText('console.log("dirty changes");');
243235

244-
await expect.soft(await firstStashFileText.count()).toBe(1);
236+
await expect.soft(firstStashFileText).toHaveCount(1);
245237

246238
// open the second file has changes applied
247239
await page.getByRole('tab', { name: 'File Browser' }).click();
@@ -254,11 +246,9 @@ test.describe('Git Stash Commands', () => {
254246
// Wait for revertFile to finish
255247
await page.waitForTimeout(100);
256248

257-
const secondStashFileText = await page
258-
.locator('pre')
259-
.filter({ hasText: 'This is some dirty changes' });
249+
const secondStashFileText = page.getByText('This is some dirty changes');
260250

261-
await expect.soft(await secondStashFileText.count()).toBe(1);
251+
await expect.soft(secondStashFileText).toHaveCount(1);
262252

263253
// See if the nStashes remains the same
264254

@@ -267,7 +257,7 @@ test.describe('Git Stash Commands', () => {
267257
return element && !(element.textContent ?? '').includes('(2)');
268258
});
269259

270-
const numberOfStashes = await page.locator('[data-test-id="num-stashes"]');
271-
await expect(await numberOfStashes.innerText()).toBe('(1)');
260+
const numberOfStashes = page.locator('[data-test-id="num-stashes"]');
261+
await expect(numberOfStashes).toHaveText('(1)');
272262
});
273263
});
Loading
Loading

ui-tests/tests/rebase.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ test.describe('Rebase', () => {
2121
await page.getByRole('button', { name: 'Current Branch master' }).click();
2222

2323
// Switch to a-branch
24-
await page.getByRole('button', { name: 'a-branch' }).click();
24+
await page.getByRole('listitem', { name: 'Switch to branch: a-branch' }).click();
2525

2626
// Hide branch panel
2727
await page.getByRole('button', { name: 'Current Branch a-branch' }).click();

0 commit comments

Comments
 (0)