Skip to content

Commit 9bddcec

Browse files
justafishdawehner
andcommitted
[#736] Fixes Nightwatch setup and instructions, and re-enables in Cir… (#740)
* [#736] Fixes Nightwatch setup and instructions, and re-enables in CircleCI * [#736] Try a different base url * [#736] Install Chromium * [#736] Install google chrome * Update README.md Co-Authored-By: Daniel Wehner <[email protected]>
1 parent 31f6cf1 commit 9bddcec

File tree

4 files changed

+28
-26
lines changed

4 files changed

+28
-26
lines changed

.circleci/config.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,22 @@ jobs:
8989
steps:
9090
- setup-project
9191
- run:
92-
name: Buld projects
92+
name: Install Chrome
93+
command: |
94+
sudo apt-get update
95+
sudo apt-get install lsb-release libappindicator3-1
96+
curl -L -o google-chrome.deb https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
97+
sudo dpkg -i google-chrome.deb
98+
sudo sed -i 's|HERE/chrome"|HERE/chrome" --no-sandbox|g' /opt/google/chrome/google-chrome
99+
rm google-chrome.deb
100+
- run:
101+
name: Build projects
93102
command: yarn build
94103
- run:
95104
name: Run tests
96105
command: |
97106
docker exec -it drupal_admin_ui_drupal drush user:password admin admin
98-
REACT_APP_DRUPAL_BASE_URL=http://drupal NIGHTWATCH_LOGIN_admin_PASSWORD=admin yarn test
107+
yarn test
99108
- store_test_results:
100109
path: ~/project/packages/admin-ui/reports
101110
- store_artifacts:

README.md

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ This is an admin UI for Drupal, built with JavaScript and based on [create-react
2525

2626
## Installation
2727

28-
### Drupal
29-
3028
Ensure that you currently have nothing running on port 80 (e.g. a local webserver) or port 3000 (e.g. a local node process). You can run ` lsof -i :80 -S` to see what you currently have running.
3129

3230
```
@@ -57,18 +55,22 @@ Open the one time login link in your browser to log into Drupal. You will then h
5755
| http://127.0.0.1 | Regular Drupal installation / JSON API endpoints |
5856
| http://127.0.0.1/admin/content | A page taken over by the new admin UI. This uses the bundled version from `packages/admin-ui/build`, run `yarn workspace admin-ui build` in the node container to re-build |
5957

60-
### Admin UI
58+
## Development
6159

6260
`yarn workspace @drupal/admin-ui start` will start the Webpack dev sever that comes with [Create React App](https://facebook.github.io/create-react-app).
6361

62+
### Testing
63+
64+
We have functional testing with [Nightwatch](http://nightwatchjs.org/), and component/unit testing with [Jest](https://jestjs.io/).
65+
66+
When deciding which system to use to add test coverage, the general rule is Nightwatch should be used to test the common path, and Jest can be used for more detailed test coverage. Nightwatch tests will run slower as they simulate clicking around in a real browser.
67+
6468
#### Nightwatch
6569
- If you don't know the password for admin, change it with `docker exec -it drupal_admin_ui_drupal drush user:password admin admin`
66-
- Run `docker exec -it -e REACT_APP_DRUPAL_BASE_URL=http://drupal drupal_admin_ui_node yarn workspace admin-ui build`, which
67-
creates a build that uses `http://drupal` as it's base URL, which is the URL that the node container sees Drupal on internally.
68-
- Run `docker exec -it -e REACT_APP_DRUPAL_BASE_URL=http://drupal -e NIGHTWATCH_LOGIN_admin_PASSWORD=admin drupal_admin_ui_node yarn workspace admin-ui nightwatch`
69-
or `docker exec -it -e REACT_APP_DRUPAL_BASE_URL=http://drupal -e NIGHTWATCH_LOGIN_admin_PASSWORD=admin drupal_admin_ui_node yarn test` to run all tests
70-
- When you're finished, restore the regular build if you want to browse the compiled version in your browser with `docker exec -it drupal_admin_ui_node yarn workspace admin-ui build`.
71-
This will also be restored when you restart your containers.
70+
- Update your `.env.local` file, setting `NIGHTWATCH_LOGIN_admin_PASSWORD` to the password you set above e.g. `NIGHTWATCH_LOGIN_admin_PASSWORD=admin`
71+
- If you want to test against the current JS, not the production build change set `NIGHTWATCH_URL=http://127.0.0.1:3000` in the `.env.local` file.
72+
- Run `yarn workspace @drupal/admin-ui build`, which creates a new production build to test.
73+
- Run `yarn workspace @drupal/admin-ui nightwatch` or `yarn test` to run all tests
7274

7375
#### React AXE
7476

@@ -78,15 +80,7 @@ Due to outstanding performance issues, `react-axe` is behind a flag. To enable t
7880
REACT_APP_AXE=true yarn workspace @drupal/admin-ui start
7981
```
8082

81-
## Development guidelines
82-
83-
### Testing
84-
85-
We have functional testing with [Nightwatch](http://nightwatchjs.org/), and component/unit testing with [Jest](https://jestjs.io/).
86-
87-
When deciding which system to use to add test coverage, the general rule is Nightwatch should be used to test the common path, and Jest can be used for more detailed test coverage. Nightwatch tests will run slower as they simulate clicking around in a real browser.
88-
89-
## Contributing to This Repository
83+
### Contributing to This Repository
9084

9185
- [Fork this repo](https://help.github.com/articles/fork-a-repo/) to your own user
9286
- Set your fork as origin, and this repo as upstream. From inside the `drupal-admin-ui` folder:

packages/admin-ui/.env

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ REACT_APP_DRUPAL_BASE_URL="http://127.0.0.1"
44
REACT_APP_DRUPAL_ROOT=/
55

66
# Testing
7-
#NIGHTWATCH_CHROMEDRIVER_PATH=node_modules/.bin/chromedriver
8-
#NIGHTWATCH_CHROME_ARGS=--headless
9-
#NIGHTWATCH_URL=http://localhost:3000
10-
#NIGHTWATCH_LOGIN_admin_PASSWORD=
7+
NIGHTWATCH_CHROMEDRIVER_PATH=node_modules/.bin/chromedriver
8+
NIGHTWATCH_CHROME_ARGS=--headless
9+
NIGHTWATCH_URL=http://127.0.0.1
10+
NIGHTWATCH_LOGIN_admin_PASSWORD=admin

packages/admin-ui/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,7 @@
9191
"nightwatch": "nightwatch --config ./src/tests/Nightwatch/nightwatch.conf.js",
9292
"storybook": "start-storybook -p 9001 -c .storybook",
9393
"// Test commands for the CI": "⬅✌➡",
94-
"test": "yarn test:unit",
95-
"test:functional": "yarn nightwatch",
94+
"test": "yarn test:unit && yarn nightwatch",
9695
"test:unit": "CI=true JEST_JUNIT_OUTPUT=reports/jest-junit.xml react-scripts test --reporters=default --reporters=../../node_modules/jest-junit --env=jsdom",
9796
"eject": "react-scripts eject"
9897
},

0 commit comments

Comments
 (0)