Skip to content

Commit 2e3429a

Browse files
authored
[dashboard] fix EXP-901 (#19043)
1 parent 4de3805 commit 2e3429a

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

components/dashboard/src/data/git-providers/unified-repositories-search-query.test.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ test("it should exclude project entries", () => {
4040
repo("foo", "project-foo"),
4141
];
4242
const deduplicated = deduplicateAndFilterRepositories("foo", true, suggestedRepos);
43-
expect(deduplicated.length).toEqual(1);
43+
expect(deduplicated.length).toEqual(2);
44+
expect(deduplicated[0].repositoryName).toEqual("foo");
45+
expect(deduplicated[1].repositoryName).toEqual("foo2");
4446
});
4547

4648
test("it should match entries in url as well as poject name", () => {
@@ -75,3 +77,17 @@ test("it keeps the order", () => {
7577
expect(deduplicated[2].projectName).toEqual("someFootest");
7678
expect(deduplicated[3].projectName).toEqual("FOOtest");
7779
});
80+
81+
test("it should return all repositories without duplicates when excludeProjects is true", () => {
82+
const suggestedRepos: SuggestedRepository[] = [
83+
repo("foo"),
84+
repo("foo", "project-foo"),
85+
repo("foo", "project-bar"),
86+
repo("bar", "project-foo"),
87+
repo("bar", "project-bar"),
88+
];
89+
const deduplicated = deduplicateAndFilterRepositories("foo", true, suggestedRepos);
90+
expect(deduplicated.length).toEqual(2);
91+
expect(deduplicated[0].repositoryName).toEqual("foo");
92+
expect(deduplicated[1].repositoryName).toEqual("bar");
93+
});

components/dashboard/src/data/git-providers/unified-repositories-search-query.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,6 @@ export function deduplicateAndFilterRepositories(
5353
});
5454
}
5555
for (const repo of suggestedRepos) {
56-
// filter out project entries if excludeProjects is true
57-
if (repo.projectId && excludeProjects) {
58-
continue;
59-
}
6056
// filter out project-less entries if an entry with a project exists
6157
if (!repo.projectId && reposWithProject.has(repo.url)) {
6258
continue;
@@ -66,7 +62,7 @@ export function deduplicateAndFilterRepositories(
6662
continue;
6763
}
6864
// filter out duplicates
69-
const key = `${repo.url}:${repo.projectId || "no-project"}`;
65+
const key = `${repo.url}:${excludeProjects ? "" : repo.projectId || "no-project"}`;
7066
if (collected.has(key)) {
7167
continue;
7268
}

0 commit comments

Comments
 (0)