Feature/branch details (#1876)

Enrich branch overview with more details like last committer and ahead/behind commits. Since calculating this information is pretty intense, we request it in chunks to prevent very long loading times. Also we cache the results in frontend and backend.

Co-authored-by: René Pfeuffer <rene.pfeuffer@cloudogu.com>
This commit is contained in:
Eduard Heimbuch
2021-12-01 14:19:18 +01:00
committed by GitHub
parent ce2eae1843
commit 9cc134f5a8
59 changed files with 1933 additions and 154 deletions

View File

@@ -36,36 +36,38 @@ describe("Test branches hooks", () => {
type: "hg",
_links: {
branches: {
href: "/hog/branches",
},
},
href: "/hog/branches"
}
}
};
const develop: Branch = {
name: "develop",
revision: "42",
lastCommitter: { name: "trillian" },
_links: {
delete: {
href: "/hog/branches/develop",
},
},
href: "/hog/branches/develop"
}
}
};
const feature: Branch = {
name: "feature/something-special",
revision: "42",
lastCommitter: { name: "trillian" },
_links: {
delete: {
href: "/hog/branches/feature%2Fsomething-special",
},
},
href: "/hog/branches/feature%2Fsomething-special"
}
}
};
const branches: BranchCollection = {
_embedded: {
branches: [develop],
branches: [develop]
},
_links: {},
_links: {}
};
const queryClient = createInfiniteCachingClient();
@@ -83,7 +85,7 @@ describe("Test branches hooks", () => {
fetchMock.getOnce("/api/v2/hog/branches", branches);
const { result, waitFor } = renderHook(() => useBranches(repository), {
wrapper: createWrapper(undefined, queryClient),
wrapper: createWrapper(undefined, queryClient)
});
await waitFor(() => {
return !!result.current.data;
@@ -104,7 +106,7 @@ describe("Test branches hooks", () => {
"repository",
"hitchhiker",
"heart-of-gold",
"branches",
"branches"
]);
expect(data).toEqual(branches);
});
@@ -115,7 +117,7 @@ describe("Test branches hooks", () => {
fetchMock.getOnce("/api/v2/hog/branches/" + encodeURIComponent(name), branch);
const { result, waitFor } = renderHook(() => useBranch(repository, name), {
wrapper: createWrapper(undefined, queryClient),
wrapper: createWrapper(undefined, queryClient)
});
expect(result.error).toBeUndefined();
@@ -143,14 +145,14 @@ describe("Test branches hooks", () => {
fetchMock.postOnce("/api/v2/hog/branches", {
status: 201,
headers: {
Location: "/hog/branches/develop",
},
Location: "/hog/branches/develop"
}
});
fetchMock.getOnce("/api/v2/hog/branches/develop", develop);
const { result, waitForNextUpdate } = renderHook(() => useCreateBranch(repository), {
wrapper: createWrapper(undefined, queryClient),
wrapper: createWrapper(undefined, queryClient)
});
await act(() => {
@@ -175,7 +177,7 @@ describe("Test branches hooks", () => {
"hitchhiker",
"heart-of-gold",
"branch",
"develop",
"develop"
]);
expect(branch).toEqual(develop);
});
@@ -192,11 +194,11 @@ describe("Test branches hooks", () => {
describe("useDeleteBranch tests", () => {
const deleteBranch = async () => {
fetchMock.deleteOnce("/api/v2/hog/branches/develop", {
status: 204,
status: 204
});
const { result, waitForNextUpdate } = renderHook(() => useDeleteBranch(repository), {
wrapper: createWrapper(undefined, queryClient),
wrapper: createWrapper(undefined, queryClient)
});
await act(() => {