Skip to content

Commit

Permalink
Update test
Browse files Browse the repository at this point in the history
  • Loading branch information
trungleduc committed Mar 28, 2024
1 parent 466f6fb commit af99ac9
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 73 deletions.
113 changes: 57 additions & 56 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,62 +38,62 @@ jobs:
dist/tljh_repo2docker*.whl
if-no-files-found: error

isolated-tests:
name: Isolated tests
needs: build
runs-on: ubuntu-latest

steps:
- name: Base Setup
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1

- uses: actions/download-artifact@v3
with:
name: tljh_repo2docker-artifacts

- name: Install and Test
run: |
set -eux
# Remove NodeJS, twice to take care of system and locally installed node versions.
sudo rm -rf $(which node)
sudo rm -rf $(which node)
python -m pip install git+https://github.com/jupyterhub/the-littlest-jupyterhub tljh_repo2docker*.whl
- name: Test import
run: python -c "import tljh_repo2docker"

unit-tests:
name: Unit tests
needs: build
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10"]

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

- name: Base Setup
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1

- name: Download app package
uses: actions/download-artifact@v3
with:
name: tljh_repo2docker-artifacts

- name: Install package
run: |
set -eux
python -m pip install -r dev-requirements.txt
python -m pip install tljh_repo2docker*.whl
npm -g install configurable-http-proxy
- name: Run Tests
run: |
python -m pytest --cov
# isolated-tests:
# name: Isolated tests
# needs: build
# runs-on: ubuntu-latest

# steps:
# - name: Base Setup
# uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1

# - uses: actions/download-artifact@v3
# with:
# name: tljh_repo2docker-artifacts

# - name: Install and Test
# run: |
# set -eux
# # Remove NodeJS, twice to take care of system and locally installed node versions.
# sudo rm -rf $(which node)
# sudo rm -rf $(which node)

# python -m pip install git+https://github.com/jupyterhub/the-littlest-jupyterhub tljh_repo2docker*.whl

# - name: Test import
# run: python -c "import tljh_repo2docker"

# unit-tests:
# name: Unit tests
# needs: build
# runs-on: ubuntu-latest
# strategy:
# fail-fast: false
# matrix:
# python-version: ["3.8", "3.9", "3.10"]

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

# - name: Base Setup
# uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1

# - name: Download app package
# uses: actions/download-artifact@v3
# with:
# name: tljh_repo2docker-artifacts

# - name: Install package
# run: |
# set -eux
# python -m pip install -r dev-requirements.txt
# python -m pip install tljh_repo2docker*.whl
# npm -g install configurable-http-proxy

# - name: Run Tests
# run: |
# python -m pytest --cov

integration-tests:
name: Integration tests
Expand Down Expand Up @@ -152,3 +152,4 @@ jobs:
path: |
ui-tests/test-results
ui-tests/playwright-report
ui-tests/server.log
24 changes: 12 additions & 12 deletions .github/workflows/check-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Base Setup
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
# - name: Base Setup
# uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1

- name: Check Release
uses: jupyter-server/jupyter_releaser/.github/actions/check-release@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
version_spec: next
# - name: Check Release
# uses: jupyter-server/jupyter_releaser/.github/actions/check-release@v2
# with:
# token: ${{ secrets.GITHUB_TOKEN }}
# version_spec: next

- name: Upload Distributions
uses: actions/upload-artifact@v3
with:
name: tljh_repo2docker-releaser-dist-${{ github.run_number }}
path: .jupyter_releaser_checkout/dist
# - name: Upload Distributions
# uses: actions/upload-artifact@v3
# with:
# name: tljh_repo2docker-releaser-dist-${{ github.run_number }}
# path: .jupyter_releaser_checkout/dist
1 change: 1 addition & 0 deletions src/servers/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ if (rootElement) {
service_prefix,
admin_access
} = jhData;
console.log('USING ###########', xsrf_token);
root.render(
<JupyterhubContext.Provider
value={{
Expand Down
10 changes: 9 additions & 1 deletion tljh_repo2docker/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from jinja2 import Template
from jupyterhub.services.auth import HubOAuthenticated
from jupyterhub.utils import url_path_join
from tornado import web
from tornado import web, version as tor_Version

from tljh_repo2docker import TLJH_R2D_ADMIN_SCOPE

Expand Down Expand Up @@ -81,6 +81,14 @@ async def render_template(self, name: str, **kwargs) -> str:
"""
user = await self.fetch_user()
base_url = self.settings.get("base_url", "/")
version, token, timestamp = self._get_raw_xsrf_token()
self.settings["log"].info(
f"########## CHECKING RAW {token} timescpae {timestamp} version {version} tornado {tor_Version}"
)
self.settings["log"].info(
f'########## SENDING {self.xsrf_token.decode("ascii")} version {self.settings.get("xsrf_cookie_version", "NOTFOUND")}'
)

template_ns = dict(
service_prefix=self.settings.get("service_prefix", "/"),
hub_prefix=self.settings.get("hub_prefix", "/"),
Expand Down
3 changes: 2 additions & 1 deletion ui-tests/playwright.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ module.exports = {
}
},
webServer: {
command: 'python -m jupyterhub -f ../jupyterhub_config.py',
command:
'python -m jupyterhub -f ../jupyterhub_config.py > server.log 2>&1',
url: 'http://localhost:8000',
timeout: 120 * 1000,
reuseExistingServer: true
Expand Down
21 changes: 18 additions & 3 deletions ui-tests/tests/ui.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect, test, Page } from '@playwright/test';
import { expect, test, Page, Cookie } from '@playwright/test';

async function login(page: Page, user: string) {
await page.goto('hub/login');
Expand Down Expand Up @@ -123,9 +123,22 @@ test.describe('tljh_repo2docker UI Tests', () => {
expect(await page.screenshot()).toMatchSnapshot('servers-dialog.png');
});

test('Start server', async ({ page }) => {
test('Start server', async ({ page, context }) => {
await login(page, 'alice');
await page.goto('/services/tljh_repo2docker/servers');
console.log('########### AFTER GOTO PAGE', await context.cookies());
const newCookies = (await context.cookies()).filter(el => {
if (el.name !== '_xsrf') {
return true;
}
if (el.path === '/hub/') {
return true;
}
});
await context.clearCookies();
await context.addCookies(newCookies);
console.log('########### AFTER FILTERED', await context.cookies());

await page.waitForTimeout(500);
await page.waitForSelector('div:has-text("No servers are running")', {
timeout: 1000
Expand All @@ -142,9 +155,11 @@ test.describe('tljh_repo2docker UI Tests', () => {
const createServer = await page.getByRole('button', {
name: 'Create Server'
});

await createServer.click();
await expect(createServer).toHaveCount(0);
// await page.waitForTimeout(1000);
await page.waitForURL('**/servers');
// await expect(createServer).toHaveCount(0);
await page.waitForTimeout(1000);

expect(await page.screenshot()).toMatchSnapshot('running-servers.png');
Expand Down

0 comments on commit af99ac9

Please sign in to comment.