Test: pin the integrations web entry point to the node public surface (stacked on #236) - #513
Conversation
integrations/src/index_web.ts is the declared browser entry in integrations/package.json but is imported by nothing, so it sat at 0% once the unit:integrations project started running. The two entry points can drift independently; this asserts they export the same names, taking integrations/src from 66.66% to 100%.
|
Heads-up: this PR is now a no-op against its own base. A correctness review on #236 — the branch this PR is stacked on — blocked it for leaving The implementation that landed keeps this PR's Closing this is your call; flagging it rather than doing it from #236. |
Please ensure you have read the contribution guide before creating a pull request.
Link to Issue or Description of Change
Closes: #issue_number
Related: #issue_number
Collision check (run before any code was written).
gh pr list --repo AmaadMartin/adk-js --state open --limit 1000returned 413 open PRs.The task this branch was created for — "wire the orphaned
unit:integrationsVitestproject into the test scripts" — is already implemented by open PR #236, whose diff
adds
--project unit:integrationstotest,test:unitandtest:coverageand replacesthe rotted
expect(version).toBe('1.3.0')literal with a comparison against the packagemanifest. Two further attempts at the same work are already closed (#245, #476), and three
PRs are open on top of #236: #479 (hardens the same
version_test.ts), #343 (CI guard forprojects run by no npm script) and #311 (wildcard unit-project selection).
A competing wiring PR was therefore not opened. What follows is the one piece of the
original task that #236 does not cover, stacked on it as the overlap rule prescribes.
Problem:
integrations/src/index_web.tsis the declaredbrowserentry point inintegrations/package.json, but nothing imports it — not the node entry, not the existingtest. Once #236 makes the
unit:integrationsproject actually run,integrations/srclands at 66.66% with
index_web.tsat a flat 0%:The gap is not just a number.
index.tsandindex_web.tsare two hand-maintained copiesof the same export list, and nothing anywhere asserts they agree — the web bundle can lose
an export and no test notices. That is the same class of silent rot that let
version_test.tssit on a false assertion across two releases.Solution: one test,
integrations/test/index_web_test.ts, asserting that the web entryexposes the same export names as the node entry. It closes the coverage gap and pins a real
invariant at the same time, so the coverage is a by-product of a meaningful assertion rather
than an import written to move a percentage.
Two deliberate choices, both worth calling out:
../src/index.js/../src/index_web.jsimports instead of the@google/adk-integrationspackage name. The repo guideline is to import via the publicentry point, and it does not apply here: the Vitest alias
(
vitest.config.ts) maps@google/adk-integrationstointegrations/src, which resolvesto
index.tsonly. There is no aliased specifier for the web entry, and comparing thenode entry against itself would assert nothing. Both entries must be reached by path for
the comparison to mean anything.
expect(nodeExports).not.toHaveLength(0)before the parity assertion. Without it thetest passes vacuously if both entries lose their exports —
[] equals []. Given thiswhole task exists because a test quietly stopped meaning anything, a self-check against
the degenerate case is worth one line. Mutation 2 below demonstrates it fires.
No production source changed;
git diffagainst the base is exactly one added file.Testing Plan
Please describe the tests that you ran to verify your changes. This is required for all PRs that are not small documentation or typo fixes.
Environment:
unset GOOGLE_CLOUD_PROJECT GOOGLE_CLOUD_LOCATION, thennpm installandnpm run build(the build is mandatory —globalSetupresolves@google/adkthroughcore/dist, so an unbuilt tree fails withFailed to resolve entry for package "@google/adk"and the misleading
No test files found).Unit Tests:
[x] I have added or updated unit tests for my change.
[x] All unit tests pass locally.
Confirming the stacked wiring actually reaches the new file (not just a direct
--projectinvocation):Coverage —
integrations/src, measured on this checkout:Per file after:
index.ts100%,index_web.ts100% (was 0%, lines 1-7 uncovered),version.ts100%.Threshold decision:
vitest.config.tsthresholdsleft unchanged. The configuredvalues (86/87/88/86) are minimums, and
coverage.includeis untouched by this PR — nodenominator grows, so no configured metric can fall. The change only adds covered lines in a
three-file directory, so the repo-wide movement is a rounding-level increase and nothing
approaches an integer boundary near the configured values. Ratcheting the thresholds to
today's exact numbers is a separate policy change with real downside (unrelated PRs go red on
rounding-level movement) and is out of scope here; #377 and #324 are the PRs already looking
at that question.
Proof each assertion can fail (both mutations reverted;
git statusclean afterwards):Parity assertion. Appended
export const webOnly = true;tointegrations/src/index_web.tsonly:Vacuous-pass guard. Replaced
export {version} from './version.js';withexport {};in both
index.tsandindex_web.ts— the case where the parity assertion alonewould pass on
[] equals []:Manual End-to-End (E2E) Tests:
npx tsc --noEmiton the new file with the root compiler options(
--strict --module nodenext --moduleResolution nodenext --target ES2020 --lib ES2022,DOM --skipLibCheck) exits 0. Noany, no cast, no@ts-expect-error, noeslint-disableanywhere in the diff.
CI note: because this PR is stacked (base is
fix/run-unit-integrations-vitest-project,not
main), thevalidationworkflow — which triggers onpull_requesttomain— doesnot run. All validation above was performed locally on the exact pushed commit.
Checklist
[x] I have read the CONTRIBUTING.md document.
[x] I have performed a self-review of my own code.
[x] I have commented my code, particularly in hard-to-understand areas.
[x] I have added tests that prove my fix is effective or that my feature works.
[x] New and existing unit tests pass locally with my changes.