When constructing a sling model from a wrapped resource (i.e. ModelFactory#getModelFromWrappedRequest) if the resource provided is from a different page then the "resourcePage" injected into the model does not match the page of the resource provided.
In fact, the resourcePage that is injected into the newly constructed model is the same that was injected into the calling module. It seems like that value is set once per request and is not re-calculated.
This differs from the documented behaviour where the "resourcePage" is always expected to be the page containing the current resource.
This works in an actual AEM instance, the injected "resourcePage" is actually the page that contains the resource. The result is that tests fail when they would actually work correctly in AEM.
thanks for reporting - can you provide a PR with a test case that shows the problematic behavior?
please also specify which way you are using to inject the "resourcePage" object in your model (via wcm.io AEM Sling Models extension or via other ways, e.g. injecting from script variables).