Skip to content

refactor: Split integration suite into flat per-capability cases - #1202

Draft
MQ37 wants to merge 3 commits into
masterfrom
refactor/776-flat-integration-test-cases
Draft

refactor: Split integration suite into flat per-capability cases#1202
MQ37 wants to merge 3 commits into
masterfrom
refactor/776-flat-integration-test-cases

Conversation

@MQ37

@MQ37 MQ37 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

🚧 DO NOT REVIEW — WIP. May be split into multiple PRs once finished.

What

Splits tests/integration/suite.ts (3292 lines, 117 cases) into flat tests/integration/cases/*.cases.ts files, grouped by capability (registration, tools, actors, apps, tasks, storage, payments), per the flat structure agreed in #776. Adds src/test_kit/ (./test-kit package export, vitest optional peerDependency) so apify-mcp-server-internal can run a curated critical: true subset against its own live deploy instead of hand-duplicating assertions — wired for 2 scenarios as a working example.

Why

One file, 117 cases, unmaintainable by more than one person at a time. See #776.

Testing

  • Mechanical move only, no behavior change: verified via AST title diff — 117 test titles before, 117 after, zero difference.
  • pnpm run type-check, pnpm run lint, pnpm run format, pnpm run test:unit (1267 tests), pnpm run check:agents, pnpm run build (confirms dist/test_kit output) all pass.
  • Full integration suite collection verified across all 3 transport dimensions (356 tests collected, matches pre-refactor count).

AI use disclosure

Statement extraction (line-range slicing) was scripted from a TypeScript AST parse of the original file; grouping decisions, the test-kit design, and all verification were done and reviewed by hand.

Fixes #776

@MQ37 MQ37 added the beta Create beta prereleases label Aug 5, 2026
@github-actions github-actions Bot added the t-ai Issues owned by the AI team. label Aug 5, 2026
@pkg-pr-new

pkg-pr-new Bot commented Aug 5, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@apify/actors-mcp-server@1202

commit: 5f3879c

Splits tests/integration/suite.ts (3292 lines, 117 cases) into
tests/integration/cases/*.cases.ts, grouped flat by capability
(registration, tools, actors, apps, tasks, storage, payments), per
the plan agreed in #776 (flat structure, no folder-per-tool mirror of
src/). Every register*Cases(ctx) is a mechanical move — same test
names, bodies, and transport gates; suite.ts now only wires the three
transport dimensions and calls the register functions. Verified via
AST title diff: 117 titles before, 117 after, zero difference.

Adds src/test_kit/ (published behind the "./test-kit" package export,
vitest optional peerDependency) so apify-mcp-server-internal can
import and run a curated critical: true subset against its own live
deploy instead of hand-duplicating assertions. Wires two scenarios
(tests/integration/cases/shared_scenarios.ts) through it as a working
example; growing that subset is a per-PR judgment call, left for
follow-up.

Updates AGENTS.md and DEVELOPMENT.md per #776's own requirement to
document the new structure when the first capability module lands.

Fixes #776

AI use disclosed: mechanical statement extraction (line-range slicing
driven by a TypeScript AST parse) was scripted; grouping decisions,
the test-kit design, and all verification were reviewed by hand.
@MQ37
MQ37 force-pushed the refactor/776-flat-integration-test-cases branch from 19bd50d to c679b71 Compare August 5, 2026 11:13
MQ37 added 2 commits August 5, 2026 13:53
Moves createMcpStreamableClient/createMcpStatelessClient from
tests/helpers.ts (unpublished test tree) into src/test_kit/mcp_client.ts,
exported behind the existing "./test-kit" package export. Widens
SuiteClientOptions to a strict superset of apify-mcp-server-internal's
own MCPClientOptions:

- explicit token?: string | null (omitted -> process.env.APIFY_TOKEN,
  unchanged default; null -> no Authorization header at all, needed
  for internal's negative-auth / payment-mode tests where the run's
  APIFY_TOKEN is set for everything else)
- serverMode/payment as plain strings, matching internal's ui/
  paymentProvider/skyfireMode fields (same ?ui=/?payment= query
  params under the hood, one canonical name instead of three)

tests/helpers.ts now re-exports these instead of maintaining its own
copy; createMcpStdioClient (spawns this repo's own dist/stdio.js,
irrelevant to a hosted-deploy consumer) stays local and unpublished.

Lets apify-mcp-server-internal delete test/integration/src/mcp-clients.ts
entirely and import the same client instead of maintaining its own.

Verified: type-check, lint, format, 1267 unit tests, full integration
suite collection (356 tests, unchanged), build (dist/test_kit/mcp_client.js),
check:agents all pass.

Refs #776
Moves registrationCriticalScenarios/actorsCriticalScenarios from
tests/integration/cases/shared_scenarios.ts (unpublished test tree)
into src/test_kit/scenarios.ts, exported behind the existing
"./test-kit" package export. registerScenarios alone wasn't enough —
apify-mcp-server-internal needs the actual Scenario[] content to
register, not just the registration helper.

tests/integration/cases/shared_scenarios.ts now just re-exports from
src/ so registration.cases.ts/actors.cases.ts need no changes.

Verified: type-check, lint, format, 1267 unit tests, integration
suite collection (356, unchanged), build (dist/test_kit/scenarios.js),
check:agents.

Refs #776
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

beta Create beta prereleases t-ai Issues owned by the AI team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: Split the shared integration suite by capability

2 participants