test(routes): make route-lifecycle test pass under the core resolver - #28
Merged
Merged
Conversation
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
src/tests/route-lifecycle.test.ts("getRegisteredRouteHandlers" > "returns complete registered handlers without replacing the provider") passes in this repo but fails when run from an implementation module such as@antelopejs/api, becauseajs module testthere also runs the tests shipped innode_modules/@antelopejs/interface-api/dist/tests/.Root cause: with
@antelopejs/core>= 1.4.11, the shipped test'srequire("../index")is resolved as an interface import, so the exported functions are facades and every value passed toRegisterRoute(handler)is bound through the core. Objects holding functions become facades, so the registered handler stores wrappedcallback,parametersandproperties, and the reference checks (assert.strictEqual(registered.handler.callback, original.callback), and the same for the provider'sonRegisterpayload) fail. In this repo../indexis a plain local import, so identity holds. The facades are intentional core behavior (module context capture,GetResponsibleModule, unload cleanup); no runtime or core change is needed.What changed (test only):
callback: asserted by calling it (returns the route location) instead of by reference.parameters/properties: structure asserted (length,nullslot, keys, empty modifiers) and eachproviderstill returns"parameter".proto:deepEqual.onRegisterpayload and the registered handler are compared on stable fields (location,method,mode,module,priority) instead of object identity.moduleis set on the registered handler and not added to the original object.No change to
src/index.ts, dependencies, orantelope.test.ts.A patch release of
@antelopejs/interface-apiis needed after merging so that theapirepository can move to the latest interface version with a green test suite.Related issue
None; the failure was found while bumping
@antelopejs/interface-apito 0.0.13 and@antelopejs/coreto 1.9.1 inAntelopeJS/api.Verification
This repository (
ajs1.9.1, loopback-only network namespace because port 5010 is in use on the host):pnpm prepack,pnpm lint(no new warnings),pnpm format:check,pnpm knip: passpnpm test: 83 passing, 0 failingImplementation context (throwaway clone of
AntelopeJS/apimain, not pushed):@antelopejs/interface-api0.0.13 and@antelopejs/core1.9.1 installed, thennode_modules/@antelopejs/interface-api/distreplaced with this branch's build, andpnpm testrun:Expected "actual" to be reference-equal to "expected"oncompleteRouteCallback)Checklist