-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: import config #55
Merged
+154
−66
Merged
Changes from 27 commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
9d4662b
Sets up basics for device naming screen. Still needs api call to work.
cimigree 1ebb36c
Removes console logs.
cimigree 0ed4682
Adds the next screen create join project screen to check that the dev…
cimigree 45e02b5
Adds segmenter count and byte count to limit device name length.
cimigree 5441dda
Makes reusable onboarding layout component. Makes create join project…
cimigree b3747c2
Merges with main for device naming grapheme count logic.
cimigree 8b2414b
Updates grapheme count methods
cimigree 527f4c8
Moves files into various folders and updates imports. Fixes height is…
cimigree 087c785
Adjustments to device naming screen.
cimigree 5465d5f
Fixes height of screens. Finishes basic UI for create a project screen.
cimigree 2e0ffca
Allows button to take className prop. Sets up top menu so user cannot…
cimigree 856bf01
Adds join project screen.
cimigree 35e5687
Adds bigger icons
cimigree ce4e810
Fixes styling and responsiveness of first screen.
cimigree 586d2d3
Makes the layout and menu component just styles and less logic. Moves…
cimigree e99e409
CHanges spacing to 12 and 20 to reflect design decision.
cimigree 3434ed7
Adds ability to import a config file while creating a project.
cimigree f3d6c8b
Merges with main.
cimigree ca1c0fc
Some tweaks to file after merge conflicts.
cimigree 5ea8957
Adds a test for the config file importer test.
cimigree f52ab4b
Adds a test for the config file importer test.
cimigree 29a1e64
Merge branch 'main' into feat/import-config
cimigree 5a0c1bd
Merges with main.
cimigree 1d4d7da
Merges with main.
cimigree ab532c5
Merge branch 'main' into feat/import-config
cimigree 9de7aac
Replaces html file input with hook that uses electron import dialog. …
cimigree f105668
Fixes import. Fixes test.
cimigree d0ce621
Merge branch 'main' into feat/import-config
cimigree 36101ed
Fixes project creation error message. Fixes test. Displays file name …
cimigree 00a3a47
Removes unnecessary prop from test.
cimigree 1d2958b
Merge branch 'main' into feat/import-config
cimigree 768cff9
Updates config importer to use new select file. Updates test.
cimigree 924c8f7
Updates test to include throwing an error.
cimigree 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 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 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 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,70 @@ | ||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query' | ||
import { act, renderHook } from '@testing-library/react' | ||
import { beforeEach, describe, expect, it, vi } from 'vitest' | ||
|
||
import { useSelectProjectConfigFile } from './mutations/file-system' | ||
|
||
describe('useSelectProjectConfigFile', () => { | ||
beforeEach(() => { | ||
window.runtime = { | ||
init: vi.fn(), | ||
getLocale: vi.fn().mockResolvedValue('en'), | ||
updateLocale: vi.fn(), | ||
selectFile: vi.fn(), | ||
} | ||
}) | ||
|
||
it('returns file path from window.runtime.selectFile', async () => { | ||
vi.spyOn(window.runtime, 'selectFile').mockResolvedValue( | ||
'/some/path.comapeocat', | ||
) | ||
|
||
const queryClient = new QueryClient() | ||
|
||
const wrapper = ({ children }: { children: React.ReactNode }) => ( | ||
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider> | ||
) | ||
|
||
const { result } = renderHook(() => useSelectProjectConfigFile(), { | ||
wrapper, | ||
}) | ||
|
||
let selectedPath: string | undefined | ||
|
||
await act(async () => { | ||
await result.current.mutateAsync(undefined, { | ||
onSuccess: (val) => { | ||
selectedPath = val | ||
}, | ||
}) | ||
cimigree marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}) | ||
|
||
expect(selectedPath).toBe('/some/path.comapeocat') | ||
}) | ||
|
||
it('returns undefined if user cancels', async () => { | ||
vi.spyOn(window.runtime, 'selectFile').mockResolvedValue(undefined) | ||
|
||
const queryClient = new QueryClient() | ||
|
||
const wrapper = ({ children }: { children: React.ReactNode }) => ( | ||
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider> | ||
) | ||
|
||
const { result } = renderHook(() => useSelectProjectConfigFile(), { | ||
wrapper, | ||
}) | ||
|
||
let selectedPath: string | undefined | ||
|
||
await act(async () => { | ||
await result.current.mutateAsync(undefined, { | ||
onSuccess: (val) => { | ||
selectedPath = val | ||
}, | ||
}) | ||
cimigree marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}) | ||
|
||
expect(selectedPath).toBeUndefined() | ||
}) | ||
}) |
This file contains 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 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.
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.
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.
non-blocking but would be good to add a test here for when the payload from
window.runtime.selectFile()
is invalid e.g. thepath
orname
are not stringsThere 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.
Just FYI, to get it to "throw" the error, I have to mock the selectFile as a rejected promise... because otherwise I would actually have to spin up Electron or the preload script with an integration test or an E2E test. Hope that is ok. Is this useful? Not sure...
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.
yeah this is what I figured you would do for now. think that's fine 👍
EDIT: re-reading it and yeah, my initial suggestion was something that can't be done easily (i.e. stub the ipc call to electron). there's probably a way to do it but not worth figuring it out. Given that, maybe not as useful as I initially thought