Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelSun48 committed Oct 3, 2024
1 parent f9d8a66 commit 3579cf3
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 4 deletions.
2 changes: 1 addition & 1 deletion static/app/components/draggableTabs/draggableTabList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,9 @@ function BaseDraggableTabList({
tabVariant = 'filled',
...props
}: BaseDraggableTabListProps) {
const navigate = useNavigate();
const [hoveringKey, setHoveringKey] = useState<Key | null>(null);
const {rootProps, setTabListState} = useContext(TabsContext);
const navigate = useNavigate();
const organization = useOrganization();
const {
value,
Expand Down
53 changes: 50 additions & 3 deletions static/app/views/issueList/customViewsHeader.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import preview from 'jest-preview';
import {LocationFixture} from 'sentry-fixture/locationFixture';
import {OrganizationFixture} from 'sentry-fixture/organization';
import {RouterFixture} from 'sentry-fixture/routerFixture';
Expand Down Expand Up @@ -502,7 +501,56 @@ describe('CustomViewsHeader', () => {
).not.toBeInTheDocument();
});

describe('Tab renaming', () => {});
describe('Tab renaming', () => {
it('should begin editing the tab if the "Rename" ellipsis menu options is clicked', async () => {
const mockPutRequest = MockApiClient.addMockResponse({
url: `/organizations/org-slug/group-search-views/`,
method: 'PUT',
});

render(<CustomViewsIssueListHeader {...defaultProps} />, {router: defaultRouter});

userEvent.click(
await screen.findByRole('button', {name: 'High Priority Ellipsis Menu'})
);

await userEvent.click(await screen.findByRole('menuitemradio', {name: 'Rename'}));

expect(await screen.findByRole('textbox')).toHaveValue('High Priority');

await userEvent.type(
await screen.findByRole('textbox'),
'{control>}A{/control}{backspace}'
);
await userEvent.type(await screen.findByRole('textbox'), 'New Name');
await userEvent.type(await screen.findByRole('textbox'), '{enter}');

expect(defaultRouter.push).not.toHaveBeenCalled();

// Make sure the put request is called, and the renamed view is in the request
expect(mockPutRequest).toHaveBeenCalledTimes(1);
const putRequestViews = mockPutRequest.mock.calls[0][1].data.views;
expect(putRequestViews).toHaveLength(3);
expect(putRequestViews).toEqual(
expect.arrayContaining([
expect.objectContaining({
id: getRequestViews[0].id,
name: 'New Name',
query: getRequestViews[0].query,
querySort: getRequestViews[0].querySort,
}),
])
);
});

it('should revert edits if esc is pressed while editing', async () => {
// TODO(msun)
});

it('should revert edits if the user attemps to rename the tab to an empty string', async () => {
// TODO(msun)
});
});

describe('Tab duplication', () => {
it('should duplicate the tab and then select the new tab', async () => {
Expand All @@ -512,7 +560,6 @@ describe('CustomViewsHeader', () => {
});

render(<CustomViewsIssueListHeader {...defaultProps} />, {router: defaultRouter});
preview.debug();

userEvent.click(
await screen.findByRole('button', {name: 'High Priority Ellipsis Menu'})
Expand Down

0 comments on commit 3579cf3

Please sign in to comment.