Skip to content

Commit

Permalink
Add UI test job
Browse files Browse the repository at this point in the history
  • Loading branch information
trungleduc committed Jan 22, 2024
1 parent 3467259 commit bce691a
Show file tree
Hide file tree
Showing 7 changed files with 1,087 additions and 10 deletions.
99 changes: 92 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches: master
pull_request:
branches: '*'
branches: "*"

jobs:
build:
Expand All @@ -19,6 +19,8 @@ jobs:
uses: mamba-org/setup-micromamba@v1
with:
environment-name: tljh
micromamba-version: "1.5.5-0"
init-shell: bash
create-args: >-
python=3.10
nodejs=18
Expand All @@ -39,7 +41,7 @@ jobs:

- name: Setup yarn cache
uses: actions/cache@v2
id: yarn-cache
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: yarn-${{ hashFiles('frontend/yarn.lock') }}
Expand All @@ -50,7 +52,7 @@ jobs:
shell: bash -l {0}
run: |
set -eux
pip install build
python -m pip install build
python -m build .
- name: Upload package
Expand All @@ -69,8 +71,8 @@ jobs:
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
architecture: 'x64'
python-version: "3.10"
architecture: "x64"

- uses: actions/download-artifact@v3
with:
Expand All @@ -83,8 +85,91 @@ jobs:
sudo rm -rf $(which node)
sudo rm -rf $(which node)
python -m pip install tljh_repo2docker*.whl
python -m pip install git+https://github.com/jupyterhub/the-littlest-jupyterhub tljh_repo2docker*.whl
- name: Test import
shell: bash -l {0}
run: python -c "import tljh_repo2docker"
run: python -c "import tljh_repo2docker"

integration-tests:
name: Integration tests
needs: build
runs-on: ubuntu-latest

env:
PLAYWRIGHT_BROWSERS_PATH: ${{ github.workspace }}/pw-browsers

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install Conda environment with Micromamba
uses: mamba-org/setup-micromamba@v1
with:
micromamba-version: "1.5.5-0"
environment-name: tljh
init-shell: bash
create-args: >-
python=3.10
nodejs=18
yarn=3
- name: Download app package
uses: actions/download-artifact@v3
with:
name: tljh_repo2docker-artifacts

- name: Install package
shell: bash -l {0}
run: |
set -eux
# Remove NodeJS, twice to take care of system and locally installed node versions.
python -m pip install -r dev-requirements.txt
python -m pip install tljh_repo2docker*.whl
npm -g install configurable-http-proxy
- name: Install UI test dependencies
shell: bash -l {0}
working-directory: frontend/ui-tests
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
run: yarn install

- name: Set up browser cache
uses: actions/cache@v3
with:
path: |
${{ github.workspace }}/pw-browsers
key: ${{ runner.os }}-${{ hashFiles('frontend/ui-tests/yarn.lock') }}

- name: Install browser
shell: bash -l {0}
run: npx playwright install chromium
working-directory: frontend/ui-tests

- name: Start JupyterHub
shell: bash -l {0}
run: |
python -m jupyterhub -f ./jupyterhub_config.py &
- name: Wait for JupyterHub
uses: ifaxity/wait-on-action@v1
with:
resource: http-get://localhost:8000
timeout: 360000

- name: Execute integration tests
shell: bash -l {0}
working-directory: frontend/ui-tests
run: |
npx playwright test
- name: Upload Playwright Test report
if: always()
uses: actions/upload-artifact@v3
with:
name: tljh-playwright-tests
path: |
frontend/ui-tests/test-results
frontend/ui-tests/playwright-report
8 changes: 5 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ docs/_build
docs/build
.ipynb_checkpoints
jupyterhub_cookie_secret
jupyterhub.sqlite
jupyterhub-proxy.pid
**/jupyterhub.sqlite
**/jupyterhub-proxy.pid
*.egg-info
MANIFEST
.coverage
Expand All @@ -24,4 +24,6 @@ config.yaml
node_modules
frontend/dist
frontend/lib
**/js/react/
frontend/ui-tests/playwright-report
frontend/ui-tests/test-results
**/js/react/
16 changes: 16 additions & 0 deletions frontend/ui-tests/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "tljh_repo2docker-ui-tests",
"version": "1.0.0",
"description": "tljh_repo2docker UI Tests",
"private": true,
"scripts": {
"test": "npx playwright test --workers 1",
"test:update": "npx playwright test --update-snapshots",
"test:debug": "PWDEBUG=1 npx playwright test --workers 1"
},
"license": "BSD-3-Clause",
"dependencies": {
"@playwright/test": "^1.31.0",
"rimraf": "^4.1.2"
}
}
22 changes: 22 additions & 0 deletions frontend/ui-tests/playwright.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module.exports = {
timeout: 120000,
reporter: [[process.env.CI ? "dot" : "list"], ["html"]],
use: {
baseURL: "http://localhost:8000",
video: "retain-on-failure",
},
retries: 0,
expect: {
toMatchSnapshot: {
maxDiffPixelRatio: 0.02,
},
},
webServer: [
{
command: "yarn start",
port: 8000,
timeout: 120 * 1000,
reuseExistingServer: false,
},
],
};
17 changes: 17 additions & 0 deletions frontend/ui-tests/tests/ui.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { expect, test } from '@playwright/test';

test.describe('tljh_repo2docker UI Tests', () => {
test.beforeEach(({ page }) => {
page.setDefaultTimeout(60000);
});

test.afterEach(async ({ page }) => {
await page.close({ runBeforeUnload: true });
});

test('Render Login', async ({ page }) => {
await page.goto('hub/login');
await page.getByText('Sign in');
expect(await page.screenshot()).toMatchSnapshot();
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit bce691a

Please sign in to comment.