-
Notifications
You must be signed in to change notification settings - Fork 0
RIC-T40 Permissions fix #23
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import type { ConfigContext } from '@expo/config'; | ||
|
|
||
| import createExpoConfig from '../../app.config'; | ||
|
|
||
| jest.mock('zod', () => jest.requireActual('zod')); | ||
|
|
||
| const blockedMediaPermissions = [ | ||
| 'android.permission.READ_MEDIA_IMAGES', | ||
| 'android.permission.READ_MEDIA_VIDEO', | ||
| 'android.permission.READ_MEDIA_VISUAL_USER_SELECTED', | ||
| 'android.permission.READ_EXTERNAL_STORAGE', | ||
| 'android.permission.WRITE_EXTERNAL_STORAGE', | ||
| ]; | ||
|
|
||
| describe('Android media permissions', () => { | ||
| it('blocks broad media access so system pickers remain the only gallery access path', () => { | ||
| const config = createExpoConfig({ | ||
| config: { | ||
| name: 'Resgrid IC', | ||
| slug: 'resgrid-ic', | ||
| }, | ||
| } as ConfigContext); | ||
|
|
||
| expect(config.android?.blockedPermissions).toEqual(expect.arrayContaining(blockedMediaPermissions)); | ||
| blockedMediaPermissions.forEach((permission) => { | ||
| expect(config.android?.permissions).not.toContain(permission); | ||
| }); | ||
| }); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import * as ImagePicker from 'expo-image-picker'; | ||
|
|
||
| import { launchCallImagePicker } from '@/components/calls/call-image-picker'; | ||
|
|
||
| jest.mock('expo-image-picker', () => ({ | ||
| launchImageLibraryAsync: jest.fn(), | ||
| })); | ||
|
|
||
| const mockLaunchImageLibraryAsync = ImagePicker.launchImageLibraryAsync as jest.MockedFunction<typeof ImagePicker.launchImageLibraryAsync>; | ||
|
|
||
| describe('launchCallImagePicker', () => { | ||
| it('uses the non-legacy system image picker without requesting broad media access', async () => { | ||
| const pickerResult: ImagePicker.ImagePickerResult = { | ||
| assets: null, | ||
| canceled: true, | ||
| }; | ||
| mockLaunchImageLibraryAsync.mockResolvedValue(pickerResult); | ||
|
|
||
| await expect(launchCallImagePicker()).resolves.toBe(pickerResult); | ||
| expect(mockLaunchImageLibraryAsync).toHaveBeenCalledWith({ | ||
| mediaTypes: ['images'], | ||
| allowsEditing: true, | ||
| quality: 0.8, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Inlined magic number for the quality value risks inconsistency between the test and implementation, also occurring in Kody rule violation: Replace magic numbers with named constants Prompt for LLMTalk to Kody by mentioning @kody Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction. |
||
| legacy: false, | ||
| }); | ||
| }); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import * as ImagePicker from 'expo-image-picker'; | ||
|
|
||
| export const launchCallImagePicker = (): Promise<ImagePicker.ImagePickerResult> => | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing JSDoc documentation for the Promise-returning function obscures the resolve value shape, rejection conditions, and await requirement. Add a JSDoc block specifying Kody rule violation: Document async/Promise behavior and errors Prompt for LLMTalk to Kody by mentioning @kody Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction. |
||
| ImagePicker.launchImageLibraryAsync({ | ||
| mediaTypes: ['images'], | ||
| allowsEditing: true, | ||
| quality: 0.8, | ||
| legacy: false, | ||
| }); | ||
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.
Raw string literal used for the media type risks drift from the implementation and obscures intent. Use the shared
MediaTypeconstant/enum from the picker module or Expo API, such asmediaTypes: [MediaType.Images].Kody rule violation: Use enums instead of magic strings
Prompt for LLM
Talk to Kody by mentioning @kody
Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.