Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add basic search test with playwright #31

Merged
merged 10 commits into from
Mar 10, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ jobs:
run: |
set -eux
python -m pytest -vv -r ap --cov jupyterlab_search_replace

- name: Playwright Tests
run: |
set -eux
jlpm playwright test
madhur-tandon marked this conversation as resolved.
Show resolved Hide resolved

- name: Check JupyterLab installation
run: |
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ MANIFEST
pip-log.txt
pip-delete-this-directory.txt

# Integration tests
ui-tests/test-results/
ui-tests/playwright-report/

# Unit test / coverage reports
htmlcov/
.tox/
Expand Down
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ include RELEASE.md
include pyproject.toml
recursive-include jupyter-config *.json
recursive-include jupyterlab_search_replace *.json
include jupyter_server_test_config.py
include conftest.py

include package.json
include install.json
include ts*.json
include *.config.js
include yarn.lock

graft jupyterlab_search_replace/labextension
Expand All @@ -17,6 +19,7 @@ graft jupyterlab_search_replace/labextension
graft src
graft style
graft schema
graft ui-tests
prune **/node_modules
prune lib
prune binder
Expand Down
19 changes: 19 additions & 0 deletions ui-tests/jupyter_server_test_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"""Server configuration for integration tests.
!! Never use this configuration in production because it
opens the server to the world and provide access to JupyterLab
JavaScript objects through the global window variable.
"""
from tempfile import mkdtemp

c.ServerApp.port = 8888
c.ServerApp.port_retries = 0
c.ServerApp.open_browser = False

c.ServerApp.root_dir = mkdtemp(prefix="galata-test-")
c.ServerApp.token = ""
c.ServerApp.password = ""
c.ServerApp.disable_check_xsrf = True
c.LabApp.expose_app_in_browser = True

# Uncomment to set server log level to debug level
# c.ServerApp.log_level = "DEBUG"
14 changes: 14 additions & 0 deletions ui-tests/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "search-replace-ui-tests",
"version": "1.0.0",
"description": "JupyterLab search-replace Integration Tests",
"private": true,
"scripts": {
"start": "jupyter lab --config jupyter_server_test_config.py",
"test": "jlpm playwright test"
},
"devDependencies": {
"@jupyterlab/galata": "^4.1.0",
"@playwright/test": "^1.19.0"
}
}
14 changes: 14 additions & 0 deletions ui-tests/playwright.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* Configuration for Playwright using default from @jupyterlab/galata
*/
const baseConfig = require('@jupyterlab/galata/lib/playwright-config');

module.exports = {
...baseConfig,
webServer: {
command: 'jlpm start',
url: 'http://localhost:8888/lab',
timeout: 120 * 1000,
reuseExistingServer: !process.env.CI,
},
}
25 changes: 25 additions & 0 deletions ui-tests/tests/search.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { test } from '@jupyterlab/galata';
import { expect } from '@playwright/test';

test('test', async ({ page }) => {
// Click #tab-key-0 .lm-TabBar-tabIcon svg >> nth=0
await page.locator('#tab-key-0 .lm-TabBar-tabIcon svg').first().click();
madhur-tandon marked this conversation as resolved.
Show resolved Hide resolved
// Click input[type="search"]
await page.locator('input[type="search"]').click();
// Fill input[type="search"]
await page.locator('input[type="search"]').fill('strange');

await Promise.all([
page.waitForResponse(
response =>
/.*search\/\?query=strange/.test(
response.url()
) && response.request().method() === 'GET'
),
page.locator('input[type="search"]').press('Enter')
]);

expect(
await page.waitForSelector(`#jp-search-replace >> text=${JSON.stringify({"matches":[]}, undefined, 4)}`)
).toBeTruthy();
});
Loading