Skip to content

Commit 470be54

Browse files
JonasBaClaude Sonnet 4
andcommitted
test(pageFilters): Scope generic tests to closed-membership org
The top-level organization fixture was open-membership, causing generic tests (single selection, multiple selection, keyboard navigation, reset, etc.) to implicitly test open-membership behavior. This made many assertions read 'All Projects' when the tests had nothing to do with open-membership logic. Revert the top-level fixture to a plain closed-membership org so generic tests use 'My Projects' as the default — matching actual default behavior. Move the open-membership fixture into the dedicated 'open-membership org defaults' describe block, which is the only place that should assert open-membership behavior. Co-Authored-By: Claude Sonnet 4 <noreply@example.com>
1 parent 5a27dbc commit 470be54

File tree

1 file changed

+22
-16
lines changed

1 file changed

+22
-16
lines changed

static/app/components/pageFilters/project/projectPageFilter.spec.tsx

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import PageFiltersStore from 'sentry/components/pageFilters/store';
1717
import {OrganizationStore} from 'sentry/stores/organizationStore';
1818
import {ProjectsStore} from 'sentry/stores/projectsStore';
1919

20-
const organization = OrganizationFixture({openMembership: true});
20+
const organization = OrganizationFixture();
2121
const projects = [
2222
ProjectFixture({id: '1', slug: 'project-1', isMember: true}),
2323
ProjectFixture({id: '2', slug: 'project-2', isMember: true}),
@@ -50,7 +50,7 @@ describe('ProjectPageFilter', () => {
5050
});
5151

5252
// Open menu
53-
await userEvent.click(screen.getByRole('button', {name: 'All Projects'}));
53+
await userEvent.click(screen.getByRole('button', {name: 'My Projects'}));
5454

5555
// Select only project-1
5656
await userEvent.click(screen.getByRole('row', {name: 'project-1'}));
@@ -68,11 +68,14 @@ describe('ProjectPageFilter', () => {
6868
},
6969
});
7070

71-
// Open menu — initial state is All Projects (open-membership org)
72-
await userEvent.click(screen.getByRole('button', {name: 'All Projects'}));
71+
// Open menu
72+
await userEvent.click(screen.getByRole('button', {name: 'My Projects'}));
7373

74-
// Uncheck All Projects to clear the selection, then select only project-3
75-
await userEvent.click(screen.getByRole('checkbox', {name: 'Select All Projects'}));
74+
// Deselect project-1 & project-2 by clicking on their checkboxes
75+
await userEvent.click(screen.getByRole('checkbox', {name: 'Select project-1'}));
76+
await userEvent.click(screen.getByRole('checkbox', {name: 'Select project-2'}));
77+
78+
// Select project-3 by clicking on its checkbox
7679
await userEvent.click(screen.getByRole('checkbox', {name: 'Select project-3'}));
7780

7881
// Click "Apply"
@@ -99,12 +102,13 @@ describe('ProjectPageFilter', () => {
99102
});
100103

101104
// Open the menu, search input has focus
102-
await userEvent.click(screen.getByRole('button', {name: 'All Projects'}));
105+
await userEvent.click(screen.getByRole('button', {name: 'My Projects'}));
103106
await waitFor(() => {
104107
expect(screen.getByPlaceholderText('Search…')).toHaveFocus();
105108
});
106109

107-
// Move focus past the one special item ("All Projects") to project-1
110+
// Move focus past the two special items ("All Projects", "My Projects") to project-1
111+
await userEvent.keyboard('{ArrowDown}');
108112
await userEvent.keyboard('{ArrowDown}');
109113
await userEvent.keyboard('{ArrowDown}');
110114
const optionOne = screen.getByRole('row', {name: 'project-1'});
@@ -166,7 +170,7 @@ describe('ProjectPageFilter', () => {
166170
});
167171

168172
// Open the menu, select project-1
169-
await userEvent.click(screen.getByRole('button', {name: 'All Projects'}));
173+
await userEvent.click(screen.getByRole('button', {name: 'My Projects'}));
170174
await userEvent.click(screen.getByRole('row', {name: 'project-1'}));
171175
expect(router.location.query).toEqual({project: '1'});
172176

@@ -175,7 +179,7 @@ describe('ProjectPageFilter', () => {
175179
await userEvent.click(screen.getByRole('button', {name: 'Reset'}));
176180

177181
// Trigger button was updated, onReset was called
178-
expect(screen.getByRole('button', {name: 'All Projects'})).toBeInTheDocument();
182+
expect(screen.getByRole('button', {name: 'My Projects'})).toBeInTheDocument();
179183
expect(onReset).toHaveBeenCalled();
180184
});
181185

@@ -192,7 +196,7 @@ describe('ProjectPageFilter', () => {
192196
});
193197

194198
// Confirm initial selection
195-
expect(await screen.findByRole('button', {name: 'All Projects'})).toBeInTheDocument();
199+
expect(await screen.findByRole('button', {name: 'My Projects'})).toBeInTheDocument();
196200

197201
// Edit store value
198202
act(() => updateProjects([2], mockRouter));
@@ -401,7 +405,7 @@ describe('ProjectPageFilter', () => {
401405
},
402406
});
403407

404-
await userEvent.click(screen.getByRole('button', {name: 'All Projects'}));
408+
await userEvent.click(screen.getByRole('button', {name: 'My Projects'}));
405409
await userEvent.type(screen.getByPlaceholderText('Search…'), 'project-1');
406410

407411
expect(
@@ -884,9 +888,11 @@ describe('ProjectPageFilter', () => {
884888
});
885889

886890
describe('open-membership org defaults', () => {
891+
const openOrg = OrganizationFixture({openMembership: true});
892+
887893
it('shows All Projects (not My Projects) as the default trigger label', async () => {
888894
render(<ProjectPageFilter />, {
889-
organization,
895+
organization: openOrg,
890896
initialRouterConfig: {
891897
location: {pathname: '/organizations/org-slug/issues/', query: {}},
892898
},
@@ -899,7 +905,7 @@ describe('ProjectPageFilter', () => {
899905

900906
it('does not show the My Projects option in the dropdown', async () => {
901907
render(<ProjectPageFilter />, {
902-
organization,
908+
organization: openOrg,
903909
initialRouterConfig: {
904910
location: {pathname: '/organizations/org-slug/issues/', query: {}},
905911
},
@@ -914,7 +920,7 @@ describe('ProjectPageFilter', () => {
914920

915921
it('sends no project param for the default All Projects state', async () => {
916922
const {router} = render(<ProjectPageFilter />, {
917-
organization,
923+
organization: openOrg,
918924
initialRouterConfig: {
919925
location: {pathname: '/organizations/org-slug/issues/', query: {}},
920926
},
@@ -936,7 +942,7 @@ describe('ProjectPageFilter', () => {
936942
});
937943

938944
const {router} = render(<ProjectPageFilter />, {
939-
organization,
945+
organization: openOrg,
940946
initialRouterConfig: {
941947
location: {pathname: '/organizations/org-slug/issues/', query: {project: '1'}},
942948
},

0 commit comments

Comments
 (0)