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

MEGA: Make E2E Great Again #3444

Merged
merged 55 commits into from
Feb 8, 2022
Merged
Show file tree
Hide file tree
Changes from 49 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
a5d4bbd
attempt
Murderlon Nov 22, 2021
6494bb7
attemps
Murderlon Nov 29, 2021
6c612a0
Merge branch 'main' into cypress
Murderlon Dec 27, 2021
4ff1745
More wip
Murderlon Jan 4, 2022
978e53e
Merge branch 'main' into cypress
Murderlon Jan 12, 2022
4f529ea
another wip
Murderlon Jan 12, 2022
7bfc7cd
fix typescript
Murderlon Jan 13, 2022
c5386f6
Merge branch 'main' into cypress
Murderlon Jan 13, 2022
39e2865
Proper tests, generate test script, other improvements
Murderlon Jan 13, 2022
2a0673a
tweaks
Murderlon Jan 13, 2022
bef8806
Fix generate test formatting
Murderlon Jan 18, 2022
6e1f4a3
Fix eslint errors and add eslint-cypress
Murderlon Jan 18, 2022
eb92b39
Merge branch 'main' into cypress
Murderlon Jan 18, 2022
e59a0c8
Add companion server, add more tests
Murderlon Jan 21, 2022
77bfdad
Update contributing.md
Murderlon Jan 21, 2022
debcf10
Move .parceltc into e2e, fix env and companion setup
Murderlon Jan 21, 2022
422b874
Revert eslint formatting
Murderlon Jan 21, 2022
47eff74
Improve tus tests for reliability
Murderlon Jan 24, 2022
6d7cd80
Update GitHub Actions
Murderlon Jan 24, 2022
2134a09
Don't set companion url in env vars, always local
Murderlon Jan 24, 2022
cb5b04e
fixup! Revert eslint formatting
aduh95 Jan 24, 2022
a165e96
Update `yarn.lock` (fix `yarn dev`)
aduh95 Jan 24, 2022
e56b84c
remove unrelated changes (wrong merge?)
aduh95 Jan 24, 2022
88d3ce2
fixup! remove unrelated changes (wrong merge?)
aduh95 Jan 24, 2022
169a622
fixup! fixup! remove unrelated changes (wrong merge?)
aduh95 Jan 24, 2022
45d4d19
Move all test resources into cypress
Murderlon Jan 26, 2022
a427bba
Add test for dashboard with react
Murderlon Jan 26, 2022
29705ba
Create test for Vue 3 but disable it for now
Murderlon Jan 26, 2022
bde1b1f
Remove old test suite files
Murderlon Jan 26, 2022
d8297b1
Update yarn.lock
Murderlon Jan 26, 2022
b4a94a7
revert `.eslintrc.js` changes
aduh95 Jan 26, 2022
f853f3d
Update script
Murderlon Jan 31, 2022
a42e2de
Merge branch 'main' into cypress
Murderlon Jan 31, 2022
cbf095c
Merge branch 'cypress' of /~https://github.com/transloadit/uppy into cy…
Murderlon Jan 31, 2022
9112e4d
Run e2e also on pull_request
Murderlon Jan 31, 2022
11ede08
bin/companion.sh -> private/dev/companion.js & unify all env files
Murderlon Jan 31, 2022
0272597
Back to companion.sh because that works on CI too
Murderlon Jan 31, 2022
07dc38f
Improve GH Actions triggers
Murderlon Jan 31, 2022
9ec5f46
Try to correctly use env in companion.sh
Murderlon Jan 31, 2022
cab6d92
Use `fileURLToPath` in vite.config.js
Murderlon Jan 31, 2022
910af28
Update CONTRIBUTING.md
Murderlon Jan 31, 2022
b66d7ec
Inject contributing.md in website and fix lint error
Murderlon Feb 1, 2022
45c3158
Don't ignore .env.example
Murderlon Feb 2, 2022
7cce447
Also do not forget to actually commit .env.example
Murderlon Feb 2, 2022
c1b929b
Apply suggestions from code review
Murderlon Feb 2, 2022
2716cdd
Make generate-test executable
Murderlon Feb 3, 2022
d31f09f
Use top level await in generate-test
Murderlon Feb 3, 2022
7ddf791
Fix lint errors
Murderlon Feb 3, 2022
956cd92
Actually fix lint error
Murderlon Feb 3, 2022
f460e7a
reuse VITE env variable for convenience
aduh95 Feb 7, 2022
e542df4
Upgrade npm deps
aduh95 Feb 7, 2022
69128fd
fixup! reuse VITE env variable for convenience
aduh95 Feb 8, 2022
7679bcb
fix conflicts
aduh95 Feb 8, 2022
1699548
Merge branch 'main' of /~https://github.com/transloadit/uppy
aduh95 Feb 8, 2022
ee9d715
Update `yarn.lock`
aduh95 Feb 8, 2022
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
59 changes: 59 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Rename this file to `.env`

NODE_ENV=development

# Companion
# =======================
COMPANION_DATADIR=./output
COMPANION_DOMAIN=localhost:3020
COMPANION_PROTOCOL=http
COMPANION_PORT=3020
COMPANION_CLIENT_ORIGINS=
COMPANION_SECRET=development

COMPANION_DROPBOX_KEY=***
COMPANION_DROPBOX_SECRET=***

COMPANION_BOX_KEY=***
COMPANION_BOX_SECRET=***

COMPANION_GOOGLE_KEY=***
COMPANION_GOOGLE_SECRET=***

COMPANION_INSTAGRAM_KEY=***
COMPANION_INSTAGRAM_SECRET=***

COMPANION_FACEBOOK_KEY=***
COMPANION_FACEBOOK_SECRET=***

COMPANION_ZOOM_KEY=***
COMPANION_ZOOM_SECRET=***

COMPANION_UNSPLASH_KEY=***
COMPANION_UNSPLASH_SECRET=***

# Transloadit keys can also be used in `e2e/clients`
TRANSLOADIT_KEY=***
TRANSLOADIT_TEMPLATE=***
TRANSLOADIT_SERVICE_URL=https://api2.transloadit.com

# Development environment
# =======================

VITE_UPLOADER=tus
# VITE_UPLOADER=s3
# VITE_UPLOADER=s3-multipart
# xhr will use protocol 'multipart' in companion, if used with a remote service, e.g. google drive.
# If local upload will use browser XHR
# VITE_UPLOADER=xhr
# VITE_UPLOADER=transloadit
# VITE_UPLOADER=transloadit-s3
# VITE_UPLOADER=transloadit-xhr

VITE_COMPANION_URL=http://localhost:3020
VITE_TUS_ENDPOINT=https://tusd.tusdemo.net/files/
VITE_XHR_ENDPOINT=https://xhr-server.herokuapp.com/upload

VITE_TRANSLOADIT_KEY=***
VITE_TRANSLOADIT_TEMPLATE=***
VITE_TRANSLOADIT_SERVICE_URL=https://api2.transloadit.com
20 changes: 17 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,14 @@ module.exports = {
files: ['**/*.ts', '**/*.md/*.ts', '**/*.md/*.typescript'],
excludedFiles: ['examples/angular-example/**/*.ts', 'packages/@uppy/angular/**/*.ts'],
parser: '@typescript-eslint/parser',
plugins: [
'@typescript-eslint',
],
settings: {
'import/resolver': {
node: {
extensions: ['.js', '.jsx', '.ts', '.tsx'],
},
},
},
plugins: ['@typescript-eslint'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
Expand All @@ -302,6 +307,7 @@ module.exports = {
rules: {
'import/prefer-default-export': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-namespace': 'off',
},
},
{
Expand All @@ -320,5 +326,13 @@ module.exports = {
react: { pragma: 'React' },
},
},
{
files: ['e2e/**/*.ts'],
extends: ['plugin:cypress/recommended'],
},
{
files: ['e2e/**/*.ts', 'e2e/**/*.js'],
rules: { 'import/no-extraneous-dependencies': 'off' },
},
],
}
43 changes: 9 additions & 34 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,52 +30,27 @@ Our website’s examples section is also our playground, please read the [Local

## Tests

### Unit tests

Unit tests are using Jest and can be run with:

```bash
yarn run test:unit
```

For end-to-end tests, we use [Webdriverio](http://webdriver.io). For it to run locally, you need to install a Selenium standalone server. Follow [the Webdriverio guide](https://webdriver.io/docs/selenium-standalone-service) to do so. You can also install a Selenium standalone server from NPM:

```bash
npm install selenium-standalone -g
selenium-standalone install
```

And then launch it:

```bash
selenium-standalone start
```

After you have installed and launched the selenium standalone server, run:

```bash
yarn run test:endtoend:local
```

By default, `test:endtoend:local` uses Firefox. You can use a different browser, like Chrome, by passing the `-b` flag:

```bash
yarn run test:endtoend:local -- -b chrome
```
### End-to-End tests

> Note: The `--` is important, it tells yarn that the remaining arguments should be interpreted by the script itself, not by yarn.
We use [Cypress](cypress.io/) for our e2e test suite. Be sure to checkout “[Writing your first test](https://docs.cypress.io/guides/getting-started/writing-your-first-test#Add-a-test-file)” and the “[Introduction to Cypress](https://docs.cypress.io/guides/core-concepts/introduction-to-cypress#Cypress-Can-Be-Simple-Sometimes)”. You should also be aware of the “[Best Practices](https://docs.cypress.io/guides/references/best-practices)”.

You can run in several browsers by passing several `-b` flags:
To get started make sure you have your `.env` set up. If it doesn’t exist, copy and rename the `.env.local` file and populate (some) of the values. What values need to be populated depends on what tests you want to run.

```bash
yarn run test:endtoend:local -- -b chrome -b firefox
```
To start the testing suite run:

When trying to get a specific integration test to pass, it’s not that helpful to continuously run _all_ tests. You can use the `--suite` flag to run tests from a single `./test/endtoend` folder. For example, `--suite thumbnails` will only run the tests from `./test/endtoend/thumbnails`. It can also be used in conjunction with one or more `-b` flags.
yarn e2e

```bash
yarn run test:endtoend:local -- -b chrome --suite thumbnails
```
To generate the boilerplate for a new test run:

These tests are also run automatically on Travis builds with [SauceLabs](https://saucelabs.com/) cloud service using different OSes.
yarn e2e:generate

## Development

Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
name: CI
on: [push, pull_request]

on:
push:
branches: [ main ]
pull_request:
# We want all branches so we configure types to be the GH default again
types: [ opened, synchronize, reopened ]

jobs:
unit_tests:
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/companion.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
name: Companion
on: [push, pull_request]
on:
push:
branches: [ main ]
pull_request:
# We want all branches so we configure types to be the GH default again
types: [ opened, synchronize, reopened ]

jobs:
test:
Expand Down
31 changes: 13 additions & 18 deletions .github/workflows/end-to-end.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
name: End-to-end tests
on: push

env:
GIT_AUTHOR_NAME: Uppy Bot
GIT_COMMITTER_NAME: Uppy Bot
GIT_AUTHOR_EMAIL: uppybot@uppy.io
GIT_COMMITTER_EMAIL: uppybot@uppy.io
on:
push:
branches: [ main ]
pull_request:
# We want all branches so we configure types to be the GH default again
types: [ opened, synchronize, reopened ]

jobs:
e2e:
Expand All @@ -30,17 +29,13 @@ jobs:
node-version: 16.x
- name: Install dependencies
run: corepack yarn install --immutable
- name: Start Sauce Connect
uses: saucelabs/sauce-connect-action@v1.1.1
with:
username: ${{secrets.SAUCE_USERNAME}}
accessKey: ${{secrets.SAUCE_ACCESS_KEY}}
tunnelIdentifier: ${{github.run_id}}.${{github.run_number}}
- name: Build Uppy packages
run: corepack yarn build
- name: Run end-to-end browser tests
run: corepack yarn run test:endtoend
run: corepack yarn run e2e:ci
env:
SAUCE_TUNNEL_IDENTIFIER: ${{github.run_id}}.${{github.run_number}}
SAUCE_BUILD: ${{github.run_id}}
SAUCE_USERNAME: ${{secrets.SAUCE_USERNAME}}
SAUCE_ACCESS_KEY: ${{secrets.SAUCE_ACCESS_KEY}}
COMPANION_UNSPLASH_KEY: ${{secrets.COMPANION_UNSPLASH_KEY}}
COMPANION_UNSPLASH_SECRET: ${{secrets.COMPANION_UNSPLASH_SECRET}}
TRANSLOADIT_KEY: ${{secrets.TRANSLOADIT_KEY}}
TRANSLOADIT_TEMPLATE: ${{secrets.TRANSLOADIT_TEMPLATE}}
TRANSLOADIT_SERVICE_URL: ${{secrets.TRANSLOADIT_SERVICE_URL}}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ node_modules
.yarn/install-state.gz
yarn-error.log

env.sh
.env
*.local

dist/
Expand Down
11 changes: 0 additions & 11 deletions bin/companion

This file was deleted.

19 changes: 19 additions & 0 deletions bin/companion.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

# Load local env vars. In CI, these are injected.
if [ -f .env ]; then
# https://gist.github.com/mihow/9c7f559807069a03e302605691f85572?permalink_comment_id=3625310#gistcomment-3625310
set -a
source <(sed -e '/^#/d;/^\s*$/d' -e "s/'/'\\\''/g" -e "s/=\(.*\)/='\1'/g" .env)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you considered /~https://github.com/motdotla/dotenv ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, tried it here: 11ede08 but couldn't get it to work in CI.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What didn't work? didn't it load the .env file?
If .env was inside private/dev/.env, then I suspect that this line was the problem:

    "start:companion": "yarn node private/dev/companion.js",

11ede08#diff-7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519R146

I think dotenv searches inside CWD and not inside the directory of the .js file, so for it to work it would have to be changed to:

    "start:companion": "cd private/dev && yarn node companion.js",

set +a
nodemon --watch packages/@uppy/companion/src --exec node ./packages/@uppy/companion/src/standalone/start-server.js
else
env \
COMPANION_DATADIR="./output" \
COMPANION_DOMAIN="localhost:3020" \
COMPANION_PROTOCOL="http" \
COMPANION_PORT=3020 \
COMPANION_CLIENT_ORIGINS="" \
COMPANION_SECRET="development" \
nodemon --watch packages/@uppy/companion/src --exec node ./packages/@uppy/companion/src/standalone/start-server.js
fi
19 changes: 0 additions & 19 deletions bin/endtoend-build

This file was deleted.

88 changes: 0 additions & 88 deletions bin/endtoend-build-ci

This file was deleted.

Loading