Altinn / app-localtest

Solution for testing apps locally on your own machine
8 stars 13 forks source link

PDF generator preview #79

Closed bjosttveit closed 9 months ago

bjosttveit commented 9 months ago

Description

This allows you to use the local PDF generator in docker/podman to generate a PDF preview for an app. This has some benefits:

It needs queryParameters for the org, app, instance, and lang. App-frontend can easily set these correctly: https://github.com/Altinn/app-frontend-react/pull/1794

For now, you can just refresh the page to regenerate the PDF.

Note: For this to work it requires changing some cookies to no longer have httpOnly, since the cookies need to be sent along to the PDF generator in the request body.

image

Related Issue(s)

Verification

Documentation

bjosttveit commented 9 months ago

It seems to me like this code will work fine to put directly in dev tools. Any reason why not?

You are probably right, I suppose it could pop up in a modal maybe

ivarne commented 9 months ago

If you put everything in dev tools, it will work in tt02 and prod also, if you have the pdf image running locally

bjosttveit commented 9 months ago

If you put everything in dev tools, it will work in tt02 and prod also, if you have the pdf image running locally

I still don't think that would be possible since the AltinnStudioRuntime cookie would not be accessible there?

ivarne commented 9 months ago

No, it should absolutely not be accessible from JavaScript so that is a definitive NO on this approach from me. I also think we should be careful about having different cookie settings in LocalTest. The proper solution would be to have an app lib expose an api for generating pdfs for preview before submission. The alternative is to have an API in local test to fetch the cookie value so that the current code works with a small modification to fetch the auth token.