Improve e2e tests (#8927)
* get e2e image picker working * verify create account actually reaches onboarding * wait for image to actually be attached before posting * wait until login finishes before moving on * sign out before switch accounts then wait until logged in * disable onboarding experiments in e2e * add testId to handle availability checkmark * fix too long username * update thread muting test to reflect current behaviour * hackfix for the british english translation * unflake the onboarding tests * fix curate list flow * admit defeat on the most list one
This commit is contained in:
@@ -7,6 +7,7 @@ import ExpoImageCropTool, {type OpenCropperOptions} from 'expo-image-crop-tool'
|
||||
|
||||
import {compressIfNeeded} from './manip'
|
||||
import {type PickerImage} from './picker.shared'
|
||||
import {ImagePickerResult} from 'expo-image-picker'
|
||||
|
||||
async function getFile() {
|
||||
const imagesDir = documentDirectory!
|
||||
@@ -38,6 +39,22 @@ export async function openPicker(): Promise<PickerImage[]> {
|
||||
return [await getFile()]
|
||||
}
|
||||
|
||||
export async function openUnifiedPicker(): Promise<ImagePickerResult> {
|
||||
const file = await getFile()
|
||||
|
||||
return {
|
||||
assets: [
|
||||
{
|
||||
type: 'image',
|
||||
uri: file.path,
|
||||
mimeType: file.mime,
|
||||
...file,
|
||||
},
|
||||
],
|
||||
canceled: false,
|
||||
}
|
||||
}
|
||||
|
||||
export async function openCamera(): Promise<PickerImage> {
|
||||
return await getFile()
|
||||
}
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
import {
|
||||
type ImagePickerOptions,
|
||||
launchImageLibraryAsync,
|
||||
UIImagePickerPreferredAssetRepresentationMode,
|
||||
} from 'expo-image-picker'
|
||||
import {t} from '@lingui/macro'
|
||||
|
||||
import {isIOS, isWeb} from '#/platform/detection'
|
||||
import {type ImageMeta} from '#/state/gallery'
|
||||
import * as Toast from '#/view/com/util/Toast'
|
||||
import {VIDEO_MAX_DURATION_MS} from '../constants'
|
||||
import {getDataUriSize} from './util'
|
||||
|
||||
export type PickerImage = ImageMeta & {
|
||||
@@ -36,3 +39,22 @@ export async function openPicker(opts?: ImagePickerOptions) {
|
||||
size: getDataUriSize(image.uri),
|
||||
}))
|
||||
}
|
||||
|
||||
export async function openUnifiedPicker({
|
||||
selectionCountRemaining,
|
||||
}: {
|
||||
selectionCountRemaining: number
|
||||
}) {
|
||||
return await launchImageLibraryAsync({
|
||||
exif: false,
|
||||
mediaTypes: ['images', 'videos'],
|
||||
quality: 1,
|
||||
allowsMultipleSelection: true,
|
||||
legacy: true,
|
||||
base64: isWeb,
|
||||
selectionLimit: isIOS ? selectionCountRemaining : undefined,
|
||||
preferredAssetRepresentationMode:
|
||||
UIImagePickerPreferredAssetRepresentationMode.Current,
|
||||
videoMaxDuration: VIDEO_MAX_DURATION_MS / 1000,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
import ExpoImageCropTool, {type OpenCropperOptions} from 'expo-image-crop-tool'
|
||||
import {type ImagePickerOptions, launchCameraAsync} from 'expo-image-picker'
|
||||
|
||||
export {openPicker, type PickerImage as RNImage} from './picker.shared'
|
||||
export {
|
||||
openPicker,
|
||||
openUnifiedPicker,
|
||||
type PickerImage as RNImage,
|
||||
} from './picker.shared'
|
||||
|
||||
export async function openCamera(customOpts: ImagePickerOptions) {
|
||||
const opts: ImagePickerOptions = {
|
||||
|
||||
@@ -3,7 +3,7 @@ import {type OpenCropperOptions} from 'expo-image-crop-tool'
|
||||
import {type PickerImage} from './picker.shared'
|
||||
import {type CameraOpts} from './types'
|
||||
|
||||
export {openPicker} from './picker.shared'
|
||||
export {openPicker, openUnifiedPicker} from './picker.shared'
|
||||
|
||||
export async function openCamera(_opts: CameraOpts): Promise<PickerImage> {
|
||||
throw new Error('openCamera is not supported on web')
|
||||
|
||||
Reference in New Issue
Block a user