diff --git a/.betterer.results b/.betterer.results index e7c5b4af315..5cdf0fe5ed9 100644 --- a/.betterer.results +++ b/.betterer.results @@ -242,9 +242,6 @@ exports[`no enzyme tests`] = { "public/app/features/teams/TeamSettings.test.tsx:2043271249": [ [0, 19, 13, "RegExp match", "2409514259"] ], - "public/app/features/users/UsersActionBar.test.tsx:3740177621": [ - [0, 19, 13, "RegExp match", "2409514259"] - ], "public/app/features/users/UsersListPage.test.tsx:3908145117": [ [0, 19, 13, "RegExp match", "2409514259"] ], diff --git a/public/app/features/users/UsersActionBar.test.tsx b/public/app/features/users/UsersActionBar.test.tsx index a9e9c4b4490..1e8d2d44a73 100644 --- a/public/app/features/users/UsersActionBar.test.tsx +++ b/public/app/features/users/UsersActionBar.test.tsx @@ -1,4 +1,4 @@ -import { shallow } from 'enzyme'; +import { render, screen } from '@testing-library/react'; import React from 'react'; import { mockToolkitActionCreator } from 'test/core/redux/mocks'; @@ -26,37 +26,40 @@ const setup = (propOverrides?: object) => { Object.assign(props, propOverrides); - return shallow(); + const { rerender } = render(); + + return { rerender, props }; }; describe('Render', () => { it('should render component', () => { - const wrapper = setup(); + setup(); - expect(wrapper).toMatchSnapshot(); + expect(screen.getByTestId('users-action-bar')).toBeInTheDocument(); }); it('should render pending invites button', () => { - const wrapper = setup({ + setup({ pendingInvitesCount: 5, }); - expect(wrapper).toMatchSnapshot(); + expect(screen.getByRole('radio', { name: 'Pending Invites (5)' })).toBeInTheDocument(); }); it('should show invite button', () => { - const wrapper = setup({ + setup({ canInvite: true, }); - expect(wrapper).toMatchSnapshot(); + expect(screen.getByRole('link', { name: 'Invite' })).toHaveAttribute('href', 'org/users/invite'); }); it('should show external user management button', () => { - const wrapper = setup({ + setup({ externalUserMngLinkUrl: 'some/url', + externalUserMngLinkName: 'someUrl', }); - expect(wrapper).toMatchSnapshot(); + expect(screen.getByRole('link', { name: 'someUrl' })).toHaveAttribute('href', 'some/url'); }); }); diff --git a/public/app/features/users/UsersActionBar.tsx b/public/app/features/users/UsersActionBar.tsx index 05b1166b2c1..55fe3b046f3 100644 --- a/public/app/features/users/UsersActionBar.tsx +++ b/public/app/features/users/UsersActionBar.tsx @@ -40,7 +40,7 @@ export class UsersActionBar extends PureComponent { const canAddToOrg = contextSrv.hasAccess(AccessControlAction.UsersCreate, canInvite); return ( -
+
-
- -
- - Invite - -
-`; - -exports[`Render should render pending invites button 1`] = ` -
-
- -
-
- -
- - Invite - -
-`; - -exports[`Render should show external user management button 1`] = ` -
-
- -
- - Invite - - -
-`; - -exports[`Render should show invite button 1`] = ` -
-
- -
- - Invite - -
-`;