Skip to content
Merged
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
49 changes: 49 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: CI

on:
push:
pull_request:

jobs:
test:
runs-on: ubuntu-latest

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

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -e .
pip install pytest

- name: Run Python tests
run: python -m pytest tests/ -q

- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"

- name: Install Playwright package
run: npm install

- name: Cache Playwright browsers
id: playwright-cache
uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ hashFiles('package-lock.json') }}

- name: Install Playwright browser
run: npx playwright install --with-deps chromium

- name: Run Playwright smoke tests
run: npm run test:e2e
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
node_modules/
test-results/
.ipynb_checkpoints
legacy_code/
.DS_Store
Expand Down
42 changes: 41 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,44 @@ A method for drawing ancestral recombination graphs from tskit tree sequences in

Users can click and drag the nodes (including the sample) along the x-axis to further clean up the layout of the graph. The simulation does not take into account line crosses, which can often be improved with some fiddling. Once a node has been moved by a user, its position is fixed with regards to the force simulation.

See [tutorial.md](https://github.com/kitchensjn/tskit_arg_visualizer/blob/main/docs/tutorial.md) for a walkthrough of the package.
See [tutorial.md](https://github.com/kitchensjn/tskit_arg_visualizer/blob/main/docs/tutorial.md) for a walkthrough of the package.

## Testing (Local and CI)

This repository now includes:

- Python tests (pytest), under `tests/`
- Minimal browser smoke tests (Playwright), under `tests/playwright/`

### Local setup

1. Install Python dependencies and test runner:

```bash
python -m pip install --upgrade pip
pip install -e .
pip install pytest
```

2. Install Playwright tooling:

```bash
npm install
npx playwright install --with-deps chromium
```

3. Run tests:

```bash
python -m pytest tests/ -q
npm run test:e2e
```

### GitHub Actions

CI is defined in `.github/workflows/ci.yml` and runs both:

- `python -m pytest tests/ -q`
- `npm run test:e2e`

If commands change locally, update them in both this README and the workflow file so local and CI behavior stay aligned.
74 changes: 74 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "tskit_arg_visualizer-e2e",
"private": true,
"version": "0.0.0",
"description": "Minimal Playwright setup for browser smoke tests",
"scripts": {
"test:e2e": "playwright test",
"test:e2e:headed": "playwright test --headed",
"test:e2e:install": "playwright install --with-deps chromium"
},
"devDependencies": {
"@playwright/test": "^1.54.1"
}
}
18 changes: 18 additions & 0 deletions playwright.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const { defineConfig } = require("@playwright/test");

module.exports = defineConfig({
testDir: "tests/playwright",
timeout: 30 * 1000,
expect: {
timeout: 5 * 1000,
},
use: {
headless: true,
},
projects: [
{
name: "chromium",
use: { browserName: "chromium" },
},
],
});
28 changes: 28 additions & 0 deletions tests/playwright/smoke.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const { test, expect } = require("@playwright/test");
const fs = require("fs");
const os = require("os");
const path = require("path");

// This smoke test intentionally avoids network or project-specific runtime
// dependencies. It verifies that Playwright is wired up and can execute
// JavaScript in a real browser context in CI.
test("opens local HTML and evaluates client-side JS", async ({ page }) => {
const html = [
"<!doctype html>",
"<html>",
"<head><meta charset='utf-8'><title>argviz smoke</title></head>",
"<body>",
" <h1 id='status'>ready</h1>",
" <script>",
" document.getElementById('status').textContent = 'playwright-ok';",
" </script>",
"</body>",
"</html>",
].join("\n");

const htmlPath = path.join(os.tmpdir(), `argviz-playwright-${Date.now()}.html`);
fs.writeFileSync(htmlPath, html, "utf8");

await page.goto(`file://${htmlPath}`);
await expect(page.locator("#status")).toHaveText("playwright-ok");
});
Loading
Loading