Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f7638a0
ci: init e2e test for browser env
XiaochenCui Oct 21, 2025
c2fb724
test: update fsentry definition, add tests
XiaochenCui Oct 23, 2025
90b2121
test: pass puter-js mkdir test
XiaochenCui Oct 23, 2025
a6494b0
test: add test for puter-js move
XiaochenCui Oct 23, 2025
6c64591
tidy code
XiaochenCui Oct 23, 2025
b49ac98
tidy code
XiaochenCui Oct 23, 2025
e66c49d
doc: add docs for playwright test
XiaochenCui Oct 23, 2025
e81ca5c
recover memoryfs
XiaochenCui Oct 23, 2025
4990269
test: puter-js readdir/stat
XiaochenCui Oct 27, 2025
343c37b
test: puter-js write
XiaochenCui Oct 27, 2025
4e29623
test: puter-js read
XiaochenCui Oct 27, 2025
f875cac
test: puter-js move_cart
XiaochenCui Oct 27, 2025
42553ce
test: fix failed tests on move
XiaochenCui Oct 27, 2025
d098674
tests: rename files
XiaochenCui Oct 27, 2025
9468d44
test: puter-js copy_cart
XiaochenCui Oct 27, 2025
0d44dfc
tests: puter-js batch/delete, read config from file
XiaochenCui Oct 28, 2025
a814dcb
ci: add vitest
XiaochenCui Oct 28, 2025
92ee44b
ci: update names and timeout
XiaochenCui Oct 28, 2025
950861b
ci: simplify playwright-test
XiaochenCui Oct 28, 2025
16f8fe3
ci: simplify api-test
XiaochenCui Oct 28, 2025
4cbf245
move "api-tester" from tools to tests
XiaochenCui Oct 28, 2025
c6222d1
test: update example config
XiaochenCui Oct 28, 2025
47a2b07
test: remove folder tests/api-tester/ci
XiaochenCui Oct 28, 2025
77e0403
test: unify config location
XiaochenCui Oct 28, 2025
2627ca2
test: remove unused files
XiaochenCui Oct 28, 2025
347615b
ci: fix wrong config
XiaochenCui Oct 28, 2025
81151bc
ci: fix wrong path
XiaochenCui Oct 28, 2025
2f5f37d
test: add docs
XiaochenCui Oct 28, 2025
d6ee80f
ci: update timeout, print artifact url
XiaochenCui Oct 28, 2025
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
125 changes: 108 additions & 17 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: test

on:
push:
branches: [ "main" ]
branches: ["main"]
pull_request:
branches: [ "main" ]
branches: ["main"]

jobs:
test:
Expand All @@ -15,23 +15,24 @@ jobs:
node-version: [20.x, 22.x]

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

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Build
run: |
rm package-lock.json
npm install -g npm@latest
npm install
npm run test
- name: Build
run: |
rm package-lock.json
npm install -g npm@latest
npm install
npm run test

api-test:
name: backend (node env, api-test)
runs-on: ubuntu-latest
timeout-minutes: 10
timeout-minutes: 5

strategy:
matrix:
Expand All @@ -44,8 +45,98 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: API Test
run: |
pip install -r ./tools/api-tester/ci/requirements.txt
./tools/api-tester/ci/run.py
pip install -r ./tests/ci/requirements.txt
./tests/ci/api-test.py

playwright-test:
name: puterjs (browser env, playwright)
runs-on: ubuntu-latest
timeout-minutes: 10

strategy:
matrix:
node-version: [22.x]

steps:
- uses: actions/checkout@v4

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Install Dependencies
run: npm install
working-directory: ./tests/playwright

- name: Install Playwright Browsers
run: npx playwright install --with-deps
working-directory: ./tests/playwright

- name: Playwright Test
run: |
pip install -r ./tests/ci/requirements.txt
./tests/ci/playwright-test.py

- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: server-logs
path: |
/tmp/backend.log
/tmp/fs-tree-manager.log
retention-days: 3

- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: config-files
path: |
./volatile/config/config.json
./src/fs_tree_manager/config.yaml
./tests/client-config.yaml
retention-days: 3

- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
id: playwright-report
with:
name: playwright-report
path: tests/playwright/playwright-report/
retention-days: 3

- name: Get Playwright artifact URL
run: |
ARTIFACT_URL=$(gh api repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts \
--jq '.artifacts[] | select(.name=="playwright-report") | .archive_download_url')
echo "url=$ARTIFACT_URL" >> $GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Output artifact URL
run: echo 'Artifact URL is ${{ steps.playwright-report.outputs.artifact-url }}'

vitest:
name: puterjs (node env, vitest)
runs-on: ubuntu-latest
timeout-minutes: 5

strategy:
matrix:
node-version: [22.x]

steps:
- uses: actions/checkout@v4

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Vitest Test
run: |
pip install -r ./tests/ci/requirements.txt
./tests/ci/vitest.py
14 changes: 13 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,22 @@ jsconfig.json
# the exact tree installed in the node_modules folder
package-lock.json

# ======================================================================
# playwright test (currently only test the file-system)
# ======================================================================
tests/client-config.yaml

# ======================================================================
# python
# ======================================================================
__pycache__/

# ======================================================================
# other
# ======================================================================
# AI STUFF
AGENTS.md
.roo


# source maps
*.map
54 changes: 54 additions & 0 deletions doc/test/playwright-test.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
## Summary

Playwright test the puter-js API in browser environment.

## Motivation

Some features of the puter-js/puter-GUI only work in the browser environment:

- file system
- naive-cache
- client-replica (WIP)
- wspush

## Setup

Install dependencies:

```sh
cd ./tests/playwright
npm install
npx playwright install --with-deps
```

Initialize the client config (working directory: `./tests/playwright`):

1. `cp ../example-client-config.yaml ../client-config.yaml`
2. Edit the `client-config.yaml` to set the `auth_token`

## Run tests

### CLI

Working directory: `./tests/playwright`

```sh
# run all tests
npx playwright test

# run a test by name
# e.g: npx playwright test -g "mkdir in root directory is prohibited"
npx playwright test -g "mkdir in root directory is prohibited"

# run the tests that failed in the last test run
npx playwright test --last-failed

# open the report of the last test run in the browser
npx playwright show-report
```

### VSCode/Cursor

1. Install the "Playwright Test for VSCode" extension.
2. Go to "Testing" tab in the sidebar.
3. Click buttons to run tests.
23 changes: 23 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export default defineConfig([
// TypeScript support block
{
files: ['**/*.ts'],
ignores: ['tests/**/*.ts'],
languageOptions: {
parser: tseslintParser,
parserOptions: {
Expand All @@ -70,6 +71,28 @@ export default defineConfig([
'@typescript-eslint/consistent-type-definitions': ['error', 'interface'],
},
},
// TypeScript support for tests
{
files: ['tests/**/*.ts'],
languageOptions: {
parser: tseslintParser,
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
project: './tests/tsconfig.json',
},
},
plugins: {
'@typescript-eslint': tseslintPlugin,
},
rules: {
// Recommended rules for TypeScript
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
'@typescript-eslint/ban-ts-comment': 'warn',
'@typescript-eslint/consistent-type-definitions': ['error', 'interface'],
},
},
{
plugins: {
js,
Expand Down
Loading