Skip to content

Commit

Permalink
Add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
trungleduc committed Dec 19, 2024
1 parent 1516b96 commit b957411
Show file tree
Hide file tree
Showing 11 changed files with 126 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,5 @@ python/jupyter_suggestions_rtc/jupyter_suggestions_rtc/_version.py

# Integration tests
**/ui-tests/test-results/
**/ui-tests/playwright-report/
**/ui-tests/playwright-report/
**/*/.jupyter_ystore.db
5 changes: 3 additions & 2 deletions ui-tests/playwright.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ module.exports = {
timeout: 120 * 1000,
reuseExistingServer: false
},
retries: 1,
retries: 0,
use: {
...baseConfig.use,
trace: 'off',

video: 'retain-on-failure',
viewport: { width: 1920, height: 1080 },
},
expect: {
toMatchSnapshot: {
Expand Down
53 changes: 53 additions & 0 deletions ui-tests/tests/notebooks/test.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "b9356f9a-ea42-4050-a3a9-5684edd6bf18",
"metadata": {},
"outputs": [],
"source": [
"def foo():\n",
" print(123)\n",
" return 0"
]
},
{
"cell_type": "markdown",
"id": "3ff6c3ec-e344-4262-818a-a1ced33c3cac",
"metadata": {},
"source": [
"## This is a markdown cell"
]
},
{
"cell_type": "raw",
"id": "dadedd23-c079-4149-8db6-c8e305e55462",
"metadata": {},
"source": [
"This a a raw cell"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.11"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
68 changes: 68 additions & 0 deletions ui-tests/tests/ui.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,72 @@ test.describe('UI Test', () => {
});
});
});
test.describe('Panel activation test', () => {
test('should add the suggestion panel to the right', async ({
page,
request
}) => {
await page.goto();

await page.sidebar.open('right');
await page.getByTitle('Jupyter Suggestions').click();
await page.getByTitle('All Suggestions');
expect(await page.screenshot()).toMatchSnapshot({

Check failure on line 40 in ui-tests/tests/ui.spec.ts

View workflow job for this annotation

GitHub Actions / Integration tests (local)

tests/ui.spec.ts:31:9 › UI Test › Panel activation test › should add the suggestion panel to the right

2) tests/ui.spec.ts:31:9 › UI Test › Panel activation test › should add the suggestion panel to the right Error: A snapshot doesn't exist at /home/runner/work/jupyter-suggestions/jupyter-suggestions/ui-tests/tests/ui.spec.ts-snapshots/local-side-panel-linux.png, writing actual. 38 | await page.getByTitle('Jupyter Suggestions').click(); 39 | await page.getByTitle('All Suggestions'); > 40 | expect(await page.screenshot()).toMatchSnapshot({ | ^ 41 | name: `${BACKEND}-side-panel.png` 42 | }); 43 | }); at /home/runner/work/jupyter-suggestions/jupyter-suggestions/ui-tests/tests/ui.spec.ts:40:39
name: `${BACKEND}-side-panel.png`
});
});
});
});

test.describe('Notebook Test', () => {
test.beforeEach(async ({ page, tmpPath }) => {
await page.contents.uploadDirectory(
path.resolve(__dirname, './notebooks'),
tmpPath
);
await page.filebrowser.openDirectory(tmpPath);
});

test('Should add suggestion widget', async ({ page, tmpPath }) => {
await page.goto();
const notebook = 'test.ipynb';
await page.sidebar.open('right');
await page.getByTitle('Jupyter Suggestions').click();
await page.getByTitle('All Suggestions');

await page.notebook.openByPath(`${tmpPath}/${notebook}`);
await page.notebook.activate(notebook);

await page.notebook.selectCells(0);
await page.getByRole('button', { name: 'Suggestion menu' }).click();
await page.getByText('Suggest change').click();
await page.waitForTimeout(500);
await page.notebook.selectCells(1);
await page.getByRole('button', { name: 'Suggestion menu' }).click();
await page.getByText('Suggest delete').click();
await page.waitForTimeout(500);
expect(await page.screenshot()).toMatchSnapshot({

Check failure on line 74 in ui-tests/tests/ui.spec.ts

View workflow job for this annotation

GitHub Actions / Integration tests (local)

tests/ui.spec.ts:56:7 › Notebook Test › Should add suggestion widget

3) tests/ui.spec.ts:56:7 › Notebook Test › Should add suggestion widget ────────────────────────── Error: A snapshot doesn't exist at /home/runner/work/jupyter-suggestions/jupyter-suggestions/ui-tests/tests/ui.spec.ts-snapshots/local-add-suggestion-linux.png, writing actual. 72 | await page.getByText('Suggest delete').click(); 73 | await page.waitForTimeout(500); > 74 | expect(await page.screenshot()).toMatchSnapshot({ | ^ 75 | name: `${BACKEND}-add-suggestion.png` 76 | }); 77 | await page at /home/runner/work/jupyter-suggestions/jupyter-suggestions/ui-tests/tests/ui.spec.ts:74:37
name: `${BACKEND}-add-suggestion.png`
});
await page
.getByLabel('All Suggestions (2)', { exact: true })
.getByText('def foo(): print(123) return')
.fill('def foobar():\n print(123)\n return 123');
await page.waitForTimeout(500);
expect(
await page.getByLabel('All Suggestions (2)', { exact: true }).screenshot()
).toMatchSnapshot({

Check failure on line 84 in ui-tests/tests/ui.spec.ts

View workflow job for this annotation

GitHub Actions / Integration tests (local)

tests/ui.spec.ts:56:7 › Notebook Test › Should add suggestion widget

3) tests/ui.spec.ts:56:7 › Notebook Test › Should add suggestion widget ────────────────────────── Error: A snapshot doesn't exist at /home/runner/work/jupyter-suggestions/jupyter-suggestions/ui-tests/tests/ui.spec.ts-snapshots/local-change-cell-content-linux.png, writing actual. 82 | expect( 83 | await page.getByLabel('All Suggestions (2)', { exact: true }).screenshot() > 84 | ).toMatchSnapshot({ | ^ 85 | name: `${BACKEND}-change-cell-content.png` 86 | }); 87 | await page.getByLabel('Accept suggestion').nth(2).click(); at /home/runner/work/jupyter-suggestions/jupyter-suggestions/ui-tests/tests/ui.spec.ts:84:7
name: `${BACKEND}-change-cell-content.png`
});
await page.getByLabel('Accept suggestion').nth(2).click();
await page.waitForTimeout(500);
expect(await page.screenshot()).toMatchSnapshot({

Check failure on line 89 in ui-tests/tests/ui.spec.ts

View workflow job for this annotation

GitHub Actions / Integration tests (local)

tests/ui.spec.ts:56:7 › Notebook Test › Should add suggestion widget

3) tests/ui.spec.ts:56:7 › Notebook Test › Should add suggestion widget ────────────────────────── Error: A snapshot doesn't exist at /home/runner/work/jupyter-suggestions/jupyter-suggestions/ui-tests/tests/ui.spec.ts-snapshots/local-accept-change-suggestion-linux.png, writing actual. 87 | await page.getByLabel('Accept suggestion').nth(2).click(); 88 | await page.waitForTimeout(500); > 89 | expect(await page.screenshot()).toMatchSnapshot({ | ^ 90 | name: `${BACKEND}-accept-change-suggestion.png` 91 | }); 92 | await page.getByLabel('Accept suggestion').nth(1).click(); at /home/runner/work/jupyter-suggestions/jupyter-suggestions/ui-tests/tests/ui.spec.ts:89:37
name: `${BACKEND}-accept-change-suggestion.png`
});
await page.getByLabel('Accept suggestion').nth(1).click();
await page.waitForTimeout(500);
expect(await page.screenshot()).toMatchSnapshot({

Check failure on line 94 in ui-tests/tests/ui.spec.ts

View workflow job for this annotation

GitHub Actions / Integration tests (local)

tests/ui.spec.ts:56:7 › Notebook Test › Should add suggestion widget

3) tests/ui.spec.ts:56:7 › Notebook Test › Should add suggestion widget ────────────────────────── Error: A snapshot doesn't exist at /home/runner/work/jupyter-suggestions/jupyter-suggestions/ui-tests/tests/ui.spec.ts-snapshots/local-accept-delete-suggestion-linux.png, writing actual. 92 | await page.getByLabel('Accept suggestion').nth(1).click(); 93 | await page.waitForTimeout(500); > 94 | expect(await page.screenshot()).toMatchSnapshot({ | ^ 95 | name: `${BACKEND}-accept-delete-suggestion.png` 96 | }); 97 | }); at /home/runner/work/jupyter-suggestions/jupyter-suggestions/ui-tests/tests/ui.spec.ts:94:37
name: `${BACKEND}-accept-delete-suggestion.png`
});
});
});
Binary file not shown.
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.
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.
Binary file modified ui-tests/tests/ui.spec.ts-snapshots/rtc-main-page-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.

0 comments on commit b957411

Please sign in to comment.