Skip to content

Commit

Permalink
Fix integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fcollonval committed Oct 24, 2023
1 parent c383552 commit cd8f265
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 52 deletions.
4 changes: 2 additions & 2 deletions ui-tests/tests/commit-diff.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ test.describe('Commits diff', () => {

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

await page.waitForSelector('#jp-git-sessions >> ol >> text=example.ipynb');
Expand Down
98 changes: 49 additions & 49 deletions ui-tests/tests/git-stash.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ test.describe('Git Stash Commands', () => {
});

test('should show the current stash list of two items', async ({ page }) => {
const stashButton = await page.getByRole('button', {
const stashButton = page.getByRole('button', {
name: 'Stash latest changes'
});
const numberOfStashes = await page.locator('[data-test-id="num-stashes"]');
const numberOfStashes = page.locator('[data-test-id="num-stashes"]');

await page.getByText('Stash', { exact: true }).click();

expect.soft(stashButton).toBeTruthy();
await expect(await numberOfStashes.innerText()).toBe('(2)');
await expect(numberOfStashes).toHaveText('(2)');
});

test('should drop a single stash entry when `stash drop` button is clicked', async ({
Expand All @@ -41,13 +41,14 @@ test.describe('Git Stash Commands', () => {
// Open the stash list
await page.getByText('Stash', { exact: true }).click();
// Hover on the stash list
const stashSection = await page.getByText('Stash(2)');
const stashSection = page.getByText('Stash(2)');
await stashSection.hover();

// Click drop stash on the first item
const dropFirstStashBtn = await page
.locator('span')
.filter({ hasText: 'notebook stash (on master)' })
const dropFirstStashBtn = page
.locator('div')
.filter({ hasText: /^notebook stash \(on master\)$/ })
.last()
.getByRole('button', { name: 'Drop stash entry' });

await dropFirstStashBtn.click();
Expand All @@ -59,9 +60,9 @@ test.describe('Git Stash Commands', () => {
});

// Now there should be only one stash
const numberOfStashes = await page.locator('[data-test-id="num-stashes"]');
const numberOfStashes = page.locator('[data-test-id="num-stashes"]');

await expect(await numberOfStashes.innerText()).toBe('(1)');
await expect(numberOfStashes).toHaveText('(1)');
});

test('should clear all the stashes when `stash clear` button is clicked', async ({
Expand All @@ -70,7 +71,7 @@ test.describe('Git Stash Commands', () => {
// Open the stash list
await page.getByText('Stash', { exact: true }).click();
// Hover on the stash list
const stashSection = await page.getByText('Stash(2)');
const stashSection = page.getByText('Stash(2)');
await stashSection.hover();

// Click clear all stash button
Expand All @@ -87,9 +88,9 @@ test.describe('Git Stash Commands', () => {
});

// Now there should be only one stash
const numberOfStashes = await page.locator('[data-test-id="num-stashes"]');
const numberOfStashes = page.locator('[data-test-id="num-stashes"]');

await expect(await numberOfStashes.innerText()).toBe('(0)');
await expect(numberOfStashes).toHaveText('(0)');
});

test('should add a stash when the `stash changes` button is clicked', async ({
Expand All @@ -112,9 +113,9 @@ test.describe('Git Stash Commands', () => {

// Should have the old tetx

const oldText = await page.locator('text="This is some dirty changes"');
await expect.soft(await oldText.count()).toBe(1);
const stashButton = await page.getByRole('button', {
const oldText = page.locator('text="This is some dirty changes"');
await expect.soft(oldText).toHaveCount(1);
const stashButton = page.getByRole('button', {
name: 'Stash latest changes'
});
await stashButton.click();
Expand All @@ -133,16 +134,16 @@ test.describe('Git Stash Commands', () => {
});

// See if the nStashes becomes (3)
const numberOfStashes = await page.locator('[data-test-id="num-stashes"]');
const numberOfStashes = page.locator('[data-test-id="num-stashes"]');

await expect.soft(await numberOfStashes.innerText()).toBe('(3)');
await expect.soft(numberOfStashes).toHaveText('(3)');
// check that our stash message showed up properly
await expect
.soft(await page.getByText('some stash message (on master)'))
.toBeTruthy();
.soft(page.getByText('some stash message (on master)'))
.toBeVisible();
await page.waitForTimeout(100);
// Check that the stash removed the old text disappears
await expect(await oldText.count()).toBe(0);
await expect(oldText).toHaveCount(0);
});

test('should apply a stash entry when the `stash apply` button is clicked (does not remove stash entry from list)', async ({
Expand All @@ -162,21 +163,23 @@ test.describe('Git Stash Commands', () => {
// Show the stash entries and hover on the stash entry
await page.getByText('Stash(2)').click();
await page
.locator('span')
.filter({ hasText: 'stashy stash (on master)' })
.locator('div')
.filter({ hasText: /^stashy stash \(on master\)$/ })
.last()
.hover();

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

await applyStashBtn.click();

// Check that the stash applies
await expect
.soft(await page.getByText('console.log("dirty changes");'))
.toBeTruthy();
.soft(page.getByText('console.log("dirty changes");'))
.toHaveCount(1);

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

await expect
.soft(await page.getByText('This is some dirty changes'))
.toBeTruthy();
.soft(page.getByText('This is some dirty changes'))
.toHaveCount(1);

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

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

await page
.locator('span')
.filter({ hasText: 'stashy stash (on master)' })
.locator('div')
.filter({ hasText: /^stashy stash \(on master\)$/ })
.last()
.hover();

const popStashBtn = await page
.locator('span')
.filter({ hasText: 'stashy stash (on master)' })
.getByRole('button', { name: 'Pop stash entry' });

await popStashBtn.click();
await page
.locator('div')
.filter({ hasText: /^stashy stash \(on master\)$/ })
.last()
.getByRole('button', { name: 'Pop stash entry' })
.click();

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

await expect.soft(await firstStashFileText.count()).toBe(1);
await expect.soft(firstStashFileText).toHaveCount(1);

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

const secondStashFileText = await page
.locator('pre')
.filter({ hasText: 'This is some dirty changes' });
const secondStashFileText = page.getByText('This is some dirty changes');

await expect.soft(await secondStashFileText.count()).toBe(1);
await expect.soft(secondStashFileText).toHaveCount(1);

// See if the nStashes remains the same

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

const numberOfStashes = await page.locator('[data-test-id="num-stashes"]');
await expect(await numberOfStashes.innerText()).toBe('(1)');
const numberOfStashes = page.locator('[data-test-id="num-stashes"]');
await expect(numberOfStashes).toHaveText('(1)');
});
});
Binary file modified ui-tests/tests/image-diff.spec.ts-snapshots/jpeg-diff-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion ui-tests/tests/rebase.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ test.describe('Rebase', () => {
await page.getByRole('button', { name: 'Current Branch master' }).click();

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

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

0 comments on commit cd8f265

Please sign in to comment.