Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
2 changes: 1 addition & 1 deletion .depcheckrc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"ignores": [
"@commitlint/*",
"cross-env",
"@ethersphere/bee-factory",
"rimraf",
"ts-node",
"@types/*",
Expand Down
44 changes: 9 additions & 35 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -1,92 +1,66 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run the tests

name: Tests

on:
push:
branches: ['master']
branches: [master, develop]
pull_request:
branches:
- '**'
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
unit-tests:
runs-on: ubuntu-latest

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

steps:
- uses: actions/checkout@v4

- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10

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

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Build
run: pnpm run build

- name: Run unit tests
run: pnpm run test:ut

integration-tests:
runs-on: ubuntu-latest

if: >-
github.event_name == 'push' || github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' &&
github.base_ref == 'master') || contains(github.event.pull_request.labels.*.name, 'run-it')
strategy:
matrix:
node-version: [24.x]

steps:
- uses: actions/checkout@v4

- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10

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

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.24'
cache: false

- name: Get Bee branch commit SHA
id: bee-commit
run: |
BEE_COMMIT=$(git ls-remote https://github.com/Solar-Punk-Ltd/bee.git refs/heads/temp/dev-test | cut -f1)
echo "sha=$BEE_COMMIT" >> $GITHUB_OUTPUT
echo "Bee temp/dev-test branch commit: $BEE_COMMIT"

- name: Cache Bee binary
uses: actions/cache@v4
with:
path: tests/integration/test-node-setup/bee-dev/dist/bee
key: bee-binary-${{ runner.os }}-${{ steps.bee-commit.outputs.sha }}
restore-keys: |
bee-binary-${{ runner.os }}-

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Build
run: pnpm run build

- name: Run integration tests
run: pnpm run test:it
46 changes: 46 additions & 0 deletions changelog/v2-tests.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# v2/tests — suite reorg, bee-factory environment, CI

## Test environment (bee-factory)

- `jest.config.ts` now defines two projects, `unit` and `integration`, selectable via `--selectProjects`.
- Integration `globalSetup` / `globalTeardown` (`tests/integration/setup/jestSetup.ts` / `jestTeardown.ts`) provision
the Bee nodes with `@ethersphere/bee-factory` — queen at `127.0.0.1:1633`, worker at `127.0.0.1:1635`. This replaces
the shell-script bootstrap (`tests/integration/test-node-setup/*.sh` + its jest setup/teardown), which is removed.
- `package.json` gains the `bee-factory` dev dependency and the `test`, `test:ut`, `test:it`, `test:coverage` scripts.

## Suite reorganization

The monolithic `tests/integration/fileManager.spec.ts` and `tests/unit/fileManager.spec.ts` are split into
per-capability suites:

- **Integration** (`tests/integration/`): `abort`, `drive`, `e2e`, `file`, `folder`, `init`, `trash`, `version`.
- **Unit** (`tests/unit/`): `abort`, `drive`, `events`, `file`, `folder`, `init`, `trash`, `version`.

Trash suites cover the full lifecycle for both files and folders (trash / recover / forget).

## Shared fixtures & helpers

- `tests/integration/setup/utils.ts` (new) — `setupUserDrive` (single-call bee + FileManager + drive fixture),
`tempFileRegistry` (temp files are tracked and removed by one `afterAll`, so no temporary file survives a run), and
`ensureUniqueSignerWithStamp`.
- `tests/unit/setup.ts` (new) — centralizes `jest.mock` and exposes `applyDefaultMocks`; `tests/unit/mock.ts` (record /
drive seeding) replaces `tests/mockHelpers.ts`.
- `tests/utils.ts` — shared node URLs, mock signers, `retryOnPropagationDelay`, and `createInitializedFileManager`.
- Static `tests/fixtures/*` inputs are removed — suites write their inputs through `tempFileRegistry` instead.

## CI (`.github/workflows/tests.yaml`)

- Unit tests run on every PR and on push to `master` / `develop`.
- Integration tests (Docker + bee-factory, resource-heavy) run only on push to `master` / `develop`, manual dispatch, a
PR targeting `master`, or a PR carrying the `run-it` label.
- A `concurrency` group cancels superseded runs on the same ref.

## Docs

- `tests/TESTS.md` rewritten for the two-project layout, bee-factory prerequisites, the shared-helper model, and
per-suite coverage.

## Gate

- `pnpm run lint` and `build` clean
- `pnpm run test` clean, every test case and suite passes.
2 changes: 2 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export default [
FileList: 'readonly',
ReadableStream: 'readonly',
AbortController: 'readonly',
Response: 'readonly',
},
},
},
Expand Down Expand Up @@ -137,6 +138,7 @@ export default [
'jest/no-disabled-tests': 'warn',
'jest/no-focused-tests': 'error',
'jest/no-identical-title': 'error',
'@typescript-eslint/explicit-function-return-type': 'off',
'jest/prefer-to-have-length': 'warn',
'jest/valid-expect': 'error',
'@typescript-eslint/no-explicit-any': 'off',
Expand Down
5 changes: 3 additions & 2 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ module.exports = {
'^@/(.*)$': '<rootDir>/src/$1',
},
testMatch: ['<rootDir>/tests/unit/**/*.spec.ts'],
setupFilesAfterEnv: ['<rootDir>/tests/unit/setup.ts'],
},
{
displayName: 'integration',
Expand All @@ -48,8 +49,8 @@ module.exports = {
'^@/(.*)$': '<rootDir>/src/$1',
},
testMatch: ['<rootDir>/tests/integration/**/*.spec.ts'],
globalSetup: '<rootDir>/tests/integration/test-node-setup/jestSetup.ts',
globalTeardown: '<rootDir>/tests/integration/test-node-setup/jestTeardown.ts',
globalSetup: '<rootDir>/tests/integration/setup/jestSetup.ts',
globalTeardown: '<rootDir>/tests/integration/setup/jestTeardown.ts',
},
],
};
12 changes: 8 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@
"build:esm": "tsc -p tsconfig.esm.json",
"build:types": "tsc --emitDeclarationOnly --declaration --outDir dist/types",
"test": "jest --config=jest.config.ts --runInBand --verbose --silent",
"test:keep": "cross-env KEEP_BEE_DIRS=true pnpm run test",
"test:ut": "cross-env KEEP_BEE_DIRS=true pnpm run test --selectProjects=unit",
"test:it": "cross-env KEEP_BEE_DIRS=true pnpm run test --selectProjects=integration",
"test:ut": "pnpm run test --selectProjects=unit",
"test:it": "pnpm run test --selectProjects=integration",
"test:coverage": "jest --coverage",
"lint": "eslint . --report-unused-disable-directives --no-cache --max-warnings=5",
"lint:fix": "pnpm run lint --fix",
Expand Down Expand Up @@ -55,17 +54,22 @@
"cafe-utility": "^36.2.0",
"std-env": "^3.10.0"
},
"overrides": {
"@ethersphere/bee-factory": {
"@ethersphere/bee-js": "npm:@solarpunkltd/bee-js@0.0.0-fmv2.1"
}
},
"devDependencies": {
"@commitlint/cli": "^20.4.1",
"@commitlint/config-conventional": "^20.4.1",
"@ethersphere/bee-factory": "^1.1.1",
"@eslint/js": "^9.39.2",
"@types/event-emitter": "^0.3.5",
"@types/fs-extra": "^11.0.4",
"@types/jest": "^30.0.0",
"@types/node": "^25.1.0",
"@typescript-eslint/eslint-plugin": "^8.54.0",
"@typescript-eslint/parser": "^8.54.0",
"cross-env": "^10.1.0",
"depcheck": "^1.4.7",
"eslint": "^9.39.2",
"eslint-config-prettier": "^10.1.8",
Expand Down
Loading
Loading