Finished testing implementation

This commit is contained in:
Christopher Sanden
2026-03-18 16:38:55 +01:00
parent c73363efb9
commit 7aad9dc34d
15 changed files with 3177 additions and 33 deletions

View File

@@ -91,10 +91,11 @@ function ThemedRootLayout() {
function NotificationProviderGate({ children }: PropsWithChildren) {
const isAndroidExpoGo = Platform.OS === "android" && Constants.executionEnvironment === "storeClient"
const isTestEnvironment = process.env.NODE_ENV === "test"
const [provider, setProvider] = useState<ComponentType<PropsWithChildren> | null>(null)
useEffect(() => {
if (isAndroidExpoGo) {
if (isAndroidExpoGo || isTestEnvironment) {
return
}
@@ -117,9 +118,9 @@ function NotificationProviderGate({ children }: PropsWithChildren) {
return () => {
isMounted = false
}
}, [isAndroidExpoGo])
}, [isAndroidExpoGo, isTestEnvironment])
if (isAndroidExpoGo || !provider) {
if (isAndroidExpoGo || isTestEnvironment || !provider) {
return children
}

View File

@@ -1,6 +1,7 @@
import { useEffect, useState } from "react"
import {
Alert,
ActivityIndicator,
KeyboardAvoidingView,
Platform,
Pressable,
@@ -28,7 +29,7 @@ export default function DetailScreen() {
id?: string
}>()
const { claims } = useAuthContext()
const { deleteNote, errorMessage, notes, updateNote } = useNotes()
const { deleteNote, errorMessage, fetchNoteById, notes, updateNote } = useNotes()
const note = notes.find((entry) => entry.id === id)
const canEdit = note?.createdBy === claims?.sub
const [title, setTitle] = useState(note?.title ?? "")
@@ -40,6 +41,7 @@ export default function DetailScreen() {
const [uploadProgress, setUploadProgress] = useState<number | null>(null)
const [localErrorMessage, setLocalErrorMessage] = useState<string | null>(null)
const [statusMessage, setStatusMessage] = useState<string | null>(null)
const [isLoadingNote, setIsLoadingNote] = useState(false)
const insets = useSafeAreaInsets()
const headerHeight = useHeaderHeight()
const { colorScheme, palette } = useAppTheme()
@@ -61,6 +63,27 @@ export default function DetailScreen() {
setImageChange({ type: "keep" })
}, [note?.content, note?.id, note?.title])
useEffect(() => {
if (!id || note) {
setIsLoadingNote(false)
return
}
let isMounted = true
setIsLoadingNote(true)
void fetchNoteById(id).finally(() => {
if (isMounted) {
setIsLoadingNote(false)
}
})
return () => {
isMounted = false
}
}, [fetchNoteById, id, note])
const attachFromCamera = async () => {
try {
const image = await pickImageFromCamera()
@@ -171,6 +194,18 @@ export default function DetailScreen() {
}
}
if (isLoadingNote && !note) {
return (
<View
testID="note-detail-loader"
style={[styles.container, { backgroundColor: palette.background, padding: 16, justifyContent: "center" }]}
>
<ActivityIndicator size="large" color={palette.accent} />
<Text style={[styles.content, { color: palette.mutedText, marginTop: 12 }]}>Loading note...</Text>
</View>
)
}
if (!note) {
return (
<View style={[styles.container, { backgroundColor: palette.background, padding: 16 }]}>