Open kirillplatonov opened 2 weeks ago
@zzooeeyy it seems like test helpers and testing documentation require an update
Good call out! I'll add that to our backlog
I was able to fix it with a simple patch to helper:
def setup_shopify_session(session_id:, shop_domain:)
ShopifyAPI::Auth::Session.new(id: session_id, shop: shop_domain).tap do |session|
ShopifyApp::SessionRepository.stubs(:load_session).returns(session)
ShopifyAPI::Utils::SessionUtils.stubs(:current_session_id).returns(session.id)
+ ShopifyAPI::Utils::SessionUtils.stubs(:session_id_from_shopify_id_token).returns(session.id)
ShopifyAPI::Context.activate_session(session)
end
end
Issue summary
I'm using shopify_app v22.2.1 with enabled token exchange.
I was trying to write a test for an app that upgraded to token exchange. But old way to stub session no longer works: https://github.com/Shopify/shopify_app/blob/main/docs/shopify_app/testing.md
Expected behavior
setup_shopify_session
should stub the session and skip ID token check.Actual behavior
I'm getting error
ShopifyAPI::Errors::MissingJwtTokenError
:Steps to reproduce the problem
setup_shopify_session
helper