feat: Redesign git changes to split stage/unstaged files. (#1359)
* feat: Redesign git changes to split stage/unstaged files. Signed-off-by: Paolo Insogna <paolo@cowtech.it> * fixup Signed-off-by: Paolo Insogna <paolo@cowtech.it> * fixup Signed-off-by: Paolo Insogna <paolo@cowtech.it> * refactor: streamline git changes panel * fix: label staged and working diff tabs * fix: isolate staged and working diff files * fix: scope staged and working diff updates * fix: scope git row revert to working changes --------- Signed-off-by: Paolo Insogna <paolo@cowtech.it> Co-authored-by: Bohdan Triapitsyn <artmore@protonmail.com>
This commit is contained in:
committed by
GitHub
co-authored by
Bohdan Triapitsyn
parent
9af0de0056
commit
e16097b05d
@@ -0,0 +1,72 @@
|
||||
import { beforeEach, describe, expect, it, mock } from 'bun:test';
|
||||
|
||||
const gitService = {
|
||||
stageGitFiles: mock(),
|
||||
unstageGitFiles: mock(),
|
||||
};
|
||||
|
||||
mock.module('./gitService', () => gitService);
|
||||
|
||||
const { handleStandardGitBridgeMessage } = await import('./bridge-git-runtime');
|
||||
|
||||
describe('bridge git runtime index mutations', () => {
|
||||
beforeEach(() => {
|
||||
gitService.stageGitFiles.mockReset();
|
||||
gitService.unstageGitFiles.mockReset();
|
||||
});
|
||||
|
||||
it('accepts legacy stage path payloads', async () => {
|
||||
const response = await handleStandardGitBridgeMessage({
|
||||
id: '1',
|
||||
type: 'api:git/stage',
|
||||
payload: { directory: '/repo', path: 'a.ts' },
|
||||
});
|
||||
|
||||
expect(response).toEqual({ id: '1', type: 'api:git/stage', success: true, data: { success: true } });
|
||||
expect(gitService.stageGitFiles).toHaveBeenCalledWith('/repo', ['a.ts']);
|
||||
});
|
||||
|
||||
it('accepts bulk stage paths payloads', async () => {
|
||||
const response = await handleStandardGitBridgeMessage({
|
||||
id: '1',
|
||||
type: 'api:git/stage',
|
||||
payload: { directory: '/repo', paths: ['a.ts', 'b.ts'] },
|
||||
});
|
||||
|
||||
expect(response?.success).toBe(true);
|
||||
expect(gitService.stageGitFiles).toHaveBeenCalledWith('/repo', ['a.ts', 'b.ts']);
|
||||
});
|
||||
|
||||
it('accepts legacy unstage path payloads', async () => {
|
||||
const response = await handleStandardGitBridgeMessage({
|
||||
id: '1',
|
||||
type: 'api:git/unstage',
|
||||
payload: { directory: '/repo', path: 'a.ts' },
|
||||
});
|
||||
|
||||
expect(response).toEqual({ id: '1', type: 'api:git/unstage', success: true, data: { success: true } });
|
||||
expect(gitService.unstageGitFiles).toHaveBeenCalledWith('/repo', ['a.ts']);
|
||||
});
|
||||
|
||||
it('accepts bulk unstage paths payloads', async () => {
|
||||
const response = await handleStandardGitBridgeMessage({
|
||||
id: '1',
|
||||
type: 'api:git/unstage',
|
||||
payload: { directory: '/repo', paths: ['a.ts', 'b.ts'] },
|
||||
});
|
||||
|
||||
expect(response?.success).toBe(true);
|
||||
expect(gitService.unstageGitFiles).toHaveBeenCalledWith('/repo', ['a.ts', 'b.ts']);
|
||||
});
|
||||
|
||||
it('rejects invalid path payloads', async () => {
|
||||
const response = await handleStandardGitBridgeMessage({
|
||||
id: '1',
|
||||
type: 'api:git/stage',
|
||||
payload: { directory: '/repo', paths: [' ', null] },
|
||||
});
|
||||
|
||||
expect(response?.success).toBe(false);
|
||||
expect(gitService.stageGitFiles).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user