Repository navigation
Update task layer, tests and coverage config - #44
Theosakamg wants to merge 6 commits into
Conversation
- 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
|
📋 PR Summary This PR reworks the SDK's core task layer and Changes
|
There was a problem hiding this comment.
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
ProjectsTaskgetsDeploymentTargetApias its new last constructor argument in bothupsun.tsand the unit test, and the argument order matches.- Making
paramsrequired inupdatemethods is consistent with callers:projects.info,organizations.infoandenvironments.infoonly callupdateonce params are present. activities.logfollowscursoronly whilehasMoreResultsis true, and it checksenvironmentIdbefore fetching the activity.downloadInvoicechecks the token through the newcheckInvoiceTokenbefore callingdownloadInvoiceRaw.
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
| LogsQueryLogKindsEnum.CRON, | ||
| ], | ||
| logKindsMode: '1', | ||
| from: now - 3600, |
There was a problem hiding this comment.
🟡 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: [''].
| tests/ | ||
| ├── setup.ts # Configuration globale des tests | ||
| ├── unit/ # Tests unitaires | ||
| │ ├── upsun-client.test.ts # Tests du client principal |
There was a problem hiding this comment.
🟡 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", …).
|
|
||
| describe('get', () => { | ||
| it('should have get method defined', () => { | ||
| expect(metricsTask.get).toBeDefined(); |
There was a problem hiding this comment.
🔵 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
There was a problem hiding this comment.
Warning
Changes suggested — 🟡 1 warning
🔁 Incremental · 10 files reviewed · e81cecf..bd78640
Verification
- After
MetricsTaskwas deleted, nothing insrc/ortests/still mentionsMetricsTask,fetchMetricsor.metrics.. - The call
projects.create(org, region, { projectTitle, defaultBranch })in the updated tests type-checks:createtakes aProjectCreateRequest(anOmitofCreateOrgSubscriptionRequest) as its third argument. - The
domains.update(projectId, domainId, { isDefault: false })call matches theupdate(projectId, domainId, domainPatch, environmentId?)signature. - The
environments.urlscall is gone fromtests/unit/upsun-dev.test.ts, whichtsconfig.test.jsontype-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
| public integrations: IntegrationsTask; | ||
| public invitations: UsersInvitationsTask; | ||
| public metrics: MetricsTask; | ||
| public mounts: MountsTask; |
There was a problem hiding this comment.
🟡 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.
Superseded: the latest Upsun Dispatch review no longer requests changes.
There was a problem hiding this comment.
Note
Reviewed — No new blocking findings · 🔵 1 minor point
🔁 Incremental (head + base moved) · 1 file reviewed · ea94a59..7f2ba53
Verification
testPathIgnorePatternskeeps/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.skipintegration files already fall outsidetestMatch. tests/unit/upsun-dev.test.tsis the only test file whose top-level suite isdescribe.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
Upsun SDK checker reportDisplay raw output |
Summary
UpsunClient(addDeploymentTargetApi, JSDoc improvements)upsun-devtest, test utils and tests READMEdotenvto ^18.0.10 and adjustspec:clean