-
Notifications
You must be signed in to change notification settings - Fork 12
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
feat: sky zoo #25
Open
ImLunaHey
wants to merge
5
commits into
main
Choose a base branch
from
luna/add-sky-zoo
base: main
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
feat: sky zoo #25
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6c19459
feat: sky zoo
ImLunaHey 81ba256
Merge branch 'main' into luna/add-sky-zoo
ImLunaHey 37e9884
Merge branch 'main' into luna/add-sky-zoo
ImLunaHey 27d5e72
Merge branch 'main' into luna/add-sky-zoo
ImLunaHey b561528
Merge branch 'main' into luna/add-sky-zoo
ImLunaHey 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 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,24 @@ | ||
import { renderHook, waitFor } from '@testing-library/react'; | ||
import { describe, expect, test } from 'vitest'; | ||
import { useSkyZoo } from './useSkyZoo'; | ||
import { TestRouterProvider } from '@/test/helpers/test-router-provider'; | ||
|
||
describe('useSkyZoo', () => { | ||
test('returns user position', async () => { | ||
const { result } = renderHook(() => useSkyZoo({ did: 'did:plc:k6acu4chiwkixvdedcmdgmal' }), { | ||
wrapper: ({ children }) => <TestRouterProvider>{children}</TestRouterProvider>, | ||
}); | ||
|
||
expect(result.current.data).toBe(undefined); | ||
expect(result.current.error).toBe(null); | ||
|
||
await waitFor(() => expect(result.current.isSuccess).toBe(true)); | ||
Check failure on line 15 in src/hooks/useSkyZoo.test.tsx GitHub Actions / test (22.x)src/hooks/useSkyZoo.test.tsx > useSkyZoo > returns user position
|
||
|
||
expect(result.current.data).toEqual({ | ||
did: 'did:plc:k6acu4chiwkixvdedcmdgmal', | ||
pos_atproto: 13658725, | ||
pos_bsky: 13591459, | ||
createdAt: '2024-10-21T12:09:43.477Z', | ||
}); | ||
}); | ||
}); |
This file contains 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,17 @@ | ||
import { useQuery } from '@tanstack/react-query'; | ||
|
||
export function useSkyZoo({ did }: { did: string }) { | ||
return useQuery({ | ||
queryKey: ['sky-zoo', { did }], | ||
queryFn: async () => { | ||
const response = await fetch(`https://skyzoo.blue/stats/plc/${did}`); | ||
if (!response.ok) throw new Error('Failed to fetch SkyZoo stats'); | ||
return (await response.json()) as { | ||
did: string; | ||
pos_atproto: number; | ||
pos_bsky: number; | ||
createdAt: string; | ||
}; | ||
}, | ||
}); | ||
} |
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.
@jycouet i get CORS errors when running this in tests. is there any chance the headers could be a little less restrictive?
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.
You are running test on what port ?
(I'm avoiding laptop until next Monday, but I'll do something)
Let me know ✌️
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.
I had a quick look, but don't manage to see the error test.
When I do
npm run test
, I don't get dirrectly failed test, I need to check the report. I'm missing something ?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.
is there any reason you're restricting the CORS at all? why not just set it to
*
?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.
I was a bit worried about over usage... But you are right, I'll open it!
It should be working now with
*
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.
Test is still not ok ? 🧐
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.
are you seeing any requests on your end? its weird because this only fails in the tests. if i try it in my browser it's fine. 🤔
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.
I don't know why is that in test env !
And don't manage to see "log" with "npm run test" I see the summary, but not live tests. It's a config issue ?
I'll look into it 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.
we may need to merge with the test skipped and revisit it. it works in the browser and thats what really matters.
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.
Sure
I let you do ✌️