Skip to content

Commit

Permalink
[dashboard] fix EXP-901 (#19043)
Browse files Browse the repository at this point in the history
  • Loading branch information
svenefftinge authored Nov 9, 2023
1 parent 4de3805 commit 2e3429a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ test("it should exclude project entries", () => {
repo("foo", "project-foo"),
];
const deduplicated = deduplicateAndFilterRepositories("foo", true, suggestedRepos);
expect(deduplicated.length).toEqual(1);
expect(deduplicated.length).toEqual(2);
expect(deduplicated[0].repositoryName).toEqual("foo");
expect(deduplicated[1].repositoryName).toEqual("foo2");
});

test("it should match entries in url as well as poject name", () => {
Expand Down Expand Up @@ -75,3 +77,17 @@ test("it keeps the order", () => {
expect(deduplicated[2].projectName).toEqual("someFootest");
expect(deduplicated[3].projectName).toEqual("FOOtest");
});

test("it should return all repositories without duplicates when excludeProjects is true", () => {
const suggestedRepos: SuggestedRepository[] = [
repo("foo"),
repo("foo", "project-foo"),
repo("foo", "project-bar"),
repo("bar", "project-foo"),
repo("bar", "project-bar"),
];
const deduplicated = deduplicateAndFilterRepositories("foo", true, suggestedRepos);
expect(deduplicated.length).toEqual(2);
expect(deduplicated[0].repositoryName).toEqual("foo");
expect(deduplicated[1].repositoryName).toEqual("bar");
});
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ export function deduplicateAndFilterRepositories(
});
}
for (const repo of suggestedRepos) {
// filter out project entries if excludeProjects is true
if (repo.projectId && excludeProjects) {
continue;
}
// filter out project-less entries if an entry with a project exists
if (!repo.projectId && reposWithProject.has(repo.url)) {
continue;
Expand All @@ -66,7 +62,7 @@ export function deduplicateAndFilterRepositories(
continue;
}
// filter out duplicates
const key = `${repo.url}:${repo.projectId || "no-project"}`;
const key = `${repo.url}:${excludeProjects ? "" : repo.projectId || "no-project"}`;
if (collected.has(key)) {
continue;
}
Expand Down

0 comments on commit 2e3429a

Please sign in to comment.