Skip to content

Update task layer, tests and coverage config - #44

Open
Theosakamg wants to merge 6 commits into
mainfrom
chore/tasks-refactor-tests-docs
Open

Theosakamg wants to merge 6 commits into
mainfrom
chore/tasks-refactor-tests-docs

Conversation

@Theosakamg

Copy link
Copy Markdown
Collaborator

Summary

  • Update core tasks and UpsunClient (add DeploymentTargetApi, JSDoc improvements)
  • Expand unit tests; add upsun-dev test, test utils and tests README
  • Restrict coverage to non-generated sources
  • Bump dotenv to ^18.0.10 and adjust spec:clean

- Update core tasks and UpsunClient (DeploymentTargetApi, JSDoc)
- Expand unit tests, add upsun-dev test, test utils and tests README
- Restrict coverage to non-generated sources
- Bump dotenv to ^18.0.10 and adjust spec:clean
@upsun-dispatch

upsun-dispatch Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

📋 PR Summary

This PR reworks the SDK's core task layer and UpsunClient. It adds DeploymentTargetApi, improves the JSDoc, and removes the metrics task. It also adds more unit tests, an upsun-dev test, test utilities and a tests README, limits coverage to non-generated sources, and bumps dotenv. The latest push stops Jest from ignoring the upsun-dev unit test. Instead, the global test setup now calls nock.restore() when it loads and only turns nock on in beforeAll, so files where every test is skipped don't leave the patch in place for other test files running in the same worker.

Changes
Layer / File(s) Summary
Test configuration
jest.config.js Limits coverage to non-generated sources. Removes the testPathIgnorePatterns entry that excluded the upsun-dev unit test.
tests/setup.ts Turns nock off when the setup file loads and back on in beforeAll, then restores it in afterAll, so files where every test is skipped don't leak the patch.
package.json Bumps dotenv to ^18.0.10 and changes the spec:clean script.
Core tasks and client
src/upsun.ts Adds DeploymentTargetApi to UpsunClient and improves the JSDoc.
src/core/tasks/metrics.ts Removes the metrics task; it is also dropped from the tasks index.
src/core/tasks/projects.ts Updates the project task methods and their documentation.
Tests
tests/unit/upsun-dev.test.ts New unit test suite for upsun-dev.
tests/utils/auth-mock.ts New helper that mocks authentication in tests.
tests/README.md New guide to the test suite.

@upsun-dispatch upsun-dispatch Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

1 critical finding in this review. Details below.

Caution

Changes requested — 🔴 1 critical · 🟡 2 warnings · 🔵 1 minor point

🔍 Full review · 37 files reviewed · ccd9a14

Verification
  • ProjectsTask gets DeploymentTargetApi as its new last constructor argument in both upsun.ts and the unit test, and the argument order matches.
  • Making params required in update methods is consistent with callers: projects.info, organizations.info and environments.info only call update once params are present.
  • activities.log follows cursor only while hasMoreResults is true, and it checks environmentId before fetching the activity.
  • downloadInvoice checks the token through the new checkInvoiceToken before calling downloadInvoiceRaw.

The diff adds unit tests for activities.log, environments.logs, downloadInvoice, the deployment-target methods and restartGitServer, and drops the tests for the old omitted-params defaults. The develop.yml tests job covers them through npm run test:types and npm run test:unit. That job's type-check step will fail because the new upsun-dev.test.ts calls the nonexistent environments.urls, and the coverage job is disabled (if: false).


Review 1 of 10 for this pull request · View the full run

Comment thread tests/unit/upsun-dev.test.ts Resolved
LogsQueryLogKindsEnum.CRON,
],
logKindsMode: '1',
from: now - 3600,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Warning — Callers who set only to silently get no log entries back, and the method's promise to filter to one application can be broken.

logs() fills in from and to on their own and then spreads ...params over them. If a caller passes only to, for a moment more than an hour ago (e.g. { to: yesterday }), from keeps its default of now - 3600, so from > to and the query has an inverted, empty range. The spread also lets params.services or servicesMode replace [appName], and an explicit { from: undefined } wipes out the default. Either way the JSDoc's "Only the entries of the given application are returned" stops being true. appName is never validated either: '' produces services: [''].

Comment thread tests/README.md
tests/
├── setup.ts # Configuration globale des tests
├── unit/ # Tests unitaires
│ ├── upsun-client.test.ts # Tests du client principal

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Warning — Contributors following this doc will look for tests and guarantees that aren't there.

The new README describes files and behaviour that don't exist. The tree lists upsun-client / oauth2-client tests and task files named organization.test.ts, project.test.ts, activity.test.ts, route.test.ts, service.test.ts, but the real files are plural (organizations.test.ts, …). It presents integration/workflows.test.ts and performance/sdk-performance.test.ts as active, but they are committed as .skip. It says coverage only excludes src/api/, but jest.config.js now also excludes src/model, src/app.ts and src/core/runtime.ts. It gives coverage targets (80/75/85%) that no coverageThreshold enforces, and claims CI runs "with code coverage verification" when the coverage job is if: false. Several sections are also left in French ("Configuration et mocking", "Bonnes pratiques", …).

Comment thread tests/unit/tasks/metrics.test.ts.skip Outdated

describe('get', () => {
it('should have get method defined', () => {
expect(metricsTask.get).toBeDefined();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Minor — This is dead test code, and it misleads readers about what the API looks like.

This skipped test calls metricsTask.get(...) and expects 'Method not implemented', but MetricsTask only has fetchMetrics. The .skip files are dead and stale: upsun-dev.integration.test.ts.skip still uses the old singular client properties (upsun.activity, upsun.backup), workflows.test.ts.skip builds an UpsunConfig with fields like base_url, and tests/utils/auth-mock.ts is imported nowhere. Renaming any of them back to .ts would not compile.

- Remove MetricsTask (hardcoded dates/URL) and its tests
- Fix type errors in upsun-dev unit test and skipped tests

@upsun-dispatch upsun-dispatch Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Warning

Changes suggested — 🟡 1 warning

🔁 Incremental · 10 files reviewed · e81cecf..bd78640

Verification
  • After MetricsTask was deleted, nothing in src/ or tests/ still mentions MetricsTask, fetchMetrics or .metrics..
  • The call projects.create(org, region, { projectTitle, defaultBranch }) in the updated tests type-checks: create takes a ProjectCreateRequest (an Omit of CreateOrgSubscriptionRequest) as its third argument.
  • The domains.update(projectId, domainId, { isDefault: false }) call matches the update(projectId, domainId, domainPatch, environmentId?) signature.
  • The environments.urls call is gone from tests/unit/upsun-dev.test.ts, which tsconfig.test.json type-checks.

This commit only deletes metrics.test.ts and fixes the type errors in tests. No test checks that the remaining public surface stays compatible. The tests are type-checked and run by the test:types and jest steps in .github/workflows/develop.yml. The .skip files are not compiled at all.


Review 3 of 10 for this pull request · View the full run

Comment thread src/upsun.ts
public integrations: IntegrationsTask;
public invitations: UsersInvitationsTask;
public metrics: MetricsTask;
public mounts: MountsTask;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Warning — SDK users upgrading get a breaking API removal without notice or a version signal.

This commit takes public metrics: MetricsTask off UpsunClient and drops export * from './metrics.js' from src/core/tasks/index.ts. Both existed on the base branch (60ff904), so they are part of the published 0.8.0 public surface. Any consumer that calls client.metrics.fetchMetrics(...) or imports MetricsTask will now get a compile error, or a runtime TypeError: Cannot read properties of undefined in JS. Nothing replaces them: no deprecation shim, no version bump in package.json (still 0.8.0), and no mention in the PR description, which only talks about updating tasks and tests.

@upsun-dispatch
upsun-dispatch Bot dismissed their stale review November 19, 2026 11:43

Superseded: the latest Upsun Dispatch review no longer requests changes.

@upsun-dispatch upsun-dispatch Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Note

Reviewed — No new blocking findings · 🔵 1 minor point

🔁 Incremental (head + base moved) · 1 file reviewed · ea94a59..7f2ba53

Verification
  • testPathIgnorePatterns keeps /node_modules/, so adding the key leaves Jest's default node_modules exclusion in place.
  • The anchored regex /tests/unit/upsun-dev\.test\.ts$ matches only that file; the .skip integration files already fall outside testMatch.
  • tests/unit/upsun-dev.test.ts is the only test file whose top-level suite is describe.skip, so no other fully skipped file currently hits the same setup leak.
  • The base branch only bumped actions/setup-java from v5 to v6 in its workflows; nothing this PR uses was renamed or removed.

This change is Jest configuration only, and no test checks it. The unit test and test:types steps in .github/workflows/develop.yml cover it indirectly. The ignored file is still type-checked through tsconfig.test.json but never run.


Review 5 of 10 for this pull request · View the full run

Comment thread jest.config.js Resolved
@github-actions

Copy link
Copy Markdown

Upsun SDK checker report

Display raw output
/home/runner/work/upsun-sdk-node/upsun-sdk-node/node_modules/ts-api-utils/lib/index.cjs:787
var IntrinsicTypeFlags = ts9__default.default.TypeFlags.Intrinsic ?? ts9__default.default.TypeFlags.Any | ts9__default.default.TypeFlags.Unknown | ts9__default.default.TypeFlags.String | ts9__default.default.TypeFlags.Number | ts9__default.default.TypeFlags.BigInt | ts9__default.default.TypeFlags.Boolean | ts9__default.default.TypeFlags.BooleanLiteral | ts9__default.default.TypeFlags.ESSymbol | ts9__default.default.TypeFlags.Void | ts9__default.default.TypeFlags.Undefined | ts9__default.default.TypeFlags.Null | ts9__default.default.TypeFlags.Never | ts9__default.default.TypeFlags.NonPrimitive;
                                                        ^

TypeError: Cannot read properties of undefined (reading 'Intrinsic')
    at Object.<anonymous> (/home/runner/work/upsun-sdk-node/upsun-sdk-node/node_modules/ts-api-utils/lib/index.cjs:787:57)
    at Module._compile (node:internal/modules/cjs/loader:1781:14)
    at Object..js (node:internal/modules/cjs/loader:1913:10)
    at Module.load (node:internal/modules/cjs/loader:1505:32)
    at Function._load (node:internal/modules/cjs/loader:1309:12)
    at wrapModuleLoad (node:internal/modules/cjs/loader:254:19)
    at Module.require (node:internal/modules/cjs/loader:1527:12)
    at require (node:internal/modules/helpers:147:16)
    at Object.<anonymous> (/home/runner/work/upsun-sdk-node/upsun-sdk-node/node_modules/upsun-sdk-checker/node_modules/@typescript-eslint/typescript-estree/dist/convert-comments.js:37:30)
    at Module._compile (node:internal/modules/cjs/loader:1781:14)

Node.js v22.23.5

This branch has not been deployed

No deployments
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.

1 participant