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

Functionnal testing with auth #4527

Closed
Moumouuu opened this issue Apr 17, 2024 · 7 comments
Closed

Functionnal testing with auth #4527

Moumouuu opened this issue Apr 17, 2024 · 7 comments
Assignees
Labels
Type: Question Needs clarification

Comments

@Moumouuu
Copy link

Package version

6.2.2

Describe the bug

I'm trying to do some tests to find out if after a disconnection I have the correct response from the API.

I have everything setup as in the doc, updated the bootstrap file and the .env.test file with SESSION_DRIVER=memory

Only difference I have with the docs that in bootstrap.ts file i have authApiClient(app) and apiClient()

Capture d’écran 2024-04-17 à 13 33 57 Capture d’écran 2024-04-17 à 13 34 23 Capture d’écran 2024-04-17 à 13 36 28

Reproduction repo

https://github.com/Avocado-Community/api.avocadogrowth

@RomainLanz
Copy link
Member

RomainLanz commented Apr 17, 2024

Hey @Moumouuu! 👋🏻

Have you added the authApiClient plugin to Japa and activated the memory driver for the session store when testing as per our documentation?

Also, you must use the Session module when using the Session Guard

@Moumouuu
Copy link
Author

Thank you for the quick response!

Could you please clarify what you meant by 'added the authApiClient plugin to Japa and activated the memory driver for the session store'?

As shown in my screenshot, I included the authApiClient in the plugins section of bootstrap.ts, and in .env.test, I configured 'SESSION_DRIVER=memory'. Additionally, I'm utilizing Session and Session Guard.

I'm really following the documentation closely..

@quentinhaenn
Copy link

unfortunately i'm facing the exact same issue, following the doc guidelines for auth testing but cannot resolve it with ease. I already verified that before each test the SESSION_DRIVER is set to memory using env.get("SESSION_DRIVER"), added authApiClient in test/bootstrap.ts file as a plugin, and using the loginAs func to provide a authenticated session. But, as far as I understand, the client used in my test has type ApiClient, not authApiClient, might this be the cause of the TypeError thrown ?

@RomainLanz
Copy link
Member

RomainLanz commented Apr 17, 2024

It seems that your reproduction is not updated. Could you please push your latest version @Moumouuu?

Could you also try to change the loading order of the Japa plugins and put the authApiClient plugin at the end.

@Moumouuu
Copy link
Author

I pushed my modifications and also added authApiClient at the end, but no changes occurred.

On this branch : https://github.com/Avocado-Community/api.avocadogrowth/tree/11-dev-logout

@thetutlage
Copy link
Member

You are also missing the sessionApiClient. I highly recommend reading the docs carefully, since all this is covered in docs very clearly.

@thetutlage thetutlage self-assigned this Apr 18, 2024
@thetutlage thetutlage added the Type: Question Needs clarification label Apr 18, 2024
@quentinhaenn
Copy link

Thanks for the answer !

I highly recommend reading the docs carefully, since all this is covered in docs very clearly.

Since the two of us followed very carefully the docs, but did not found the right command or plugin to use, I may recommend to detail the two cases in the doc, separating specs required for auth testing with session and those for auth testing without session, it was very unclear for us that the authApiClient did not handle that itslef.

Anyway, I think a complete minimum working example would greatly enhance the documentation for these particular cases.

Thanks again !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Question Needs clarification
Projects
None yet
Development

No branches or pull requests

4 participants