A lot of bikes are sold as complete bikes. You may have a few component options from which to choose, but you are otherwise more or less forced to accept the bike as is or pay extra to have certain things swapped out (shops will often work with you on this). Some bikes may be purchased as a frame only. You could then build it up as you wish. It's typically more expensive to do that, especially if you get the parts through your shop (versus online). Plus, you might end up paying a build fee of $200-$300 at your shop. But, again, you get what you want.
As for test riding, a shop will generally let you test a bike with your own pedals and saddle. As for being able to order a bike for a test ride with no obligation to purchase: I don't think it's the norm, but it depends on the shop. Find a shop with a good fitter and try your best, with their help, to figure out the geometry you need prior to ordering and then work with them to dial in the fit after you buy the bike.
Live with intention. Walk to the edge. Listen hard. Practice wellness. Play with abandon. Laugh. Choose with no regret. Continue to learn. Appreciate your friends. Do what you love. Live as if this is all there is.
--Mary Anne Radmacher