Skip to content

feat: add searching for projects by id #98005

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 32 additions & 4 deletions static/app/views/projectsDashboard/index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,7 @@ describe('ProjectsDashboard', () => {

expect(await screen.findByTestId('join-team')).toBeInTheDocument();
expect(screen.getByTestId('create-project')).toBeInTheDocument();
expect(
screen.getByPlaceholderText('Search for projects by name')
).toBeInTheDocument();
expect(screen.getByPlaceholderText('Search for projects')).toBeInTheDocument();
expect(screen.getByText('My Teams')).toBeInTheDocument();
expect(screen.getByText('Resources')).toBeInTheDocument();
expect(await screen.findByTestId('badge-display-name')).toBeInTheDocument();
Expand Down Expand Up @@ -433,7 +431,7 @@ describe('ProjectsDashboard', () => {
deprecatedRouterMocks: true,
});
await userEvent.type(
screen.getByPlaceholderText('Search for projects by name'),
screen.getByPlaceholderText('Search for projects'),
'project2{enter}'
);
expect(screen.getByText('project2')).toBeInTheDocument();
Expand All @@ -443,6 +441,36 @@ describe('ProjectsDashboard', () => {
expect(screen.queryByTestId('loading-placeholder')).not.toBeInTheDocument();
});

it('searches projects by id', async () => {
const teamA = TeamFixture({slug: 'team1', isMember: true});
MockApiClient.addMockResponse({
url: `/organizations/${org.slug}/projects/`,
body: [],
});
const projects = [
ProjectFixture({
id: '123',
slug: 'project1',
teams: [teamA],
firstEvent: new Date().toISOString(),
stats: [],
}),
];

ProjectsStore.loadInitialData(projects);
const teamWithProject = [TeamFixture({projects})];
TeamStore.loadInitialData(teamWithProject);
render(<ProjectsDashboard />, {
deprecatedRouterMocks: true,
});
await userEvent.type(
screen.getByPlaceholderText('Search for projects'),
'123{enter}'
);
expect(screen.getByText('project1')).toBeInTheDocument();
expect(screen.queryByTestId('loading-placeholder')).not.toBeInTheDocument();
});

it('renders bookmarked projects first in team list', async () => {
const teamA = TeamFixture({slug: 'team1', isMember: true});
const projects = [
Expand Down
6 changes: 3 additions & 3 deletions static/app/views/projectsDashboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ function getFilteredProjectsBasedOnTeams({
isAllTeams && showNonMemberProjects
? projects.filter(project => !currentProjectIds.has(project.id))
: [];
return [...currentProjects, ...unassignedProjects].filter(project =>
project.slug.includes(projectQuery)
return [...currentProjects, ...unassignedProjects].filter(
project => project.slug.includes(projectQuery) || project.id.startsWith(projectQuery)
);
}

Expand Down Expand Up @@ -262,7 +262,7 @@ function Dashboard() {
/>
<StyledSearchBar
defaultQuery=""
placeholder={t('Search for projects by name')}
placeholder={t('Search for projects')}
onChange={debouncedSearchQuery}
query={projectQuery}
/>
Expand Down
Loading