diff --git a/Makefile b/Makefile index 0189f821..d47e38a0 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,7 @@ .DEFAULT_GOAL := help +JS_TEST_URL := http://localhost:8001/umap/static/umap/test/index.html + .PHONY: install install: ## Install the dependencies python3 -m pip install --upgrade pip @@ -73,10 +75,21 @@ vendors: npm run vendors installjs: npm install -testjsfx: - firefox umap/static/umap/test/index.html + testjs: node_modules - @./node_modules/mocha-phantomjs/bin/mocha-phantomjs --view 1024x768 umap/static/umap/test/index.html + @{ \ + trap 'kill $$PID; exit' INT; \ + python -m http.server 8001 & \ + PID=$$!; \ + sleep 1; \ + echo "Opening $(JS_TEST_URL)"; \ + if command -v python -m webbrowser > /dev/null 2>&1; then \ + python -m webbrowser "$(JS_TEST_URL)"; \ + else \ + echo "Please open $(JS_TEST_URL) in your web browser"; \ + fi; \ + wait $$PID; \ + } tx_push: tx push -s tx_pull: diff --git a/docs/contributing.md b/docs/contributing.md index c96991a8..e66baea0 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -29,19 +29,52 @@ To be sure to install all the dev dependencies, and have everything working loca make develop ``` +#### JavaScript + +For JavaScript, here is the tooling we use: + +- Format your code with [Prettier](https://prettier.io/) +- Be sure to configure your editor to insert new lines at the end of files. + ### Hack! You can now do your changes in a specific branch, and when you're ready you can open a pull-request for us to review. -### Run tests +### Running tests Multiple tests suites are in use in the project. -| Test suite | Location | Command | -| ---------- | -------- | ------- | -| Python unit tests | `umap/tests/` | `pytest . --ignore umap/tests/integration` | -| Javascript unit tests | `umap/static/test` | `make testjs`| -| Integration tests | `umap/tests/integration` | `pytest umap/tests/integration` | + +#### Python unit tests + +```bash +pytest . --ignore umap/tests/integration +``` + +By default, the tests are run in parallel to reduce the time taken to run them. You can run them in serial mode by using the `-n1` option. + +If you only want to run one test, you can add `-k specific-test-name` to the command line. + +#### Integration tests + +```bash +pytest umap/tests/integration +``` + +The tests are using [Playwright](https://playwright.dev), which spawns a headless browser and runs the tests on it. +If the tests are failing, it might be useful to step trough the tests in the browser. This will let you go step by step with a debugger, so you can see what is happening on a real browser. + +```bash +PWDEBUG=1 pytest --headed -n1 -k specific-test-name +``` + +#### JS tests + +```bash +make testjs +``` + +These tests are located in `umap/static/test`, and we are currently using a mocha test runner. All the tests are run when you're creating a pull request, to avoid regressions. diff --git a/docs/install.md b/docs/install.md index 70b60cd6..77e36a27 100644 --- a/docs/install.md +++ b/docs/install.md @@ -168,4 +168,4 @@ pip install umap-project --upgrade umap migrate umap collectstatic umap compress -``` \ No newline at end of file +``` diff --git a/umap/models.py b/umap/models.py index 4dfcf2ef..71f68144 100644 --- a/umap/models.py +++ b/umap/models.py @@ -16,7 +16,7 @@ from .managers import PublicManager # Did not find a clean way to do this in Django # - creating a Proxy model would mean replacing get_user_model by this proxy model # in every template -# - extending User model woulc mean a non trivial migration +# - extending User model would mean a non trivial migration def display_name(self): return settings.USER_DISPLAY_NAME.format(**self.__dict__)