diff --git a/docs/hacking_howto.md b/docs/hacking_howto.md index 1933990cba6..d28da58ade5 100644 --- a/docs/hacking_howto.md +++ b/docs/hacking_howto.md @@ -4,7 +4,7 @@ This chapter helps you get an installation of Kitsune up and running. -If you have any problems getting Kitsune running, let us know. See [Contact us](contactus.md). +If you have any problems getting Kitsune running, [let us know](contactus.md). ## Getting up and running @@ -51,11 +51,11 @@ and follow the following steps. The running instance will be located at http://localhost:8000/ unless you specified otherwise, and the administrative control panel will be at http://localhost:8000/admin/. -Another way you might choose to run the app (step 3 above) is by getting a shell in the container and then manually +Another way you might choose to run the app (instead of step 4 above) is by getting a shell in the container and then manually running the Django dev server from there. This should make frequent restarts of the server a lot faster and easier if you need to do that: -``` +```sh make runshell ./manage.py runserver 0.0.0.0:8000 ``` @@ -82,20 +82,20 @@ After the above you can do some optional steps if you want to use the admin: - Enable the admin control panel - ``` + ```sh echo "ENABLE_ADMIN=True" >> .env ``` - Create a superuser - ``` - docker-compose exec web ./manage.py createsuperuser + ```sh + docker compose exec web ./manage.py createsuperuser ``` - Create a profile for this user - ``` - docker-compose exec web ./manage.py shell_plus + ```sh + docker compose exec web ./manage.py shell_plus In [1]: u = User.objects.get(username="superuser") In [2]: Profile(user=u).save() ``` @@ -109,8 +109,8 @@ add `ENABLE_DEV_LOGIN=True` to your `.env` file. You can create a normal user like so: -``` -docker-compose exec web ./manage.py shell_plus +```sh +docker compose exec web ./manage.py shell_plus In [1]: u = User(username="foobar") In [2]: u.save() In [3]: Profile(user=u).save() @@ -123,8 +123,8 @@ You can then log in as that user by visiting: `http://localhost:8000/user/foobar We include some sample data to get you started. You can install it by running this command: -``` -docker-compose exec web ./manage.py generatedata +```sh +docker compose exec web ./manage.py generatedata ``` ### Get AAQ working @@ -163,18 +163,18 @@ or have entered data yourself through the admin interface. 1. Enter into the web container - ```shell - docker-compose exec web bash + ```sh + docker compose exec web bash ``` 2. Build the indicies - ```bash + ```sh ./manage.py es_init && ./manage.py es_reindex ``` 3. Now, exit from web's bash shell - ```bash + ```sh exit ``` @@ -191,13 +191,13 @@ Install it globally, or in a venv, outside of the docker container with: -```bash +```sh pip install pre-commit ``` Then set up its git pre-commit hook: -```bash +```sh pre-commit install ``` @@ -206,14 +206,14 @@ every time you commit, pre-commit will check your changes for style problems. To run it manually you can use the command: -```bash +```sh pre-commit run ``` which will run the checks for only your changes, or if you want to run the lint checks for all files: -```bash +```sh pre-commit run --all-files ``` @@ -227,8 +227,8 @@ For more details see the [pre-commit docs](https://pre-commit.com). JSON files containing historical Firefox version data and write them within its package directory. To set this up, run this command to do the initial fetch: - ```bash - docker-compose exec web ./manage.py update_product_details + ```sh + docker compose exec web ./manage.py update_product_details ``` ### Using Django Debug Toolbar @@ -248,7 +248,7 @@ USE_DEBUG_TOOLBAR=True Running the test suite is easy: -```bash +```sh ./bin/run-unit-tests.sh ``` diff --git a/docs/tests.md b/docs/tests.md index aee5d597a8f..76ba459a1ec 100644 --- a/docs/tests.md +++ b/docs/tests.md @@ -8,14 +8,13 @@ title: All about testing Kitsune has a fairly comprehensive Python test suite. Changes should not -break tests\-\--only change a test if there is a good reason to change -the expected behavior\-\--and new code should come with tests. +break tests—only change a test if there is a good reason to change +the expected behavior—and new code should come with tests. # Running the Test Suite -If you followed the steps in `the installation docs -`{.interpreted-text role="any"}, then you should be all -set setup-wise. +If you followed the steps in [the installation docs](hacking_howto.md), +then you should be all set setup-wise. To run the tests, you need to do: @@ -129,13 +128,13 @@ Frontend JavaScript is currently tested with To run tests, make sure you have have the NPM dependencies installed, and then run: - $ npm run webpack:test + npm run webpack:test ## Writing JavaScript Tests Mocha tests are discovered using the pattern `kitsune/*/static/*/js/tests/**/*.js`. That means that any app can have -a [tests]{.title-ref} directory in its JavaScript directory, and the +a `tests` directory in its JavaScript directory, and the files in there will all be considered test files. Files that don't define tests won't cause issues, so it is safe to put testing utilities in these directories as well. @@ -144,7 +143,7 @@ Here are a few tips for writing tests: - Any HTML required for your test should be added by the tests or a `beforeEach` function in that test suite. React is useful for this. -- You can use [sinon]{.title-ref} to mock out parts of libraries or +- You can use `sinon` to mock out parts of libraries or functions under test. This is useful for testing AJAX. - The tests run in a Node.js environment. A browser environment can be simulated using `jsdom`.