Open tamsingreen opened 3 years ago
I've been looking into the emulator stuff as part of the #190 - I'm encountering this issue where it's accessing the locally setup firestore. I imagine this ticket will encounter similar issues.
Mobbed with @allishultes and @aniablaziak and have been able to pinpoint to the security rules. This issue is similar, but not exactly the same: https://github.com/firebase/firebase-ios-sdk/issues/5072 It looks like the token is not being passed from the emulated version to the firestore. Even when the user is "authenticated" firestore thinks it's not.
What I've tried so far:
Workaround:
firestore.rules
as belowrules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if true;
}
}
}
Error log
prebuilt-4888bff0-430c65bc.js:180 Uncaught (in promise) FirebaseError:
Null value error. for 'get' @ L15, Null value error. for 'get' @ L19
at new e (http://localhost:3000/static/js/vendors~main.chunk.js:34030:19)
at http://localhost:3000/static/js/vendors~main.chunk.js:45834:18
at http://localhost:3000/static/js/vendors~main.chunk.js:45835:10
at e.onMessage (http://localhost:3000/static/js/vendors~main.chunk.js:45856:6)
at http://localhost:3000/static/js/vendors~main.chunk.js:45747:18
at http://localhost:3000/static/js/vendors~main.chunk.js:45785:29
at http://localhost:3000/static/js/vendors~main.chunk.js:51567:25
e @ prebuilt-4888bff0-430c65bc.js:180
(anonymous) @ prebuilt-4888bff0-430c65bc.js:10407
(anonymous) @ prebuilt-4888bff0-430c65bc.js:10408
e.onMessage @ prebuilt-4888bff0-430c65bc.js:10430
(anonymous) @ prebuilt-4888bff0-430c65bc.js:10347
(anonymous) @ prebuilt-4888bff0-430c65bc.js:10378
(anonymous) @ prebuilt-4888bff0-430c65bc.js:15107
Promise.then (async)
asyncGeneratorStep @ asyncToGenerator.js:13
_next @ asyncToGenerator.js:25
(anonymous) @ asyncToGenerator.js:32
(anonymous) @ asyncToGenerator.js:21
getUser @ App.js:31
(anonymous) @ App.js:37
commitHookEffectListMount @ react-dom.development.js:19731
commitPassiveHookEffects @ react-dom.development.js:19769
callCallback @ react-dom.development.js:188
invokeGuardedCallbackDev @ react-dom.development.js:237
invokeGuardedCallback @ react-dom.development.js:292
flushPassiveEffectsImpl @ react-dom.development.js:22853
unstable_runWithPriority @ scheduler.development.js:653
runWithPriority$1 @ react-dom.development.js:11039
flushPassiveEffects @ react-dom.development.js:22820
(anonymous) @ react-dom.development.js:22699
workLoop @ scheduler.development.js:597
flushWork @ scheduler.development.js:552
performWorkUntilDeadline @ scheduler.development.js:164
I found firebase-mock, which includes documentation on firebase.admin and authentication? I'm not sure if that would help us...
Is your feature request related to a problem? Please describe. In order to test components we'll need get past Firebase authentication.
Describe the solution you'd like This ticket is largely exploratory as I can't find a good example of an approach using React online. The 'official' way would be to use firebase emulator to initialise a mock app with an authenticated user. See: https://firebase.google.com/docs/firestore/security/test-rules-emulator https://github.com/firebase/quickstart-testing It might look something like:
this example needs more work :-)
Describe alternatives you've considered