feat: enhance import session handling by adding session UUID to commitImport function
This commit is contained in:
@@ -27,8 +27,8 @@ export const getImportPreview = async (): Promise<ImportPreview> => {
|
||||
return data;
|
||||
};
|
||||
|
||||
export const commitImport = async (resolutions: Record<string, string>): Promise<void> => {
|
||||
await client.post('/import/commit', { resolutions });
|
||||
export const commitImport = async (sessionUUID: string, resolutions: Record<string, string>): Promise<void> => {
|
||||
await client.post('/import/commit', { session_uuid: sessionUUID, resolutions });
|
||||
};
|
||||
|
||||
export const cancelImport = async (): Promise<void> => {
|
||||
|
||||
@@ -63,6 +63,11 @@ const mockNotifications: api.Notification[] = [
|
||||
describe('NotificationCenter', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
vi.mocked(api.checkUpdates).mockResolvedValue({
|
||||
available: false,
|
||||
latest_version: '0.0.0',
|
||||
changelog_url: '',
|
||||
})
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
|
||||
@@ -143,7 +143,7 @@ describe('useImport', () => {
|
||||
await result.current.commit({ 'test.com': 'skip' })
|
||||
})
|
||||
|
||||
expect(api.commitImport).toHaveBeenCalledWith({ 'test.com': 'skip' })
|
||||
expect(api.commitImport).toHaveBeenCalledWith('session-2', { 'test.com': 'skip' })
|
||||
|
||||
await waitFor(() => {
|
||||
expect(result.current.session).toBeNull()
|
||||
|
||||
@@ -43,7 +43,11 @@ export function useImport() {
|
||||
});
|
||||
|
||||
const commitMutation = useMutation({
|
||||
mutationFn: (resolutions: Record<string, string>) => commitImport(resolutions),
|
||||
mutationFn: (resolutions: Record<string, string>) => {
|
||||
const sessionId = statusQuery.data?.session?.id;
|
||||
if (!sessionId) throw new Error("No active session");
|
||||
return commitImport(sessionId, resolutions);
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: QUERY_KEY });
|
||||
queryClient.invalidateQueries({ queryKey: ['import-preview'] });
|
||||
|
||||
Reference in New Issue
Block a user