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

test(app): Add end-to-end test automation using Cypress #8081

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,9 @@ api/pyproject.toml
*.tsbuildinfo

# Static storybook build artifacts
storybook-static/
storybook-static/

# Cypress screenshots and videos
app/cypress/screenshots
app/cypress/videos
app/cypress/downloads
12 changes: 12 additions & 0 deletions .opentrons_config/robot/deck_calibration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"attitude": [
[1.0, -0.0, 0.0],
[-0.0, 1.0, 0.0],
[0.0, 0.0, 1.0]
],
"pipette_calibrated_with": "P20SV202020070101",
"last_modified": "2021-07-07T15:30:26.457191+00:00",
"tiprack": "60e107ba7e6e5d23beefe9f0c888f860f7b923c71906aaa5e7f460ab25c4f38a",
"source": "user",
"status": { "markedBad": false }
}
1 change: 1 addition & 0 deletions .opentrons_config/robot/pipettes/index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "left": ["P3HMV202020041605"], "right": ["P20SV202020070101"] }
8 changes: 8 additions & 0 deletions .opentrons_config/robot/pipettes/left/P3HMV202020041605.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"offset": [-1.7763568394002505e-15, 0.0, -5.0],
"tiprack": "60e107ba7e6e5d23beefe9f0c888f860f7b923c71906aaa5e7f460ab25c4f38a",
"uri": "opentrons/opentrons_96_tiprack_20ul/1",
"last_modified": "2021-07-07T15:54:07.984819+00:00",
"source": "user",
"status": { "markedBad": false }
}
8 changes: 8 additions & 0 deletions .opentrons_config/robot/pipettes/right/P20SV202020070101.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"offset": [0.0, 0.0, -5.0],
"tiprack": "60e107ba7e6e5d23beefe9f0c888f860f7b923c71906aaa5e7f460ab25c4f38a",
"uri": "opentrons/opentrons_96_tiprack_20ul/1",
"last_modified": "2021-07-07T15:54:22.044521+00:00",
"source": "user",
"status": { "markedBad": false }
}
9 changes: 9 additions & 0 deletions .opentrons_config/tip_lengths/P20SV202020070101.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"60e107ba7e6e5d23beefe9f0c888f860f7b923c71906aaa5e7f460ab25c4f38a": {
"tipLength": 30.950000000000003,
"lastModified": "2021-07-07T15:30:01.867528+00:00",
"source": "user",
"status": { "markedBad": false },
"uri": "opentrons/opentrons_96_tiprack_20ul/1"
}
}
9 changes: 9 additions & 0 deletions .opentrons_config/tip_lengths/P3HMV202020041605.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"60e107ba7e6e5d23beefe9f0c888f860f7b923c71906aaa5e7f460ab25c4f38a": {
"tipLength": 30.950000000000017,
"lastModified": "2021-07-07T15:29:42.868663+00:00",
"source": "user",
"status": { "markedBad": false },
"uri": "opentrons/opentrons_96_tiprack_20ul/1"
}
}
6 changes: 6 additions & 0 deletions .opentrons_config/tip_lengths/index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"60e107ba7e6e5d23beefe9f0c888f860f7b923c71906aaa5e7f460ab25c4f38a": [
"P3HMV202020041605",
"P20SV202020070101"
]
}
35 changes: 35 additions & 0 deletions app/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,38 @@ dev-shell:
wait-on http-get:https://localhost:$(PORT)
$(MAKE) -C $(shell_dir) dev

# end-to-end tests
#####################################################################

.PHONY: docker-emulator
docker-emulator:
docker-compose down
docker-compose up --build

.PHONY: external-browser-app
external-browser-app:
$(MAKE) dev OT_APP_UI__EXTERNAL_BROWSER=1

.PHONY: test-cypress
test-cypress:
wait-on http:https://localhost:$(PORT) && \
wait-on http-get:https://localhost:31950/openapi.json && \
cypress run --browser electron --record false

.PHONY: test-e2e
test-e2e:
concurrently --kill-others --names "emulator,app,tests" \
"$(MAKE) docker-emulator" \
"$(MAKE) external-browser-app" \
"$(MAKE) test-cypress"

.PHONY: cypress-visual
cypress-visual:
cypress open

.PHONY: visual
visual:
concurrently --kill-others --names "emulator,app,tests" \
"$(MAKE) docker-emulator" \
"$(MAKE) external-browser-app" \
"$(MAKE) cypress-visual"
15 changes: 15 additions & 0 deletions app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,21 @@ Test tasks can also be run with the following arguments:
| watch | false | Run tests in watch mode | `$ make test-unit watch=true` |
| cover | !watch | Calculate code coverage | `$ make test watch=true cover=true` |

For end-to-end tests using Cypress, ensure that the Docker emulator is running and calibrated before attempting to execute the following.
See DOCKER.md in root directory for instructions on running the Docker emulator.

Incorporating this into the test automation is currently in progress.

```shell
# To launch the app in an external browser mode.
make -C app dev OT_APP_UI__EXTERNAL_BROWSER=1
# Run Cypress end-to-end tests in terminal without any GUI.
make test-e2e
# Open the Cypress test runner GUI to visually see the test suites run.
# Won't automatically start running tests. You will need to click on the test suites to run them.
make cypress-visual
```

## building

If you'd like to build the Electron desktop app, see the [app shell's build instructions][app-shell-readme-build].
Expand Down
4 changes: 4 additions & 0 deletions app/cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"defaultCommandTimeout": 20000,
"video": false
}
55 changes: 55 additions & 0 deletions app/cypress/fixtures/Opentrons_Logo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
def get_values(*names):
import json
_all_values = json.loads("""{"pip_model":"p20_single_gen2","pip_mount":"right","dp_type":"nest_96_wellplate_200ul_flat","dye_type":"usascientific_12_reservoir_22ml"}""")
return [_all_values[n] for n in names]


metadata = {
'protocolName': 'Opentrons Logo',
'author': 'Opentrons <[email protected]>',
'source': 'Protocol Library',
'apiLevel': '2.2'
}


def run(protocol):
[pip_model, pip_mount, dp_type, dye_type] = get_values( # noqa: F821
'pip_model', 'pip_mount', 'dp_type', 'dye_type')

# create pipette and tiprack
tip_size = pip_model.split('_')[0][1:]
tip_size = '300' if tip_size == '50' else tip_size
tip_name = 'opentrons_96_tiprack_'+tip_size+'ul'
tips = [protocol.load_labware(tip_name, '1', 'Opentrons Tips')]

pipette = protocol.load_instrument(
pip_model, pip_mount, tip_racks=tips)

# create plates and pattern list
output = protocol.load_labware(dp_type, '3', 'Destination Plate')

dye_container = protocol.load_labware(dye_type, '2', 'Dye Source')

# Well Location set-up
dye1_wells = ['A5', 'A6', 'A8', 'A9', 'B4', 'B10', 'C3', 'C11', 'D3',
'D11', 'E3', 'E11', 'F3', 'F11', 'G4', 'G10',
'H5', 'H6', 'H7', 'H8', 'H9']

dye2_wells = ['C7', 'D6', 'D7', 'D8', 'E5', 'E6', 'E7', 'E8',
'E9', 'F5', 'F6', 'F7', 'F8', 'F9', 'G6', 'G7', 'G8']

dye2 = dye_container['A1']
dye1 = dye_container['A2']

dye_vol = 100 if tip_size == '1000' else 50

pipette.distribute(
dye_vol,
dye1,
[output.wells_by_name()[well_name] for well_name in dye1_wells],
new_tip='once')
pipette.distribute(
dye_vol,
dye2,
[output.wells_by_name()[well_name] for well_name in dye2_wells],
new_tip='once')
Loading