-
-
Notifications
You must be signed in to change notification settings - Fork 538
[Feature]: Fetch steam deck comaptibility #2829
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
Merged
Merged
Changes from 11 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
eac60cd
Get steamdeck comaptibility
kohend d5649ea
Attempt to fix actions
kohend 9438351
unify steam data
kohend 453e321
yarn lock
kohend 0f60d50
Merge branch 'Heroic-Games-Launcher:main' into steamdeck
kohend d4fa5ef
UI support
kohend 685937f
Get/Show unknown properly
kohend f7e8c1d
Make compatibility info a link
kohend 212ec2b
Get proton and Steam Deck info only on Linux
kohend fdecdbd
Fix tests warnings
kohend 51df291
Design and backend clean up
Nocccer 4a4f3b0
Added review suggestion
Nocccer 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
52 changes: 52 additions & 0 deletions
52
src/backend/wiki_game_info/steamdeck/__tests__/utils.test.ts
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,52 @@ | ||
| import { logError } from 'backend/logger/logger' | ||
| import { getSteamDeckComp } from '../utils' | ||
| import axios, { AxiosError } from 'axios' | ||
|
|
||
| jest.mock('backend/logger/logfile') | ||
| jest.mock('backend/logger/logger') | ||
|
|
||
| describe('getSteamDeckComp', () => { | ||
| test('fetches successfully via steamid', async () => { | ||
| const mockAxios = jest.spyOn(axios, 'get').mockResolvedValue({ | ||
| data: { results: { resolved_category: 1 } } | ||
| }) | ||
|
|
||
| const result = await getSteamDeckComp('1234') | ||
| expect(result).toStrictEqual(testProtonDBInfo) | ||
| expect(mockAxios).toBeCalled() | ||
| }) | ||
| test('api change', async () => { | ||
| const mockAxios = jest.spyOn(axios, 'get').mockResolvedValue({ | ||
| data: { results: { tierLevel: 'gold' } } | ||
| }) | ||
|
|
||
| const result = await getSteamDeckComp('1234') | ||
| expect(result).toStrictEqual(null) | ||
| expect(mockAxios).toBeCalled() | ||
| }) | ||
| test('does not find game', async () => { | ||
| const mockAxios = jest | ||
| .spyOn(axios, 'get') | ||
| .mockRejectedValue(<AxiosError>new Error('not found')) | ||
|
|
||
| const result = await getSteamDeckComp('1234') | ||
| expect(result).toBeNull() | ||
| expect(mockAxios).toBeCalled() | ||
| expect(logError).toBeCalledWith( | ||
| ['Was not able to get Stem Deck data for 1234', undefined], | ||
| 'ExtraGameInfo' | ||
| ) | ||
| }) | ||
|
|
||
| test('no SteamID', async () => { | ||
| const mockAxios = jest.spyOn(axios, 'get') | ||
|
|
||
| const result = await getSteamDeckComp('') | ||
| expect(result).toBeNull() | ||
| expect(mockAxios).not.toBeCalled() | ||
| }) | ||
| }) | ||
|
|
||
| const testProtonDBInfo = { | ||
| category: 1 | ||
| } |
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,39 @@ | ||
| import { SteamDeckComp } from 'common/types' | ||
| import axios, { AxiosError } from 'axios' | ||
| import { logDebug, logError, LogPrefix } from 'backend/logger/logger' | ||
|
|
||
| export async function getSteamDeckComp( | ||
| steamID: string | undefined | ||
| ): Promise<SteamDeckComp | null> { | ||
| if (!steamID) { | ||
| logDebug('No SteamID, not getting Stem Deck info') | ||
| return null | ||
| } | ||
| const url = `https://store.steampowered.com/saleaction/ajaxgetdeckappcompatibilityreport?nAppID=${steamID}` | ||
|
|
||
| const response = await axios | ||
| .get(url, { headers: {} }) | ||
| .catch((error: AxiosError) => { | ||
| logError( | ||
| [ | ||
| `Was not able to get Stem Deck data for ${steamID}`, | ||
| error.response?.data.error_description | ||
| ], | ||
| LogPrefix.ExtraGameInfo | ||
| ) | ||
| return null | ||
| }) | ||
|
|
||
| if (!response) { | ||
| logDebug('No response when getting Stem Deck info') | ||
| return null | ||
| } | ||
| const resp_str = JSON.stringify(response.data) | ||
| logDebug(`SteamDeck data for ${steamID} ${resp_str}`) | ||
|
|
||
| if (!Number.isFinite(response.data?.results?.resolved_category)) { | ||
| logError('No resolved_category in response, API changed?') | ||
| return null | ||
| } | ||
| return { category: response.data.results.resolved_category } | ||
| } |
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.
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.
Uh oh!
There was an error while loading. Please reload this page.