Skip to content

v2/tests: fix and restructure integration and unit tests - #69

Merged
bosi95 merged 9 commits into
feat/v2from
v2/tests
Aug 10, 2026
Merged

v2/tests: fix and restructure integration and unit tests#69
bosi95 merged 9 commits into
feat/v2from
v2/tests

Conversation

@bosi95

@bosi95 bosi95 commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Do NOT merge until PR #68 review is complete and merged.

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.

fix: folder status on creation
fix: failing IT cases
@bosi95
bosi95 marked this pull request as ready for review August 3, 2026 12:07
chore: recoverFolder unit test
@ferencsarai

Copy link
Copy Markdown
Member

Could you confirm that the new test specs have the same coverage as the old tests? A before/after coverage comprassion would be helpful.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Reworks the v2 test suite to be split into focused unit/integration domains, and updates the integration environment + CI to use @ethersphere/bee-factory instead of custom shell bootstrapping.

Changes:

  • Split the former monolithic unit/integration specs into per-capability suites and introduced shared test helpers.
  • Switched integration test provisioning to bee-factory via Jest globalSetup/globalTeardown, and updated docs accordingly.
  • Updated CI to always run unit tests, and to run integration tests only on master/develop pushes, manual dispatch, PRs targeting master, or PRs labeled run-it.

Reviewed changes

Copilot reviewed 43 out of 46 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tsconfig.json Includes tests/ in typechecking and removes deprecated compiler option override.
tests/utils.ts Central shared test utilities (bee URLs, signers, init helper, stream/retry helpers).
tests/unit/setup.ts Centralizes Jest module mocks for unit tests via setupFilesAfterEnv.
tests/unit/mock.ts Provides unit mock factories, Bee spies, and cache seeding helpers.
tests/unit/init.spec.ts New unit coverage for initialization and reinitialization behaviors.
tests/unit/drive.spec.ts New unit coverage for drive create/destroy/forget flows.
tests/unit/file.spec.ts New unit coverage for file upload/download/update/move behaviors.
tests/unit/folder.spec.ts New unit coverage for folder list/download/create/move behaviors.
tests/unit/version.spec.ts New unit coverage for version fetch/restore behavior.
tests/unit/trash.spec.ts New unit coverage for trash/recover/listTrash/forget lifecycle.
tests/unit/events.spec.ts New unit coverage for emitted events and deterministic payload expectations.
tests/unit/abort.spec.ts New unit coverage for abort-signal forwarding/guards.
tests/unit/fileManager.spec.ts Removes the old monolithic unit spec in favor of per-domain suites.
tests/integration/setup/jestSetup.ts Starts bee-factory stack before integration tests.
tests/integration/setup/jestTeardown.ts Stops bee-factory stack after integration tests.
tests/integration/setup/utils.ts Adds integration fixtures (setupUserDrive, temp file registry, signer+stamp helper).
tests/integration/init.spec.ts New integration coverage for initialization, admin feed/topic behavior, and revalidation.
tests/integration/drive.spec.ts New integration coverage for drive create/forget/destroy guardrails.
tests/integration/file.spec.ts New integration coverage for upload(s), update, download(s), and move behaviors.
tests/integration/folder.spec.ts New integration coverage for listFolder/downloadFolder and folder moves.
tests/integration/version.spec.ts New integration coverage for versioning, lazy hydration, restore semantics.
tests/integration/trash.spec.ts New integration coverage for trash/recover/forget lifecycle and dedupe guarantees.
tests/integration/abort.spec.ts New integration coverage for abort behavior across upload/download/listFolder.
tests/integration/e2e.spec.ts New end-to-end workflow integration coverage.
tests/integration/testSetupHelpers.ts Removes old integration bootstrap helper (superseded by setup utils + bee-factory).
tests/integration/test-node-setup/runBeeNode.sh Removes legacy shell-based Bee bootstrap.
tests/integration/test-node-setup/stopBeeNode.sh Removes legacy shell-based Bee teardown.
tests/integration/test-node-setup/jestSetup.ts Removes legacy Jest globalSetup for shell bootstrap.
tests/integration/test-node-setup/jestTeardown.ts Removes legacy Jest globalTeardown for shell bootstrap.
tests/TESTS.md Updates test documentation for new suite layout, bee-factory, and helper patterns.
tests/fixtures/test.txt Removes static fixture (tests now generate temp inputs).
tests/fixtures/nested/nested.txt Removes static fixture (tests now generate temp inputs).
tests/fixtures/nested/extra/extra.txt Removes static fixture (tests now generate temp inputs).
tests/fixtures/folder/1.txt Removes static fixture (tests now generate temp inputs).
tests/fixtures/data.txt Removes static fixture (tests now generate temp inputs).
src/fileManager.ts Ensures created folders are explicitly marked NodeStatus.Active.
pnpm-workspace.yaml Expands allowBuilds to include additional native/build-time deps.
package.json Adds @ethersphere/bee-factory, adjusts test scripts, and introduces an override for bee-js in bee-factory.
jest.config.ts Splits Jest config into unit and integration projects; wires unit setup file and new global setup/teardown.
eslint.config.mjs Adds Response global and relaxes explicit return type rule for Jest suite ergonomics.
changelog/v2-tests.md Adds a changelog entry documenting the test suite reorg and CI changes.
.github/workflows/tests.yaml Updates CI to always run unit tests and conditionally run integration tests; adds concurrency cancelation.
.depcheckrc.json Updates depcheck ignores to account for @ethersphere/bee-factory.
Files not reviewed (1)
  • pnpm-lock.yaml: Generated file

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tests/integration/setup/jestSetup.ts Outdated
Comment thread tests/unit/drive.spec.ts Outdated
Comment thread tests/utils.ts
Comment on lines +57 to 70
export async function retryOnPropagationDelay<T>(fn: () => Promise<T>, attempts = 5, delayMs = 500): Promise<T> {
let lastError: unknown;
for (let i = 0; i < attempts; i++) {
try {
return await fn();
} catch (err: unknown) {
lastError = err;
if (i < attempts - 1) {
await new Promise((resolve) => setTimeout(resolve, delayMs));
}
}
}
throw lastError;
}
@bosi95
bosi95 merged commit d8de0fe into feat/v2 Aug 10, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants