-
Notifications
You must be signed in to change notification settings - Fork 2
feat: improve mocking and add react devtools #65
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 all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
e7d6aad
feat(mock): reactive in-memory Firestore backend with fixtures and si…
claude 3026267
feat(devtools): TanStack Devtools plugin for the mock Firestore backend
claude f6c5be8
Merge remote-tracking branch 'origin/claude/vigilant-pascal-qgjsm4' i…
claude fffb5ae
feat(example): mock backend mode with Firestore Mock devtools
claude 3d3a3b9
Merge remote-tracking branch 'origin/main' into claude/react-effect-a…
claude aa872c0
Merge remote-tracking branch 'origin/main' into claude/react-effect-a…
claude 4471cee
chore: align with updated dependencies and formatting
claude f3535b7
feat(mock): generatedFixture — schema-derived documents via Schema.to…
claude 1e6a1f1
feat(schema): constrain generated timestamps to Firestore's valid range
claude 7e67077
fix: address review findings on recovery callbacks and orderBy semantics
claude 26829ef
fix: address CodeRabbit review findings
claude d225372
fix(example): make the simulated loading state visible on mounted pages
claude 3606c7d
fix(mock): antisymmetric opaque ordering and fixture ID validation
claude e3fa817
fix(devtools): report the effective wildcard state after clear and reset
claude 351117e
chore: clean up implementation
fwal ee22abc
fix(mock): address review findings on the cleaned-up implementation
claude 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
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,74 @@ | ||
| import { DateTime, Option } from 'effect'; | ||
| import { fixture, make } from '@effect-firebase/mock'; | ||
| import { AuthorId, AuthorModel, PostId, PostModel } from '@example/shared'; | ||
|
|
||
| const at = (iso: string) => DateTime.makeUnsafe(iso); | ||
|
|
||
| const author = (id: string, name: string, created: string) => | ||
| new AuthorModel({ | ||
| id: AuthorId.make(id), | ||
| name, | ||
| createdAt: at(created), | ||
| updatedAt: at(created), | ||
| }); | ||
|
|
||
| const post = ( | ||
| id: string, | ||
| title: string, | ||
| content: string, | ||
| created: string, | ||
| authorId = 'ada', | ||
| ) => | ||
| new PostModel({ | ||
| id: PostId.make(id), | ||
| title, | ||
| content, | ||
| author: AuthorId.make(authorId), | ||
| createdAt: at(created), | ||
| updatedAt: at(created), | ||
| checked: false, | ||
| optional: Option.none(), | ||
| list: [], | ||
| }); | ||
|
|
||
| /** | ||
| * A static mock backend for developing pages without the Firebase emulator. | ||
| * | ||
| * Enabled by starting the app with `VITE_MOCK_BACKEND=1` (see `app.tsx`). | ||
| * The handle is shared between the app runtime (which provides | ||
| * `mockBackend.layer` through `firestoreLayerAtom`) and the Firestore Mock | ||
| * devtools panel (which drives `mockBackend.controller`). | ||
| */ | ||
| export const mockBackend = make({ | ||
| fixtures: [ | ||
| fixture(AuthorModel, { | ||
| collectionPath: 'authors', | ||
| idField: 'id', | ||
| docs: [author('ada', 'Ada Lovelace', '2024-01-01T09:00:00Z')], | ||
| }), | ||
| fixture(PostModel, { | ||
| collectionPath: 'posts', | ||
| idField: 'id', | ||
| docs: [ | ||
| post( | ||
| 'welcome', | ||
| 'Welcome to mock mode', | ||
| 'This post is served from the in-memory mock backend — no emulator running. Open the TanStack Devtools panel to toggle this collection between data, empty, loading and error.', | ||
| '2024-05-03T10:00:00Z', | ||
| ), | ||
| post( | ||
| 'fixtures', | ||
| 'Fixtures are schema-encoded', | ||
| 'These documents were written through PostModel, so timestamps, references and options decode exactly like production data.', | ||
| '2024-05-02T15:30:00Z', | ||
| ), | ||
| post( | ||
| 'try-writing', | ||
| 'Writes are live', | ||
| 'Create, edit or delete posts — the mock store is reactive, so the stream behind this list re-emits just like onSnapshot.', | ||
| '2024-05-01T08:15:00Z', | ||
| ), | ||
| ], | ||
| }), | ||
| ], | ||
| }); |
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 |
|---|---|---|
| @@ -1,16 +1,16 @@ | ||
| import { Outlet, createRootRoute } from '@tanstack/react-router'; | ||
| import { TanStackRouterDevtools } from '@tanstack/react-router-devtools'; | ||
| import App from '../app/app'; | ||
|
fwal marked this conversation as resolved.
|
||
|
|
||
| export const Route = createRootRoute({ | ||
| component: RootComponent, | ||
| }); | ||
|
|
||
| // Devtools (router + Firestore mock) are mounted by <App /> in a single | ||
| // TanStack Devtools shell. | ||
| function RootComponent() { | ||
| return ( | ||
| <App> | ||
| <Outlet /> | ||
| <TanStackRouterDevtools position="bottom-right" /> | ||
| </App> | ||
| ); | ||
| } | ||
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
Oops, something went wrong.
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.