-
Notifications
You must be signed in to change notification settings - Fork 38
fix(ci): fix failing unit tests and Playwright global setup #2457
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
Open
mikib0
wants to merge
6
commits into
development
Choose a base branch
from
fix/ci-unit-and-e2e-test-failures
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
674263b
fix(ci): fix failing unit tests and Playwright global setup
mikib0 90a79fd
fix(ci): fix no-owned-max-params lint violations and web E2E auth
mikib0 e163e5c
fix(e2e): guard null refreshToken in Playwright storageState fixture
mikib0 2d1419f
chore(e2e): bump Playwright and CI job timeouts
mikib0 6435354
fix(e2e): fix web auth in Playwright tests
mikib0 de6a3cb
fix(e2e): align auth flow with Better Auth endpoints and harden globa…
mikib0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import { createApiClient } from '@packrat/api-client'; | ||
| import { clientEnvs } from '@packrat/env/expo-client'; | ||
| import { store } from 'expo-app/atoms/store'; | ||
| import { needsReauthAtom } from 'expo-app/features/auth/atoms/authAtoms'; | ||
| import { authClient, getActiveToken } from 'expo-app/lib/auth-client'; | ||
|
|
||
| // On web, expo-secure-store's ExpoSecureStore.web.js is an empty object so | ||
| // SecureStore.getItemAsync throws at runtime. Use getActiveToken() instead, | ||
| // which reads the session token from authClient.getSession(). In E2E tests | ||
| // that call is intercepted by a Playwright route mock; in production it relies | ||
| // on the browser's native cookie handling via Better Auth. | ||
| export const apiClient = createApiClient({ | ||
| baseUrl: clientEnvs.EXPO_PUBLIC_API_URL, | ||
| auth: { | ||
| getAccessToken: getActiveToken, | ||
| getRefreshToken: () => null, | ||
| onAccessTokenRefreshed: () => {}, | ||
| onNeedsReauth: async () => { | ||
| const { data } = await authClient.getSession(); | ||
| if (data?.session) return; | ||
| store.set(needsReauthAtom, true); | ||
| }, | ||
| }, | ||
| }); | ||
|
|
||
| export type PackRatApi = typeof apiClient; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: PackRat-AI/PackRat
Length of output: 280
🏁 Script executed:
Repository: PackRat-AI/PackRat
Length of output: 1036
🏁 Script executed:
# Read the packrat.web.ts file to see the complete context cat -n apps/expo/lib/api/packrat.web.tsRepository: PackRat-AI/PackRat
Length of output: 1340
🏁 Script executed:
Repository: PackRat-AI/PackRat
Length of output: 13294
🏁 Script executed:
Repository: PackRat-AI/PackRat
Length of output: 405
Handle errors from
authClient.getSession()before setting reauth state.onNeedsReauthignores theerrorfield fromauthClient.getSession(). If the call fails transiently (network issue, service error), the code setsneedsReauthAtom = trueand bounces the user to login unnecessarily. The codebase already acknowledges this risk in a similar call atapps/expo/lib/api/packrat.tsline 42–46. The auth initialization code inuseAuthInit.tsshows the correct pattern: checkerrorfirst and return early if present.Suggested fix
onNeedsReauth: async () => { - const { data } = await authClient.getSession(); - if (data?.session) return; + const { data, error } = await authClient.getSession(); + if (error) return; + if (data?.session) return; store.set(needsReauthAtom, true); },🤖 Prompt for AI Agents