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

ENH - Add Playwright for automated testing #293

Merged
merged 25 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
6a53bb9
add playwright files, add github ci test
kcpevey Sep 18, 2023
dc14b04
fix typo
kcpevey Sep 18, 2023
aa21b48
fix another typo...
kcpevey Sep 18, 2023
4e6a4ba
take a different approach to yarn start
kcpevey Sep 18, 2023
3b99b39
take a different approach to yarn start
kcpevey Sep 18, 2023
ceb95ae
gh action syntax fix
kcpevey Sep 18, 2023
45947bd
add wait-for-it
kcpevey Sep 18, 2023
3402f33
ensure conda env is activated
kcpevey Sep 18, 2023
70a58c3
yarm immutable installs false
kcpevey Sep 18, 2023
6dd6a5d
screenshot is a forbidden pytest option, create .env file
kcpevey Sep 18, 2023
09399d1
switch to expect new ui on 8080
kcpevey Sep 19, 2023
aa9e039
switch to look on port 8081 for the test
kcpevey Sep 20, 2023
4c57eb6
i obviously didn't know how to envsubst works
kcpevey Sep 20, 2023
8da719f
why does this work differently on my machine???
kcpevey Sep 20, 2023
25ca867
switch back to 5000 for conda-store-server and 8080 for the ui
kcpevey Sep 22, 2023
6f54bd1
add a long timeout for the first page load to ensure startup is complete
kcpevey Sep 22, 2023
56cc4f0
use 5000 for server port
kcpevey Oct 2, 2023
dc98247
one. more. try.
kcpevey Oct 2, 2023
9300c5b
cleanup
kcpevey Oct 2, 2023
84039b0
env var in ci
kcpevey Oct 2, 2023
da7a1ec
gh actions doesnt support env vars in env vars
kcpevey Oct 3, 2023
b28084d
add a few more doc strings
kcpevey Oct 5, 2023
3822789
Merge branch 'main' into add_playwright
kcpevey Oct 5, 2023
71537bf
attempt to fix mamba issues with unknown symbol
kcpevey Oct 5, 2023
00da8d6
fix for setup-miniconda solver issues
kcpevey Oct 6, 2023
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
8 changes: 8 additions & 0 deletions .env.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
REACT_APP_API_URL=$REACT_APP_API_URL
REACT_APP_AUTH_METHOD=$REACT_APP_AUTH_METHOD
REACT_APP_LOGIN_PAGE_URL=$REACT_APP_LOGIN_PAGE_URL
REACT_APP_AUTH_TOKEN=$REACT_APP_AUTH_TOKEN
REACT_APP_STYLE_TYPE=$REACT_APP_STYLE_TYPE
REACT_APP_CONTEXT=$REACT_APP_CONTEXT
REACT_APP_SHOW_AUTH_BUTTON=$REACT_APP_SHOW_AUTH_BUTTON
REACT_APP_LOGOUT_PAGE_URL=$REACT_APP_LOGOUT_PAGE_URL
77 changes: 77 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Playwright Tests

env:
CONDA_STORE_SERVER_PORT: 8080
CONDA_STORE_BASE_URL: http://localhost:8080
CONDA_STORE_AUTH: basic
CONDA_STORE_USERNAME: username
CONDA_STORE_PASSWORD: password
REACT_APP_API_URL: http://localhost:5000/conda-store/
REACT_APP_AUTH_METHOD: cookie
REACT_APP_LOGIN_PAGE_URL: http://localhost:5000/conda-store/login?next=
REACT_APP_AUTH_TOKEN:
REACT_APP_STYLE_TYPE: green-accent
REACT_APP_CONTEXT: webapp
REACT_APP_SHOW_AUTH_BUTTON: true
REACT_APP_LOGOUT_PAGE_URL: http://localhost:5000/conda-store/logout?next=/
YARN_ENABLE_IMMUTABLE_INSTALLS: false

on:
pull_request:
push:
branches:
- main

jobs:
test-conda-store-ui:
name: 'unit-test conda-store-ui'
strategy:
matrix:
# cannot run on windows due to needing fake-chroot for conda-docker
# osx takes forever to get a scheduled job
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash -el {0}
steps:
- name: 'Checkout Repository'
uses: actions/checkout@master

- name: Set up Python
uses: conda-incubator/setup-miniconda@v2
env:
CONDA_SOLVER: libmamba
with:
activate-environment: test-env
environment-file: environment_dev.yml
auto-activate-base: false

- name: Install Dependencies
run: |
sudo apt install wait-for-it -y

- name: Deploy conda-store-server docker container
run: |
docker-compose -f docker-compose-dev.yml up -d --build
docker ps

wait-for-it localhost:5000 # conda-store-server


- name: Deploy webpack dev server
shell: bash -el {0}
run: |
conda list
playwright install chromium
yarn install
yarn run build
yarn run start &
pytest --video on --output test-results --screenshots true test/playwright/test_ux.py

- name: Upload artifacts
uses: actions/upload-artifact@v2
if: ${{ always() }}
with:
name: playwright-tests
path: test-results
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,6 @@ coverage
*.swp

src/version.ts

# playwright screenshots
static
14 changes: 14 additions & 0 deletions environment_dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Environment for developing the conda-store-ui and for running
# playwright tests

name: test-env
channels:
- conda-forge
dependencies:
- python=3.10
- yarn
- nodejs==16.14.2
steff456 marked this conversation as resolved.
Show resolved Hide resolved
- pytest
- pip:
- playwright
- pytest-playwright
12 changes: 12 additions & 0 deletions test/playwright/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import pytest


def pytest_addoption(parser):
parser.addoption("--screenshots", action="store", default="false")

@pytest.fixture(scope="session")
def screenshot(pytestconfig):
if pytestconfig.getoption("screenshots") == 'false':
return False
else:
return True
Loading
Loading