Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature request: prefix for route reports #10

Open
tacman opened this issue Dec 31, 2024 · 2 comments · May be fixed by #11
Open

feature request: prefix for route reports #10

tacman opened this issue Dec 31, 2024 · 2 comments · May be fixed by #11

Comments

@tacman
Copy link

tacman commented Dec 31, 2024

when the log shows an error, I'd like to click on it and open the web page to see what it was.

To do that, you'd need to allow the bundle to take a configuration parameter (base_url) or an environment variable in phpunit.

/home/tac/g/sites/packages/vendor/pierstoval/smoke-testing/src/SmokeTestStaticRoutes.php:76

5) App\Tests\AllRoutesTest::testRoutesDoNotReturnInternalError with data set "GET /package/new" ('GET', 'package_new', '/package/new')
Request "GET /package/new" for route "package_new" returned an internal error.
Failed asserting that 500 is less than 500.

/home/tac/g/sites/packages/vendor/pierstoval/smoke-testing/src/SmokeTestStaticRoutes.php:76

What I'd rather see is

  Request "GET https://mydomain.wip/package/new" for route "package_new" returned an internal error.

  <env name="SMOKE_TESTING_ROUTES_BASE_URL" value="https://mydomain.wip" />
@Pierstoval
Copy link
Owner

Pierstoval commented Jan 1, 2025

I'm not sure this would work. Instead, we could change the route path to be the whole URL based on what the router sends back, because you can configure the domain property in any route, even dynamically with a request parameter directly built in the route so that your domain can be app-configured (I'm doing this on a few projects), so overriding it in test env seems a bit overkill.

You can also customize this directly in the container parameters router.request_context.host, router.request_context.scheme, router.request_context.base_url. I think you can also do this with this:

framework:
    router:
        # ...
        default_uri: 'https://example.org/my/path/'

I'm not 100% sure of all this, it has to be tested, but I think it would need a slight change in Pierstoval\SmokeTesting\RoutesExtractor::extractRoutesFromRouter() to change how $router->generate($routeName) is called. By default, it's called with referenceType: Symfony\Component\Routing\Generator\UrlGeneratorInterface::ABSOLUTE_PATH, but maybe using ABSOLUTE_URL would "simply" do the trick. As said: needs to be tested. I may try to find time in the next weeks to investigate more on this, unless you're quicker than me :)

@tacman
Copy link
Author

tacman commented Jan 1, 2025

Yeah, that's a better solution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants