Skip to content

Commit

Permalink
test: E2E test flows + new app harness (#256)
Browse files Browse the repository at this point in the history
* test: E2E test flows + new app harness

* feedback from Brett
  • Loading branch information
aarongranick-okta authored Oct 24, 2019
1 parent 037d912 commit 2a6a631
Show file tree
Hide file tree
Showing 39 changed files with 14,500 additions and 10,895 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.DS_Store
dist
target
node_modules/*
node_modules
build2
test/SpecRunner.html
npm-debug.log
Expand Down
7 changes: 5 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ language: node_js
node_js:
- '8'
install:
- yarn install
- TMPDIR=/tmp yarn install
- yarn install --frozen-lockfile
- yarn --cwd test/app install --frozen-lockfile
- yarn --cwd test/e2e install --frozen-lockfile
script:
- yarn lint
- yarn test
cache: false
addons:
chrome: stable
13 changes: 12 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
}
},

{
"name": "E2E Current file",
"type": "node",
"request": "launch",
"args": ["wdio.conf.js", "--spec", "${file}"],
"cwd": "${workspaceFolder}/test/e2e",
"autoAttachChildProcesses": true,
"program": "${workspaceRoot}/test/e2e/node_modules/@wdio/cli/bin/wdio.js",
"console": "integratedTerminal"
}
]
}
22 changes: 15 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1762,16 +1762,24 @@ yarn install

### Build and Test Commands

| Command | Description |
| --------------------- | ------------------------------ |
| `yarn build` | Build the SDK with a sourcemap |
| `yarn test` | Run unit tests |
| `yarn lint` | Run eslint linting |
| `yarn start` | Start internal test app |
| Command | Description |
| --------------------- | ------------------------------- |
| `yarn build` | Build the SDK with a sourcemap |
| `yarn start` | Start internal test app |
| `yarn lint` | Run eslint linting |
| `yarn test:unit` | Run only unit tests |
| `yarn test:e2e` | Run only E2E (end-to-end) tests |
| `yarn test` | Run all tests |

#### Test Environment

Before running the E2E tests, you will need to setup a test environment. See [test/e2e/README](test/e2e/README.md) for more information.

#### Test App

Implements a simple SPA application to demonstrate functionality and provide for manual testing. [See here for more information](test/app/README.md).
We have implemented a small SPA app, located at `./test/app/` which is used internally as a test harness for the E2E tests. The app can be run manually using `yarn start`. This will start a webpack dev server and open a new browser window at `http://localhost:8080`. The app provides a high level of feedback and configurability which make it useful as a tool for troubleshooting and manual testing scenarios. See [test/app/README](test/app/README.md) for more information on the test app.

Because this test app is set up to dynamically change configuration and leak internal information, users should not use this test app as the basis for their own applications. Instead, use the example usage outlined elsewhere in this README.

## Contributing

Expand Down
11 changes: 5 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,16 @@
"scripts": {
"lint": "eslint .",
"lint:report": "eslint -f checkstyle -o build2/reports/lint/eslint-checkstyle-result.xml .",
"test": "yarn test:karma && yarn test:browser && yarn test:server",
"test": "yarn test:unit && yarn test:e2e",
"test:e2e": "yarn --cwd test/e2e start",
"test:unit": "yarn test:karma && yarn test:browser && yarn test:server",
"test:karma": "karma start --single-run",
"test:browser": "jest --config ./jest.browser.js",
"test:server": "jest --config ./jest.server.js",
"test:report": "yarn test --ci --silent || true",
"build": "node ./writeConfig.js && webpack --config webpack.config.js",
"prepare": "yarn build",
"install:app": "yarn --cwd test/app install",
"start:app": "yarn --cwd test/app start",
"prestart": "yarn install:app",
"start": "yarn start:app"
"start": "yarn --cwd test/app start --open"
},
"author": "Okta",
"keywords": [
Expand Down Expand Up @@ -81,4 +80,4 @@
"jest-junit": {
"output": "./build2/reports/unit/junit-result.xml"
}
}
}
2 changes: 0 additions & 2 deletions test/app/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
node_modules/
.env
.yalc
*.lock
*.log
36 changes: 29 additions & 7 deletions test/app/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,37 @@
# test-app

The following enironment variables are **required**. You can use a [.env file](https://github.com/motdotla/dotenv#usage) in this directory.
By default the app server runs at `http://localhost:8080`. The callback redirect URI is `http://localhost:8080/implicit/callback`

* `CLIENT_ID` - abc12
* `ISSUER` - x.okta.com/oauth2/default
## Commands

If running from the workspace directory, add the `--cwd` option: `yarn --cwd test/e2e start`

The following parameters are accepted in the URL:
| Command | Description |
| --------------------- | ------------------------------ |
| `yarn start` | Starts the app server in headless mode |
| `yarn start:dev` | Start the app server and open a new browser window |

* `pkce` - set PKCE flow
## Configuring via URL parameters

The following config parameters are accepted in the URL as encoded query parameters:

* `clientId` - set the client ID
* `issuer` - set the issuer
* `pkce` - true|false enable PKCE flow
* `scopes` - set the scopes passed during OAuth flow. Comma delimited.
* `responseType` - set the responseType passed during OAuth flow. Comma delimited.

Params can be used together:
`http://localhost:8080/?scopes=openid,email&responseType=id_token,token`
Example:

```html
http://localhost:8080/?issuer=https%3A%2F%2Fabc.oktapreview.com%2Foauth2%2Fdefault&clientId=01234567xcdfgC80h7&pkce=false=openid,email&responseType=id_token,token
```

## Configuring via environment variables

Using environment variables is **optional**. They provide default values in the form only if **no** query parameters are provided in the URL. If **any** query parameters are passed, then **all** parameters will be read from the URL and environment variables will be ignored.

Environment variables are read from a file named `testenv`, if it exists, in the workspace directory. The format is that of a basic "ini" file. See [dotenv](https://www.npmjs.com/package/dotenv) for more details on this file format.

* `CLIENT_ID` - abc12
* `ISSUER` - x.okta.com/oauth2/default
Loading

0 comments on commit 2a6a631

Please sign in to comment.